Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/wasix/tests/wasm_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ mod lifecycle_tests;
mod longjmp_tests;
mod path_tests;
mod poll_tests;
mod proc_exec;
mod proc_exec2;
mod reflection_tests;
mod semaphore_tests;
mod shared_library_tests;
Expand Down
7 changes: 7 additions & 0 deletions lib/wasix/tests/wasm_tests/proc_exec.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use super::{run_build_script, run_wasm};

#[test]
fn test_proc_exec() {
let wasm = run_build_script(file!(), ".").unwrap();
run_wasm(&wasm, wasm.parent().unwrap()).unwrap();
}
5 changes: 5 additions & 0 deletions lib/wasix/tests/wasm_tests/proc_exec/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail

$CC proc_exec_child.c -o proc_exec_child.wasm
$CC main.c -o main
20 changes: 20 additions & 0 deletions lib/wasix/tests/wasm_tests/proc_exec/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
#include <wasi/api_wasix.h>

int main(void) {
char cwd[256];
assert(getcwd(cwd, sizeof(cwd)) != NULL);

char name[512];
int name_len = snprintf(name, sizeof(name), "%s/proc_exec_child.wasm", cwd);
assert(name_len > 0 && name_len < (int)sizeof(name));

char args[512];
int args_len = snprintf(args, sizeof(args), "%s\ncanary", name);
assert(args_len > 0 && args_len < (int)sizeof(args));

__wasi_proc_exec(name, args);
assert(!"proc_exec returned");
}
8 changes: 8 additions & 0 deletions lib/wasix/tests/wasm_tests/proc_exec/proc_exec_child.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <assert.h>
#include <string.h>

int main(int argc, char** argv) {
assert(argc >= 2);
assert(strcmp(argv[1], "canary") == 0);
return 0;
}
7 changes: 7 additions & 0 deletions lib/wasix/tests/wasm_tests/proc_exec2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use super::{run_build_script, run_wasm};

#[test]
fn test_proc_exec2() {
let wasm = run_build_script(file!(), ".").unwrap();
run_wasm(&wasm, wasm.parent().unwrap()).unwrap();
}
5 changes: 5 additions & 0 deletions lib/wasix/tests/wasm_tests/proc_exec2/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail

$CC proc_exec2_child.c -o proc_exec2_child.wasm
$CC main.c -o main
22 changes: 22 additions & 0 deletions lib/wasix/tests/wasm_tests/proc_exec2/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
#include <wasi/api_wasix.h>

int main(void) {
char cwd[256];
assert(getcwd(cwd, sizeof(cwd)) != NULL);

char name[512];
int name_len = snprintf(name, sizeof(name), "%s/proc_exec2_child.wasm", cwd);
assert(name_len > 0 && name_len < (int)sizeof(name));

char args[512];
int args_len = snprintf(args, sizeof(args), "%s\ncanary", name);
assert(args_len > 0 && args_len < (int)sizeof(args));

const char* envs = "LTP_TEST_ENV_VAR=test";

__wasi_proc_exec2(name, args, envs);
assert(!"proc_exec2 returned");
}
13 changes: 13 additions & 0 deletions lib/wasix/tests/wasm_tests/proc_exec2/proc_exec2_child.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char** argv) {
assert(argc >= 2);
assert(strcmp(argv[1], "canary") == 0);

const char* v = getenv("LTP_TEST_ENV_VAR");
assert(v != NULL);
assert(strcmp(v, "test") == 0);
return 0;
}
Loading