From ffff885b8c44af75f0cd22f9b0fe42380b9ca1c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C5=8Dshin?= Date: Sun, 31 Dec 2023 11:03:56 -0500 Subject: [PATCH] check for metal and file access Properly tests the behavior on Metal now, which is to always return `APE_COM_NAME`. Ensures that the path of the test itself as returned by `GetProgramExecutableName` is executable. --- test/libc/calls/getprogramexecutablename_test.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/libc/calls/getprogramexecutablename_test.c b/test/libc/calls/getprogramexecutablename_test.c index 274a5bd97..2a5547be6 100644 --- a/test/libc/calls/getprogramexecutablename_test.c +++ b/test/libc/calls/getprogramexecutablename_test.c @@ -17,12 +17,14 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" +#include "libc/calls/metalfile.internal.h" #include "libc/dce.h" #include "libc/limits.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/o.h" +#include "libc/sysv/consts/ok.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/subprocess.h" #include "libc/testlib/testlib.h" @@ -36,6 +38,7 @@ void SetUpOnce(void) { __attribute__((__constructor__)) static void Child(int argc, char *argv[]) { if (argc >= 2 && !strcmp(argv[1], "Child")) { + if (IsMetal()) exit(0); if (strcmp(argv[2], GetProgramExecutableName())) { exit(123); } @@ -53,8 +56,13 @@ __attribute__((__constructor__)) static void Child(int argc, char *argv[]) { } TEST(GetProgramExecutableName, ofThisFile) { - EXPECT_EQ('/', *self); - EXPECT_TRUE(!!strstr(self, "getprogramexecutablename_test")); + if (IsMetal()) { + EXPECT_STREQ(self, APE_COM_NAME); + } else { + EXPECT_EQ('/', *self); + EXPECT_TRUE(!!strstr(self, "getprogramexecutablename_test")); + ASSERT_SYS(0, 0, access(self, X_OK)); + } } TEST(GetProgramExecutableName, nullEnv) {