From 22bf046643a22b1ab26d32a75f9211d9e6bbe10a Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sat, 17 Feb 2024 15:33:08 +0000 Subject: [PATCH] Fix fix fix tests. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4852 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- src/main.c | 3 +-- src/task.c | 12 ++++++++++-- src/taskstub.js.c | 1 + src/tests.c | 5 ++--- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main.c b/src/main.c index ee1809a9..39df759e 100644 --- a/src/main.c +++ b/src/main.c @@ -398,8 +398,7 @@ static void _shed_privileges() #if defined(__OpenBSD__) /* How do I unveil nothing? */ - if (unveil("/dev/null", "r") || - unveil(NULL, NULL)) + if (unveil("/dev/null", "r") || unveil(NULL, NULL)) { perror("unveil"); exit(-1); diff --git a/src/task.c b/src/task.c index 65806f85..83a6fff1 100644 --- a/src/task.c +++ b/src/task.c @@ -34,6 +34,10 @@ #include #endif +#if defined(_WIN32) +#define WEXITSTATUS(x) (x) +#endif + #if !defined(__APPLE__) && !defined(__OpenBSD__) #include #endif @@ -2134,8 +2138,12 @@ static JSValue _tf_task_setTimeout(JSContext* context, JSValueConst this_val, in static JSValue _tf_task_pokeSandbox(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv) { +#if TARGET_OS_IPHONE + tf_printf("Not sure what we can try to poke on iOS.\n"); +#else tf_printf("Poking sandbox.\n"); - system("pwd"); + int result = system("pwd"); tf_printf("Sandbox poked.\n"); - return JS_UNDEFINED; +#endif + return JS_NewInt32(context, WEXITSTATUS(result)); } diff --git a/src/taskstub.js.c b/src/taskstub.js.c index 60c9671f..83ee41dc 100644 --- a/src/taskstub.js.c +++ b/src/taskstub.js.c @@ -175,6 +175,7 @@ static JSValue _taskstub_create(JSContext* context, JSValueConst this_val, int a options.stdio = io; options.stdio_count = sizeof(io) / sizeof(*io); options.file = command_argv[0]; + options.env = (char*[]) { "ASAN_OPTIONS=detect_leaks=0", NULL }; stub->_process.data = stub; int spawn_result = uv_spawn(tf_task_get_loop(parent), &stub->_process, &options); diff --git a/src/tests.c b/src/tests.c index 92e8ba2c..5b1b3c66 100644 --- a/src/tests.c +++ b/src/tests.c @@ -77,9 +77,8 @@ static void _test_sandbox(const tf_test_options_t* options) _write_file("out/child.js", "print('Poking the sandbox. This should fail.');\n" - "pokeSandbox();\n" - "print('We poked the sandbox without failing.');\n" - "exit(0);\n"); + "let r = pokeSandbox();\n" + "exit(r);\n"); char command[256]; snprintf(command, sizeof(command), "%s run --db-path=:memory: -s out/test.js" TEST_ARGS, options->exe_path);