about summary refs log tree commit diff
path: root/nixpkgs/pkgs/build-support/libredirect/test.c
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/build-support/libredirect/test.c')
-rw-r--r--nixpkgs/pkgs/build-support/libredirect/test.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/nixpkgs/pkgs/build-support/libredirect/test.c b/nixpkgs/pkgs/build-support/libredirect/test.c
index 722d1303771c..853f26bb5209 100644
--- a/nixpkgs/pkgs/build-support/libredirect/test.c
+++ b/nixpkgs/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