mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 10:47:34 +00:00
LibWasm+Meta: Add test-wasm and optionally test the conformance tests
This only tests "can it be parsed", but the goal of this commit is to provide a test framework that can be built upon :) The conformance tests are downloaded, compiled* and installed only if the INCLUDE_WASM_SPEC_TESTS cmake option is enabled. (*) Since we do not yet have a wast parser, the compilation is delegated to an external tool from binaryen, `wasm-as`, which is required for the test suite download/install to succeed. This *does* run the tests in CI, but it currently does not include the spec conformance tests.
This commit is contained in:
parent
ba2fce14d3
commit
b3c13c3e8a
11 changed files with 207 additions and 1 deletions
|
@ -27,6 +27,7 @@ option(ENABLE_COMPILETIME_FORMAT_CHECK "Enable compiletime format string checks"
|
|||
option(ENABLE_PCI_IDS_DOWNLOAD "Enable download of the pci.ids database at build time" ON)
|
||||
option(BUILD_LAGOM "Build parts of the system targeting the host OS for fuzzing/testing" OFF)
|
||||
option(ENABLE_KERNEL_LTO "Build the kernel with link-time optimization" OFF)
|
||||
option(INCLUDE_WASM_SPEC_TESTS "Download and include the WebAssembly spec testsuite" OFF)
|
||||
|
||||
add_custom_target(run
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/Meta/run.sh
|
||||
|
@ -245,3 +246,33 @@ if(EXISTS ${PCI_IDS_GZ_PATH} AND NOT EXISTS ${PCI_IDS_INSTALL_PATH})
|
|||
file(MAKE_DIRECTORY ${CMAKE_INSTALL_DATAROOTDIR})
|
||||
file(RENAME ${PCI_IDS_PATH} ${PCI_IDS_INSTALL_PATH})
|
||||
endif()
|
||||
|
||||
if(INCLUDE_WASM_SPEC_TESTS)
|
||||
set(WASM_SPEC_TEST_GZ_URL https://github.com/WebAssembly/testsuite/archive/refs/heads/master.tar.gz)
|
||||
set(WASM_SPEC_TEST_GZ_PATH ${CMAKE_BINARY_DIR}/wasm-spec-testsuite.tar.gz)
|
||||
set(WASM_SPEC_TEST_TAR_PATH ${CMAKE_BINARY_DIR}/wasm-spec-testsuite.tar)
|
||||
set(WASM_SPEC_TEST_PATH ${CMAKE_SOURCE_DIR}/Userland/Libraries/LibWasm/Tests/Fixtures/SpecTests)
|
||||
|
||||
if(NOT EXISTS ${WASM_SPEC_TEST_GZ_PATH})
|
||||
message(STATUS "Downloading the WebAssembly testsuite from ${WASM_SPEC_TEST_GZ_URL}...")
|
||||
file(DOWNLOAD ${WASM_SPEC_TEST_GZ_URL} ${WASM_SPEC_TEST_GZ_PATH} INACTIVITY_TIMEOUT 10)
|
||||
endif()
|
||||
|
||||
if(EXISTS ${WASM_SPEC_TEST_GZ_PATH} AND NOT EXISTS ${WASM_SPEC_TEST_PATH})
|
||||
message(STATUS "Extracting the WebAssembly testsuite from ${WASM_SPEC_TEST_GZ_PATH}...")
|
||||
file(MAKE_DIRECTORY ${WASM_SPEC_TEST_PATH})
|
||||
execute_process(COMMAND gzip -k -d ${WASM_SPEC_TEST_GZ_PATH})
|
||||
execute_process(COMMAND tar -xf ${WASM_SPEC_TEST_TAR_PATH})
|
||||
execute_process(COMMAND rm ${WASM_SPEC_TEST_TAR_PATH})
|
||||
file(GLOB WASM_TESTS "${CMAKE_BINARY_DIR}/testsuite-master/*.wast")
|
||||
foreach(PATH ${WASM_TESTS})
|
||||
get_filename_component(NAME ${PATH} NAME_WLE)
|
||||
message(STATUS "Compiling WebAssembly test ${NAME}...")
|
||||
execute_process(
|
||||
COMMAND wasm-as -n ${PATH} -o "${WASM_SPEC_TEST_PATH}/${NAME}.wasm"
|
||||
OUTPUT_QUIET
|
||||
ERROR_QUIET)
|
||||
endforeach()
|
||||
file(REMOVE testsuite-master)
|
||||
endif()
|
||||
endif()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue