From 0f3f4bf73c75cfe40407b341903c8380a9b8d81d Mon Sep 17 00:00:00 2001 From: bplu4t2f Date: Sat, 10 Oct 2026 13:29:53 +0200 Subject: [PATCH] run_tests.sh now understands "slim" and "no-clang" arguments. --- run_tests.bat | 93 +++++++++++++++++++++++++++++++++++++++----- run_tests.sh | 82 +++++++++++++++++++++++++++++++++++--- tests/issues/run.bat | 14 +++---- tests/issues/run.sh | 18 ++++----- 4 files changed, 176 insertions(+), 31 deletions(-) diff --git a/run_tests.bat b/run_tests.bat index fedf23960..e383e811e 100644 --- a/run_tests.bat +++ b/run_tests.bat @@ -1,5 +1,35 @@ @rem This file runs most of the tests that the CI would run. -@rem It omits time-intensive optimized core library tests and Wycheproof tests. +@rem When the "slim" argument is provided, it omits time-intensive optimized core library tests and Wycheproof tests. + +setlocal EnableDelayedExpansion + +@echo off + +set SLIM= + +for %%A in (%*) do ( + if "%%A"=="slim" ( + set SLIM=1 + ) else if "%%A"=="no-clang" ( + set ODIN_TESTS_NO_CLANG=1 + ) else ( + echo Unrecognized argument: %%A + exit /b + ) +) + +rem Check if clang is present +if not defined ODIN_TESTS_NO_CLANG ( + clang --version + if !ERRORLEVEL! neq 0 ( + echo ERROR: clang is not present. Some tests require this. + echo Note: You can try using msvc instead by specifying the "no-clang" argument, or setting ODIN_TESTS_NO_CLANG=1 + echo However, some ABI tests will be skipped. + exit /b + ) +) + +@echo on @rem Check examples/all @pushd . @@ -38,11 +68,56 @@ cd tests\issues call run.bat || exit /b @popd -@rem Run ABI tests -@pushd . -cd tests\abi -set ABI_CFLAGS= -call run.bat || exit /b -set ABI_CFLAGS=-O2 -call run.bat -o:speed || exit /b -@popd +@rem The ABI tests can be disabled here because they require clang at the moment. +@rem TODO: Maybe try to make them work with msvc as well? +if not defined ODIN_TESTS_NO_CLANG ( + + @rem Run ABI tests + @pushd . + cd tests\abi + set ABI_CFLAGS= + call run.bat || exit /b + set ABI_CFLAGS=-O2 + call run.bat -o:speed || exit /b + @popd + +) + +@rem More extensive tests (non-slim): + +if not defined SLIM ( + + @echo Running extended tests... + + @rem Optimized Core library tests + @pushd tests\core + ..\..\odin test speed.odin -o:speed -file -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true || exit /b + @popd + + @rem Wycheproof tests + @pushd tests\core + ..\..\odin test crypto/wycheproof -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed || exit /b + @popd + + @rem Noise Protocol Framework tests + @pushd tests\core + ..\..\odin test crypto/noise -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed || exit /b + @popd + + @rem X.509 limbo tests + @pushd tests\core + ..\..\odin test crypto/x509_limbo -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed || exit /b + @popd + + @echo SUCCESS: Extended tests have been executed successfully. + @echo Note: You can call "run_tests slim" to omit some of the slower tests. + +) else ( + + @echo SUCCESS: Slim tests have been executed successfully. + +) + +if defined ODIN_TESTS_NO_CLANG ( + @echo WARNING: ODIN_TESTS_NO_CLANG specified - ABI tests have been skipped. +) diff --git a/run_tests.sh b/run_tests.sh index 37110265c..648cc34b2 100644 --- a/run_tests.sh +++ b/run_tests.sh @@ -7,6 +7,31 @@ set -eu here=$(cd "$(dirname "$0")" && pwd) : "${ODIN:=$here/odin}" +SLIM= +for arg in "$@"; do + case "$arg" in + slim) + SLIM=1 + ;; + no-clang) + export ODIN_TESTS_NO_CLANG=1 + ;; + *) + echo "Unrecognized argument: $arg" + exit 1 + ;; + esac +done + +if [[ -z "${ODIN_TESTS_NO_CLANG:-}" ]]; then + if ! clang --version >/dev/null 2>&1; then + echo "ERROR: clang is not present. Some tests require this." + echo "Note: You can disable tests that require clang by specifying the \"no-clang\" argument, or setting ODIN_TESTS_NO_CLANG=1" + # TODO: Can we figure out how to make everything work with gcc as well when ODIN_TESTS_NO_CLANG is set? + exit 1 + fi +fi + # Check examples/all "$ODIN" check "$here/examples/all" -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do @@ -43,9 +68,54 @@ rm -rf "$vendor_build" ./run.sh ) -# Run ABI tests -( - cd "$here/tests/abi" - ABI_CFLAGS= ./run.sh - ABI_CFLAGS=-O2 ./run.sh -o:speed -) +# The ABI tests can be disabled because they require clang at the moment. +# TODO: Maybe try to make them work with msvc as well? +if [[ -z "${ODIN_TESTS_NO_CLANG:-}" ]]; then + # Run ABI tests + ( + cd "$here/tests/abi" + ABI_CFLAGS= ./run.sh + ABI_CFLAGS=-O2 ./run.sh -o:speed + ) +fi + +# More extensive tests (non-slim): +if [[ -z "${SLIM:-}" ]]; then + + echo "Running extended tests..." + + # Optimized Core library tests + ( + cd "$here/tests/core" + "$ODIN" test speed.odin -o:speed -file -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true + ) + + # Wycheproof tests + ( + cd "$here/tests/core" + "$ODIN" test crypto/wycheproof -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed + ) + + # Noise Protocol Framework tests + ( + cd "$here/tests/core" + "$ODIN" test crypto/noise -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed + ) + + # X.509 limbo tests + ( + cd "$here/tests/core" + "$ODIN" test crypto/x509_limbo -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed + ) + + echo "SUCCESS: Extended tests have been executed successfully." + echo "Note: You can call \"run_tests slim\" to omit some of the slower tests." + +else + echo "SUCCESS: Slim tests have been executed successfully." + +fi + +if [[ -n "${ODIN_TESTS_NO_CLANG:-}" ]]; then + echo "WARNING: ODIN_TESTS_NO_CLANG specified - ABI tests have been skipped." +fi diff --git a/tests/issues/run.bat b/tests/issues/run.bat index 50eb360ba..4d4a18674 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -95,12 +95,12 @@ set ODIN=..\..\..\odin @rem Test clang - improve error message for users that don't have it. -@if "%ISSUES_TESTS_NO_CLANG%" == "" ( +@if "%ODIN_TESTS_NO_CLANG%" == "" ( @echo Testing for clang... clang --version if !ERRORLEVEL! neq 0 ( @echo ERROR: clang not working. This is required for some tests. - @echo You can try msvc instead: set ISSUES_TESTS_NO_CLANG=1 + @echo You can try msvc instead: set ODIN_TESTS_NO_CLANG=1 exit /b ) ) else ( @@ -108,7 +108,7 @@ set ODIN=..\..\..\odin cl if !ERRORLEVEL! neq 0 ( @echo ERROR: msvc not working. This is required for some tests. - @echo You can try clang instead: set ISSUES_TESTS_NO_CLANG= + @echo You can try clang instead: set ODIN_TESTS_NO_CLANG= exit /b ) ) @@ -116,7 +116,7 @@ set ODIN=..\..\..\odin @rem ######################################################################################################### @rem "odin test" tests with special needs, or others (e.g. "odin doc"): -@if "%ISSUES_TESTS_NO_CLANG%" == "" ( +@if "%ODIN_TESTS_NO_CLANG%" == "" ( clang -c "..\test_issue_5640\test_issue_5640.c" -o test_issue_5640_c.o || exit /b ) else ( cl -c "..\test_issue_5640\test_issue_5640.c" /Fo:test_issue_5640_c.o || exit /b @@ -124,7 +124,7 @@ set ODIN=..\..\..\odin %ODIN% test "..\test_issue_5640" %COMMON% || exit /b -@if "%ISSUES_TESTS_NO_CLANG%" == "" ( +@if "%ODIN_TESTS_NO_CLANG%" == "" ( clang -c "..\test_issue_6809_6816\test_issue_6809_6816.c" -o test_issue_6809_6816_c.o -O3 || exit /b ) else ( cl -c "..\test_issue_6809_6816\test_issue_6809_6816.c" /Fo:test_issue_6809_6816_c.o -O3 || exit /b @@ -137,7 +137,7 @@ set ODIN=..\..\..\odin %ODIN% test "..\test_pr_6470" %COMMON% -define:TEST_EXPECT_FAILURE=true 2>&1 | find /c "Error:" | findstr /x "1" || exit /b @rem It seems at this point 7010 is not for Windows. -@rem @if "%ISSUES_TESTS_NO_CLANG%" == "" ( +@rem @if "%ODIN_TESTS_NO_CLANG%" == "" ( @rem clang -c "..\test_issue_7010\test_issue_7010.c" -o test_issue_7010_c.o || exit /b @rem %ODIN% test "..\test_issue_7010" %COMMON% || exit /b @rem ) else ( @@ -157,7 +157,7 @@ set ODIN=..\..\..\odin %ODIN% test "..\test_lifetime_markers" %COMMON% -o:size -lifetime-markers || exit /b %ODIN% test "..\test_lifetime_markers" %COMMON% -o:speed -lifetime-markers || exit /b -@if "%ISSUES_TESTS_NO_CLANG%" == "" ( +@if "%ODIN_TESTS_NO_CLANG%" == "" ( clang -c "..\test_issue_sysv_abi\test_issue_sysv_abi.c" -o test_issue_sysv_abi_c.o || exit /b ) else ( cl -c "..\test_issue_sysv_abi\test_issue_sysv_abi.c" /Fo:test_issue_sysv_abi_c.o || exit /b diff --git a/tests/issues/run.sh b/tests/issues/run.sh index 733a9ec53..261e12c20 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -18,7 +18,7 @@ set -x # update `run.bat` as well. # Some tests require a C compiler. -# By default, it uses clang. export ISSUES_TESTS_NO_CLANG=1 to disable these tests. +# By default, it uses clang. export ODIN_TESTS_NO_CLANG=1 to disable these tests. # TODO: See if we can make the tests work with gcc instead? ######################################################################################################### @@ -280,11 +280,11 @@ $ODIN run ../test_issue_7798 $COMMON # Test clang - improve error message for users that don't have it. # -if [[ -z ${ISSUES_TESTS_NO_CLANG+x} ]]; then +if [[ -z ${ODIN_TESTS_NO_CLANG+x} ]]; then if ! clang --version; then set +x echo "ERROR: clang not working. This is required for some tests." - echo "You can disable tests that require clang: export ISSUES_TESTS_NO_CLANG=1" + echo "You can disable tests that require clang: export ODIN_TESTS_NO_CLANG=1" exit 1 fi fi @@ -295,7 +295,7 @@ fi # "odin test" tests with special needs, or others (e.g. "odin doc"): # -if [[ -z ${ISSUES_TESTS_NO_CLANG+x} ]]; then +if [[ -z ${ODIN_TESTS_NO_CLANG+x} ]]; then clang -c ../test_issue_5640/test_issue_5640.c -o test_issue_5640_c.o if [[ "$(uname)" != "NetBSD" ]]; then @@ -305,7 +305,7 @@ if [[ -z ${ISSUES_TESTS_NO_CLANG+x} ]]; then fi fi -if [[ -z ${ISSUES_TESTS_NO_CLANG+x} ]]; then +if [[ -z ${ODIN_TESTS_NO_CLANG+x} ]]; then clang -c ../test_issue_6809_6816/test_issue_6809_6816.c -o test_issue_6809_6816_c.o -O3 $ODIN test ../test_issue_6809_6816 -o:speed $COMMON fi @@ -319,7 +319,7 @@ else exit 1 fi -if [[ -z ${ISSUES_TESTS_NO_CLANG+x} ]]; then +if [[ -z ${ODIN_TESTS_NO_CLANG+x} ]]; then clang -c ../test_issue_7010/test_issue_7010.c -o test_issue_7010_c.o $ODIN test ../test_issue_7010 $COMMON fi @@ -357,13 +357,13 @@ fi $ODIN test ../test_lifetime_markers $COMMON -o:size -lifetime-markers $ODIN test ../test_lifetime_markers $COMMON -o:speed -lifetime-markers -if [[ -z ${ISSUES_TESTS_NO_CLANG+x} ]]; then +if [[ -z ${ODIN_TESTS_NO_CLANG+x} ]]; then clang -c ../test_issue_sysv_abi/test_issue_sysv_abi.c -o test_issue_sysv_abi_c.o $ODIN test ../test_issue_sysv_abi $COMMON fi # AVX-512 asked for through -target-features on the default microarch; needs a CPU that has it -if [[ -z ${ISSUES_TESTS_NO_CLANG+x} ]]; then +if [[ -z ${ODIN_TESTS_NO_CLANG+x} ]]; then if grep -qw avx512f /proc/cpuinfo 2>/dev/null; then clang -c ../test_issue_avx512_vector_abi/test_issue_avx512_vector_abi.c -o test_issue_avx512_vector_abi_c.o -mavx512f $ODIN test ../test_issue_avx512_vector_abi $COMMON_CHECK -target-features:avx512f @@ -375,7 +375,7 @@ $ODIN test ../test_issue_loaded_pointer_alignment $COMMON -o:speed ######################################################################################################### -if [[ ! -z ${ISSUES_TESTS_NO_CLANG+x} ]]; then +if [[ ! -z ${ODIN_TESTS_NO_CLANG+x} ]]; then echo "!!! WARNING !!! Tests that require clang have been skipped" fi