pipecmd: test can't-exec case.
authorRusty Russell <rusty@rustcorp.com.au>
Fri, 20 Nov 2015 06:32:14 +0000 (17:02 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 20 Nov 2015 06:35:47 +0000 (17:05 +1030)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/pipecmd/test/run.c

index b08d194d4663c515443bb99459fe10a2361fff9d..425e7d00bbd79729d5897a6161550bbb0bab2a61 100644 (file)
@@ -34,7 +34,7 @@ int main(int argc, char *argv[])
        }
 
        /* This is how many tests you plan to run */
-       plan_tests(26);
+       plan_tests(28);
        child = pipecmd(&outfd, &infd, argv[0], "inout", NULL);
        if (!ok1(child > 0))
                exit(1);
@@ -79,6 +79,11 @@ int main(int argc, char *argv[])
        ok1(WIFEXITED(status));
        ok1(WEXITSTATUS(status) == 1);
 
+       // Can't run non-existent file, but errno set correctly.
+       child = pipecmd(NULL, NULL, "/doesnotexist", "in", NULL);
+       ok1(errno == ENOENT);
+       ok1(child < 0);
+
        /* This exits depending on whether all tests passed */
        return exit_status();
 }