Skip to content

Commit 5ab7fa1

Browse files
committed
Compile tests with --sysroot
Gives them access to the `wasi/version.h` header for example
1 parent 3c738db commit 5ab7fa1

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

test/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ else()
3434
add_custom_target(engine)
3535
endif()
3636

37+
# All tests are compiled against the wasi-libc sysroot
38+
add_compile_options(--sysroot ${SYSROOT})
39+
add_link_options(--sysroot ${SYSROOT})
40+
3741
# ========= libc-test defined tests =============================
3842

3943
function(add_wasilibc_flags target)
@@ -295,6 +299,7 @@ add_wasilibc_test(seekdir.c FS FAILP3)
295299
add_wasilibc_test(usleep.c)
296300
add_wasilibc_test(nanosleep.c)
297301
add_wasilibc_test(write.c FS FAILP3)
302+
add_wasilibc_test(wasi-defines.c)
298303

299304
if (TARGET_TRIPLE MATCHES "-threads")
300305
add_wasilibc_test(busywait.c)

test/src/wasi-defines.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <wasi/version.h>
2+
3+
int main() {
4+
#if defined(__wasip1__) || defined(__wasip2__) || defined(__wasip3__)
5+
return 0;
6+
#else
7+
#error "Expected a wasi #define"
8+
return 1;
9+
#endif
10+
}

0 commit comments

Comments
 (0)