mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-06 18:00:28 +00:00
Re-enable non-argv[0] exe name tests
These should always pass no matter what and if they don't it's a bug somewhere. Cases where they fail: - assimilated binary on OpenBSD or x86_64 XNU (no `KERN_PROC_PATHNAME`) - bad loader that did not implement `RealPath` on Free/Net BSD
This commit is contained in:
parent
14fe83facd
commit
4f032d82fa
1 changed files with 6 additions and 11 deletions
|
@ -39,6 +39,12 @@ __attribute__((__constructor__)) static void Child(int argc, char *argv[]) {
|
|||
if (strcmp(argv[2], GetProgramExecutableName())) {
|
||||
exit(123);
|
||||
}
|
||||
if (!IsXnuSilicon()) exit(0);
|
||||
/* TODO(mrdomino): argv[0] tests only pass on XnuSilicon right now because
|
||||
__sys_execve fails there, so the ape loader is used.
|
||||
the correct check is "we have been invoked either as an
|
||||
assimilated binary or via the ape loader, and not via a
|
||||
raw __sys_execve." */
|
||||
if (strcmp(argv[3], argv[0])) {
|
||||
exit(124);
|
||||
}
|
||||
|
@ -51,14 +57,7 @@ TEST(GetProgramExecutableName, ofThisFile) {
|
|||
EXPECT_TRUE(!!strstr(self, "getprogramexecutablename_test"));
|
||||
}
|
||||
|
||||
/* TODO(mrdomino): these tests only pass on XnuSilicon right now because
|
||||
__sys_execve fails there, so the ape loader is used.
|
||||
the correct check here is "we have been invoked either
|
||||
as an assimilated binary or via the ape loader, and not
|
||||
via a raw __sys_execve." */
|
||||
|
||||
TEST(GetProgramExecutableName, nullEnv) {
|
||||
if (!IsXnuSilicon()) return;
|
||||
SPAWN(fork);
|
||||
execve(self, (char *[]){self, "Child", self, self, 0}, (char *[]){0});
|
||||
abort();
|
||||
|
@ -66,7 +65,6 @@ TEST(GetProgramExecutableName, nullEnv) {
|
|||
}
|
||||
|
||||
TEST(GetProramExecutableName, weirdArgv0NullEnv) {
|
||||
if (!IsXnuSilicon()) return;
|
||||
SPAWN(fork);
|
||||
execve(self, (char *[]){"hello", "Child", self, "hello", 0}, (char *[]){0});
|
||||
abort();
|
||||
|
@ -74,7 +72,6 @@ TEST(GetProramExecutableName, weirdArgv0NullEnv) {
|
|||
}
|
||||
|
||||
TEST(GetProgramExecutableName, weirdArgv0CosmoVar) {
|
||||
if (!IsXnuSilicon()) return;
|
||||
char buf[32 + PATH_MAX];
|
||||
stpcpy(stpcpy(buf, "COSMOPOLITAN_PROGRAM_EXECUTABLE="), self);
|
||||
SPAWN(fork);
|
||||
|
@ -85,7 +82,6 @@ TEST(GetProgramExecutableName, weirdArgv0CosmoVar) {
|
|||
}
|
||||
|
||||
TEST(GetProgramExecutableName, weirdArgv0WrongCosmoVar) {
|
||||
if (!IsXnuSilicon()) return;
|
||||
char *bad = "COSMOPOLITAN_PROGRAM_EXECUTABLE=hi";
|
||||
SPAWN(fork);
|
||||
execve(self, (char *[]){"hello", "Child", self, "hello", 0},
|
||||
|
@ -95,7 +91,6 @@ TEST(GetProgramExecutableName, weirdArgv0WrongCosmoVar) {
|
|||
}
|
||||
|
||||
TEST(GetProgramExecutableName, movedSelf) {
|
||||
if (!IsXnuSilicon()) return;
|
||||
char buf[BUFSIZ];
|
||||
ASSERT_SYS(0, 3, open(GetProgramExecutableName(), O_RDONLY));
|
||||
ASSERT_SYS(0, 4, creat("test", 0755));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue