diff --git a/tests/wasix/chdir-getcwd/main.c b/tests/wasix/chdir-getcwd/main.c new file mode 100644 index 00000000000..5e284634433 --- /dev/null +++ b/tests/wasix/chdir-getcwd/main.c @@ -0,0 +1,30 @@ +#include +#include +#include +#include + +int main() +{ + char cwd[1024]; + + int status = EXIT_FAILURE; + + if (chdir("/tmp") != 0) + { + goto end; + } + + if (getcwd(cwd, sizeof(cwd)) == NULL) + { + goto end; + } + + if (strcmp(cwd, "/tmp") == 0) + { + status = EXIT_SUCCESS; + } + +end: + printf("%d", status); + exit(status); +} diff --git a/tests/wasix/chdir-getcwd/run.sh b/tests/wasix/chdir-getcwd/run.sh new file mode 100755 index 00000000000..3e033fb8981 --- /dev/null +++ b/tests/wasix/chdir-getcwd/run.sh @@ -0,0 +1,3 @@ +$WASMER -q run main.wasm > output + +printf "0" | diff -u output - 1>/dev/null \ No newline at end of file diff --git a/tests/wasix/epoll-create-ctl-wait/main.c b/tests/wasix/epoll-create-ctl-wait/main.c new file mode 100644 index 00000000000..2c6c930fc26 --- /dev/null +++ b/tests/wasix/epoll-create-ctl-wait/main.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include +#include + +int main() +{ + int status = EXIT_FAILURE; + + int efd, epoll_fd; + struct epoll_event event; + struct epoll_event events[1]; + + efd = eventfd(0, 0); + if (efd == -1) + { + goto end; + } + + epoll_fd = epoll_create1(0); + if (epoll_fd == -1) + { + goto end; + } + + event.events = EPOLLIN; + event.data.fd = efd; + if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, efd, &event) == -1) + { + goto end; + } + + uint64_t val = 1; + if (write(efd, &val, sizeof(uint64_t)) != sizeof(uint64_t)) + { + goto end; + } + + int n = epoll_wait(epoll_fd, events, 1, -1); + if (n == -1) + { + goto end;; + } + + status = EXIT_SUCCESS; + +end: + printf("%d", status); + return status; +} diff --git a/tests/wasix/epoll-create-ctl-wait/run.sh b/tests/wasix/epoll-create-ctl-wait/run.sh new file mode 100755 index 00000000000..3e033fb8981 --- /dev/null +++ b/tests/wasix/epoll-create-ctl-wait/run.sh @@ -0,0 +1,3 @@ +$WASMER -q run main.wasm > output + +printf "0" | diff -u output - 1>/dev/null \ No newline at end of file diff --git a/tests/wasix/fd_pipe/main.c b/tests/wasix/fd_pipe/main.c new file mode 100644 index 00000000000..acf76ff902f --- /dev/null +++ b/tests/wasix/fd_pipe/main.c @@ -0,0 +1,58 @@ +#include +#include +#include +#include +#include +#include + +int main() +{ + int status = EXIT_FAILURE; + + int socks[2]; + char buf[1024]; + ssize_t numRead; + + if (socketpair(AF_UNIX, SOCK_STREAM, 0, socks) == -1) + { + goto end; + } + + if (write(socks[0], "foo", 3) == -1) + { + goto end; + } + + memset(buf, 0, sizeof(buf)); + numRead = read(socks[1], buf, sizeof(buf)); + if (numRead == -1) + { + goto end; + } + if (strncmp(buf, "foo", 3) != 0) + { + goto end; + } + + if (write(socks[1], "bar", 3) == -1) + { + goto end; + } + + memset(buf, 0, sizeof(buf)); + numRead = read(socks[0], buf, sizeof(buf)); + if (numRead == -1) + { + goto end; + } + if (strncmp(buf, "bar", 3) != 0) + { + goto end; + } + + status = EXIT_SUCCESS; + +end: + printf("%d", status); + return status; +} diff --git a/tests/wasix/fd_pipe/run.sh b/tests/wasix/fd_pipe/run.sh new file mode 100755 index 00000000000..3e033fb8981 --- /dev/null +++ b/tests/wasix/fd_pipe/run.sh @@ -0,0 +1,3 @@ +$WASMER -q run main.wasm > output + +printf "0" | diff -u output - 1>/dev/null \ No newline at end of file diff --git a/tests/wasix/proc-exec/main.c b/tests/wasix/proc-exec/main.c index d68337f443f..0da133b51a3 100644 --- a/tests/wasix/proc-exec/main.c +++ b/tests/wasix/proc-exec/main.c @@ -22,7 +22,7 @@ int main(int argc, char *argv[]) execv("/code/main.wasm", newargv); - exit(EXIT_FAILURE); + goto end; } else { diff --git a/tests/wasix/signal/main.c b/tests/wasix/signal/main.c new file mode 100644 index 00000000000..956471b24d6 --- /dev/null +++ b/tests/wasix/signal/main.c @@ -0,0 +1,35 @@ +#include +#include +#include +#include +#include + +void sig_handler(int signo) +{ + exit(signo != SIGHUP); +} + +int main(int argc, char *argv[]) +{ +pid_t pid; + int status; + + pid = fork(); + + if (pid == -1) { + return EXIT_FAILURE; + } else if (pid == 0) { + signal(SIGHUP, sig_handler); + while (1) { + sleep(1); + } + } else { + sleep(1); + + kill(pid, SIGHUP); + + waitpid(pid, &status, 0); + + printf("%d", status); + } +} \ No newline at end of file diff --git a/tests/wasix/signal/run.sh b/tests/wasix/signal/run.sh new file mode 100755 index 00000000000..3e033fb8981 --- /dev/null +++ b/tests/wasix/signal/run.sh @@ -0,0 +1,3 @@ +$WASMER -q run main.wasm > output + +printf "0" | diff -u output - 1>/dev/null \ No newline at end of file