File tree Expand file tree Collapse file tree 4 files changed +78
-1
lines changed Expand file tree Collapse file tree 4 files changed +78
-1
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ default: build
53
53
check :
54
54
CC=" clang --sysroot=$( BUILD_PREFIX) /share/wasi-sysroot" \
55
55
CXX=" clang++ --sysroot=$( BUILD_PREFIX) /share/wasi-sysroot -fno-exceptions" \
56
- PATH=" $( PATH_PREFIX) /bin:$$ PATH" tests/run.sh $(RUNTIME )
56
+ PATH=" $( PATH_PREFIX) /bin:$$ PATH" tests/run.sh " $( RUNTIME) " " $( BUILD_PREFIX ) "
57
57
58
58
clean :
59
59
rm -rf build $(DESTDIR )
Original file line number Diff line number Diff line change
1
+ cmake_minimum_required (VERSION 3.22)
2
+
3
+ project (wasi-sdk-test )
4
+
5
+ # Sanity check setup
6
+ if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL WASI)
7
+ message (FATAL_ERROR "Wrong system name (${CMAKE_SYSTEM_NAME} ), wrong toolchain file in use?" )
8
+ endif ()
9
+
10
+ if (NOT DEFINED WASI)
11
+ message (FATAL_ERROR "WASI is not set, platform file likely not loaded" )
12
+ endif ()
13
+
14
+ set (RUNWASI "" CACHE STRING "Path to or name of WASM runner" )
15
+
16
+ # Test build a C and C++ target respectively
17
+ add_executable (void_main_c ../general/void_main.c)
18
+ add_executable (void_main_cc ../general/void_main.cc)
19
+
20
+ include (CTest)
21
+ enable_testing ()
22
+
23
+ add_test (NAME void_main_c
24
+ COMMAND
25
+ ${CMAKE_CURRENT_SOURCE_DIR} /test_driver.sh
26
+ ${RUNWASI}
27
+ $<TARGET_FILE:void_main_c>
28
+ ${CMAKE_CURRENT_SOURCE_DIR} /../general/void_main.c.stdout.expected)
29
+ add_test (NAME void_main_cc
30
+ COMMAND
31
+ ${CMAKE_CURRENT_SOURCE_DIR} /test_driver.sh
32
+ ${RUNWASI}
33
+ $<TARGET_FILE:void_main_cc>
34
+ ${CMAKE_CURRENT_SOURCE_DIR} /../general/void_main.cc.stdout.expected)
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # Simplified runner for cmake
3
+
4
+ set -ex
5
+
6
+ runwasi=" $1 "
7
+ target=" $2 "
8
+ stdout_expected=" $3 "
9
+ stderr_expected=" /dev/null"
10
+
11
+ stdout_observed=" $target .stdout.observed"
12
+ stderr_observed=" $target .stderr.observed"
13
+
14
+ " $runwasi " " $target " > " $stdout_observed " 2> " $stderr_observed "
15
+
16
+ diff -u " $stderr_expected " " $stderr_observed "
17
+ diff -u " $stdout_expected " " $stdout_observed "
Original file line number Diff line number Diff line change 20
20
runwasi=" "
21
21
fi
22
22
23
+ if [ $# -gt 1 ]; then
24
+ wasi_sdk=" $2 "
25
+ else
26
+ wasi_sdk=" "
27
+ fi
28
+
23
29
testdir=$( dirname $0 )
24
30
CC=${CC:= clang}
25
31
CXX=${CXX:= clang++}
26
32
27
33
echo $CC
28
34
echo $CXX
35
+ echo " SDK: $wasi_sdk "
29
36
30
37
cd $testdir /compile-only
31
38
for options in -O0 -O2 " -O2 -flto" ; do
@@ -54,3 +61,22 @@ for options in -O0 -O2 "-O2 -flto"; do
54
61
done
55
62
done
56
63
cd - > /dev/null
64
+
65
+ if [[ -n " $wasi_sdk " ]]; then
66
+ for option in Debug Release; do
67
+ rm -rf " $testdir /cmake/build/$option "
68
+ mkdir -p " $testdir /cmake/build/$option "
69
+ cd " $testdir /cmake/build/$option "
70
+ cmake \
71
+ -DCMAKE_BUILD_TYPE=" $option " \
72
+ -DRUNWASI=" $runwasi " \
73
+ -DWASI_SDK_PREFIX=" $wasi_sdk " \
74
+ -DCMAKE_TOOLCHAIN_FILE=" $wasi_sdk /share/cmake/wasi-sdk.cmake" \
75
+ ../..
76
+ make
77
+ if [[ -n " $runwasi " ]]; then
78
+ ctest --output-on-failure
79
+ fi
80
+ cd - > /dev/null
81
+ done
82
+ fi
You can’t perform that action at this time.
0 commit comments