Skip argv[0] tests with old/no loader

This commit is contained in:
Jōshin 2023-12-15 15:54:53 +00:00
parent 580982ea60
commit c8395bf2f3
No known key found for this signature in database

View file

@ -29,19 +29,25 @@
static char *self;
void SetUp(void) {
self = GetProgramExecutableName();
}
void SetUpOnce(void) {
self = GetProgramExecutableName();
testlib_enable_tmp_setup_teardown();
}
__attribute__((__constructor__)) static void Child(int argc, char *argv[]) {
static bool skiparg0tests;
if (!__program_executable_name && !IsFreebsd() && !IsNetbsd()) {
skiparg0tests = true;
if (argc < 2) {
fprintf(stderr, "warning: old/no loader; skipping argv[0] tests\n");
}
}
if (argc >= 2 && !strcmp(argv[1], "Child")) {
ASSERT_EQ(argc, 4);
EXPECT_STREQ(argv[2], GetProgramExecutableName());
EXPECT_STREQ(argv[3], argv[0]);
if (!skiparg0tests) {
EXPECT_STREQ(argv[3], argv[0]);
}
exit(g_testlib_failed);
}
}