about summary refs log tree commit diff
path: root/pkgs/build-support/libredirect/test.c
diff options
context:
space:
mode:
authorPascal Bach <pascal.bach@nextrem.ch>2021-09-03 22:03:38 +0200
committerPascal Bach <pascal.bach@nextrem.ch>2021-09-03 23:45:46 +0200
commitfc5196c2f089e1483429aecd8dff56387a444e6b (patch)
tree3f4c8c0088763b3007b0ad114ad80fd1cecbe663 /pkgs/build-support/libredirect/test.c
parent4961547d05376023fdc7a4664aba4d933d43e7b5 (diff)
libredirect: add subprocess test
Diffstat (limited to 'pkgs/build-support/libredirect/test.c')
-rw-r--r--pkgs/build-support/libredirect/test.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/pkgs/build-support/libredirect/test.c b/pkgs/build-support/libredirect/test.c
index 722d1303771c8..853f26bb52092 100644
--- a/pkgs/build-support/libredirect/test.c
+++ b/pkgs/build-support/libredirect/test.c
@@ -10,6 +10,7 @@
 #include <sys/wait.h>
 
 #define TESTPATH "/foo/bar/test"
+#define SUBTEST "./test sub"
 
 extern char **environ;
 
@@ -36,7 +37,11 @@ void test_system(void) {
     assert(system(TESTPATH) == 0);
 }
 
-int main(void)
+void test_subprocess(void) {
+    assert(system(SUBTEST) == 0);
+}
+
+int main(int argc, char *argv[])
 {
     FILE *testfp;
     int testfd;
@@ -56,6 +61,14 @@ int main(void)
 
     test_spawn();
     test_system();
+
+    // Only run subprocess if no arguments are given
+    // as the subprocess will be called without argument
+    // otherwise we will have infinite recursion
+    if (argc == 1) {
+        test_subprocess();
+    }
+
     test_execv();
 
     /* If all goes well, this is never reached because test_execv() replaces