diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 814e34c00..cc6f61d2d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -84,14 +84,6 @@ jobs: TARGET_TRIPLE: wasm32-wasip2 WASI_SNAPSHOT: p2 MAKE_TARGETS: "default libc_so" - - name: Test wasm32-wasi-threads - os: ubuntu-24.04 - clang_version: 19 - test: true - upload: wasm32-wasi-threads - env: - TARGET_TRIPLE: wasm32-wasi-threads - THREAD_MODEL: posix - name: Test wasm32-wasip1-threads os: ubuntu-24.04 clang_version: 19 @@ -122,6 +114,7 @@ jobs: test: true upload: wasm32-wasi-simd env: + TARGET_TRIPLE: wasm32-wasip1 MAKE_TARGETS: "no-check-symbols" EXTRA_CFLAGS: "-O2 -DNDEBUG -msimd128 -mrelaxed-simd -mbulk-memory -D__wasilibc_simd_string" @@ -138,20 +131,30 @@ jobs: - name: Build libc run: make -j4 $MAKE_TARGETS CHECK_SYMBOLS=yes - - name: Download Test dependencies - if: matrix.test - run: cd test && make download - - name: Install V8 dependencies if: matrix.test_with_v8 run: | npm -C test/scripts/browser-test install npx -C test/scripts/browser-test playwright install chromium-headless-shell echo ENGINE="$PWD/test/scripts/browser-test/harness.mjs" >> $GITHUB_ENV + echo CTEST_ARGS="--label-exclude v8fail" >> $GITHUB_ENV + + - name: Setup testing + if: matrix.test + run: | + cmake -S test -B testbuild -G Ninja \ + -DTARGET_TRIPLE=${{ env.TARGET_TRIPLE }} \ + -DENGINE=${{ env.ENGINE }} \ + -DCMAKE_LINK_DEPENDS_USE_LINKER=OFF + + - name: Build tests + if: matrix.test + run: ninja -C testbuild - name: Test if: matrix.test - run: make -C test test + run: ctest --test-dir testbuild --output-on-failure -j4 $CTEST_ARGS + - uses: actions/upload-artifact@v4.4.0 if: matrix.upload diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 000000000..a45eb5549 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,413 @@ +cmake_minimum_required(VERSION 3.26) +project(wasi-libc-tests) + +if(NOT CMAKE_C_COMPILER_ID MATCHES Clang) + message(FATAL_ERROR "C compiler ${CMAKE_C_COMPILER} is not `Clang`, it is ${CMAKE_C_COMPILER_ID}") +endif() + +message(STATUS "Found executable for `nm`: ${CMAKE_NM}") +message(STATUS "Found executable for `ar`: ${CMAKE_AR}") +message(STATUS "Found executable for `ranlib`: ${CMAKE_RANLIB}") + +include(FetchContent) +include(ExternalProject) +include(CTest) +enable_testing() + +set(TARGET_TRIPLE "wasm32-wasi" CACHE STRING "WASI target to test") + +# ========= Sysroot sanity check ================================ + +cmake_path(GET CMAKE_CURRENT_SOURCE_DIR PARENT_PATH LIBC_SRC_DIR) +set(SYSROOT_DIR "${LIBC_SRC_DIR}/sysroot") +set(SYSROOT "${SYSROOT_DIR}/lib/${TARGET_TRIPLE}") + +# This build configuration does not currently manage the sysroot itself (but +# ideally it will one day). Double-check that the sysroot exists before actually +# trying to build any tests. +if (NOT EXISTS "${SYSROOT_DIR}") + message(FATAL_ERROR " + No sysroot for ${TARGET_TRIPLE} available at ${SYSROOT_DIR}; to build it, e.g.: + cd ${LIBC_SRC_DIR} + make TARGET_TRIPLE=${TARGET_TRIPLE} + ") +endif() + +# ========= Clone libc-test ===================================== + +FetchContent_Declare( + libc-test + GIT_REPOSITORY https://github.com/bytecodealliance/libc-test + GIT_TAG 18e28496adee3d84fefdda6efcb9c5b8996a2398 + GIT_SHALLOW true +) +FetchContent_MakeAvailable(libc-test) +set(LIBC_TEST "${libc-test_SOURCE_DIR}") +message(STATUS "libc-test source directory: ${LIBC_TEST}") + +# ========= Download wasmtime as a test runner ================== + +if(NOT ENGINE OR ENGINE STREQUAL "") + set(WASMTIME_VERSION "v38.0.2") + set(WASMTIME_ARCH "${CMAKE_HOST_SYSTEM_PROCESSOR}") + set(WASMTIME_REPO "https://github.com/bytecodealliance/wasmtime") + + ExternalProject_Add( + engine + URL "${WASMTIME_REPO}/releases/download/${WASMTIME_VERSION}/wasmtime-${WASMTIME_VERSION}-${WASMTIME_ARCH}-linux.tar.xz" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) + ExternalProject_Get_Property(engine SOURCE_DIR) + set(ENGINE "${SOURCE_DIR}/wasmtime") + message(STATUS "Wasmtime executable: ${ENGINE}") +else() + add_custom_target(engine) +endif() + +# ========= libc-test defined tests ============================= + +function(add_wasilibc_flags target) + target_compile_options(${target} PRIVATE + "--target=${TARGET_TRIPLE}" + "--sysroot=${SYSROOT_DIR}" + ) + target_link_options(${target} PRIVATE + "--target=${TARGET_TRIPLE}" + "--sysroot=${SYSROOT_DIR}" + "-resource-dir=${LIBC_SRC_DIR}/build/${TARGET_TRIPLE}/resource-dir" + ) + if (TARGET_TRIPLE MATCHES "-threads") + target_compile_options(${target} PRIVATE -pthread) + target_link_options(${target} PRIVATE -pthread + -Wl,--import-memory,--export-memory,--shared-memory,--max-memory=1073741824) + endif() +endfunction() + +add_library(libc_test_support STATIC + "${LIBC_TEST}/src/common/path.c" + "${LIBC_TEST}/src/common/print.c" + "${LIBC_TEST}/src/common/rand.c" + "${LIBC_TEST}/src/common/utf8.c" +) +target_include_directories(libc_test_support PUBLIC "${LIBC_TEST}/src/common") +add_wasilibc_flags(libc_test_support) + +# Adds a new test executable to build +# +# * `executable_name` must be a unique name and valid cmake target name. +# * `src` is the path to the test file to compile. +# +# Optional arguments: +# +# * `CFLAGS -a -b -c` - additional flags to pass to the compiler +# * `LDFLAGS -a -b -c` - additional flags to pass to the linker +function(add_test_executable executable_name src) + set(options) + set(oneValueArgs) + set(multiValueArgs LDFLAGS CFLAGS) + cmake_parse_arguments(PARSE_ARGV 1 arg "${options}" "${oneValueArgs}" "${multiValueArgs}") + + # Build the test exeutable itself and apply all custom options as applicable. + add_executable(${executable_name} ${src}) + add_wasilibc_flags(${executable_name}) + target_link_libraries(${executable_name} libc_test_support) + foreach(flag IN LISTS arg_CFLAGS) + target_compile_options(${executable_name} PRIVATE ${flag}) + endforeach() + foreach(flag IN LISTS arg_LDFLAGS) + target_link_options(${executable_name} PRIVATE ${flag}) + endforeach() + target_include_directories(${executable_name} PRIVATE "${LIBC_TEST}") +endfunction() + +# Adds a new test to run. +# +# * `test_name` must be a unique name and valid cmake target name. +# * `test_file` is the path to the test file to compile. +# +# Optional arguments: +# +# * `FS` - this test requires a temporary directory mounted as `/` +# * `ARGV arg1 arg2` - additional arguments to pass to the test at runtime +# * `ENV a=b b=c` - set env vars for when executing this test +# * `NETWORK` - this test uses the network and sockets. +# * `PASS_REGULAR_EXPRESSION` - a regex that must match the test output to pass +function(register_test test_name executable_name) + set(options FS NETWORK) + set(oneValueArgs CLIENT PASS_REGULAR_EXPRESSION) + set(multiValueArgs ARGV ENV LDFLAGS CFLAGS) + cmake_parse_arguments(PARSE_ARGV 1 arg "${options}" "${oneValueArgs}" "${multiValueArgs}") + + set(wasmtime_args) + + if (arg_FS) + set(fsdir "${CMAKE_CURRENT_BINARY_DIR}/tmp/${test_name}/fs") + list(APPEND wasmtime_args --dir ${fsdir}::/) + endif() + if (arg_NETWORK) + list(APPEND wasmtime_args -Sinherit-network) + endif() + foreach(env IN LISTS arg_ENV) + list(APPEND wasmtime_args --env ${env}) + endforeach() + if (TARGET_TRIPLE MATCHES "-threads") + list(APPEND wasmtime_args --wasi threads) + endif() + + add_test( + NAME "${test_name}" + COMMAND + ${ENGINE} + ${wasmtime_args} + $ ${arg_ARGV} + ) + + # Use CTest fixtures to create a the temporary directory before the test + # starts running and clean it up afterwards. + if (arg_FS) + add_test(NAME "setup_${test_name}" COMMAND mkdir -p ${fsdir}) + add_test(NAME "cleanup_${test_name}" COMMAND rm -rf ${fsdir}) + set_tests_properties("setup_${test_name}" PROPERTIES FIXTURES_SETUP "fs_${test_name}") + set_tests_properties("cleanup_${test_name}" PROPERTIES FIXTURES_CLEANUP "fs_${test_name}") + set_tests_properties("${test_name}" PROPERTIES FIXTURES_REQUIRED "fs_${test_name}") + endif() + + # All sockets tests use the same port right now, so only one can run at a + # time. + if (arg_NETWORK) + set_tests_properties(${test_name} PROPERTIES RESOURCE_LOCK socket-test) + endif() + + if (arg_PASS_REGULAR_EXPRESSION) + set_tests_properties(${test_name} PROPERTIES PASS_REGULAR_EXPRESSION "${arg_PASS_REGULAR_EXPRESSION}") + endif() + set_tests_properties(${test_name} PROPERTIES TIMEOUT 10) + + add_dependencies(${test_name} engine) +endfunction() + +# Adds a new test from the `libc-test` repository where `test_file` is a +# relative path from the `src` directory. +# +# Also supports options `register_test` does. +function(add_libc_test test_file) + cmake_path(REPLACE_EXTENSION test_file wasm OUTPUT_VARIABLE test_name) + string(REPLACE "/" "_" test_name ${test_name}) + set(test_name "libc_test_${test_name}") + set(test_file "${LIBC_TEST}/src/${test_file}") + + add_test_executable(${test_name} "${test_file}" ${ARGN}) + register_test(${test_name} ${test_name} ${ARGN}) +endfunction() + +add_libc_test(functional/argv.c) +add_libc_test(functional/basename.c) +add_libc_test(functional/clocale_mbfuncs.c) +add_libc_test(functional/clock_gettime.c) +add_libc_test(functional/crypt.c) +add_libc_test(functional/dirname.c) +add_libc_test(functional/env.c) +add_libc_test(functional/fnmatch.c) +add_libc_test(functional/iconv_open.c) +add_libc_test(functional/mbc.c) +add_libc_test(functional/memstream.c) +add_libc_test(functional/qsort.c) +add_libc_test(functional/random.c) +add_libc_test(functional/search_hsearch.c) +add_libc_test(functional/search_insque.c) +add_libc_test(functional/search_lsearch.c) +add_libc_test(functional/search_tsearch.c) +add_libc_test(functional/snprintf.c) +add_libc_test(functional/sscanf.c) +add_libc_test(functional/strftime.c) +add_libc_test(functional/string.c) +add_libc_test(functional/string_memcpy.c) +add_libc_test(functional/string_memmem.c) +add_libc_test(functional/string_memset.c) +add_libc_test(functional/string_strchr.c) +add_libc_test(functional/string_strcspn.c) +add_libc_test(functional/string_strstr.c) +add_libc_test(functional/strtod.c) +add_libc_test(functional/strtod_long.c) +add_libc_test(functional/strtod_simple.c) +add_libc_test(functional/strtof.c) +add_libc_test(functional/strtol.c) +add_libc_test(functional/strtold.c LDFLAGS -lc-printscan-long-double) +add_libc_test(functional/swprintf.c) +add_libc_test(functional/tgmath.c) +add_libc_test(functional/udiv.c) +add_libc_test(functional/wcsstr.c) +add_libc_test(functional/wcstol.c) + +if (TARGET_TRIPLE MATCHES "-threads") + add_libc_test(functional/pthread_mutex.c) + add_libc_test(functional/pthread_tsd.c) + add_libc_test(functional/pthread_cond.c) +endif() + +# ========= wasi-libc-test defined tests ======================== + +function(add_wasilibc_test test_file) + cmake_path(REPLACE_EXTENSION test_file wasm OUTPUT_VARIABLE test_name) + set(test_file "${CMAKE_CURRENT_SOURCE_DIR}/src/${test_file}") + + add_test_executable(${test_name} "${test_file}" ${ARGN}) + register_test(${test_name} ${test_name} ${ARGN}) +endfunction() + +# TODO: this test fails with `-Sthreads` in Wasmtime since that uses a different +# implementation of WASI which causes this test to fail. +if (NOT TARGET_TRIPLE MATCHES "-threads") + add_wasilibc_test(access.c FS) +endif() +add_wasilibc_test(argv_two_args.c ARGV foo bar) +add_wasilibc_test(clock_nanosleep.c) +add_wasilibc_test(external_env.c ENV VAR1=foo VAR2=bar) +add_wasilibc_test(fadvise.c FS) +add_wasilibc_test(fallocate.c FS) +add_wasilibc_test(fcntl.c FS) +add_wasilibc_test(fdatasync.c FS) +add_wasilibc_test(fdopen.c FS) +add_wasilibc_test(feof.c FS) +add_wasilibc_test(file_permissions.c FS) +add_wasilibc_test(fseek.c FS) +add_wasilibc_test(fsync.c FS) +add_wasilibc_test(ftruncate.c FS) +add_wasilibc_test(fts.c FS) +add_wasilibc_test(fwscanf.c FS) +add_wasilibc_test(getentropy.c) +add_wasilibc_test(hello.c PASS_REGULAR_EXPRESSION "Hello, World!") +add_wasilibc_test(ioctl.c FS) +add_wasilibc_test(isatty.c FS) +add_wasilibc_test(link.c FS) +add_wasilibc_test(memchr.c LDFLAGS -Wl,--stack-first -Wl,--initial-memory=327680) +add_wasilibc_test(memcmp.c LDFLAGS -Wl,--stack-first -Wl,--initial-memory=327680) +add_wasilibc_test(opendir.c FS ARGV /) +add_wasilibc_test(open_relative_path.c FS ARGV /) +add_wasilibc_test(poll.c FS) +add_wasilibc_test(preadvwritev.c FS) +add_wasilibc_test(preadwrite.c FS) +add_wasilibc_test(readlink.c FS) +add_wasilibc_test(rename.c FS) +add_wasilibc_test(rmdir.c FS) +add_wasilibc_test(scandir.c FS) +add_wasilibc_test(stat.c FS) +add_wasilibc_test(stdio.c FS) +add_wasilibc_test(strchrnul.c LDFLAGS -Wl,--stack-first -Wl,--initial-memory=327680) +add_wasilibc_test(strlen.c LDFLAGS -Wl,--stack-first -Wl,--initial-memory=327680) +add_wasilibc_test(strptime.c) +add_wasilibc_test(strrchr.c LDFLAGS -Wl,--stack-first -Wl,--initial-memory=327680) +add_wasilibc_test(time_and_times.c + CFLAGS -D_WASI_EMULATED_PROCESS_CLOCKS + LDFLAGS -lwasi-emulated-process-clocks) +add_wasilibc_test(time.c) +add_wasilibc_test(utime.c FS) + +if (TARGET_TRIPLE MATCHES "-threads") + add_wasilibc_test(busywait.c) + add_wasilibc_test(pthread_cond_busywait.c) + add_wasilibc_test(pthread_tsd_busywait.c) + add_wasilibc_test(pthread_mutex_busywait.c) +endif() + +# ========= sockets-related tests =============================== + +if (TARGET_TRIPLE MATCHES "wasip2") + add_wasilibc_test(poll-nonblocking-socket.c NETWORK) + add_wasilibc_test(setsockopt.c NETWORK) + add_wasilibc_test(sockets-nonblocking-udp.c NETWORK) + add_wasilibc_test(sockets-nonblocking-multiple.c NETWORK) + add_wasilibc_test(sockets-nonblocking-udp-multiple.c NETWORK) + + # TODO: flaky tests + # add_wasilibc_test(sockets-nonblocking.c NETWORK) + # add_wasilibc_test(sockets-nonblocking-udp-no-connection.c NETWORK) + + # Define executables for server/client tests, and they're paired together in + # various combinations below for various tests. + function(add_sockets_test_executable path) + cmake_path(REPLACE_EXTENSION path wasm OUTPUT_VARIABLE exe_name) + set(path "src/${path}") + add_test_executable(${exe_name} ${path}) + endfunction() + + add_sockets_test_executable(sockets-client.c) + add_sockets_test_executable(sockets-client-handle-hangups.c) + add_sockets_test_executable(sockets-client-hangup-after-connect.c) + add_sockets_test_executable(sockets-client-hangup-after-sending.c) + add_sockets_test_executable(sockets-client-hangup-while-receiving.c) + add_sockets_test_executable(sockets-client-hangup-while-sending.c) + add_sockets_test_executable(sockets-client-udp-blocking.c) + add_sockets_test_executable(sockets-multiple-client.c) + add_sockets_test_executable(sockets-server.c) + add_sockets_test_executable(sockets-server-handle-hangups.c) + add_sockets_test_executable(sockets-server-hangup-before-recv.c) + add_sockets_test_executable(sockets-server-hangup-before-send.c) + add_sockets_test_executable(sockets-server-hangup-during-recv.c) + add_sockets_test_executable(sockets-server-hangup-during-send.c) + add_sockets_test_executable(sockets-server-udp-blocking.c) + add_sockets_test_executable(sockets-multiple-server.c) + + function(sockets_test test_name client server) + set(options) + set(oneValueArgs NCLIENTS) + set(multiValueArgs) + cmake_parse_arguments(PARSE_ARGV 1 arg "${options}" "${oneValueArgs}" "${multiValueArgs}") + + add_test( + NAME "${test_name}" + COMMAND + ${CMAKE_COMMAND} + -DENGINE=${ENGINE} + -DSERVER=$ + -DCLIENT=$ + -DNCLIENTS=${arg_NCLIENTS} + -P ${CMAKE_CURRENT_SOURCE_DIR}/socket-test.cmake + ) + set_tests_properties(${test_name} PROPERTIES RESOURCE_LOCK socket-test) + endfunction() + + sockets_test(sockets sockets-client.wasm sockets-server.wasm) + sockets_test(sockets-udp-blocking sockets-client-udp-blocking.wasm sockets-server-udp-blocking.wasm) + sockets_test(sockets-multiple sockets-multiple-client.wasm sockets-multiple-server.wasm + NCLIENTS 10) + + # Various forms of client hangups + sockets_test(sockets-client-hangup-after-connect + sockets-client-hangup-after-connect.wasm sockets-server-handle-hangups.wasm) + sockets_test(sockets-client-hangup-while-sending + sockets-client-hangup-while-sending.wasm sockets-server-handle-hangups.wasm) + sockets_test(sockets-client-hangup-after-sending + sockets-client-hangup-after-sending.wasm sockets-server-handle-hangups.wasm) + sockets_test(sockets-client-hangup-while-receiving + sockets-client-hangup-while-receiving.wasm sockets-server-handle-hangups.wasm) + + # Various forms of server hangups, including when there's no server at all + sockets_test(sockets-server-hangup-before-send + sockets-client-handle-hangups.wasm sockets-server-hangup-before-send.wasm) + sockets_test(sockets-server-hangup-during-send + sockets-client-handle-hangups.wasm sockets-server-hangup-during-send.wasm) + sockets_test(sockets-server-hangup-before-recv + sockets-client-handle-hangups.wasm sockets-server-hangup-before-recv.wasm) + sockets_test(sockets-server-hangup-during-recv + sockets-client-handle-hangups.wasm sockets-server-hangup-during-recv.wasm) + sockets_test(sockets-client-handle-hangups + sockets-client-handle-hangups.wasm hello.wasm) +endif() + +# Flag some tests as failing in V8 +set_tests_properties(hello.wasm PROPERTIES LABELS v8fail) +set_tests_properties(clock_nanosleep.wasm PROPERTIES LABELS v8fail) +# Skip test that uses environment variables +set_tests_properties(external_env.wasm PROPERTIES LABELS v8fail) +# Skip test that uses command-line arguments +set_tests_properties(argv_two_args.wasm PROPERTIES LABELS v8fail) +if (TARGET_TRIPLE MATCHES "-threads") + # atomic.wait32 can't be executed on the main thread + set_tests_properties(libc_test_functional_pthread_mutex.wasm PROPERTIES LABELS v8fail) + set_tests_properties(libc_test_functional_pthread_tsd.wasm PROPERTIES LABELS v8fail) + # "poll_oneoff" can't be implemented in the browser + set_tests_properties(libc_test_functional_pthread_cond.wasm PROPERTIES LABELS v8fail) +endif() diff --git a/test/Makefile b/test/Makefile deleted file mode 100644 index 64b070a51..000000000 --- a/test/Makefile +++ /dev/null @@ -1,206 +0,0 @@ -# Build the `libc-test` tests as Wasm programs and run them with the selected -# engine. Contributors beware! This Makefile follows the style of the -# `libc-test` Makefile and uses some more exotic features of `make`. -# -# The top-level `test` target is composed of a chain of several phony -# sub-targets: -# - `download`: retrieve the `libc-test` source from a Git `$(MIRROR)` -# - `build`: construct Wasm modules for a subset of the `libc-test` tests -# - `run`: execute the benchmarks with a Wasm `$(ENGINE)` of choice (e.g., -# Wasmtime) - -test: run - -# Decide which target to build for and which libc to use. -TARGET_TRIPLE ?= wasm32-wasi - -# See comment in ../Makefile -ifeq ($(THREAD_MODEL), posix) -TARGET_TRIPLE = wasm32-wasip1-threads -endif - -ifeq ($(WASI_SNAPSHOT), p2) -TARGET_TRIPLE = wasm32-wasip2 -endif - -# Setup various paths used by the tests. -OBJDIR ?= build/$(TARGET_TRIPLE) -DOWNDIR ?= build/download -SRCDIR ?= src -RUNDIR ?= run/$(TARGET_TRIPLE) - -# We also need to know the location the wasi-libc sysroot we're building -# against. -SYSROOT_DIR ?= ../sysroot -SYSROOT := $(SYSROOT_DIR)/lib/$(TARGET_TRIPLE) -$(SYSROOT): - @echo "No sysroot for $(TARGET_TRIPLE) available at $(SYSROOT_DIR); to build it, e.g.:" - @echo " cd $(dir $(SYSROOT_DIR))" - @echo " make TARGET_TRIPLE=$(TARGET_TRIPLE)" - @exit 1 - - -##### DOWNLOAD ################################################################# - -LIBC_TEST_URL ?= https://github.com/bytecodealliance/libc-test -LIBC_TEST = $(DOWNDIR)/libc-test -ARCH := $(shell uname -m) -WASMTIME_URL ?= https://github.com/bytecodealliance/wasmtime/releases/download/v38.0.2/wasmtime-v38.0.2-$(ARCH)-linux.tar.xz -WASMTIME = $(abspath $(DOWNDIR)/$(shell basename $(WASMTIME_URL) .tar.xz)/wasmtime) - -$(DOWNDIR): - @mkdir -p $@ - -$(LIBC_TEST): | $(DOWNDIR) - git clone --depth 1 $(LIBC_TEST_URL) $@ - -$(WASMTIME): | $(DOWNDIR) - wget --no-clobber --directory-prefix=$(DOWNDIR) $(WASMTIME_URL) - tar --extract --file=$(DOWNDIR)/$(shell basename $(WASMTIME_URL)) --directory=$(DOWNDIR)/ - -# Target to download all necessary dependencies. -TO_DOWNLOAD = $(LIBC_TEST) $(WASMTIME) -DOWNLOADED := $(DOWNDIR)/downloaded.stamp -$(DOWNLOADED): $(TO_DOWNLOAD) - touch $@ -download: $(DOWNLOADED) - -clean:: - rm -rf $(DOWNDIR) - -##### INFRA #################################################################### - -INFRA_OBJDIR := $(OBJDIR)/common -$(INFRA_OBJDIR): - @mkdir -p $@ - -# Build the common test infrastructure. Part of the problem including more tests -# is that the `libc-test` infrastructure code is not all Wasm-compilable. As we -# include more tests above, this list will also likely need to grow. -INFRA_FILES = $(LIBC_TEST)/src/common/path.c \ - $(LIBC_TEST)/src/common/print.c \ - $(LIBC_TEST)/src/common/rand.c \ - $(LIBC_TEST)/src/common/utf8.c -$(INFRA_FILES): $(DOWNLOADED) -INFRA_WASM_OBJS := $(patsubst $(LIBC_TEST)/src/common/%.c,$(OBJDIR)/common/%.wasm.o,$(INFRA_FILES)) -$(OBJDIR)/common/%.wasm.o: $(LIBC_TEST)/src/common/%.c | $(INFRA_OBJDIR) - $(CC) $(CFLAGS) -c $< -o $@ - -# Also, include the `libc-test` infrastructure headers. -INFRA_HEADERS_DIR := $(LIBC_TEST)/src/common -INFRA_HEADERS := $(shell find $(INFRA_HEADERS_DIR) -name '*.h') -$(INFRA_HEADERS): $(DOWNLOADED) - -##### BUILD #################################################################### - -# Create various lists containing the various artifacts to be built: mainly, -# $(WASM_OBJS) are compiled in the $(OBJDIRS) and then linked together to form -# the $(WASMS) tests. -ALL_TESTS := $(shell find $(SRCDIR) -name '*.c') -TESTS := $(shell TARGET_TRIPLE=$(TARGET_TRIPLE) scripts/filter.py $(ALL_TESTS)) -WASM_OBJS := $(TESTS:$(SRCDIR)/%.c=$(OBJDIR)/%.wasm.o) -WASM_OBJS += $(INFRA_WASM_OBJS) -WASMS := $(TESTS:$(SRCDIR)/%.c=$(OBJDIR)/%.wasm) - - -# Setup the compiler. We allow $(CC) to be set from the command line; ?= doesn't -# work for CC because make has a default value for it. -ifeq ($(origin CC), default) -CC := clang -endif -LDFLAGS ?= -CFLAGS ?= --target=$(TARGET_TRIPLE) --sysroot=$(SYSROOT_DIR) -# Always include the `libc-test` infrastructure headers. -CFLAGS += -I$(INFRA_HEADERS_DIR) -ifneq ($(findstring -threads,$(TARGET_TRIPLE)),) -CFLAGS += -pthread -endif - -ifeq ($(DEBUG), true) -CFLAGS += -g -O0 -endif - -# Handle compiler-rt which is required for tests. This is done by requesting -# that the parent directory, the main wasi-libc directory, fetch its compiler-rt -# which will create a `resource-dir` argument which we can then add to LDFLAGS -# which gets fed down below into the actual linking of wasms. -LDFLAGS += -resource-dir ../build/$(TARGET_TRIPLE)/resource-dir -BUILTINS_STAMP := $(OBJDIR)/builtins.stamp -$(BUILTINS_STAMP): - make -C .. builtins - touch $@ - -# Build up all the `*.wasm.o` object files; these are the same regardless of -# whether we're building core modules or components. -$(WASM_OBJS): $(INFRA_HEADERS) -$(OBJDIR)/%.wasm.o: $(SRCDIR)/%.c $(DOWNLOADED) $(SYSROOT) - @mkdir -p $(@D) - $(CC) $(CFLAGS) $(shell scripts/add-flags.py CFLAGS $<) -c $< -o $@ - -# Build up all the `*.wasm` files. -obj_to_c = $(patsubst $(OBJDIR)/%.wasm.o,$(SRCDIR)/%.c,$1) -$(OBJDIR)/%.wasm: $(OBJDIR)/%.wasm.o $(INFRA_WASM_OBJS) | $(BUILTINS_STAMP) - @mkdir -p $(@D) - $(CC) $(CFLAGS) $(LDFLAGS) $(shell scripts/add-flags.py LDFLAGS $(call obj_to_c,$<)) $^ -o $@ - -# Compile each selected test using Clang. Note that failures here are likely -# due to a missing `libclang_rt.builtins-wasm32.a` in the Clang lib directory. -# This location is system-dependent, but could be fixed by something like: -# $ sudo mkdir /usr/lib64/clang/14.0.5/lib/wasi -# $ sudo cp download/libclang_rt.builtins-wasm32.a /usr/lib64/clang/14.0.5/lib/wasi/ -build: $(DOWNLOADED) $(WASMS) - -clean:: - rm -rf $(OBJDIR) - -##### GENERATE ################################################################# - -# Not all of the downloaded `libc-test` tests can be built and run with -# `wasi-libc`. Thus, we only include the subset that can be in `src/libc-test` -# as stub files that `#include` the original test files. When we want to add -# more tests, though, the `generate-stubs` target will generate stubs for the -# missing tests which we can delete or alter as needed. - -STUBDIR := $(SRCDIR)/libc-test -generate-stubs: - FROM_DIR=$(LIBC_TEST) TO_DIR=$(STUBDIR) scripts/generate-stubs.sh - -##### RUN ###################################################################### - -ENGINE ?= $(WASMTIME) run -OBJPAT := $(OBJDIR)/%.wasm - -# Each Wasm test is run every time, generating a folder containing a `cmd.sh` -# script and an `output.log` file (see `scripts/run-test.sh` for details). The -# `success` file is never generated, which means the test will rerun every time. -# To ignore a test temporarily, `touch .../success:`. -RUNTESTS:=$(WASMS:$(OBJPAT)=$(RUNDIR)/%/success) -wasm_to_c = $(patsubst $(OBJPAT),$(SRCDIR)/%.c,$1) -$(RUNDIR)/%/success: $(OBJPAT) - @mkdir -p $(@D) - @DIR="$(abspath $(@D))" \ - ENV="$(shell scripts/add-flags.py ENV $(call wasm_to_c,$<))" \ - WASM="$(abspath $<)" \ - ENGINE="$(ENGINE)" \ - RUN="$(shell scripts/add-flags.py RUN $(call wasm_to_c,$<))" \ - ARGS="$(shell scripts/add-flags.py ARGS $(call wasm_to_c,$<))" \ - scripts/run-test.sh - -# Use the provided Wasm engine to execute each test, emitting its output into -# a `.err` file. -run: build $(RUNTESTS) - @if scripts/failed-tests.sh $(RUNDIR); then \ - echo "Tests passed"; \ - else \ - echo "Tests failed:"; \ - VERBOSE=1 scripts/failed-tests.sh $(RUNDIR); \ - fi - -clean:: - rm -rf $(RUNDIR) - -##### MISC ##################################################################### - -# Note: the `clean` target has been built up by all of the previous sections. - -.PHONY: test download build run generate-stubs clean diff --git a/test/README.md b/test/README.md index 275678a9a..389eb573d 100644 --- a/test/README.md +++ b/test/README.md @@ -7,34 +7,62 @@ tests; all enabled tests are contained in the [`src`] directory. ### Pre-requisites - Clang -- [`libc-test`] -- `libclang_rt.builtins-wasm32.a` -- a WebAssembly engine -- other WebAssembly tools, especially for `wasm32-wasip2` support (see the - [`Makefile] for a complete list) - -All but Clang are downloaded automatically by the `make download` target. +- CMake ### Build and run -To build and run all tests: +Before building/running tests `wasi-libc` must itself be built. For example +`make` must be run in the root of the repository. + +Next tests must be configured with CMake. This can be done like so from the root +of the `wasi-libc` repository: ```sh -$ make TARGET_TRIPLE=... -Tests passed +$ cmake -S test -B testbuild ``` -Note that `wasm-ld` must be available, so an additional -`CC=/bin/clang` may be necessary. Each test runs in a directory that -looks like (see [`run-test.sh`]): +This will by default build test for `wasm32-wasi` and must match the target +found in the `sysroot` folder of the repository too. + +There are a few configuration options you might want to specify to the `cmake` +command line as well: + +* `-G Ninja` - or some other build system, but this configures the default build + system that CMake will generate. +* `-DCMAKE_C_COMPILER=clang` - specifies which compiler to use when building tests. +* `-DTARGET_TRIPLE=wasm32-wasip1` - specify an alternative target to be tested. +* `-DENGINE=engine` - override the default usage of Wasmtime to run test with + the `engine` specified. + +This `cmake` step will create a folder called `testbuild` which contains the +build system and will have the intermediate artifacts of the tests as well. If +`-G Ninja` was passed then the tests can then be built as: ```sh -$ ls run/$TARGET_TRIPLE/misc/some-test -cmd.sh # the exact command used to run the test -fs # a directory containing any test-created files -output.log # the captured printed output--only for errors +$ ninja -C testbuild ``` +This build step is required as the testing/`ctest` step below will not build +tests. By building tests ahead of time you're ensuring that the latest copy of +tests are available. + +Finally tests can be run with: + +```sh +$ ninja -C testbuild test +``` + +This will run all tests with CMake's `ctest` executable. You can also directly +run `ctest` for more control over the output. For example: + +```sh +$ ctest -j4 --output-on-failure --test-dir testbuild +``` + +CMake's [documentation for +CTest](https://cmake.org/cmake/help/book/mastering-cmake/chapter/Testing%20With%20CMake%20and%20CTest.html) +documents many other options/configurations as well. + ### Running tests in the browser To run a test in the browser, use the `scripts/browser-test/harness.mjs` as `ENGINE`. The harness uses [`bjorn3/browser_wasi_shim`](https://github.com/bjorn3/browser_wasi_shim/) as a WASI implementation on browser. @@ -42,54 +70,41 @@ To run a test in the browser, use the `scripts/browser-test/harness.mjs` as `ENG ```sh $ npm -C scripts/browser-test install $ npx -C scripts/browser-test playwright install chromium-headless-shell -$ make ENGINE="$PWD/scripts/browser-test/harness.mjs" TARGET_TRIPLE=... +$ cmake -S test -B testbuild -DENGINE="$PWD/scripts/browser-test/harness.mjs" -DTARGET_TRIPLE=... ``` ### Adding tests -To add a test, create a new C file in [`src/misc`]: +To add a test, create a new C file in [`src`]: ```c -//! filter.py(TARGET_TRIPLE): !wasm32-wasip2 -//! add-flags.py(CFLAGS): ... -//! add-flags.py(LDFLAGS): ... -//! add-flags.py(RUN): ... -void main() { ... } +int main() { ... } ``` -- to pass, the `main` function must exit successfully and avoid printing output -- the `filter.py` directive controls when the test builds and runs (e.g., not - for `wasip2`) -- the `add-flags.py` directive adds extra information for building or running - the test (see the [`Makefile`] for precise use). +To pass, the `main` function must exit successfully. + +Next edit [`CMakeLists.txt`] and use the `add_wasilibc_test` helper function toa +dd your test. The documentation of `register_test` shows some options which can +be passed to configuring how a test is built or what it can access at runtime. ### Enabling more [libc-test] tests -[libc-test] has more tests available that are not yet enabled (e.g., to count -the enabled subset, `find src -name *.c | wc -l`). Each enabled test contains a -stub file in [`src/libc-test`] that `#include`s its downloaded version and adds -various `filter.py` and `add-flags.py` directives. +[libc-test] has more tests available that are not yet enabled. Each enabled test +is listed in `CMakeLists.txt` and is managed with the `add_libc_test` helper +function. To enable more tests edit the section and add more tests to be +listed. -To quickly create stub files for not-yet-enabled tests: +The `cmake` configuration step will print out where `libc-test` is located: -```sh -$ make generate-stubs -$ git status +``` +$ cmake -S test -B testbuild +... +-- libc-test source directory: $PWD/testbuild/_deps/libc-test-src ... -src/libc-test/functional/tls_align.c -src/libc-test/functional/tls_align_dlopen.c -src/libc-test/functional/tls_align_dso.c -src/libc-test/functional/tls_init.c ``` -Then modify the directives for these new stub files to get the new tests to -compile and successfully run. - - +You can explore this direcotry to see what tests are available and have not yet +been enabled. [libc-test]: https://wiki.musl-libc.org/libc-test.html -[`Makefile`]: Makefile -[`run-test.sh`]: scripts/run-test.sh [`src`]: src -[`src/libc-test`]: src/libc-test -[`src/misc`]: src/misc diff --git a/test/scripts/add-flags.py b/test/scripts/add-flags.py deleted file mode 100755 index f8716d710..000000000 --- a/test/scripts/add-flags.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python3 - -# Find additional compilation flags specified in test files. -# -# This script accepts a single file as an argument and looks for a comment like -# the following: `// add-flags.py(): `. If found, the `` are -# printed to stdout. -# -# Example: -# ``` -# $ head one.c -# //! add-flags.py(CFLAGS): -DFOO -# $ ./add-flags.py CFLAGS one.c -# -DFOO - -import sys -import os -import re -import logging - -""" -Match a C comment like the following: `//! add-flags.py: `. -""" -PATTERN = re.compile('\\s*//\\!\\s*add-flags\\.py\\(([^)]+)\\):\\s*(.*)') - - -def find_flags(name, file): - with open(file, 'r') as f: - for lineno, line in enumerate(f, start=1): - match = PATTERN.match(line) - if match and match[1] == name: - pos = f'[{file}:{lineno}]' - logging.debug(f'{pos} found flags') - return match[2].strip() - - -def main(name, file): - flags = find_flags(name, file) - if flags: - print(flags) - - -if __name__ == "__main__": - logging.getLogger().name = os.path.basename(__file__) - if os.environ.get('VERBOSE'): - logging.basicConfig(level=logging.DEBUG) - if len(sys.argv) != 3: - print(f'usage: {sys.argv[0]} ') - sys.exit(1) - main(sys.argv[1], sys.argv[2]) diff --git a/test/scripts/browser-test/harness.mjs b/test/scripts/browser-test/harness.mjs index 87806ceec..6996ccd32 100755 --- a/test/scripts/browser-test/harness.mjs +++ b/test/scripts/browser-test/harness.mjs @@ -18,20 +18,6 @@ import { readFileSync } from 'node:fs'; import url from "node:url"; import { chromium } from 'playwright'; -const SKIP_TESTS = [ - // "poll_oneoff" can't be implemented in the browser - "libc-test/functional/pthread_cond", - // atomic.wait32 can't be executed on the main thread - "libc-test/functional/pthread_mutex", - "libc-test/functional/pthread_tsd", - // Skip test that uses command-line arguments - "misc/argv_two_args", - // Skip test that uses environment variables - "misc/external_env", - // XFAIL: @bjorn3/browser_wasi_shim doesn't support symlinks for now - "misc/fts", -]; - /** * @param {{wasmPath: string, port: number}} * @returns {Promise<{server: import('node:http').Server, port: number}>} @@ -128,11 +114,6 @@ async function main() { return 1; } - if (SKIP_TESTS.some(test => wasmPath.includes(test + "."))) { - // Silently skip tests that are known to fail in the browser - return 0; - } - if (args.values.dir && args.values.dir.length > 0) { // Silently skip tests that require preopened directories for now // as it adds more complexity to the harness and file system emulation diff --git a/test/scripts/failed-tests.sh b/test/scripts/failed-tests.sh deleted file mode 100755 index 381218a18..000000000 --- a/test/scripts/failed-tests.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -# This script checks for failed tests in the given directory. Failed tests will -# include text in a *.log file. -# -# Usage: failed-tests.sh [TESTDIR] -# -# Optionally set the VERBOSE environment variable to see the list of failed -# tests. - -set -e - -TESTDIR=${1:-.} -FAILED=$(find $TESTDIR -type f -and -name *.log -and -not -size 0) - -if [[ -n "$VERBOSE" ]]; then - for failed in "$FAILED"; do - echo "$failed"; - done -fi - -if [[ -n "$FAILED" ]]; then - exit 1 -fi diff --git a/test/scripts/filter.py b/test/scripts/filter.py deleted file mode 100755 index 1eb312679..000000000 --- a/test/scripts/filter.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env python3 - -# Filter out test files that do not match a configuration variable. -# -# This script accepts a list of files as arguments and looks for a comment like -# the following in each: `//! filter.py(): `. The -# `VARIABLE` value is looked up in the environment and compared with the -# expression. An `EXPRESSION` is a comma-separated list of terms: either -# `` or `!`. If the `VARIABLE` value matches the expression, the -# file is printed; otherwise, it is filtered out. -# -# Example: -# ``` -# $ head one.c -# //! filter.py(FOO): bar -# $ head two.c -# //! filter.py(FOO):!bar, baz -# $ FOO=bar ./filter.py one.c two.c -# one.c -# $ FOO=baz ./filter.py one.c two.c -# two.c -# $ ./filter.py one.c two.c -# one.c two.c -# ``` - -import sys -import os -import re -import logging - - -def parse_expression(expr): - """ - An expression is a comma-separated list of terms: either or - !. - """ - return [s.strip() for s in expr.split(',')] - - -def matches_expression(value, expr, pos): - """ - A value matches an expression if it is in the list of strings or if it is - not explicitly rejected; order matters, because the first term that matches, - wins. - """ - for e in expr: - if e.startswith('!') and value == e[1:]: - logging.debug(f'{pos} {value} != {expr}, REJECTED') - return False - elif value == e: - logging.debug(f'{pos} {value} == {expr}, ALLOWED') - return True - logging.debug(f'{pos} {value} not in {expr}, REJECTED') - return False - - -""" -Match a C comment like the following: `//! filter.py(): `. -""" -PATTERN = re.compile('\\s*//\\!\\s*filter\\.py\\(([^)]+)\\):\\s*(.*)') - - -def line_matches(line, env, pos): - match = PATTERN.match(line) - if match: - value = env.get(match[1]) - if value is None: - logging.debug(f'{pos} no value for {match[1]}, ALLOWED') - return True - else: - expr = parse_expression(match[2]) - return matches_expression(value, expr, pos) - return True - - -def file_matches(file, env): - with open(file, 'r') as f: - print = True - for lineno, line in enumerate(f, start=1): - print &= line_matches(line, env, f'[{file}:{lineno}]') - return print - - -def main(env, files): - filtered = [file for file in files if file_matches(file, env)] - print(' '.join(filtered)) - - -if __name__ == "__main__": - logging.getLogger().name = os.path.basename(__file__) - if os.environ.get('VERBOSE'): - logging.basicConfig(level=logging.DEBUG) - main(os.environ, sys.argv[1:]) diff --git a/test/scripts/run-test.sh b/test/scripts/run-test.sh deleted file mode 100755 index 88437c275..000000000 --- a/test/scripts/run-test.sh +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/env bash - -# Run a previously built test, generating in `$DIR`: -# - a `cmd.sh` script containing the actual command used to run the test in an -# engine -# - a `fs` directory which the test may have used for file IO -# - an `output.log` file containing the output of the test -# -# Usage: ENV="..." DIR=... WASM=... ENGINE=... RUN="..." ARGS="..." ./run-test.sh - -ENGINE="${ENGINE:-wasmtime}" -[ -n "$WASM" ] || (echo "missing WASM variable" && exit 1) -[ -n "$DIR" ] || (echo "missing DIR variable" && exit 1) - -# Run the client/server sockets test, which requires a client and server -# running in separate processes -# Takes the name of the .wasm file for the server as an argument -run_sockets_test() { - # Args are the same for client and server - cd $DIR - server_wasm=$1 - echo "$ENV $ENGINE $RUN $server_wasm $ARGS" > server_cmd.sh - chmod +x server_cmd.sh - # Start the server - ./server_cmd.sh &> server_output.log & - PID=$! - [ $? -ne -1 ] || (echo "Failed to start server $server_wasm" && exit 1) - echo "$ENV $ENGINE $RUN $WASM $ARGS" > cmd.sh - chmod +x cmd.sh - # Allow time for the server to start - sleep 1 - # Start the client - ./cmd.sh &> output.log - test_result=$? - # Server normally exits on its own, but kill it in case the test failed - if [ ps -p $PID > /dev/null 2>&1 ]; then - kill -9 $PID - fi - [ $test_result -eq 0 ] || echo "Test failed" >> output.log -} - -# Run the client/server sockets test, which requires one server -# and multiple clients running in separate processes -CLIENTS=10 -run_sockets_test_multiple() { - # Args are the same for client and server - cd $DIR - server_wasm=$1 - echo "$ENV $ENGINE $RUN $server_wasm $ARGS" > server_cmd.sh - chmod +x server_cmd.sh - # Start the server - ./server_cmd.sh &> server_output.log & - PID=$! - [ $? -ne -1 ] || (echo "Failed to start server $server_wasm" && exit 1) - echo "$ENV $ENGINE $RUN $WASM $ARGS" > cmd.sh - chmod +x cmd.sh - # Allow time for the server to start - sleep 1 - # Start the clients - pids=() - for ((i = 0; i < CLIENTS; i++)); do - ./cmd.sh &> output"$i".log & - pids+=( $! ) - done - ANY_FAILURES=0 - for ((i = 0; i < CLIENTS; i++)); do - wait ${pids[i]} - if [ $? -ne 0 ]; then - ANY_FAILURES=1 - fi - done - # Server normally exits on its own, but kill it in case the test failed - if [ ps -p $PID > /dev/null 2>&1 ]; then - kill -9 $PID - fi - [ $ANY_FAILURES -eq 0 ] || echo "Test failed" >> output.log -} - -testname=$(basename $WASM) -parent=$(dirname $WASM) -if [ $testname == "sockets-server.wasm" ]; then - exit 0 -fi -if [ $testname == "sockets-multiple-server.wasm" ]; then - exit 0 -fi -if [ $testname == "sockets-server-udp-blocking.wasm" ]; then - exit 0 -fi -if [ $testname == "sockets-client.wasm" ]; then - run_sockets_test $parent/"sockets-server.wasm" - exit $? -fi -if [ $testname == "sockets-client-udp-blocking.wasm" ]; then - run_sockets_test $parent/"sockets-server-udp-blocking.wasm" - exit $? -fi -if [ $testname == "sockets-multiple-client.wasm" ]; then - run_sockets_test_multiple $parent/"sockets-multiple-server.wasm" - exit $? -fi -if [ $testname = "sockets-client-hangup-after-connect.wasm" ]; then - run_sockets_test $parent/"sockets-server-handle-hangups.wasm" - exit $? -fi -if [ $testname = "sockets-client-hangup-while-sending.wasm" ]; then - run_sockets_test $parent/"sockets-server-handle-hangups.wasm" - exit $? -fi -if [ $testname = "sockets-client-hangup-after-sending.wasm" ]; then - run_sockets_test $parent/"sockets-server-handle-hangups.wasm" - exit $? -fi -if [ $testname = "sockets-client-hangup-while-receiving.wasm" ]; then - run_sockets_test $parent/"sockets-server-handle-hangups.wasm" - exit $? -fi -if [ $testname == "sockets-server-hangup-before-send.wasm" ]; then - exit 0 -fi -if [ $testname == "sockets-server-hangup-during-send.wasm" ]; then - exit 0 -fi -if [ $testname == "sockets-server-hangup-before-recv.wasm" ]; then - exit 0 -fi -if [ $testname == "sockets-server-hangup-during-recv.wasm" ]; then - exit 0 -fi -if [ $testname == "sockets-server-handle-hangups.wasm" ]; then - exit 0 -fi -if [ $testname == "sockets-client-handle-hangups.wasm" ]; then - run_sockets_test $parent/"sockets-server-hangup-before-send.wasm" - run_sockets_test $parent/"sockets-server-hangup-during-send.wasm" - run_sockets_test $parent/"sockets-server-hangup-before-recv.wasm" - run_sockets_test $parent/"sockets-server-hangup-during-recv.wasm" - # Deliberately fall through so that we can run this test without a server - # (to test the behavior when connect() fails) -fi -# This test fails nondeterministically -if [ $testname == "sockets-nonblocking-udp-multiple.c" ]; then - exit 0 -fi -cd $DIR -mkdir -p fs -echo "$ENV $ENGINE $RUN $WASM $ARGS" > cmd.sh -chmod +x cmd.sh -./cmd.sh &> output.log -[ $? -eq 0 ] || echo "Test failed" >> output.log diff --git a/test/socket-test.cmake b/test/socket-test.cmake new file mode 100644 index 000000000..6a515fc5b --- /dev/null +++ b/test/socket-test.cmake @@ -0,0 +1,25 @@ +# CMake's `execute_process` will run all commands specified concurrently but the +# stdout of each command is piped to the stdin of the next command. Tests print +# to stdout so that's not the behavior we want, so use `bash` to redirect stdout +# onto stderr. +# +# Also issue a `sleep 1` as a bit of a kludge to wait for the server to come +# online at this time. + +set(CLIENTS) + +if (NOT NCLIENTS) + set(NCLIENTS 1) +endif() + +foreach(i RANGE 1 ${NCLIENTS}) + list(APPEND CLIENTS COMMAND bash -c "sleep 1 && ${ENGINE} -Sinherit-network ${CLIENT} 1>&2") +endforeach() + +execute_process( + COMMAND bash -c "${ENGINE} -Sinherit-network ${SERVER} 1>&2" + ${CLIENTS} + TIMEOUT 5 + COMMAND_ERROR_IS_FATAL ANY + COMMAND_ECHO STDOUT +) diff --git a/test/src/misc/access.c b/test/src/access.c similarity index 97% rename from test/src/misc/access.c rename to test/src/access.c index da85bdc84..0e3bb4bff 100644 --- a/test/src/misc/access.c +++ b/test/src/access.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include diff --git a/test/src/misc/argv_two_args.c b/test/src/argv_two_args.c similarity index 92% rename from test/src/misc/argv_two_args.c rename to test/src/argv_two_args.c index 7813849f6..95b322e96 100644 --- a/test/src/misc/argv_two_args.c +++ b/test/src/argv_two_args.c @@ -1,5 +1,3 @@ -//! add-flags.py(CFLAGS): -I. -//! add-flags.py(ARGS): foo bar #include #include #include "test.h" diff --git a/test/src/misc/busywait.c b/test/src/busywait.c similarity index 77% rename from test/src/misc/busywait.c rename to test/src/busywait.c index 3644398e6..a56484558 100644 --- a/test/src/misc/busywait.c +++ b/test/src/busywait.c @@ -1,8 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip1-threads -//! add-flags.py(CFLAGS): -pthread -//! add-flags.py(LDFLAGS): -pthread -//! add-flags.py(RUN): --wasi threads - #include #include #include @@ -29,4 +24,4 @@ int main() { pthread_mutex_unlock(&mutex); return 0; -} +} diff --git a/test/src/misc/clock_nanosleep.c b/test/src/clock_nanosleep.c similarity index 73% rename from test/src/misc/clock_nanosleep.c rename to test/src/clock_nanosleep.c index 442fe5152..734ef20bd 100644 --- a/test/src/misc/clock_nanosleep.c +++ b/test/src/clock_nanosleep.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include @@ -21,11 +19,10 @@ int main(void) // Not much point running the test if the resolution is >= 1 sec TEST(clock_resolution.tv_sec==0); - // Adjust this number if necessary - // In wasip2 we don't get accurate results for sleeping < 1 ms - struct timespec time_to_sleep = { .tv_sec = 0, - .tv_nsec = 1E6 * clock_resolution.tv_nsec }; + // Sleep for a total of 5ms + long ns_to_sleep = 5E6; + struct timespec time_to_sleep = { .tv_sec = 0, .tv_nsec = ns_to_sleep }; struct timespec start_time, end_time; clock_gettime(CLOCK_MONOTONIC, &start_time); @@ -34,14 +31,14 @@ int main(void) clock_gettime(CLOCK_MONOTONIC, &end_time); TEST(end_time.tv_sec - start_time.tv_sec <= 1); - long nanoseconds_elapsed = (end_time.tv_sec - start_time.tv_sec) + long nanoseconds_elapsed = (end_time.tv_sec - start_time.tv_sec) * 1E9 - start_time.tv_nsec + end_time.tv_nsec; // Test that the difference between the requested amount of sleep // and the actual elapsed time is within an acceptable margin - double difference = abs(nanoseconds_elapsed - time_to_sleep.tv_nsec) - / time_to_sleep.tv_nsec; + double difference = abs(nanoseconds_elapsed - ns_to_sleep) + / ns_to_sleep; // Allow the actual sleep time to be twice as much as the requested time TEST(difference <= 1); diff --git a/test/src/misc/external_env.c b/test/src/external_env.c similarity index 75% rename from test/src/misc/external_env.c rename to test/src/external_env.c index 85b4ee84b..d568904df 100644 --- a/test/src/misc/external_env.c +++ b/test/src/external_env.c @@ -1,6 +1,3 @@ -//! add-flags.py(CFLAGS): -I. -//! add-flags.py(RUN): --wasi=inherit-env=y -//! add-flags.py(ENV): VAR1=foo VAR2=bar #include #include #include diff --git a/test/src/misc/fadvise.c b/test/src/fadvise.c similarity index 97% rename from test/src/misc/fadvise.c rename to test/src/fadvise.c index 805f7e9df..251f05b28 100644 --- a/test/src/misc/fadvise.c +++ b/test/src/fadvise.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include diff --git a/test/src/misc/fallocate.c b/test/src/fallocate.c similarity index 95% rename from test/src/misc/fallocate.c rename to test/src/fallocate.c index aed15fbbb..14f5e364e 100644 --- a/test/src/misc/fallocate.c +++ b/test/src/fallocate.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include diff --git a/test/src/misc/fcntl.c b/test/src/fcntl.c similarity index 97% rename from test/src/misc/fcntl.c rename to test/src/fcntl.c index f640dff3a..2ad9762d2 100644 --- a/test/src/misc/fcntl.c +++ b/test/src/fcntl.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include diff --git a/test/src/misc/fdatasync.c b/test/src/fdatasync.c similarity index 95% rename from test/src/misc/fdatasync.c rename to test/src/fdatasync.c index e8f58cf25..c58668786 100644 --- a/test/src/misc/fdatasync.c +++ b/test/src/fdatasync.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include diff --git a/test/src/misc/fdopen.c b/test/src/fdopen.c similarity index 96% rename from test/src/misc/fdopen.c rename to test/src/fdopen.c index c7e6513b8..0bd2b2edc 100644 --- a/test/src/misc/fdopen.c +++ b/test/src/fdopen.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - // Modified from libc to not use mkstemp and to use a relative path #include diff --git a/test/src/misc/feof.c b/test/src/feof.c similarity index 97% rename from test/src/misc/feof.c rename to test/src/feof.c index 35ac07501..a8b3b25e8 100644 --- a/test/src/misc/feof.c +++ b/test/src/feof.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include diff --git a/test/src/misc/file_permissions.c b/test/src/file_permissions.c similarity index 95% rename from test/src/misc/file_permissions.c rename to test/src/file_permissions.c index 36b83d192..6451c3754 100644 --- a/test/src/misc/file_permissions.c +++ b/test/src/file_permissions.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include diff --git a/test/src/misc/fseek.c b/test/src/fseek.c similarity index 98% rename from test/src/misc/fseek.c rename to test/src/fseek.c index 45751d6ed..3c60a8b60 100644 --- a/test/src/misc/fseek.c +++ b/test/src/fseek.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include diff --git a/test/src/misc/fsync.c b/test/src/fsync.c similarity index 95% rename from test/src/misc/fsync.c rename to test/src/fsync.c index c9421b47b..69a80a2cf 100644 --- a/test/src/misc/fsync.c +++ b/test/src/fsync.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include diff --git a/test/src/misc/ftruncate.c b/test/src/ftruncate.c similarity index 96% rename from test/src/misc/ftruncate.c rename to test/src/ftruncate.c index a7639d2cb..d629457bf 100644 --- a/test/src/misc/ftruncate.c +++ b/test/src/ftruncate.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include diff --git a/test/src/misc/fts.c b/test/src/fts.c similarity index 99% rename from test/src/misc/fts.c rename to test/src/fts.c index 1126f9b79..240bb3d17 100644 --- a/test/src/misc/fts.c +++ b/test/src/fts.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - /* * We modified musl-fts not to use fchdir() and we made FTS_NOCHDIR * the default behavior. This test is to make sure that the modified diff --git a/test/src/misc/fwscanf.c b/test/src/fwscanf.c similarity index 98% rename from test/src/misc/fwscanf.c rename to test/src/fwscanf.c index 81bc18341..374d937d1 100644 --- a/test/src/misc/fwscanf.c +++ b/test/src/fwscanf.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - // Modified from libc-test to not use tmpfile #include diff --git a/test/src/misc/getentropy.c b/test/src/getentropy.c similarity index 91% rename from test/src/misc/getentropy.c rename to test/src/getentropy.c index d77b436aa..5e4ee41c3 100644 --- a/test/src/misc/getentropy.c +++ b/test/src/getentropy.c @@ -1,5 +1,3 @@ -//! add-flags.py(CFLAGS): -I. -//! add-flags.py(ARGS): foo bar #include #include #include "test.h" diff --git a/test/src/hello.c b/test/src/hello.c new file mode 100644 index 000000000..91ec522d4 --- /dev/null +++ b/test/src/hello.c @@ -0,0 +1,6 @@ +#include + +int main(void) { + printf("Hello, World!\n"); + return 0; +} diff --git a/test/src/misc/ioctl.c b/test/src/ioctl.c similarity index 93% rename from test/src/misc/ioctl.c rename to test/src/ioctl.c index 457a77fd2..29d5062fe 100644 --- a/test/src/misc/ioctl.c +++ b/test/src/ioctl.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ --wasi=inherit-network=y - #include #include #include diff --git a/test/src/misc/isatty.c b/test/src/isatty.c similarity index 93% rename from test/src/misc/isatty.c rename to test/src/isatty.c index 7ddb69378..54ade366e 100644 --- a/test/src/misc/isatty.c +++ b/test/src/isatty.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include diff --git a/test/src/libc-test/functional/argv.c b/test/src/libc-test/functional/argv.c deleted file mode 100644 index e9dfc6dc0..000000000 --- a/test/src/libc-test/functional/argv.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/argv.c" diff --git a/test/src/libc-test/functional/basename.c b/test/src/libc-test/functional/basename.c deleted file mode 100644 index 977378e8b..000000000 --- a/test/src/libc-test/functional/basename.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/basename.c" diff --git a/test/src/libc-test/functional/clocale_mbfuncs.c b/test/src/libc-test/functional/clocale_mbfuncs.c deleted file mode 100644 index b7c1c2ed3..000000000 --- a/test/src/libc-test/functional/clocale_mbfuncs.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/clocale_mbfuncs.c" diff --git a/test/src/libc-test/functional/clock_gettime.c b/test/src/libc-test/functional/clock_gettime.c deleted file mode 100644 index 941b445c7..000000000 --- a/test/src/libc-test/functional/clock_gettime.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/clock_gettime.c" diff --git a/test/src/libc-test/functional/crypt.c b/test/src/libc-test/functional/crypt.c deleted file mode 100644 index 53c75df4c..000000000 --- a/test/src/libc-test/functional/crypt.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/crypt.c" diff --git a/test/src/libc-test/functional/dirname.c b/test/src/libc-test/functional/dirname.c deleted file mode 100644 index 01e20f2d3..000000000 --- a/test/src/libc-test/functional/dirname.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/dirname.c" diff --git a/test/src/libc-test/functional/env.c b/test/src/libc-test/functional/env.c deleted file mode 100644 index d86190287..000000000 --- a/test/src/libc-test/functional/env.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/env.c" diff --git a/test/src/libc-test/functional/fnmatch.c b/test/src/libc-test/functional/fnmatch.c deleted file mode 100644 index 2c1d8f0a2..000000000 --- a/test/src/libc-test/functional/fnmatch.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/fnmatch.c" diff --git a/test/src/libc-test/functional/iconv_open.c b/test/src/libc-test/functional/iconv_open.c deleted file mode 100644 index a57efa4b7..000000000 --- a/test/src/libc-test/functional/iconv_open.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/iconv_open.c" diff --git a/test/src/libc-test/functional/mbc.c b/test/src/libc-test/functional/mbc.c deleted file mode 100644 index ebfb9694e..000000000 --- a/test/src/libc-test/functional/mbc.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/mbc.c" diff --git a/test/src/libc-test/functional/memstream.c b/test/src/libc-test/functional/memstream.c deleted file mode 100644 index 151162ccf..000000000 --- a/test/src/libc-test/functional/memstream.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/memstream.c" diff --git a/test/src/libc-test/functional/pthread_cond.c b/test/src/libc-test/functional/pthread_cond.c deleted file mode 100644 index a91789500..000000000 --- a/test/src/libc-test/functional/pthread_cond.c +++ /dev/null @@ -1,5 +0,0 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip1-threads -//! add-flags.py(CFLAGS): -I. -//! add-flags.py(LDFLAGS): -Wl,--import-memory,--export-memory,--shared-memory,--max-memory=1073741824 -//! add-flags.py(RUN): --wasi threads -#include "build/download/libc-test/src/functional/pthread_cond.c" diff --git a/test/src/libc-test/functional/pthread_cond_busywait.c b/test/src/libc-test/functional/pthread_cond_busywait.c deleted file mode 100644 index dd2169119..000000000 --- a/test/src/libc-test/functional/pthread_cond_busywait.c +++ /dev/null @@ -1,13 +0,0 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip1-threads -//! add-flags.py(CFLAGS): -I. -//! add-flags.py(LDFLAGS): -Wl,--import-memory,--export-memory,--shared-memory,--max-memory=1073741824 -//! add-flags.py(RUN): --wasi threads -#include "build/download/libc-test/src/functional/pthread_cond.c" - -#include - -__attribute__((constructor)) -void __wasilibc_enable_busywait(void) -{ - __wasilibc_enable_futex_busywait_on_current_thread(); -} diff --git a/test/src/libc-test/functional/pthread_mutex.c b/test/src/libc-test/functional/pthread_mutex.c deleted file mode 100644 index 552e7e060..000000000 --- a/test/src/libc-test/functional/pthread_mutex.c +++ /dev/null @@ -1,5 +0,0 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip1-threads -//! add-flags.py(CFLAGS): -I. -//! add-flags.py(LDFLAGS): -Wl,--import-memory,--export-memory,--shared-memory,--max-memory=1073741824 -//! add-flags.py(RUN): --wasi threads -#include "build/download/libc-test/src/functional/pthread_mutex.c" diff --git a/test/src/libc-test/functional/pthread_mutex_busywait.c b/test/src/libc-test/functional/pthread_mutex_busywait.c deleted file mode 100644 index 98b355ef8..000000000 --- a/test/src/libc-test/functional/pthread_mutex_busywait.c +++ /dev/null @@ -1,13 +0,0 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip1-threads -//! add-flags.py(CFLAGS): -I. -//! add-flags.py(LDFLAGS): -Wl,--import-memory,--export-memory,--shared-memory,--max-memory=1073741824 -//! add-flags.py(RUN): --wasi threads -#include "build/download/libc-test/src/functional/pthread_mutex.c" - -#include - -__attribute__((constructor)) -void __wasilibc_enable_busywait(void) -{ - __wasilibc_enable_futex_busywait_on_current_thread(); -} diff --git a/test/src/libc-test/functional/pthread_tsd.c b/test/src/libc-test/functional/pthread_tsd.c deleted file mode 100644 index 2845516cd..000000000 --- a/test/src/libc-test/functional/pthread_tsd.c +++ /dev/null @@ -1,5 +0,0 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip1-threads -//! add-flags.py(CFLAGS): -I. -//! add-flags.py(LDFLAGS): -Wl,--import-memory,--export-memory,--shared-memory,--max-memory=1073741824 -//! add-flags.py(RUN): --wasi threads -#include "build/download/libc-test/src/functional/pthread_tsd.c" diff --git a/test/src/libc-test/functional/pthread_tsd_busywait.c b/test/src/libc-test/functional/pthread_tsd_busywait.c deleted file mode 100644 index 364b8ce0c..000000000 --- a/test/src/libc-test/functional/pthread_tsd_busywait.c +++ /dev/null @@ -1,13 +0,0 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip1-threads -//! add-flags.py(CFLAGS): -I. -//! add-flags.py(LDFLAGS): -Wl,--import-memory,--export-memory,--shared-memory,--max-memory=1073741824 -//! add-flags.py(RUN): --wasi threads -#include "build/download/libc-test/src/functional/pthread_tsd.c" - -#include - -__attribute__((constructor)) -void __wasilibc_enable_busywait(void) -{ - __wasilibc_enable_futex_busywait_on_current_thread(); -} diff --git a/test/src/libc-test/functional/qsort.c b/test/src/libc-test/functional/qsort.c deleted file mode 100644 index 68391afc3..000000000 --- a/test/src/libc-test/functional/qsort.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/qsort.c" diff --git a/test/src/libc-test/functional/random.c b/test/src/libc-test/functional/random.c deleted file mode 100644 index 00a47c5e8..000000000 --- a/test/src/libc-test/functional/random.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/random.c" diff --git a/test/src/libc-test/functional/search_hsearch.c b/test/src/libc-test/functional/search_hsearch.c deleted file mode 100644 index c38e43c70..000000000 --- a/test/src/libc-test/functional/search_hsearch.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/search_hsearch.c" diff --git a/test/src/libc-test/functional/search_insque.c b/test/src/libc-test/functional/search_insque.c deleted file mode 100644 index 6474d2302..000000000 --- a/test/src/libc-test/functional/search_insque.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/search_insque.c" diff --git a/test/src/libc-test/functional/search_lsearch.c b/test/src/libc-test/functional/search_lsearch.c deleted file mode 100644 index d5cbe5ccd..000000000 --- a/test/src/libc-test/functional/search_lsearch.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/search_lsearch.c" diff --git a/test/src/libc-test/functional/search_tsearch.c b/test/src/libc-test/functional/search_tsearch.c deleted file mode 100644 index 7b2a116e2..000000000 --- a/test/src/libc-test/functional/search_tsearch.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/search_tsearch.c" diff --git a/test/src/libc-test/functional/snprintf.c b/test/src/libc-test/functional/snprintf.c deleted file mode 100644 index 3f28e8d14..000000000 --- a/test/src/libc-test/functional/snprintf.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/snprintf.c" diff --git a/test/src/libc-test/functional/sscanf.c b/test/src/libc-test/functional/sscanf.c deleted file mode 100644 index ea566eade..000000000 --- a/test/src/libc-test/functional/sscanf.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/sscanf.c" diff --git a/test/src/libc-test/functional/strftime.c b/test/src/libc-test/functional/strftime.c deleted file mode 100644 index 0392e5567..000000000 --- a/test/src/libc-test/functional/strftime.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/strftime.c" diff --git a/test/src/libc-test/functional/string.c b/test/src/libc-test/functional/string.c deleted file mode 100644 index 46ca27dbf..000000000 --- a/test/src/libc-test/functional/string.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/string.c" diff --git a/test/src/libc-test/functional/string_memcpy.c b/test/src/libc-test/functional/string_memcpy.c deleted file mode 100644 index b932c8d1e..000000000 --- a/test/src/libc-test/functional/string_memcpy.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/string_memcpy.c" diff --git a/test/src/libc-test/functional/string_memmem.c b/test/src/libc-test/functional/string_memmem.c deleted file mode 100644 index bb32fbc9c..000000000 --- a/test/src/libc-test/functional/string_memmem.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/string_memmem.c" diff --git a/test/src/libc-test/functional/string_memset.c b/test/src/libc-test/functional/string_memset.c deleted file mode 100644 index 2b247985a..000000000 --- a/test/src/libc-test/functional/string_memset.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/string_memset.c" diff --git a/test/src/libc-test/functional/string_strchr.c b/test/src/libc-test/functional/string_strchr.c deleted file mode 100644 index ee986031f..000000000 --- a/test/src/libc-test/functional/string_strchr.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/string_strchr.c" diff --git a/test/src/libc-test/functional/string_strcspn.c b/test/src/libc-test/functional/string_strcspn.c deleted file mode 100644 index 73db119e9..000000000 --- a/test/src/libc-test/functional/string_strcspn.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/string_strcspn.c" diff --git a/test/src/libc-test/functional/string_strstr.c b/test/src/libc-test/functional/string_strstr.c deleted file mode 100644 index 6dccec462..000000000 --- a/test/src/libc-test/functional/string_strstr.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/string_strstr.c" diff --git a/test/src/libc-test/functional/strtod.c b/test/src/libc-test/functional/strtod.c deleted file mode 100644 index 45923faba..000000000 --- a/test/src/libc-test/functional/strtod.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/strtod.c" diff --git a/test/src/libc-test/functional/strtod_long.c b/test/src/libc-test/functional/strtod_long.c deleted file mode 100644 index 4e7acf18f..000000000 --- a/test/src/libc-test/functional/strtod_long.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/strtod_long.c" diff --git a/test/src/libc-test/functional/strtod_simple.c b/test/src/libc-test/functional/strtod_simple.c deleted file mode 100644 index 989fd3c2d..000000000 --- a/test/src/libc-test/functional/strtod_simple.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/strtod_simple.c" diff --git a/test/src/libc-test/functional/strtof.c b/test/src/libc-test/functional/strtof.c deleted file mode 100644 index 7f47711e4..000000000 --- a/test/src/libc-test/functional/strtof.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/strtof.c" diff --git a/test/src/libc-test/functional/strtol.c b/test/src/libc-test/functional/strtol.c deleted file mode 100644 index 5de47d79a..000000000 --- a/test/src/libc-test/functional/strtol.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/strtol.c" diff --git a/test/src/libc-test/functional/strtold.c b/test/src/libc-test/functional/strtold.c deleted file mode 100644 index 8f467fedb..000000000 --- a/test/src/libc-test/functional/strtold.c +++ /dev/null @@ -1,3 +0,0 @@ -//! add-flags.py(CFLAGS): -I. -//! add-flags.py(LDFLAGS): -lc-printscan-long-double -#include "build/download/libc-test/src/functional/strtold.c" diff --git a/test/src/libc-test/functional/swprintf.c b/test/src/libc-test/functional/swprintf.c deleted file mode 100644 index c505671a8..000000000 --- a/test/src/libc-test/functional/swprintf.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/swprintf.c" diff --git a/test/src/libc-test/functional/tgmath.c b/test/src/libc-test/functional/tgmath.c deleted file mode 100644 index 20ec1571a..000000000 --- a/test/src/libc-test/functional/tgmath.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/tgmath.c" diff --git a/test/src/libc-test/functional/udiv.c b/test/src/libc-test/functional/udiv.c deleted file mode 100644 index 2b92f34e3..000000000 --- a/test/src/libc-test/functional/udiv.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/udiv.c" diff --git a/test/src/libc-test/functional/wcsstr.c b/test/src/libc-test/functional/wcsstr.c deleted file mode 100644 index 6d5fa3823..000000000 --- a/test/src/libc-test/functional/wcsstr.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/wcsstr.c" diff --git a/test/src/libc-test/functional/wcstol.c b/test/src/libc-test/functional/wcstol.c deleted file mode 100644 index 111837872..000000000 --- a/test/src/libc-test/functional/wcstol.c +++ /dev/null @@ -1,3 +0,0 @@ -// Auto-generated by generate-stubs.sh -//! add-flags.py(CFLAGS): -I. -#include "build/download/libc-test/src/functional/wcstol.c" diff --git a/test/src/misc/link.c b/test/src/link.c similarity index 94% rename from test/src/misc/link.c rename to test/src/link.c index a9dfed377..b425ab880 100644 --- a/test/src/misc/link.c +++ b/test/src/link.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include diff --git a/test/src/misc/memchr.c b/test/src/memchr.c similarity index 95% rename from test/src/misc/memchr.c rename to test/src/memchr.c index 5af177474..68b9400fd 100644 --- a/test/src/misc/memchr.c +++ b/test/src/memchr.c @@ -1,5 +1,3 @@ -//! add-flags.py(LDFLAGS): -Wl,--stack-first -Wl,--initial-memory=327680 - #include <__macro_PAGESIZE.h> #include #include diff --git a/test/src/misc/memcmp.c b/test/src/memcmp.c similarity index 95% rename from test/src/misc/memcmp.c rename to test/src/memcmp.c index 88d580d79..1b3973fb2 100644 --- a/test/src/misc/memcmp.c +++ b/test/src/memcmp.c @@ -1,5 +1,3 @@ -//! add-flags.py(LDFLAGS): -Wl,--stack-first -Wl,--initial-memory=327680 - #include <__macro_PAGESIZE.h> #include #include diff --git a/test/src/misc/open_relative_path.c b/test/src/open_relative_path.c similarity index 94% rename from test/src/misc/open_relative_path.c rename to test/src/open_relative_path.c index e831b8655..1c935a127 100644 --- a/test/src/misc/open_relative_path.c +++ b/test/src/open_relative_path.c @@ -1,6 +1,3 @@ -//! add-flags.py(RUN): --dir fs::foo -//! add-flags.py(ARGS): foo - #include #include #include diff --git a/test/src/misc/opendir.c b/test/src/opendir.c similarity index 93% rename from test/src/misc/opendir.c rename to test/src/opendir.c index a8c2ae0e2..a45a3a94d 100644 --- a/test/src/misc/opendir.c +++ b/test/src/opendir.c @@ -1,6 +1,3 @@ -//! add-flags.py(RUN): --dir fs::foo -//! add-flags.py(ARGS): foo - #include #include #include diff --git a/test/src/misc/poll-nonblocking-socket.c b/test/src/poll-nonblocking-socket.c similarity index 94% rename from test/src/misc/poll-nonblocking-socket.c rename to test/src/poll-nonblocking-socket.c index 7d27b5997..9733f6232 100644 --- a/test/src/misc/poll-nonblocking-socket.c +++ b/test/src/poll-nonblocking-socket.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/poll.c b/test/src/poll.c similarity index 80% rename from test/src/misc/poll.c rename to test/src/poll.c index 17857ca50..424aa5646 100644 --- a/test/src/misc/poll.c +++ b/test/src/poll.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - // Modified from libc-test to not use tmpfile or /dev/null #include @@ -22,10 +20,12 @@ int main(void) TEST(write(fd, "hello", 6)==6); struct pollfd poll_fd = { .fd = fd, .events = POLLRDNORM, .revents = 0 }; - TEST(poll(&poll_fd, 1, 1)==1); + int r = poll(&poll_fd, 1, -1); + TEST(r==1, "poll returned %d, expected 1", r); poll_fd.events = POLLWRNORM; - TEST(poll(&poll_fd, 1, 1)==1); + r = poll(&poll_fd, 1, -1); + TEST(r==1, "poll returned %d, expected 1", r); close(fd); diff --git a/test/src/misc/preadvwritev.c b/test/src/preadvwritev.c similarity index 97% rename from test/src/misc/preadvwritev.c rename to test/src/preadvwritev.c index c246985f1..ecc24d115 100644 --- a/test/src/misc/preadvwritev.c +++ b/test/src/preadvwritev.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include diff --git a/test/src/misc/preadwrite.c b/test/src/preadwrite.c similarity index 95% rename from test/src/misc/preadwrite.c rename to test/src/preadwrite.c index f5b4e18f1..8cc3ef4c5 100644 --- a/test/src/misc/preadwrite.c +++ b/test/src/preadwrite.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include diff --git a/test/src/pthread_cond_busywait.c b/test/src/pthread_cond_busywait.c new file mode 100644 index 000000000..fd0f5dd0b --- /dev/null +++ b/test/src/pthread_cond_busywait.c @@ -0,0 +1,9 @@ +#include "src/functional/pthread_cond.c" + +#include + +__attribute__((constructor)) +void __wasilibc_enable_busywait(void) +{ + __wasilibc_enable_futex_busywait_on_current_thread(); +} diff --git a/test/src/pthread_mutex_busywait.c b/test/src/pthread_mutex_busywait.c new file mode 100644 index 000000000..184f1be7a --- /dev/null +++ b/test/src/pthread_mutex_busywait.c @@ -0,0 +1,9 @@ +#include "src/functional/pthread_mutex.c" + +#include + +__attribute__((constructor)) +void __wasilibc_enable_busywait(void) +{ + __wasilibc_enable_futex_busywait_on_current_thread(); +} diff --git a/test/src/pthread_tsd_busywait.c b/test/src/pthread_tsd_busywait.c new file mode 100644 index 000000000..688e6c359 --- /dev/null +++ b/test/src/pthread_tsd_busywait.c @@ -0,0 +1,9 @@ +#include "src/functional/pthread_tsd.c" + +#include + +__attribute__((constructor)) +void __wasilibc_enable_busywait(void) +{ + __wasilibc_enable_futex_busywait_on_current_thread(); +} diff --git a/test/src/misc/readlink.c b/test/src/readlink.c similarity index 95% rename from test/src/misc/readlink.c rename to test/src/readlink.c index 5132e40cc..88862c86e 100644 --- a/test/src/misc/readlink.c +++ b/test/src/readlink.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include diff --git a/test/src/misc/rename.c b/test/src/rename.c similarity index 96% rename from test/src/misc/rename.c rename to test/src/rename.c index cdfb02d72..b27e9a984 100644 --- a/test/src/misc/rename.c +++ b/test/src/rename.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include diff --git a/test/src/misc/rmdir.c b/test/src/rmdir.c similarity index 96% rename from test/src/misc/rmdir.c rename to test/src/rmdir.c index 7387fc1dc..bb519604f 100644 --- a/test/src/misc/rmdir.c +++ b/test/src/rmdir.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include diff --git a/test/src/misc/scandir.c b/test/src/scandir.c similarity index 97% rename from test/src/misc/scandir.c rename to test/src/scandir.c index bb9daa024..1a81db950 100644 --- a/test/src/misc/scandir.c +++ b/test/src/scandir.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - // Modified from libc to not use mkstemp and to use a relative path #include diff --git a/test/src/misc/setsockopt.c b/test/src/setsockopt.c similarity index 96% rename from test/src/misc/setsockopt.c rename to test/src/setsockopt.c index c05cc4b91..e40ee69a1 100644 --- a/test/src/misc/setsockopt.c +++ b/test/src/setsockopt.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-client-handle-hangups.c b/test/src/sockets-client-handle-hangups.c similarity index 95% rename from test/src/misc/sockets-client-handle-hangups.c rename to test/src/sockets-client-handle-hangups.c index 394acccae..1077d9c11 100644 --- a/test/src/misc/sockets-client-handle-hangups.c +++ b/test/src/sockets-client-handle-hangups.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-client-hangup-after-connect.c b/test/src/sockets-client-hangup-after-connect.c similarity index 92% rename from test/src/misc/sockets-client-hangup-after-connect.c rename to test/src/sockets-client-hangup-after-connect.c index b445393b1..3d0b5c2c9 100644 --- a/test/src/misc/sockets-client-hangup-after-connect.c +++ b/test/src/sockets-client-hangup-after-connect.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-client-hangup-after-sending.c b/test/src/sockets-client-hangup-after-sending.c similarity index 93% rename from test/src/misc/sockets-client-hangup-after-sending.c rename to test/src/sockets-client-hangup-after-sending.c index 89fd40884..3f00a7557 100644 --- a/test/src/misc/sockets-client-hangup-after-sending.c +++ b/test/src/sockets-client-hangup-after-sending.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-client-hangup-while-receiving.c b/test/src/sockets-client-hangup-while-receiving.c similarity index 94% rename from test/src/misc/sockets-client-hangup-while-receiving.c rename to test/src/sockets-client-hangup-while-receiving.c index d329cb0a4..d03ea34d7 100644 --- a/test/src/misc/sockets-client-hangup-while-receiving.c +++ b/test/src/sockets-client-hangup-while-receiving.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-client-hangup-while-sending.c b/test/src/sockets-client-hangup-while-sending.c similarity index 94% rename from test/src/misc/sockets-client-hangup-while-sending.c rename to test/src/sockets-client-hangup-while-sending.c index b9a3a5a0f..97816e1a1 100644 --- a/test/src/misc/sockets-client-hangup-while-sending.c +++ b/test/src/sockets-client-hangup-while-sending.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-client-udp-blocking.c b/test/src/sockets-client-udp-blocking.c similarity index 94% rename from test/src/misc/sockets-client-udp-blocking.c rename to test/src/sockets-client-udp-blocking.c index 9e35a077c..3fa7f56fa 100644 --- a/test/src/misc/sockets-client-udp-blocking.c +++ b/test/src/sockets-client-udp-blocking.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-client.c b/test/src/sockets-client.c similarity index 94% rename from test/src/misc/sockets-client.c rename to test/src/sockets-client.c index 2b0368c19..2c356c009 100644 --- a/test/src/misc/sockets-client.c +++ b/test/src/sockets-client.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-multiple-client.c b/test/src/sockets-multiple-client.c similarity index 95% rename from test/src/misc/sockets-multiple-client.c rename to test/src/sockets-multiple-client.c index 5cbc099c7..36aa4d9ab 100644 --- a/test/src/misc/sockets-multiple-client.c +++ b/test/src/sockets-multiple-client.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-multiple-server.c b/test/src/sockets-multiple-server.c similarity index 96% rename from test/src/misc/sockets-multiple-server.c rename to test/src/sockets-multiple-server.c index 65cfa7cf9..05b3dbf0a 100644 --- a/test/src/misc/sockets-multiple-server.c +++ b/test/src/sockets-multiple-server.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-nonblocking-multiple.c b/test/src/sockets-nonblocking-multiple.c similarity index 99% rename from test/src/misc/sockets-nonblocking-multiple.c rename to test/src/sockets-nonblocking-multiple.c index fb388602d..1456c1fea 100644 --- a/test/src/misc/sockets-nonblocking-multiple.c +++ b/test/src/sockets-nonblocking-multiple.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-nonblocking-udp-multiple.c b/test/src/sockets-nonblocking-udp-multiple.c similarity index 98% rename from test/src/misc/sockets-nonblocking-udp-multiple.c rename to test/src/sockets-nonblocking-udp-multiple.c index bf249a762..3f2dfeb86 100644 --- a/test/src/misc/sockets-nonblocking-udp-multiple.c +++ b/test/src/sockets-nonblocking-udp-multiple.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-nonblocking-udp-no-connection.c b/test/src/sockets-nonblocking-udp-no-connection.c similarity index 96% rename from test/src/misc/sockets-nonblocking-udp-no-connection.c rename to test/src/sockets-nonblocking-udp-no-connection.c index 0d7d1222f..ba2f037ae 100644 --- a/test/src/misc/sockets-nonblocking-udp-no-connection.c +++ b/test/src/sockets-nonblocking-udp-no-connection.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include @@ -57,7 +55,8 @@ void test_udp_client() { socklen_t sockaddr_client_len = sizeof(sockaddr_in); ssize_t bytes_received = recvfrom(server_socket_fd, server_buffer, BUFSIZE, 0, (struct sockaddr*)&sockaddr_client, &sockaddr_client_len); if (bytes_received == -1) { - TEST(errno==EWOULDBLOCK); + if (errno != EWOULDBLOCK) + t_error("recvfrom failed (errno = %d)\n", errno); } while (bytes_received == -1) { diff --git a/test/src/misc/sockets-nonblocking-udp.c b/test/src/sockets-nonblocking-udp.c similarity index 96% rename from test/src/misc/sockets-nonblocking-udp.c rename to test/src/sockets-nonblocking-udp.c index 8ca1b9138..5a7d4490d 100644 --- a/test/src/misc/sockets-nonblocking-udp.c +++ b/test/src/sockets-nonblocking-udp.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include @@ -69,7 +67,8 @@ void test_udp_client() { socklen_t sockaddr_client_len = sizeof(sockaddr_in); ssize_t bytes_received = recvfrom(server_socket_fd, server_buffer, BUFSIZE, 0, (struct sockaddr*)&sockaddr_client, &sockaddr_client_len); if (bytes_received == -1) - TEST(errno==EWOULDBLOCK); + if (errno != EWOULDBLOCK) + t_error("recvfrom failed (errno = %d)\n", errno); while (bytes_received == -1) { struct pollfd poll_fd = { .fd = server_socket_fd, .events = POLLRDNORM, .revents = 0 }; diff --git a/test/src/misc/sockets-nonblocking.c b/test/src/sockets-nonblocking.c similarity index 97% rename from test/src/misc/sockets-nonblocking.c rename to test/src/sockets-nonblocking.c index 47746dccd..66fe034ea 100644 --- a/test/src/misc/sockets-nonblocking.c +++ b/test/src/sockets-nonblocking.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-server-handle-hangups.c b/test/src/sockets-server-handle-hangups.c similarity index 95% rename from test/src/misc/sockets-server-handle-hangups.c rename to test/src/sockets-server-handle-hangups.c index e37c6bd12..7c09ce558 100644 --- a/test/src/misc/sockets-server-handle-hangups.c +++ b/test/src/sockets-server-handle-hangups.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-server-hangup-before-recv.c b/test/src/sockets-server-hangup-before-recv.c similarity index 94% rename from test/src/misc/sockets-server-hangup-before-recv.c rename to test/src/sockets-server-hangup-before-recv.c index d6d697838..9dd94ff1d 100644 --- a/test/src/misc/sockets-server-hangup-before-recv.c +++ b/test/src/sockets-server-hangup-before-recv.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-server-hangup-before-send.c b/test/src/sockets-server-hangup-before-send.c similarity index 94% rename from test/src/misc/sockets-server-hangup-before-send.c rename to test/src/sockets-server-hangup-before-send.c index 12adb5ee3..638089f95 100644 --- a/test/src/misc/sockets-server-hangup-before-send.c +++ b/test/src/sockets-server-hangup-before-send.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-server-hangup-during-recv.c b/test/src/sockets-server-hangup-during-recv.c similarity index 94% rename from test/src/misc/sockets-server-hangup-during-recv.c rename to test/src/sockets-server-hangup-during-recv.c index b06ed1e6e..0fee9b756 100644 --- a/test/src/misc/sockets-server-hangup-during-recv.c +++ b/test/src/sockets-server-hangup-during-recv.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-server-hangup-during-send.c b/test/src/sockets-server-hangup-during-send.c similarity index 94% rename from test/src/misc/sockets-server-hangup-during-send.c rename to test/src/sockets-server-hangup-during-send.c index d5b791401..606f5742b 100644 --- a/test/src/misc/sockets-server-hangup-during-send.c +++ b/test/src/sockets-server-hangup-during-send.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-server-udp-blocking.c b/test/src/sockets-server-udp-blocking.c similarity index 94% rename from test/src/misc/sockets-server-udp-blocking.c rename to test/src/sockets-server-udp-blocking.c index f6960c6de..476c6b618 100644 --- a/test/src/misc/sockets-server-udp-blocking.c +++ b/test/src/sockets-server-udp-blocking.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/sockets-server.c b/test/src/sockets-server.c similarity index 95% rename from test/src/misc/sockets-server.c rename to test/src/sockets-server.c index fcbce28d6..14c7a0d23 100644 --- a/test/src/misc/sockets-server.c +++ b/test/src/sockets-server.c @@ -1,5 +1,3 @@ -//! filter.py(TARGET_TRIPLE): wasm32-wasip2 -//! add-flags.py(RUN): --wasi=inherit-network=y #include #include #include diff --git a/test/src/misc/stat.c b/test/src/stat.c similarity index 97% rename from test/src/misc/stat.c rename to test/src/stat.c index 14c2fc27e..b42b419fd 100644 --- a/test/src/misc/stat.c +++ b/test/src/stat.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - // Modified from libc-test to not use tmpfile or /dev/null #include diff --git a/test/src/misc/stdio.c b/test/src/stdio.c similarity index 92% rename from test/src/misc/stdio.c rename to test/src/stdio.c index 92821b960..97ff8bd1a 100644 --- a/test/src/misc/stdio.c +++ b/test/src/stdio.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - #include #include #include diff --git a/test/src/misc/strchrnul.c b/test/src/strchrnul.c similarity index 95% rename from test/src/misc/strchrnul.c rename to test/src/strchrnul.c index 2b9575770..0bad5af9c 100644 --- a/test/src/misc/strchrnul.c +++ b/test/src/strchrnul.c @@ -1,5 +1,3 @@ -//! add-flags.py(LDFLAGS): -Wl,--stack-first -Wl,--initial-memory=327680 - #define _GNU_SOURCE #include <__macro_PAGESIZE.h> diff --git a/test/src/misc/strlen.c b/test/src/strlen.c similarity index 93% rename from test/src/misc/strlen.c rename to test/src/strlen.c index 41de3c3f9..7cd94f858 100644 --- a/test/src/misc/strlen.c +++ b/test/src/strlen.c @@ -1,5 +1,3 @@ -//! add-flags.py(LDFLAGS): -Wl,--stack-first -Wl,--initial-memory=327680 - #include <__macro_PAGESIZE.h> #include #include diff --git a/test/src/misc/strptime.c b/test/src/strptime.c similarity index 100% rename from test/src/misc/strptime.c rename to test/src/strptime.c diff --git a/test/src/misc/strrchr.c b/test/src/strrchr.c similarity index 95% rename from test/src/misc/strrchr.c rename to test/src/strrchr.c index 6e1128fa5..ee6a3b416 100644 --- a/test/src/misc/strrchr.c +++ b/test/src/strrchr.c @@ -1,5 +1,3 @@ -//! add-flags.py(LDFLAGS): -Wl,--stack-first -Wl,--initial-memory=327680 - #include <__macro_PAGESIZE.h> #include #include diff --git a/test/src/misc/time.c b/test/src/time.c similarity index 100% rename from test/src/misc/time.c rename to test/src/time.c diff --git a/test/src/misc/time_and_times.c b/test/src/time_and_times.c similarity index 81% rename from test/src/misc/time_and_times.c rename to test/src/time_and_times.c index 145cd9088..d3738feb1 100644 --- a/test/src/misc/time_and_times.c +++ b/test/src/time_and_times.c @@ -1,5 +1,3 @@ -//! add-flags.py(CFLAGS): -D_WASI_EMULATED_PROCESS_CLOCKS -//! add-flags.py(LDFLAGS): -lwasi-emulated-process-clocks #include #include #include diff --git a/test/src/misc/utime.c b/test/src/utime.c similarity index 98% rename from test/src/misc/utime.c rename to test/src/utime.c index aefa2cb14..0399feec8 100644 --- a/test/src/misc/utime.c +++ b/test/src/utime.c @@ -1,5 +1,3 @@ -//! add-flags.py(RUN): --dir fs::/ - // Modified from libc-test in order to not use tmpfile #include