node/test/wasi/c/readdir.c
Michael Dawson 9cb8eb7177
wasi: fix up wasi tests for ibmi
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
    https://github.com/WebAssembly/wasi-libc/issues/266 is resolved.

Signed-off-by: Michael Dawson <midawson@redhat.com>
PR-URL: https://github.com/nodejs/node/pull/49953
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-10-04 16:35:39 +00:00

41 lines
834 B
C

#include <assert.h>
#include <dirent.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
DIR* dir;
struct dirent* entry;
char* platform;
int cnt;
int has_d_type;
platform = getenv("NODE_PLATFORM");
assert(platform != NULL);
dir = opendir("/sandbox");
assert(dir != NULL);
cnt = 0;
errno = 0;
while (NULL != (entry = readdir(dir))) {
if (strcmp(entry->d_name, "input.txt") == 0 ||
strcmp(entry->d_name, "input2.txt") == 0 ||
strcmp(entry->d_name, "notadir") == 0) {
assert(entry->d_type == DT_REG);
} else if (strcmp(entry->d_name, "subdir") == 0) {
assert(entry->d_type == DT_DIR);
} else {
assert("unexpected file");
}
cnt++;
}
assert(errno == 0);
assert(cnt == 4);
closedir(dir);
return 0;
}