Skip to content

Commit

Permalink
wasi: fix up wasi tests for ibmi
Browse files Browse the repository at this point in the history
ibmi now reports os400 instead of aix

- update platform check in poll to allow for os400
- update wasi-sdk level to 20
  - document the level of wasi-sdk used to compile the tests
  - remove platform check in readdir test as it does not seem to be
    needed with wasi-sdk version 20
  - comment out tests for some clocks which are no longer available when
    compiling with wasi-sdk level 20. These may be added back after
    WebAssembly/wasi-libc#266 is resolved.

Signed-off-by: Michael Dawson <midawson@redhat.com>
PR-URL: #49953
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
mhdawson authored and targos committed Nov 11, 2023
1 parent 294b650 commit 5b695d6
Show file tree
Hide file tree
Showing 29 changed files with 21 additions and 20 deletions.
15 changes: 11 additions & 4 deletions test/wasi/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# WASI Tests

Compile with clang and `wasm32-wasi` target. The clang version used must be
built with wasi-libc. You can specify the location for clang and the sysroot
if needed when running make:
Compile with clang and `wasm32-wasi` target by using the wasi-sdk
[version 20](https://github.com/WebAssembly/wasi-sdk/releases/tag/wasi-sdk-20)

Install wasi-sdk and then set WASI\_SDK\_PATH to the root of the install.

You can then rebuild the wasm for the tests by running:

```bash
make CC=/usr/local/opt/llvm/bin/clang SYSROOT=/path/to/wasi-libc/sysroot
make CC=${WASI_SDK_PATH}/bin/clang SYSROOT=${WASI_SDK_PATH}/share/wasi-sysroot
```

If you update the version of the wasi-sdk to be used for the compile
remove all of the \*.wasm files in the wasm directory to ensure
you rebuild/test all of the tests with the new version.
11 changes: 7 additions & 4 deletions test/wasi/c/clock_getres.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ int main() {
assert(r == 0);
r = clock_getres(CLOCK_MONOTONIC, &ts);
assert(r == 0);
r = clock_getres(CLOCK_PROCESS_CPUTIME_ID, &ts);
assert(r == 0);
r = clock_getres(CLOCK_THREAD_CPUTIME_ID, &ts);
assert(r == 0);
// don't run these tests until
// https://github.com/WebAssembly/wasi-libc/issues/266
// is resolved
// r = clock_getres(CLOCK_PROCESS_CPUTIME_ID, &ts);
// assert(r == 0);
// r = clock_getres(CLOCK_THREAD_CPUTIME_ID, &ts);
// assert(r == 0);
}
6 changes: 3 additions & 3 deletions test/wasi/c/poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ int main(void) {
time_t before, now;
int ret;
char* platform;
int is_aix;
int is_aix_or_os400;
int is_win;

platform = getenv("NODE_PLATFORM");
is_aix = platform != NULL && 0 == strcmp(platform, "aix");
is_aix_or_os400 = platform != NULL && (0 == strcmp(platform, "aix") || 0 == strcmp(platform, "os400"));
is_win = platform != NULL && 0 == strcmp(platform, "win32");

// Test sleep() behavior.
Expand Down Expand Up @@ -64,7 +64,7 @@ int main(void) {
ret = poll(fds, 1, 2000);
assert(ret == 1);

if (is_aix)
if (is_aix_or_os400)
assert(fds[0].revents == POLLIN);
else
assert(fds[0].revents == (POLLHUP | POLLIN));
Expand Down
9 changes: 0 additions & 9 deletions test/wasi/c/readdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ int main() {

platform = getenv("NODE_PLATFORM");
assert(platform != NULL);
has_d_type = (0 != strcmp(platform, "aix") && 0 != strcmp(platform, "sunos"));

dir = opendir("/sandbox");
assert(dir != NULL);
Expand All @@ -25,17 +24,9 @@ int main() {
if (strcmp(entry->d_name, "input.txt") == 0 ||
strcmp(entry->d_name, "input2.txt") == 0 ||
strcmp(entry->d_name, "notadir") == 0) {
if (has_d_type) {
assert(entry->d_type == DT_REG);
} else {
assert(entry->d_type == DT_UNKNOWN);
}
} else if (strcmp(entry->d_name, "subdir") == 0) {
if (has_d_type) {
assert(entry->d_type == DT_DIR);
} else {
assert(entry->d_type == DT_UNKNOWN);
}
} else {
assert("unexpected file");
}
Expand Down
Binary file modified test/wasi/wasm/cant_dotdot.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/clock_getres.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/create_symlink.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/exitcode.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/fd_prestat_get_refresh.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/follow_symlink.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/freopen.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/ftruncate.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/getentropy.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/getrusage.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/gettimeofday.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/link.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/main_args.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/notdir.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/poll.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/preopen_populates.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/read_file.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/read_file_twice.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/readdir.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/sock.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/stat.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/stdin.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/symlink_escape.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/symlink_loop.wasm
Binary file not shown.
Binary file modified test/wasi/wasm/write_file.wasm
Binary file not shown.

0 comments on commit 5b695d6

Please sign in to comment.