Apply clang-format update to repo (#1154)

Commit bc6c183 introduced a bunch of discrepancies between what files
look like in the repo and what clang-format says they should look like.
However, there were already a few discrepancies prior to that. Most of
these discrepancies seemed to be unintentional, but a few of them were
load-bearing (e.g., a #include that violated header ordering needing
something to have been #defined by a 'later' #include.)

I opted to take what I hope is a relatively smooth-brained approach: I
reverted the .clang-format change, ran clang-format on the whole repo,
reapplied the .clang-format change, reran clang-format again, and then
reverted the commit that contained the first run. Thus the full effect
of this PR should only be to apply the changed formatting rules to the
repo, and from skimming the results, this seems to be the case.

My work can be checked by applying the short, manual commits, and then
rerunning the command listed in the autogenerated commits (those whose
messages I have prefixed auto:) and seeing if your results agree.

It might be that the other diffs should be fixed at some point but I'm
leaving that aside for now.

fd '\.c(c|pp)?$' --print0| xargs -0 clang-format -i
This commit is contained in:
Jōshin 2024-04-25 10:38:00 -07:00 committed by GitHub
parent 342d0c81e5
commit 6e6fc38935
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
863 changed files with 9201 additions and 4627 deletions

View file

@ -34,7 +34,8 @@ void SetUpOnce(void) {
}
TEST(access, efault) {
if (IsWindows() || !IsAsan()) return; // not possible
if (IsWindows() || !IsAsan())
return; // not possible
ASSERT_SYS(EFAULT, -1, access((void *)77, F_OK));
}
@ -61,7 +62,8 @@ TEST(access, test) {
}
TEST(access, testRequestWriteOnReadOnly_returnsEaccess) {
if (1) return; // TODO(jart): maybe we need root to help?
if (1)
return; // TODO(jart): maybe we need root to help?
ASSERT_SYS(ENOENT, -1, access("file", F_OK));
ASSERT_SYS(0, 0, close(creat("file", 0444)));
ASSERT_SYS(0, 0, access("file", F_OK));

View file

@ -93,7 +93,8 @@ TEST(cachestat, testCachestatSyncNoDirty) {
"total number of evicted pages is off.");
struct statfs statfs;
ASSERT_SYS(0, 0, fstatfs(3, &statfs));
if (statfs.f_type == TMPFS_MAGIC) goto done;
if (statfs.f_type == TMPFS_MAGIC)
goto done;
ASSERT_SYS(0, 0, fsync(3));
ASSERT_SYS(0, 0, cachestat(3, &range, &cs, 0));
EXPECT_EQ(0, cs.nr_dirty,

View file

@ -29,7 +29,8 @@ void SetUpOnce(void) {
TEST(chdir, efault) {
ASSERT_SYS(EFAULT, -1, chdir(0));
if (IsWindows() || !IsAsan()) return; // not possible
if (IsWindows() || !IsAsan())
return; // not possible
ASSERT_SYS(EFAULT, -1, chdir((void *)77));
}

View file

@ -40,14 +40,16 @@ TEST(clock_getres, realtimeFastHasMillisecondPrecisionOrBetter) {
}
TEST(clock_getres, realtimeCoarseHasMillisecondPrecisionOrBetter) {
if (clock_getres(CLOCK_REALTIME_COARSE, &ts)) return;
if (clock_getres(CLOCK_REALTIME_COARSE, &ts))
return;
EXPECT_EQ(0, ts.tv_sec);
EXPECT_LT(ts.tv_nsec, 100000000);
EXPECT_GT(ts.tv_nsec, 0);
}
TEST(clock_getres, realtimePreciseHasMillisecondPrecisionOrBetter) {
if (clock_getres(CLOCK_REALTIME_PRECISE, &ts)) return;
if (clock_getres(CLOCK_REALTIME_PRECISE, &ts))
return;
EXPECT_EQ(0, ts.tv_sec);
EXPECT_LT(ts.tv_nsec, 100000000);
EXPECT_GT(ts.tv_nsec, 0);
@ -68,14 +70,16 @@ TEST(clock_getres, monotonicFastHasMillisecondPrecisionOrBetter) {
}
TEST(clock_getres, monotonicCoarseHasMillisecondPrecisionOrBetter) {
if (clock_getres(CLOCK_MONOTONIC_COARSE, &ts)) return;
if (clock_getres(CLOCK_MONOTONIC_COARSE, &ts))
return;
EXPECT_EQ(0, ts.tv_sec);
EXPECT_LT(ts.tv_nsec, 100000000);
EXPECT_GT(ts.tv_nsec, 0);
}
TEST(clock_getres, monotonicPreciseHasMillisecondPrecisionOrBetter) {
if (clock_getres(CLOCK_MONOTONIC_PRECISE, &ts)) return;
if (clock_getres(CLOCK_MONOTONIC_PRECISE, &ts))
return;
EXPECT_EQ(0, ts.tv_sec);
EXPECT_LT(ts.tv_nsec, 100000000);
EXPECT_GT(ts.tv_nsec, 0);

View file

@ -70,6 +70,7 @@ TEST(close_range, test) {
}
TEST(close_range, ignoresNonexistantRanges) {
if (!IsLinux() && !IsFreebsd()) return;
if (!IsLinux() && !IsFreebsd())
return;
EXPECT_SYS(0, 0, close_range(-2, -1, 0));
}

View file

@ -100,7 +100,8 @@ TEST(commandv, test_DirPaths_wontConsiderDirectoriesExecutable2) {
}
TEST(commandv, test_nonExecutableFile_willEacces) {
if (IsWindows()) return; // TODO: fixme
if (IsWindows())
return; // TODO: fixme
setenv("PATH", "foo", true);
EXPECT_SYS(0, 0, mkdir("foo", 0755));
EXPECT_SYS(0, 0, touch("foo/bar", 0400));

View file

@ -94,19 +94,23 @@ bool HasCopyFileRange(void) {
}
TEST(copy_file_range, badFd) {
if (!HasCopyFileRange()) return;
if (!HasCopyFileRange())
return;
ASSERT_SYS(EBADF, -1, copy_file_range(-1, 0, -1, 0, -1u, 0));
}
TEST(copy_file_range, badFlags) {
if (!HasCopyFileRange()) return;
if (!HasCopyFileRange())
return;
ASSERT_SYS(EINVAL, -1, copy_file_range(0, 0, 1, 0, -1u, -1));
}
TEST(copy_file_range, differentFileSystems) {
return; // TODO(jart): Why does this flake on GitHub Actions?
if (!IsLinux()) return;
if (!HasCopyFileRange()) return;
if (!IsLinux())
return;
if (!HasCopyFileRange())
return;
ASSERT_SYS(0, 3, open("/proc/stat", 0));
ASSERT_SYS(0, 4, creat("foo", 0644));
ASSERT_SYS(EXDEV, -1, copy_file_range(3, 0, 4, 0, -1u, 0));
@ -117,7 +121,8 @@ TEST(copy_file_range, differentFileSystems) {
TEST(copy_file_range, twoDifferentFiles) {
char buf[16] = {0};
int64_t i = 1, o = 0;
if (!HasCopyFileRange()) return;
if (!HasCopyFileRange())
return;
ASSERT_SYS(0, 3, open("foo", O_RDWR | O_CREAT | O_TRUNC, 0644));
ASSERT_SYS(0, 4, open("bar", O_RDWR | O_CREAT | O_TRUNC, 0644));
ASSERT_SYS(0, 5, pwrite(3, "hello", 5, 0));
@ -134,7 +139,8 @@ TEST(copy_file_range, twoDifferentFiles) {
TEST(copy_file_range, sameFile_doesntChangeFilePointer) {
char buf[16] = {0};
int64_t i = 1, o = 5;
if (!HasCopyFileRange()) return;
if (!HasCopyFileRange())
return;
ASSERT_SYS(0, 3, open("foo", O_RDWR | O_CREAT | O_TRUNC, 0644));
ASSERT_SYS(0, 5, pwrite(3, "hello", 5, 0));
ASSERT_SYS(0, 4, copy_file_range(3, &i, 3, &o, 4, 0));
@ -148,7 +154,8 @@ TEST(copy_file_range, sameFile_doesntChangeFilePointer) {
TEST(copy_file_range, overlappingRange) {
int rc;
int64_t i = 1, o = 2;
if (!HasCopyFileRange()) return;
if (!HasCopyFileRange())
return;
ASSERT_SYS(0, 3, open("foo", O_RDWR | O_CREAT | O_TRUNC, 0644));
ASSERT_SYS(0, 5, pwrite(3, "hello", 5, 0));
rc = copy_file_range(3, &i, 3, &o, 4, 0);

View file

@ -32,7 +32,8 @@ void SetUpOnce(void) {
TEST(devfd, test) {
// TODO: What is up with this mysterious ENOENT error?
// The code appears like it should support this.
if (IsFreebsd()) return;
if (IsFreebsd())
return;
char buf[8] = {0};
struct stat st[2] = {0};
ASSERT_SYS(0, 0, xbarf("hello.txt", "bone", -1));
@ -50,7 +51,8 @@ TEST(devfd, test) {
TEST(devfd, not_DEV_FD_STAT_BROKEN) {
// fstat() and stat() are inconsistent on bsd systems
// with xnu it only appears to be st_dev that differs
if (IsBsd()) return;
if (IsBsd())
return;
char buf[8] = {0};
struct stat st[2] = {0};
ASSERT_SYS(0, 0, xbarf("hello.txt", "bone", -1));

View file

@ -34,7 +34,8 @@ void SetUpOnce(void) {
}
TEST(fchmodat, testFchmodat) {
if (IsWindows()) return; // not advanced enough yet
if (IsWindows())
return; // not advanced enough yet
struct stat st;
umask(022);
ASSERT_SYS(0, 3,

View file

@ -139,8 +139,10 @@ void OnSig(int sig) {
}
TEST(posixAdvisoryLocks, twoProcesses) {
if (IsWindows()) return; // due to signals
if (IsNetbsd()) return; // TODO: why does sigusr1 kill runitd?
if (IsWindows())
return; // due to signals
if (IsNetbsd())
return; // TODO: why does sigusr1 kill runitd?
int ws, pid;
struct flock lock;

View file

@ -70,7 +70,8 @@ TEST(ftruncate, pipeFd_einval) {
TEST(ftruncate, efbig) {
// FreeBSD and RHEL7 return 0 (why??)
if (IsLinux() || IsFreebsd()) return;
if (IsLinux() || IsFreebsd())
return;
sighandler_t old = signal(SIGXFSZ, SIG_IGN);
ASSERT_SYS(0, 3, creat("foo", 0755));
ASSERT_SYS(IsWindows() ? EINVAL : EFBIG, -1, ftruncate(3, INT64_MAX));

View file

@ -33,7 +33,8 @@ void SetUpOnce(void) {
}
TEST(__getcwd, zero) {
if (IsQemuUser()) return;
if (IsQemuUser())
return;
ASSERT_SYS(ERANGE, -1, __getcwd(0, 0));
}
@ -83,7 +84,8 @@ TEST(getcwd, testNullBuf_allocatesResult) {
}
TEST(getcwd, testWindows_addsFunnyPrefix) {
if (!IsWindows()) return;
if (!IsWindows())
return;
char path[PATH_MAX];
ASSERT_NE(0, getcwd(path, sizeof(path)));
path[1] = tolower(path[1]);

View file

@ -23,9 +23,11 @@
TEST(getgroups, test) {
int n;
if (IsWindows()) return;
if (IsWindows())
return;
uint32_t G[500];
EXPECT_GT((n = getgroups(ARRAYLEN(G), G)), 0);
if (getuid()) return; // this needs root
if (getuid())
return; // this needs root
EXPECT_SYS(0, 0, setgroups(n, G));
}

View file

@ -103,7 +103,8 @@ TEST(GetProgramExecutableName, ofThisFile) {
}
TEST(GetProgramExecutableName, nullEnv) {
if (skiptests) return;
if (skiptests)
return;
SPAWN(fork);
execve(self, (char *[]){self, "Child", self, skiparg0 ? 0 : self, 0},
(char *[]){0});
@ -112,7 +113,8 @@ TEST(GetProgramExecutableName, nullEnv) {
}
TEST(GetProramExecutableName, weirdArgv0NullEnv) {
if (skiptests) return;
if (skiptests)
return;
SPAWN(fork);
execve(self, (char *[]){"hello", "Child", self, skiparg0 ? 0 : "hello", 0},
(char *[]){0});
@ -121,7 +123,8 @@ TEST(GetProramExecutableName, weirdArgv0NullEnv) {
}
TEST(GetProgramExecutableName, movedSelf) {
if (skiptests) return;
if (skiptests)
return;
if (IsAarch64() && IsQemuUser()) {
// clang-format off
// TODO(mrdomino): fix: make -j8 m=aarch64 o/aarch64/test/libc/calls/getprogramexecutablename_test.ok

View file

@ -59,9 +59,11 @@ void *TortureWorker(void *arg) {
ASSERT_SYS(0, 0, sigprocmask(SIG_SETMASK, &ss, 0));
ready = true;
while (!done) {
if (!IsWindows()) pthread_kill(parent, SIGUSR1);
if (!IsWindows())
pthread_kill(parent, SIGUSR1);
usleep(1);
if (!IsWindows()) pthread_kill(parent, SIGUSR2);
if (!IsWindows())
pthread_kill(parent, SIGUSR2);
usleep(1);
}
return 0;
@ -78,9 +80,11 @@ TEST(getrandom, test) {
if ((e = MeasureEntropy(buf, n)) < w) {
fprintf(stderr, "error: entropy is suspect! got %g but want >=%g\n", e, w);
for (i = 0; i < n;) {
if (!(i % 16)) fprintf(stderr, "%6x ", i);
if (!(i % 16))
fprintf(stderr, "%6x ", i);
fprintf(stderr, "%lc", kCp437[buf[i] & 255]);
if (!(++i % 16)) fprintf(stderr, "\n");
if (!(++i % 16))
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
exit(1);
@ -100,7 +104,8 @@ TEST(getrandom, test2) {
ASSERT_SYS(0, 0, sigaction(SIGUSR2, &sa, 0));
parent = pthread_self();
ASSERT_EQ(0, pthread_create(&child, 0, TortureWorker, 0));
while (!ready) pthread_yield();
while (!ready)
pthread_yield();
for (k = 0; k < 10; ++k) {
ASSERT_SYS(0, 0, getrandom(0, 0, 0));
for (i = 0; i < n; i += m) {
@ -111,9 +116,11 @@ TEST(getrandom, test2) {
if ((e = MeasureEntropy(buf, n)) < w) {
fprintf(stderr, "error: entropy suspect! got %g but want >=%g\n", e, w);
for (i = 0; i < n;) {
if (!(i % 16)) fprintf(stderr, "%6x ", i);
if (!(i % 16))
fprintf(stderr, "%6x ", i);
fprintf(stderr, "%lc", kCp437[buf[i] & 255]);
if (!(++i % 16)) fprintf(stderr, "\n");
if (!(++i % 16))
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
done = true;
@ -123,7 +130,8 @@ TEST(getrandom, test2) {
}
done = true;
ASSERT_EQ(0, pthread_join(child, 0));
if (!IsWindows()) ASSERT_GT(gotsome, 0);
if (!IsWindows())
ASSERT_GT(gotsome, 0);
}
/* JustReturnZero */
@ -237,13 +245,15 @@ uint64_t SixthEditionLowByte(void) {
uint64_t MobyDick(void) {
static int i;
if ((i += 8) > kMobySize) i = 8;
if ((i += 8) > kMobySize)
i = 8;
return READ64LE(kMoby + i);
}
uint64_t ExecutableImage(void) {
static int i;
if ((i += 8) > _end - __executable_start) i = 8;
if ((i += 8) > _end - __executable_start)
i = 8;
return READ64LE(__executable_start + i);
}

View file

@ -49,7 +49,8 @@ TEST(siocgifconf, test) {
conf.ifc_len = n;
ASSERT_NE(-1, ioctl(socketfd, SIOCGIFCONF, &conf));
for (ifr = (struct ifreq *)data; (char *)ifr < data + conf.ifc_len; ++ifr) {
if (ifr->ifr_addr.sa_family != AF_INET) continue;
if (ifr->ifr_addr.sa_family != AF_INET)
continue;
ip = ntohl(((struct sockaddr_in *)&ifr->ifr_addr)->sin_addr.s_addr);
EXPECT_NE(-1, ioctl(socketfd, SIOCGIFNETMASK, ifr));
netmask = ntohl(((struct sockaddr_in *)&ifr->ifr_addr)->sin_addr.s_addr);
@ -72,7 +73,8 @@ TEST(siocgifconf, test) {
}
TEST(siocgifconf, mkntenvblock_systemroot) {
if (__argc != 1) return;
if (__argc != 1)
return;
SPAWN(fork);
execve(GetProgramExecutableName(),
(char *[]){GetProgramExecutableName(), "hi", NULL}, (char *[]){NULL});

View file

@ -48,7 +48,8 @@ _Thread_local const char *kind;
bool SupportsOfdLocks(void) {
int e;
bool r;
if (!IsLinux()) return false;
if (!IsLinux())
return false;
// F_OFD_* was introduced in linux 3.15
// getrandom() was introduced in linux 3.17
// testing for getrandom() should be a sure thing w/o creating an fd

View file

@ -72,8 +72,10 @@ TEST(madvise, subPages) {
TEST(madvise, misalign) {
char *p;
if (!IsLinux()) return; // most platforms don't care
if (IsQemuUser()) return; // qemu claims to be linux but doesn't care
if (!IsLinux())
return; // most platforms don't care
if (IsQemuUser())
return; // qemu claims to be linux but doesn't care
ASSERT_NE(MAP_FAILED, (p = mmap(0, FRAMESIZE, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0)));
ASSERT_SYS(EINVAL, -1, madvise(p + 1, FRAMESIZE - 1, MADV_WILLNEED));
@ -82,7 +84,8 @@ TEST(madvise, misalign) {
TEST(madvise, badAdvice) {
char *p;
if (IsAarch64() && IsQemuUser()) return; // qemu doesn't validate advice
if (IsAarch64() && IsQemuUser())
return; // qemu doesn't validate advice
ASSERT_NE(MAP_FAILED, (p = mmap(0, FRAMESIZE, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0)));
ASSERT_SYS(EINVAL, -1, madvise(p, FRAMESIZE, 127));
@ -90,8 +93,10 @@ TEST(madvise, badAdvice) {
}
TEST(madvise, missingMemory) {
if (!IsLinux()) return; // most platforms don't care
if (IsQemuUser()) return; // qemu claims to be linux but doesn't care
if (!IsLinux())
return; // most platforms don't care
if (IsQemuUser())
return; // qemu claims to be linux but doesn't care
ASSERT_SYS(ENOMEM, -1,
madvise((char *)0x83483838000, FRAMESIZE, MADV_WILLNEED));
}

View file

@ -71,7 +71,9 @@ TEST(makedirs, test) {
int i, n = 8;
pthread_t *t = gc(malloc(sizeof(pthread_t) * n));
ASSERT_EQ(0, pthread_barrier_init(&barrier, 0, n));
for (i = 0; i < n; ++i) ASSERT_EQ(0, pthread_create(t + i, 0, Worker, 0));
for (i = 0; i < n; ++i) EXPECT_EQ(0, pthread_join(t[i], 0));
for (i = 0; i < n; ++i)
ASSERT_EQ(0, pthread_create(t + i, 0, Worker, 0));
for (i = 0; i < n; ++i)
EXPECT_EQ(0, pthread_join(t[i], 0));
ASSERT_EQ(0, pthread_barrier_destroy(&barrier));
}

View file

@ -71,7 +71,8 @@ TEST(mkdir, enametoolong) {
int i;
size_t n = 2048;
char *s = gc(calloc(1, n));
for (i = 0; i < n - 1; ++i) s[i] = 'x';
for (i = 0; i < n - 1; ++i)
s[i] = 'x';
s[i] = 0;
EXPECT_SYS(ENAMETOOLONG, -1, mkdir(s, 0644));
}
@ -96,7 +97,8 @@ TEST(mkdirat, testRelativePath_opensRelativeToDirFd) {
TEST(mkdir, longname) {
int i;
char *d, s[270] = {0};
for (i = 0; i < sizeof(s) - 1; ++i) s[i] = 'x';
for (i = 0; i < sizeof(s) - 1; ++i)
s[i] = 'x';
s[i] = 0;
ASSERT_NE(NULL, (d = gc(getcwd(0, 0))));
memcpy(s, d, strlen(d));

View file

@ -47,7 +47,8 @@ void SetUpOnce(void) {
TEST(open, efault) {
ASSERT_SYS(EFAULT, -1, open(0, O_RDONLY));
if (IsWindows() || !IsAsan()) return; // not possible
if (IsWindows() || !IsAsan())
return; // not possible
ASSERT_SYS(EFAULT, -1, open((void *)77, O_RDONLY));
}
@ -231,7 +232,8 @@ TEST(open, norm) {
}
TEST(open, longNormDot) {
if (IsWindows()) return; // todo: why won't long paths work on windows
if (IsWindows())
return; // todo: why won't long paths work on windows
#define NAME \
"funfunfunfunfunfunfunfunfunfunfunfunfunfunfunfunfunfunfunfunfunfunfunfunfu" \
"nfunfunfunfunfunfunnfunfunfunfunfunfunnfunfunfunfunfunfununfunfunfunfunfun"
@ -243,7 +245,8 @@ TEST(open, longNormDot) {
}
TEST(open, longNormDotDot) {
if (IsWindows()) return; // todo: why won't long paths work on windows
if (IsWindows())
return; // todo: why won't long paths work on windows
#define NAME \
"funfunfunfunfunfunfunfunfunfunfunfunfunfunfunfunfunfunfunfunfunfunfunfunfu" \
"nfunfunfunfunfunfunnfunfunfunfunfunfunnfunfunfunfunfunfununfunfunfunfunfun"
@ -258,7 +261,8 @@ TEST(open, longNormDotDot) {
TEST(open, creat_directory) {
ASSERT_SYS(ENOENT, -1, open("fun", O_WRONLY | O_DIRECTORY));
ASSERT_FALSE(fileexists("fun"));
if (1) return; // linux 5.15.122-0-lts creates file and returns error D:
if (1)
return; // linux 5.15.122-0-lts creates file and returns error D:
ASSERT_SYS(ENOTDIR, -1, open("fun", O_CREAT | O_WRONLY | O_DIRECTORY, 0644));
ASSERT_TRUE(fileexists("fun"));
}
@ -312,7 +316,8 @@ int CountFds(void) {
}
TEST(open, lotsOfFds) {
if (!IsWindows()) return;
if (!IsWindows())
return;
int i, n = 200;
ASSERT_SYS(0, 0, xbarf("hello.txt", "hello", -1));
for (i = 3; i < n; ++i) {
@ -331,7 +336,8 @@ static int64_t GetInode(const char *path) {
}
TEST(open, drive) {
if (!IsWindows()) return;
if (!IsWindows())
return;
ASSERT_NE(GetInode("/"), GetInode("."));
ASSERT_EQ(GetInode("/"), GetInode("/c")); // sorry you have to run on c:/
ASSERT_EQ(GetInode("/"), GetInode("/c/"));
@ -430,7 +436,8 @@ TEST(open, creatRdonly) {
}
TEST(open, sequentialRandom_EINVAL) {
if (!IsWindows()) return;
if (!IsWindows())
return;
ASSERT_SYS(
EINVAL, -1,
open("foo", O_CREAT | O_TRUNC | O_RDWR | O_SEQUENTIAL | O_RANDOM, 0700));
@ -442,7 +449,8 @@ TEST(open, sequentialRandom_EINVAL) {
// timestamps of the file and the last data modification and last
// file status change timestamps of the parent directory." -POSIX
TEST(open, creatFile_touchesDirectory) {
if (1) return; // TODO(jart): explain the rare flakes
if (1)
return; // TODO(jart): explain the rare flakes
struct stat st;
struct timespec birth;
ASSERT_SYS(0, 0, mkdir("dir", 0755));

View file

@ -50,7 +50,8 @@ TEST(openatemp, unlink) {
}
TEST(openatemp, mode) {
if (IsWindows()) return;
if (IsWindows())
return;
unsigned omask = umask(0);
char path[] = "foo.XXXXXX";
ASSERT_SYS(0, 3, openatemp(AT_FDCWD, path, 0, 0, 0764));

View file

@ -26,8 +26,10 @@
#include "libc/testlib/testlib.h"
void CheckPlatform(void) {
if (IsOpenbsd()) return; // openbsd is ok
if (IsLinux() && __is_linux_2_6_23()) return; // non-ancient linux is ok
if (IsOpenbsd())
return; // openbsd is ok
if (IsLinux() && __is_linux_2_6_23())
return; // non-ancient linux is ok
kprintf("skipping openbsd_test\n");
exit(0);
}

View file

@ -38,8 +38,10 @@ TEST(pipe, einval) {
}
TEST(pipe, ebadf) {
if (IsFreebsd()) return; // somehow succeeds
if (IsOpenbsd()) return; // somehow succeeds
if (IsFreebsd())
return; // somehow succeeds
if (IsOpenbsd())
return; // somehow succeeds
EXPECT_SYS(0, 0, pipe(f));
EXPECT_SYS(EBADF, -1, write(f[0], "h", 1));
EXPECT_SYS(EBADF, -1, read(f[1], buf, 1));
@ -48,8 +50,10 @@ TEST(pipe, ebadf) {
}
TEST(pipe, emfile) {
if (IsWindows()) return; // TODO
if (IsCygwin()) return;
if (IsWindows())
return; // TODO
if (IsCygwin())
return;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
ASSERT_EQ(0, setrlimit(RLIMIT_NOFILE, &rlim));

View file

@ -41,7 +41,8 @@ void SetUp(void) {
}
TEST(pledge, testSoftError) {
if (IsOpenbsd()) return;
if (IsOpenbsd())
return;
SPAWN(fork);
__pledge_mode = PLEDGE_PENALTY_RETURN_EPERM;
ASSERT_SYS(0, 0, pledge("stdio", 0));
@ -67,7 +68,8 @@ TEST(pledge, testKillProcessMode) {
}
TEST(pledge, testLogMessage_inSoftyMode) {
if (IsOpenbsd()) return;
if (IsOpenbsd())
return;
int fds[2];
char msg[256] = {0};
ASSERT_SYS(0, 0, pipe(fds));

View file

@ -103,7 +103,8 @@ TEST(pledge, default_allowsExit) {
}
TEST(pledge, execpromises_notok) {
if (IsOpenbsd()) return; // b/c testing linux bpf
if (IsOpenbsd())
return; // b/c testing linux bpf
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
@ -134,7 +135,8 @@ TEST(pledge, tester) {
}
TEST(pledge, withThreadMemory) {
if (IsOpenbsd()) return; // openbsd doesn't allow it, wisely
if (IsOpenbsd())
return; // openbsd doesn't allow it, wisely
pthread_t worker;
int job[2] = {2, 2}; // create workload
ASSERT_EQ(0, pthread_create(&worker, 0, Enclave, job)); // create worker
@ -159,7 +161,8 @@ void *TgkillWorker(void *arg) {
TEST(pledge, tgkill) {
// https://github.com/jart/cosmopolitan/issues/628
if (!IsLinux()) return;
if (!IsLinux())
return;
sigset_t mask;
pthread_t worker;
SPAWN(fork);
@ -176,7 +179,8 @@ TEST(pledge, tgkill) {
}
TEST(pledge, stdio_forbidsOpeningPasswd1) {
if (!IsLinux()) return;
if (!IsLinux())
return;
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
@ -204,7 +208,8 @@ TEST(pledge, stdio_forbidsOpeningPasswd2) {
}
TEST(pledge, multipleCalls_canOnlyBecomeMoreRestrictive1) {
if (IsOpenbsd()) return;
if (IsOpenbsd())
return;
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
@ -223,7 +228,8 @@ TEST(pledge, multipleCalls_canOnlyBecomeMoreRestrictive1) {
}
TEST(pledge, multipleCalls_canOnlyBecomeMoreRestrictive2) {
if (!IsOpenbsd()) return;
if (!IsOpenbsd())
return;
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
@ -237,7 +243,8 @@ TEST(pledge, multipleCalls_canOnlyBecomeMoreRestrictive2) {
}
TEST(pledge, multipleCalls_canOnlyBecomeMoreRestrictive3) {
if (!IsOpenbsd()) return;
if (!IsOpenbsd())
return;
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
@ -252,7 +259,8 @@ TEST(pledge, multipleCalls_canOnlyBecomeMoreRestrictive3) {
}
TEST(pledge, stdio_fcntl_allowsSomeFirstArgs) {
if (IsOpenbsd()) return; // b/c testing linux bpf
if (IsOpenbsd())
return; // b/c testing linux bpf
int ws, pid;
struct flock lk;
ASSERT_NE(-1, (pid = fork()));
@ -275,7 +283,8 @@ TEST(pledge, stdio_fcntl_allowsSomeFirstArgs) {
}
TEST(pledge, stdioTty_sendtoRestricted_requiresNullAddr) {
if (IsOpenbsd()) return; // b/c testing linux bpf
if (IsOpenbsd())
return; // b/c testing linux bpf
int ws, pid, sv[2];
ASSERT_SYS(0, 0, socketpair(AF_UNIX, SOCK_STREAM, 0, sv));
ASSERT_NE(-1, (pid = fork()));
@ -303,7 +312,8 @@ TEST(pledge, stdioTty_sendtoRestricted_requiresNullAddr) {
}
TEST(pledge, unix_forbidsInetSockets) {
if (IsOpenbsd()) return; // b/c testing linux bpf
if (IsOpenbsd())
return; // b/c testing linux bpf
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
@ -345,7 +355,8 @@ TEST(pledge, wpath_doesNotImplyRpath) {
}
TEST(pledge, inet_forbidsOtherSockets) {
if (IsOpenbsd()) return; // b/c testing linux bpf
if (IsOpenbsd())
return; // b/c testing linux bpf
int ws, pid, yes = 1;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
@ -376,7 +387,8 @@ TEST(pledge, inet_forbidsOtherSockets) {
}
TEST(pledge, anet_forbidsUdpSocketsAndConnect) {
if (IsOpenbsd()) return; // b/c testing linux bpf
if (IsOpenbsd())
return; // b/c testing linux bpf
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
@ -392,7 +404,8 @@ TEST(pledge, anet_forbidsUdpSocketsAndConnect) {
}
TEST(pledge, mmap) {
if (IsOpenbsd()) return; // b/c testing linux bpf
if (IsOpenbsd())
return; // b/c testing linux bpf
char *p;
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
@ -413,7 +426,8 @@ TEST(pledge, mmap) {
}
TEST(pledge, mmapProtExec) {
if (IsOpenbsd()) return; // b/c testing linux bpf
if (IsOpenbsd())
return; // b/c testing linux bpf
char *p;
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
@ -432,7 +446,8 @@ TEST(pledge, mmapProtExec) {
}
TEST(pledge, chmod_ignoresDangerBits) {
if (IsOpenbsd()) return; // b/c testing linux bpf
if (IsOpenbsd())
return; // b/c testing linux bpf
int ws, pid;
ASSERT_SYS(0, 3, creat("foo", 0644));
ASSERT_NE(-1, (pid = fork()));
@ -452,7 +467,8 @@ TEST(pledge, chmod_ignoresDangerBits) {
}
TEST(pledge, open_rpath) {
if (IsOpenbsd()) return; // b/c testing linux bpf
if (IsOpenbsd())
return; // b/c testing linux bpf
int ws, pid;
ASSERT_SYS(0, 0, touch("foo", 0644));
ASSERT_NE(-1, (pid = fork()));
@ -470,7 +486,8 @@ TEST(pledge, open_rpath) {
}
TEST(pledge, open_wpath) {
if (IsOpenbsd()) return; // b/c testing linux bpf
if (IsOpenbsd())
return; // b/c testing linux bpf
int ws, pid;
ASSERT_SYS(0, 0, touch("foo", 0644));
ASSERT_NE(-1, (pid = fork()));
@ -487,7 +504,8 @@ TEST(pledge, open_wpath) {
}
TEST(pledge, open_cpath) {
if (IsOpenbsd()) return; // b/c testing linux bpf
if (IsOpenbsd())
return; // b/c testing linux bpf
int ws, pid;
struct stat st;
ASSERT_SYS(0, 0, touch("foo", 0644));
@ -508,7 +526,8 @@ TEST(pledge, open_cpath) {
}
TEST(pledge, execpromises_ok) {
if (IsOpenbsd()) return; // b/c testing linux bpf
if (IsOpenbsd())
return; // b/c testing linux bpf
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
@ -522,7 +541,8 @@ TEST(pledge, execpromises_ok) {
}
TEST(pledge, execpromises_notok1) {
if (IsOpenbsd()) return; // b/c testing linux bpf
if (IsOpenbsd())
return; // b/c testing linux bpf
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
@ -536,7 +556,8 @@ TEST(pledge, execpromises_notok1) {
}
TEST(pledge, execpromises_reducesAtExecOnLinux) {
if (IsOpenbsd()) return; // b/c testing linux bpf
if (IsOpenbsd())
return; // b/c testing linux bpf
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
@ -550,8 +571,10 @@ TEST(pledge, execpromises_reducesAtExecOnLinux) {
}
TEST(pledge_openbsd, execpromisesIsNull_letsItDoAnything) {
if (IsOpenbsd()) return; // mimmutable() ugh
if (!IsOpenbsd()) return;
if (IsOpenbsd())
return; // mimmutable() ugh
if (!IsOpenbsd())
return;
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
@ -567,8 +590,10 @@ TEST(pledge_openbsd, execpromisesIsNull_letsItDoAnything) {
}
TEST(pledge_openbsd, execpromisesIsSuperset_letsItDoAnything) {
if (IsOpenbsd()) return; // mimmutable() ugh
if (!IsOpenbsd()) return;
if (IsOpenbsd())
return; // mimmutable() ugh
if (!IsOpenbsd())
return;
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
@ -582,12 +607,14 @@ TEST(pledge_openbsd, execpromisesIsSuperset_letsItDoAnything) {
}
TEST(pledge_linux, execpromisesIsSuperset_notPossible) {
if (IsOpenbsd()) return;
if (IsOpenbsd())
return;
ASSERT_SYS(EINVAL, -1, pledge("stdio exec", "stdio inet exec"));
}
TEST(pledge_openbsd, execpromises_notok) {
if (IsOpenbsd()) return; // mimmutable() ugh
if (IsOpenbsd())
return; // mimmutable() ugh
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
@ -608,7 +635,8 @@ TEST(pledge_openbsd, execpromises_notok) {
}
TEST(pledge_openbsd, bigSyscalls) {
if (IsOpenbsd()) return; // testing lunix
if (IsOpenbsd())
return; // testing lunix
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {

View file

@ -66,8 +66,10 @@ TEST(poll, allZero_doesNothingPrettyMuch) {
}
TEST(ppoll, weCanProveItChecksForSignals) {
if (IsXnu()) return;
if (IsNetbsd()) return;
if (IsXnu())
return;
if (IsNetbsd())
return;
int pipefds[2];
sigset_t set, old;
struct sigaction oldss;

View file

@ -31,7 +31,8 @@ void SetUpOnce(void) {
}
void SetUp(void) {
if (IsOpenbsd() || IsXnu()) exit(0);
if (IsOpenbsd() || IsXnu())
exit(0);
}
TEST(fadvise, ebadf) {

View file

@ -78,7 +78,8 @@ TEST(read_pipe, canBeInterruptedByAlarm) {
TEST(read_directory, eisdir) {
// TODO(jart): what
if (IsWindows() || IsFreebsd()) return;
if (IsWindows() || IsFreebsd())
return;
ASSERT_SYS(0, 0, mkdir("boop", 0755));
ASSERT_SYS(0, 3, open("boop", O_RDONLY | O_DIRECTORY));
ASSERT_SYS(EISDIR, -1, read(3, 0, 0));
@ -102,7 +103,8 @@ void *GenerateData(void *arg) {
for (;;) {
usleep(223);
int rc = write(fds[1], "hi", 2);
if (rc == -1 && errno == EPIPE) break;
if (rc == -1 && errno == EPIPE)
break;
ASSERT_EQ(2, rc);
}
return 0;

View file

@ -105,8 +105,10 @@ TEST(readlinkat, statReadsNameLength_countsUtf8Bytes) {
TEST(readlinkat, realpathReturnsLongPath) {
char buf[PATH_MAX];
if (!IsWindows()) return;
if (!startswith(getcwd(buf, PATH_MAX), "/c/")) return;
if (!IsWindows())
return;
if (!startswith(getcwd(buf, PATH_MAX), "/c/"))
return;
ASSERT_SYS(0, 0, touch("froot", 0644));
ASSERT_STARTSWITH("/c/", realpath("froot", buf));
}

View file

@ -90,13 +90,17 @@ TEST(rename, enotempty) {
TEST(rename, moveIntoNonWritableDirectory_raisesEacces) {
// old versions of linux allow this
// new versions of linux report exdev?!
if (IsLinux()) return;
if (IsLinux())
return;
// netbsd and openbsd allow this
if (IsNetbsd() || IsOpenbsd()) return;
if (IsNetbsd() || IsOpenbsd())
return;
// windows doesn't really have permissions
if (IsWindows()) return;
if (IsWindows())
return;
// looks like a freebsd kernel bug
if (IsAarch64() && IsFreebsd()) return;
if (IsAarch64() && IsFreebsd())
return;
// posix specifies this behavior
ASSERT_SYS(0, 0, mkdir("foo", 0111));
ASSERT_SYS(0, 0, touch("lol", 0644));

View file

@ -65,7 +65,8 @@ TEST(sched_setscheduler, test) {
}
TEST(sched_setscheduler, testMidpoint) {
if (!CanTuneRealtimeSchedulers()) return;
if (!CanTuneRealtimeSchedulers())
return;
struct sched_param p = {(sched_get_priority_min(SCHED_FIFO) +
sched_get_priority_max(SCHED_FIFO)) /
2};

View file

@ -61,9 +61,12 @@ TEST(setrlimit, testCpuLimit) {
struct rlimit rlim;
struct timespec start;
double matrices[3][3][3];
if (IsWindows()) return; // of course it doesn't work on windows
if (IsXnu()) return; // TODO(jart): it worked before
if (IsOpenbsd()) return; // TODO(jart): fix flake
if (IsWindows())
return; // of course it doesn't work on windows
if (IsXnu())
return; // TODO(jart): it worked before
if (IsOpenbsd())
return; // TODO(jart): fix flake
ASSERT_NE(-1, (wstatus = xspawn(0)));
if (wstatus == -2) {
ASSERT_EQ(0, xsigaction(SIGXCPU, OnSigxcpu, 0, 0, 0));
@ -89,7 +92,8 @@ TEST(setrlimit, testFileSizeLimit) {
char junkdata[512];
int i, fd, wstatus;
struct rlimit rlim;
if (IsWindows()) return; /* of course it doesn't work on windows */
if (IsWindows())
return; /* of course it doesn't work on windows */
ASSERT_NE(-1, (wstatus = xspawn(0)));
if (wstatus == -2) {
ASSERT_EQ(0, xsigaction(SIGXFSZ, OnSigxfsz, 0, 0, 0));
@ -125,8 +129,10 @@ TEST(setrlimit, testMemoryLimit) {
char *p;
bool gotsome;
int i, wstatus;
if (IsXnu()) return;
if (IsAsan()) return; /* b/c we use sys_mmap */
if (IsXnu())
return;
if (IsAsan())
return; /* b/c we use sys_mmap */
ASSERT_NE(-1, (wstatus = xspawn(0)));
if (wstatus == -2) {
ASSERT_EQ(0, SetKernelEnforcedMemoryLimit(MEM));
@ -156,10 +162,14 @@ TEST(setrlimit, testMemoryLimit) {
TEST(setrlimit, testVirtualMemoryLimit) {
char *p;
int i, wstatus;
if (IsAsan()) return;
if (IsXnu()) return; /* doesn't work on darwin */
if (IsOpenbsd()) return; /* unavailable on openbsd */
if (IsWindows()) return; /* of course it doesn't work on windows */
if (IsAsan())
return;
if (IsXnu())
return; /* doesn't work on darwin */
if (IsOpenbsd())
return; /* unavailable on openbsd */
if (IsWindows())
return; /* of course it doesn't work on windows */
ASSERT_NE(-1, (wstatus = xspawn(0)));
if (wstatus == -2) {
ASSERT_EQ(0, setrlimit(RLIMIT_AS, &(struct rlimit){MEM, MEM}));
@ -184,12 +194,18 @@ TEST(setrlimit, testVirtualMemoryLimit) {
TEST(setrlimit, testDataMemoryLimit) {
char *p;
int i, wstatus;
if (IsAsan()) return;
if (IsXnu()) return; /* doesn't work on darwin */
if (IsNetbsd()) return; /* doesn't work on netbsd */
if (IsFreebsd()) return; /* doesn't work on freebsd */
if (IsLinux()) return; /* doesn't work on gnu/systemd */
if (IsWindows()) return; /* of course it doesn't work on windows */
if (IsAsan())
return;
if (IsXnu())
return; /* doesn't work on darwin */
if (IsNetbsd())
return; /* doesn't work on netbsd */
if (IsFreebsd())
return; /* doesn't work on freebsd */
if (IsLinux())
return; /* doesn't work on gnu/systemd */
if (IsWindows())
return; /* of course it doesn't work on windows */
ASSERT_NE(-1, (wstatus = xspawn(0)));
if (wstatus == -2) {
ASSERT_EQ(0, setrlimit(RLIMIT_DATA, &(struct rlimit){MEM, MEM}));
@ -231,7 +247,8 @@ wontreturn void OnVfork(void *ctx) {
TEST(setrlimit, isVforkSafe) {
int ws;
struct rlimit rlim[2];
if (IsWindows()) return; /* of course it doesn't work on windows */
if (IsWindows())
return; /* of course it doesn't work on windows */
ASSERT_EQ(0, getrlimit(RLIMIT_CPU, rlim));
ASSERT_NE(-1, (ws = xvspawn(OnVfork, rlim, 0)));
EXPECT_TRUE(WIFEXITED(ws));

View file

@ -90,7 +90,8 @@ wontreturn void Bouncer(void) {
wontreturn void Sender(void) {
/* Wait for file to exist. */
while (!*ready) donothing;
while (!*ready)
donothing;
/* Open the existing shared memory object and map it
into the caller's address space. */

View file

@ -64,9 +64,11 @@ void *Worker(void *arg) {
TEST(SetThreadContext, test) {
pthread_t th;
if (!IsWindows()) return;
if (!IsWindows())
return;
ASSERT_EQ(0, pthread_create(&th, 0, Worker, 0));
while (!ready) donothing;
while (!ready)
donothing;
usleep(1000);
int64_t hand = _pthread_syshand((struct PosixThread *)th);
ASSERT_EQ(0, SuspendThread(hand));

View file

@ -124,7 +124,8 @@ TEST(sigaction, raise) {
// test kill()
TEST(sigaction, testPingPongParentChildWithSigint) {
if (IsNetbsd()) return; // TODO: what's up with runitd on netbsd?
if (IsNetbsd())
return; // TODO: what's up with runitd on netbsd?
int pid, status;
sigset_t blockint, oldmask;
struct sigaction oldint;
@ -244,8 +245,10 @@ TEST(sigaction, ignoringSignalDiscardsSignal) {
}
TEST(sigaction, autoZombieSlayer) {
if (IsWindows()) return;
if (IsCygwin()) return;
if (IsWindows())
return;
if (IsCygwin())
return;
int pid;
struct sigaction sa;
// make sure we're starting in expected state
@ -253,7 +256,8 @@ TEST(sigaction, autoZombieSlayer) {
ASSERT_EQ(SIG_DFL, sa.sa_handler);
// verify child becomes zombie
ASSERT_NE(-1, (pid = fork()));
if (!pid) _Exit(0);
if (!pid)
_Exit(0);
ASSERT_SYS(0, pid, wait(0));
// enable automatic zombie slayer
sa.sa_handler = SIG_IGN;
@ -262,17 +266,21 @@ TEST(sigaction, autoZombieSlayer) {
ASSERT_SYS(0, 0, sigaction(SIGCHLD, &sa, &sa));
// verify it works
ASSERT_NE(-1, (pid = fork()));
if (!pid) _Exit(0);
if (!pid)
_Exit(0);
// XXX: WSL does the wrong thing here.
if (__iswsl1()) usleep(10);
if (__iswsl1())
usleep(10);
ASSERT_SYS(ECHILD, -1, wait(0));
// clean up
ASSERT_SYS(0, 0, sigaction(SIGCHLD, &sa, 0));
}
TEST(sigaction, enosys_returnsErrnoRatherThanSigsysByDefault) {
if (IsTiny()) return; // systemfive.S disables the fix w/ tiny
if (IsOpenbsd()) return; // TODO: Why does OpenBSD raise SIGABRT?
if (IsTiny())
return; // systemfive.S disables the fix w/ tiny
if (IsOpenbsd())
return; // TODO: Why does OpenBSD raise SIGABRT?
ASSERT_SYS(ENOSYS, -1, sys_bogus());
}
@ -373,7 +381,8 @@ dontubsan dontasan int Segfault(char *p) {
int (*pSegfault)(char *) = Segfault;
TEST(sigaction, returnFromSegvHandler_loopsForever) {
if (IsXnu()) return; // seems busted
if (IsXnu())
return; // seems busted
segfaults = _mapshared(sizeof(*segfaults));
SPAWN(fork);
signal(SIGSEGV, OnSegfault);

View file

@ -30,10 +30,14 @@
#include "libc/testlib/testlib.h"
void SetUp(void) {
if (IsXnu()) exit(0);
if (IsMetal()) exit(0);
if (IsWindows()) exit(0);
if (IsOpenbsd()) exit(0);
if (IsXnu())
exit(0);
if (IsMetal())
exit(0);
if (IsWindows())
exit(0);
if (IsOpenbsd())
exit(0);
}
TEST(sigtimedwait, nullSet_efault) {

View file

@ -91,7 +91,8 @@ int StackOverflow(int f(), int n) {
int (*pStackOverflow)(int (*)(), int) = StackOverflow;
TEST(stackoverflow, standardStack_altStack_process_longjmp) {
if (IsTiny()) return; // TODO(jart): why?
if (IsTiny())
return; // TODO(jart): why?
int jumpcode;
if (!(jumpcode = setjmp(recover))) {

View file

@ -94,7 +94,8 @@ TEST(timeval_toseconds, test) {
}
static long mod(long x, long y) {
if (y == -1) return 0;
if (y == -1)
return 0;
return x - y * (x / y - (x % y && (x ^ y) < 0));
}

View file

@ -30,7 +30,8 @@ void SetUpOnce(void) {
TEST(unlink, efault) {
ASSERT_SYS(EFAULT, -1, unlink(0));
if (IsWindows() || !IsAsan()) return; // not possible
if (IsWindows() || !IsAsan())
return; // not possible
ASSERT_SYS(EFAULT, -1, unlink((void *)77));
}

View file

@ -94,7 +94,8 @@ TEST(unveil, api_differences) {
}
TEST(unveil, rx_readOnlyPreexistingExecutable_worksFine) {
if (IsOpenbsd()) return; // TOOD(jart): why pledge violation?
if (IsOpenbsd())
return; // TOOD(jart): why pledge violation?
SPAWN(fork);
ASSERT_SYS(0, 0, mkdir("folder", 0755));
testlib_extract("/zip/life.elf", "folder/life.elf", 0755);
@ -151,7 +152,8 @@ TEST(unveil, rwc_createExecutableFile_isAllowedButCantBeRun) {
}
TEST(unveil, rwcx_createExecutableFile_canAlsoBeRun) {
if (IsOpenbsd()) return; // TOOD(jart): why pledge violation?
if (IsOpenbsd())
return; // TOOD(jart): why pledge violation?
SPAWN(fork);
ASSERT_SYS(0, 0, mkdir("folder", 0755));
ASSERT_SYS(0, 0, unveil("folder", "rwcx"));
@ -179,7 +181,8 @@ TEST(unveil, dirfdHacking_doesntWork) {
}
TEST(unveil, mostRestrictivePolicy) {
if (IsOpenbsd()) return; // openbsd behaves oddly; see docs
if (IsOpenbsd())
return; // openbsd behaves oddly; see docs
SPAWN(fork);
ASSERT_SYS(0, 0, mkdir("jail", 0755));
ASSERT_SYS(0, 0, mkdir("garden", 0755));
@ -221,7 +224,8 @@ TEST(unveil, overlappingDirectories_inconsistentBehavior) {
}
TEST(unveil, usedTwice_allowedOnLinux) {
if (IsOpenbsd()) return;
if (IsOpenbsd())
return;
SPAWN(fork);
ASSERT_SYS(0, 0, mkdir("jail", 0755));
ASSERT_SYS(0, 0, xbarf("jail/ok.txt", "hello", 5));
@ -259,7 +263,8 @@ TEST(unveil, truncate_isForbiddenBySeccomp) {
}
TEST(unveil, ftruncate_isForbidden) {
if (IsOpenbsd()) return; // b/c O_PATH is a Linux thing
if (IsOpenbsd())
return; // b/c O_PATH is a Linux thing
SPAWN(fork);
ASSERT_SYS(0, 0, mkdir("jail", 0755));
ASSERT_SYS(0, 0, mkdir("garden", 0755));
@ -275,7 +280,8 @@ TEST(unveil, ftruncate_isForbidden) {
}
TEST(unveil, procfs_isForbiddenByDefault) {
if (IsOpenbsd()) return;
if (IsOpenbsd())
return;
SPAWN(fork);
ASSERT_SYS(0, 0, mkdir("jail", 0755));
ASSERT_SYS(0, 0, unveil("jail", "rw"));

View file

@ -58,7 +58,8 @@ TEST(utimes, test) {
}
TEST(futimes, test) {
if (IsLinux() && !__is_linux_2_6_23()) return;
if (IsLinux() && !__is_linux_2_6_23())
return;
struct stat st;
struct timeval tv[2] = {{1655455857, 1}, {827727928, 2}};
EXPECT_SYS(0, 3, creat("boop", 0644));
@ -123,7 +124,8 @@ TEST(utimensat, testOmit) {
TEST(futimens, test2) {
struct timespec ts[2];
int fd = creat("foo", 0600);
if (fd < 0) exit(1);
if (fd < 0)
exit(1);
struct stat st;
int64_t birth;
ASSERT_SYS(0, 0, fstat(fd, &st));

View file

@ -66,7 +66,8 @@ TEST(write, readOnlyFd_ebadf) {
TEST(write, badMemory_efault) {
ASSERT_SYS(EFAULT, -1, write(1, 0, 1));
if (!IsAsan()) return;
if (!IsAsan())
return;
ASSERT_SYS(EFAULT, -1, write(1, (void *)1, 1));
}
@ -109,7 +110,8 @@ TEST(write, brokenPipe_sigpipeBlocked_returnsEpipe) {
}
TEST(write, rlimitFsizeExceeded_raisesEfbig) {
if (IsWindows()) return; // not supported
if (IsWindows())
return; // not supported
struct rlimit rl = {1, 10};
SPAWN(fork);
signal(SIGXFSZ, SIG_IGN);

View file

@ -52,7 +52,8 @@ TEST(writev, negative_einvalOrEfault) {
}
TEST(writev, exceedsIovMax_einval) {
if (IsWindows()) return; // it's complicated
if (IsWindows())
return; // it's complicated
int i, n = IOV_MAX + 1;
struct iovec *v = gc(malloc(sizeof(struct iovec) * n));
for (i = 0; i < n; ++i) {
@ -96,7 +97,8 @@ TEST(writev, big_fullCompletion) {
}
TEST(writev, asanError_efaults) {
if (!IsAsan()) return;
if (!IsAsan())
return;
void *malloc_(size_t) asm("malloc");
void free_(void *) asm("free");
void *p;