From 000cd996f3bbd7c823f0a8e1e0b1b8666af0e425 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Wed, 25 Mar 2026 04:16:16 +0700 Subject: [PATCH] Add more support test files --- check.sh | 2 +- tests/Makefile | 30 ++++++++++++++++++++++++++---- tests/src/main.rs | 15 ++++++++++++--- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/check.sh b/check.sh index c7fed0e942..b110a69fc7 100755 --- a/check.sh +++ b/check.sh @@ -103,7 +103,7 @@ run_redoxer() { if [ "$IS_HOST" -eq 0 ]; then redoxer toolchain || { echo -e "${RED}Fail: redoxer toolchain for: $target.${NC}" && exit 1; } export CARGO_TEST="redoxer" - export TEST_RUNNER="redoxer exec --folder ../sysroot/$TARGET/:/usr --folder . --" + export TEST_RUNNER="redoxer exec --folder ../../sysroot/$TARGET/:/usr --folder . --" # TODO: Identify hang issue with pthread/barrier and pthread/once tests in multi core to get rid of this limit export REDOXER_QEMU_ARGS="-smp 1" diff --git a/tests/Makefile b/tests/Makefile index 9b8322d9b2..ae485138f4 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -16,12 +16,26 @@ all: $(BINS) clean: rm -rf $(BUILD)/bins_* $(BUILD)/gen $(BUILD)/target -build: $(BUILD)/bins_verify/relibc-tests $(BINS) $(EXPECT_BINS) $(EXPECT_INPUT_BINS) support_build $(BUILD)/expected +build: $(BUILD)/bins_verify/relibc-tests $(BINS) $(EXPECT_BINS) $(EXPECT_INPUT_BINS) support_build -# "run" and "run-once" does not copy "expected" so the test runner will not pick outdated "expected" file -support_build: $(BUILD)/Makefile $(BUILD)/Makefile.tests.mk $(BUILD)/example_dir +support_build: $(BUILD)/expected \ + $(BUILD)/Makefile \ + $(BUILD)/Makefile.tests.mk \ + $(BUILD)/example_dir \ + $(BUILD)/select.c \ + $(BUILD)/stdlib/realpath.c \ + $(BUILD)/stdio/fread.in \ + $(BUILD)/stdio/fscanf_offby1.c \ + $(BUILD)/stdio/fscanf.c \ + $(BUILD)/stdio/stdio.in \ + $(BUILD)/stdio/getline.in \ + $(BUILD)/stdio/ungetc_ftell.c \ + $(BUILD)/sys_stat/stat.c \ + $(BUILD)/unistd/link.c \ + $(BUILD)/wchar/fgetwc.in \ + $(BUILD)/wchar/ungetwc.in -run: $(BUILD)/bins_verify/relibc-tests $(BINS) $(EXPECT_BINS) $(EXPECT_INPUT_BINS) support_build +run: build $(MAKE) run -C $(BUILD) run-once: $(BUILD)/bins_verify/relibc-tests $(BUILD)/$(TESTBIN) support_build @@ -46,6 +60,14 @@ $(BUILD)/example_dir: example_dir rm -rf "$@" cp -a "$<" $(BUILD)/ +$(BUILD)/%.in: %.in + @mkdir -p "$$(dirname "$@")" + cp "$*.in" "$@" + +$(BUILD)/%.c: %.c + @mkdir -p "$$(dirname "$@")" + cp "$*.c" "$@" + FLAGS=\ -std=c11 \ -fno-builtin \ diff --git a/tests/src/main.rs b/tests/src/main.rs index 9d9c099a4c..b3947e1ddc 100644 --- a/tests/src/main.rs +++ b/tests/src/main.rs @@ -10,7 +10,7 @@ use std::{ time::{Duration, Instant}, }; -fn find_expected_dir() -> Result { +fn find_expected_dir() -> Option { let mut current_dir = env::current_exe() .ok() .and_then(|p| p.parent().map(|parent| parent.to_path_buf())) @@ -26,7 +26,16 @@ fn find_expected_dir() -> Result { } } - found_expected_dir.ok_or_else(|| "Could not find 'expected' directory".to_string()) + if found_expected_dir.is_none() { + if let Ok(cwd) = env::current_dir() { + let check = cwd.join("expected"); + if check.is_dir() { + found_expected_dir = Some(check); + } + } + } + + found_expected_dir } fn expected( @@ -233,7 +242,7 @@ fn main() { }; if !status_only { - let Ok(expected_dir) = &expected_dir else { + let Some(expected_dir) = &expected_dir else { eprintln!("Expected directory not found"); process::exit(1); };