-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set CMAKE_MODULE_PATH in the cmake toolchain file (#335)
Also add some basic testing for the cmake toolchain file. Fixes: #181
- Loading branch information
1 parent
bbfb973
commit 8d4dbb1
Showing
5 changed files
with
95 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
cmake_minimum_required(VERSION 3.22) | ||
|
||
project(wasi-sdk-test) | ||
|
||
# Sanity check setup | ||
if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL WASI) | ||
message(FATAL_ERROR "Wrong system name (${CMAKE_SYSTEM_NAME}), wrong toolchain file in use?") | ||
endif() | ||
|
||
if(NOT DEFINED WASI) | ||
message(FATAL_ERROR "WASI is not set, platform file likely not loaded") | ||
endif() | ||
|
||
set(RUNWASI "" CACHE STRING "Path to or name of WASM runner") | ||
|
||
# Test build a C and C++ target respectively | ||
add_executable(void_main_c ../general/void_main.c) | ||
add_executable(void_main_cc ../general/void_main.cc) | ||
|
||
include(CTest) | ||
enable_testing() | ||
|
||
add_test(NAME void_main_c | ||
COMMAND | ||
${CMAKE_CURRENT_SOURCE_DIR}/test_driver.sh | ||
${RUNWASI} | ||
$<TARGET_FILE:void_main_c> | ||
${CMAKE_CURRENT_SOURCE_DIR}/../general/void_main.c.stdout.expected) | ||
add_test(NAME void_main_cc | ||
COMMAND | ||
${CMAKE_CURRENT_SOURCE_DIR}/test_driver.sh | ||
${RUNWASI} | ||
$<TARGET_FILE:void_main_cc> | ||
${CMAKE_CURRENT_SOURCE_DIR}/../general/void_main.cc.stdout.expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
# Simplified runner for cmake | ||
|
||
set -ex | ||
|
||
runwasi="$1" | ||
target="$2" | ||
stdout_expected="$3" | ||
stderr_expected="/dev/null" | ||
|
||
stdout_observed="$target.stdout.observed" | ||
stderr_observed="$target.stderr.observed" | ||
|
||
"$runwasi" "$target" > "$stdout_observed" 2> "$stderr_observed" | ||
|
||
diff -u "$stderr_expected" "$stderr_observed" | ||
diff -u "$stdout_expected" "$stdout_observed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters