mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-06 18:00:28 +00:00
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.
This commit is contained in:
parent
4f032d82fa
commit
ffff885b8c
1 changed files with 10 additions and 2 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue