mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-08 19:00:27 +00:00
add arg0 passing execve test
This commit is contained in:
parent
a6586cafb2
commit
b045194d99
1 changed files with 13 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue