mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-26 22:38:30 +00:00
Perform code cleanup on test pledges
This commit is contained in:
parent
3d2cf95af1
commit
3443039f34
54 changed files with 112 additions and 83 deletions
|
@ -29,7 +29,7 @@
|
|||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath fattr", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath fattr", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ char tmp[PATH_MAX];
|
|||
char pathbuf[PATH_MAX];
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath fattr", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath fattr proc exec", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath fattr", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath fattr", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -29,28 +29,23 @@
|
|||
|
||||
int64_t fd;
|
||||
struct stat st;
|
||||
const char *path;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
||||
TEST(ftruncate, test) {
|
||||
mkdir("o", 0755);
|
||||
mkdir("o/tmp", 0755);
|
||||
path = gc(xasprintf("o/tmp/%s.%d",
|
||||
firstnonnull(program_invocation_short_name, "unknown"),
|
||||
getpid()));
|
||||
ASSERT_NE(-1, (fd = creat(path, 0755)));
|
||||
ASSERT_NE(-1, (fd = creat("foo", 0755)));
|
||||
ASSERT_EQ(5, write(fd, "hello", 5));
|
||||
errno = 31337;
|
||||
ASSERT_NE(-1, ftruncate(fd, 31337));
|
||||
EXPECT_EQ(31337, errno);
|
||||
ASSERT_EQ(5, write(fd, "world", 5));
|
||||
ASSERT_NE(-1, close(fd));
|
||||
ASSERT_NE(-1, stat(path, &st));
|
||||
ASSERT_NE(-1, stat("foo", &st));
|
||||
ASSERT_EQ(31337, st.st_size);
|
||||
ASSERT_BINEQ(u"helloworld", gc(xslurp(path, 0)));
|
||||
unlink(path);
|
||||
ASSERT_BINEQ(u"helloworld", gc(xslurp("foo", 0)));
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath cpath fattr", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath fattr proc", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath fattr", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath fattr", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ int fd;
|
|||
char buf[8];
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath fattr", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/x/x.h"
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath tty proc", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ char buf[8];
|
|||
struct stat st;
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath fattr", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath fattr", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath fattr", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
#include "libc/testlib/testlib.h"
|
||||
#include "tool/net/sandbox.h"
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
pledge("stdio rpath proc", 0);
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio proc", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
|
||||
bool gotsig;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
pledge("stdio rpath", 0);
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
struct sigaction oldsa;
|
||||
volatile bool gotsigint;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath proc", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -28,8 +28,8 @@ testonly void OnUsr1(int sig) {
|
|||
_exit(0);
|
||||
}
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
pledge("stdio rpath proc", 0);
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio proc", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
|
||||
volatile int n;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
pledge("stdio rpath proc", 0);
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio proc", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ STATIC_YOINK("zip_uri_support");
|
|||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath fattr", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ char testlib_enable_tmp_setup_teardown;
|
|||
char p[2][PATH_MAX];
|
||||
struct stat st;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath fattr", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath fattr", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "libc/calls/landlock.h"
|
||||
#include "libc/calls/struct/dirent.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
|
@ -70,7 +71,7 @@ static bool SupportsLandlock(void) {
|
|||
return r;
|
||||
}
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
if (!(IsLinux() && SupportsLandlock()) && !IsOpenbsd()) exit(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath fattr", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
void SetUpOnce(void) {
|
||||
pledge("stdio rpath wpath cpath fattr", 0);
|
||||
errno = 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue