diff --git a/test/libc/calls/execve_test.c b/test/libc/calls/execve_test.c index f0ce111ea..7ab7c73ab 100644 --- a/test/libc/calls/execve_test.c +++ b/test/libc/calls/execve_test.c @@ -25,6 +25,7 @@ #include "libc/testlib/testlib.h" #define N 16 +static const char *testArg0PassingArg = "bothArgsShouldBeThis"; char *GenBuf(char buf[8], int x) { int i; @@ -41,6 +42,9 @@ __attribute__((__constructor__)) static void init(void) { if (__argc == 4 && !strcmp(__argv[1], "-")) { ASSERT_STREQ(GenBuf(buf, atoi(__argv[2])), __argv[3]); exit(0); + } else if (__argc == 2 && !strcmp(__argv[1], testArg0PassingArg)) { + ASSERT_STREQ(__argv[0], __argv[1]); + exit(0); } } @@ -58,3 +62,12 @@ TEST(execve, testArgPassing) { EXITS(0); } } + +TEST(execve, testArg0Passing) { + SPAWN(vfork); + execve(GetProgramExecutableName(), + (char *const[]){testArg0PassingArg, testArg0PassingArg, 0}, + (char *const[]){0}); + notpossible; + EXITS(0); +}