mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-06 18:00:28 +00:00
Skip tests when they will fail
GetProgramExecutableName does not work right on assimilated OpenBSD or non-silicon XNU binaries. If we are on one of those platforms, look for ape magic in ourselves and quit if none is found. If `argv[0]` is not reliable for the test invocation itself (e.g. because the test is run out of `PATH`), the test assert-fails.
This commit is contained in:
parent
673daea2c2
commit
6e25e84518
1 changed files with 16 additions and 0 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include "libc/dce.h"
|
#include "libc/dce.h"
|
||||||
#include "libc/limits.h"
|
#include "libc/limits.h"
|
||||||
#include "libc/runtime/runtime.h"
|
#include "libc/runtime/runtime.h"
|
||||||
|
#include "libc/serialize.h"
|
||||||
#include "libc/stdio/stdio.h"
|
#include "libc/stdio/stdio.h"
|
||||||
#include "libc/str/str.h"
|
#include "libc/str/str.h"
|
||||||
#include "libc/sysv/consts/o.h"
|
#include "libc/sysv/consts/o.h"
|
||||||
|
@ -34,6 +35,21 @@ static char *self;
|
||||||
void SetUpOnce(void) {
|
void SetUpOnce(void) {
|
||||||
self = GetProgramExecutableName();
|
self = GetProgramExecutableName();
|
||||||
testlib_enable_tmp_setup_teardown();
|
testlib_enable_tmp_setup_teardown();
|
||||||
|
if (IsOpenbsd() || (IsXnu() && !IsXnuSilicon())) {
|
||||||
|
ASSERT_STRNE(self, "");
|
||||||
|
ASSERT_SYS(0, 3, open(self, O_RDONLY));
|
||||||
|
char buf[8];
|
||||||
|
ASSERT_SYS(0, 8, pread(3, buf, 8, 0));
|
||||||
|
ASSERT_SYS(0, 0, close(3));
|
||||||
|
if (READ64LE(buf) != READ64LE("MZqFpD='") &&
|
||||||
|
READ64LE(buf) != READ64LE("jartsr='") &&
|
||||||
|
READ64LE(buf) != READ64LE("APEDBG='")) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"GetProgramExecutableName is unreliable on this platform for\n"
|
||||||
|
"assimilated binaries\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((__constructor__)) static void Child(int argc, char *argv[]) {
|
__attribute__((__constructor__)) static void Child(int argc, char *argv[]) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue