From 9fb859cf4355f96c6f4db50116ef6d0acd2a395f Mon Sep 17 00:00:00 2001 From: bplu4t2f Date: Sat, 10 Oct 2026 10:18:35 +0200 Subject: [PATCH 01/12] Make tests scripts behave nicer is clang is not found --- tests/issues/run.bat | 37 ++++++++++++++++++++++++++++++------- tests/issues/run.sh | 19 +++++++++++++++++-- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/tests/issues/run.bat b/tests/issues/run.bat index 745f750e8..50eb360ba 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -1,9 +1,10 @@ @echo off +setlocal EnableDelayedExpansion if not exist "build\" mkdir build pushd build -set COMMON=-define:ODIN_TEST_FANCY=false -vet -strict-style -ignore-unused-defineables +set COMMON=-define:ODIN_TEST_FANCY=false -vet -strict-style -ignore-unused-defineables -show-timings set ODIN=..\..\..\odin @echo on @@ -33,9 +34,9 @@ set ODIN=..\..\..\odin @rem "odin check" tests: %ODIN% check "..\test_issue_5105_5569" %COMMON% 2>&1 | find /c "Error:" | findstr /x "4" || exit /b -%ODIN% check "..\test_issue_6484" -no-entry-point %COMMON% || exit /b +%ODIN% check "..\test_issue_6484" -no-entry-point %COMMON% || exit /b %ODIN% check "..\test_issue_6874" %COMMON% 2>&1 | find /c "Error:" | findstr /x "1" || exit /b -%ODIN% check "..\test_issue_6979" -no-entry-point %COMMON% || exit /b +%ODIN% check "..\test_issue_6979" -no-entry-point %COMMON% || exit /b %ODIN% check "..\test_issue_7012" -no-entry-point %COMMON% || exit /b %ODIN% check "..\test_issue_7260" -no-entry-point %COMMON% || exit /b %ODIN% check "..\test_issue_7304" %COMMON% 2>&1 | find /c "9223372036854775808 is not representable by int" | findstr /x "1" || exit /b @@ -92,8 +93,30 @@ set ODIN=..\..\..\odin @rem ######################################################################################################### +@rem Test clang - improve error message for users that don't have it. + +@if "%ISSUES_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 + exit /b + ) +) else ( + @echo Testing for msvc... + 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= + exit /b + ) +) + +@rem ######################################################################################################### + @rem "odin test" tests with special needs, or others (e.g. "odin doc"): -if "%ISSUES_TESTS_NO_CLANG%" == "" ( +@if "%ISSUES_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 @@ -101,7 +124,7 @@ if "%ISSUES_TESTS_NO_CLANG%" == "" ( %ODIN% test "..\test_issue_5640" %COMMON% || exit /b -if "%ISSUES_TESTS_NO_CLANG%" == "" ( +@if "%ISSUES_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 @@ -114,7 +137,7 @@ if "%ISSUES_TESTS_NO_CLANG%" == "" ( %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 "%ISSUES_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 ( @@ -134,7 +157,7 @@ if "%ISSUES_TESTS_NO_CLANG%" == "" ( %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 "%ISSUES_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 56bac1f39..733a9ec53 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -4,8 +4,8 @@ set -eu mkdir -p build pushd build ODIN=../../../odin -COMMON="-define:ODIN_TEST_FANCY=false -vet -strict-style -ignore-unused-defineables -microarch:native" -COMMON_CHECK="-define:ODIN_TEST_FANCY=false -vet -strict-style -ignore-unused-defineables" +COMMON="-define:ODIN_TEST_FANCY=false -vet -strict-style -ignore-unused-defineables -show-timings -microarch:native" +COMMON_CHECK="-define:ODIN_TEST_FANCY=false -vet -strict-style -ignore-unused-defineables -show-timings" set -x @@ -276,6 +276,21 @@ $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 ! 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" + exit 1 + fi +fi + +######################################################################################################### + # # "odin test" tests with special needs, or others (e.g. "odin doc"): # From 0bcda50b6ca8bfc454ccc2cdf5d6e1cc29d5a502 Mon Sep 17 00:00:00 2001 From: bplu4t2f Date: Sat, 10 Oct 2026 11:49:19 +0200 Subject: [PATCH 02/12] Fix .gitignore files in tests/ directory - this was bugged because it got overridden --- .gitignore | 7 +++---- tests/abi/.gitignore | 3 ++- tests/issues/.gitignore | 1 + tests/vendor/.gitignore | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 tests/issues/.gitignore create mode 100644 tests/vendor/.gitignore diff --git a/.gitignore b/.gitignore index 81e2bb7ff..62e36469d 100644 --- a/.gitignore +++ b/.gitignore @@ -308,10 +308,9 @@ build.sh # RAD debugger project file *.raddbg *.rdi -tests/issues/build/* -tests/abi/build/* -tests/abi/build-cross/* -tests/debug_info/build/* + +# NOTE: The /tests/** directories have their own .gitignore files + misc/featuregen/featuregen # Clangd stuff diff --git a/tests/abi/.gitignore b/tests/abi/.gitignore index e390b124a..ecc2bbb49 100644 --- a/tests/abi/.gitignore +++ b/tests/abi/.gitignore @@ -1 +1,2 @@ -build/** \ No newline at end of file +build/** +build-cross/** diff --git a/tests/issues/.gitignore b/tests/issues/.gitignore new file mode 100644 index 000000000..f65519e3c --- /dev/null +++ b/tests/issues/.gitignore @@ -0,0 +1 @@ +build/** diff --git a/tests/vendor/.gitignore b/tests/vendor/.gitignore new file mode 100644 index 000000000..f65519e3c --- /dev/null +++ b/tests/vendor/.gitignore @@ -0,0 +1 @@ +build/** From 3e1c4033af8b31e41c7fb1a62f8367013e2fe459 Mon Sep 17 00:00:00 2001 From: bplu4t2f Date: Sat, 10 Oct 2026 11:49:43 +0200 Subject: [PATCH 03/12] download_assets.py now at least prints something so that we know what is happening --- tests/core/download_assets.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/core/download_assets.py b/tests/core/download_assets.py index 6e6bf83b8..11b984612 100644 --- a/tests/core/download_assets.py +++ b/tests/core/download_assets.py @@ -698,6 +698,8 @@ def main(): debug = True for suite in TEST_SUITES: + print("Downloading test assets: {}\n".format(suite)) + sys.stdout.flush() base_path = sys.argv[1] + "/{}".format(suite) # Make assets path try: @@ -712,6 +714,7 @@ def main(): # We could fall back on downloading the PNG files individually, but it's slow print("Done downloading {} assets.\n".format(suite)) + sys.stdout.flush() return 0 From 4084403294ad6008957e6af24c18f8f0a2e35633 Mon Sep 17 00:00:00 2001 From: bplu4t2f Date: Sat, 10 Oct 2026 12:02:05 +0200 Subject: [PATCH 04/12] Add batch script to run tests locally --- test_slim.bat | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 test_slim.bat diff --git a/test_slim.bat b/test_slim.bat new file mode 100644 index 000000000..fedf23960 --- /dev/null +++ b/test_slim.bat @@ -0,0 +1,48 @@ +@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 Check examples/all +@pushd . +.\odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do || exit /b +@popd + +@rem Check examples/all/sdl3 +@pushd . +.\odin check examples\all\sdl3 -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point || exit /b +@popd + +@rem Internals tests +@pushd tests\internal +..\..\odin test . -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 -sanitize:address || exit /b +@popd + +@rem Normal Core library tests +@pushd tests\core +..\..\odin test normal.odin -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 -sanitize:address || exit /b +@popd + +@rem Vendor library tests +@pushd . +cd tests\vendor +mkdir build +pushd build +copy ..\..\..\vendor\lua\5.4\windows\*.dll . +..\..\..\odin test ..\ -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 -sanitize:address || exit /b +popd +rmdir /S /Q build +@popd + +@rem Check issues +@pushd . +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 From d71d120f59830642e2c12887c48b2f144bff7846 Mon Sep 17 00:00:00 2001 From: bplu4t2f Date: Sat, 10 Oct 2026 12:16:00 +0200 Subject: [PATCH 05/12] Add bash script to run tests locally --- test_slim.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 test_slim.sh diff --git a/test_slim.sh b/test_slim.sh new file mode 100644 index 000000000..37110265c --- /dev/null +++ b/test_slim.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +set -eu + +# This file runs most of the tests that the CI would run. +# It omits time-intensive optimized core library tests and Wycheproof tests. + +here=$(cd "$(dirname "$0")" && pwd) +: "${ODIN:=$here/odin}" + +# Check examples/all +"$ODIN" check "$here/examples/all" -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do + +# Check examples/all/sdl3 +"$ODIN" check "$here/examples/all/sdl3" -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point + +# Internals tests +( + cd "$here/tests/internal" + "$ODIN" test . -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 -sanitize:address +) + +# Normal Core library tests +( + cd "$here/tests/core" + "$ODIN" test normal.odin -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 -sanitize:address +) + +# Vendor library tests +vendor_build="$here/tests/vendor/build" +mkdir -p "$vendor_build" +cp "$here"/vendor/lua/5.4/linux/*.so "$vendor_build"/ +# We are possibly on Windows, so copy the DLLs as well. +cp "$here"/vendor/lua/5.4/windows/*.dll "$vendor_build"/ +( + cd "$vendor_build" + LD_LIBRARY_PATH="$vendor_build${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" "$ODIN" test .. -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 -sanitize:address +) +rm -rf "$vendor_build" + +# Check issues +( + cd "$here/tests/issues" + ./run.sh +) + +# Run ABI tests +( + cd "$here/tests/abi" + ABI_CFLAGS= ./run.sh + ABI_CFLAGS=-O2 ./run.sh -o:speed +) From 12227d8484e2cd4ac809b0ed0d1029d2313b9b56 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 10 Oct 2026 11:18:03 +0100 Subject: [PATCH 06/12] Match clang's default x86-64 microarch in the ABI test script instead of native --- tests/abi/run.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/abi/run.sh b/tests/abi/run.sh index 80bc273f6..1275d4a74 100755 --- a/tests/abi/run.sh +++ b/tests/abi/run.sh @@ -25,7 +25,9 @@ here=$(cd "$(dirname "$0")" && pwd) COMMON="-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused-defineables" CC_TARGET=""; [ -n "$TRIPLE" ] && CC_TARGET="--target=$TRIPLE" -ODIN_TARGET="-microarch:native"; [ -n "$TARGET" ] && ODIN_TARGET="-target:$TARGET" + +HOST_MARCH=""; case "$(uname -m)" in x86_64|amd64) HOST_MARCH="-microarch:x86-64" ;; esac +ODIN_TARGET="$HOST_MARCH"; [ -n "$TARGET" ] && ODIN_TARGET="-target:$TARGET" # Cleaned BEFORE, not after: the generated corpus is left in place so it can be @@ -36,7 +38,7 @@ pushd "$here/build" > /dev/null set -x -$ODIN run ../gen.odin -file -microarch:native -- . +$ODIN run ../gen.odin -file $HOST_MARCH -- . # Ask the C compiler which tiers it has, by preprocessing the generated `build-cross/tiers.c`. # The Odin side must use the same tiers or it references symbols C never emitted. From 9a7d719d74e9f668192b91605ab28549092ef0b5 Mon Sep 17 00:00:00 2001 From: bplu4t2f Date: Sat, 10 Oct 2026 12:20:38 +0200 Subject: [PATCH 07/12] Make tests/abi/run.bat output at least a hint of error if clang is not present. --- tests/abi/run.bat | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/abi/run.bat b/tests/abi/run.bat index db03eda3b..e61cb5073 100644 --- a/tests/abi/run.bat +++ b/tests/abi/run.bat @@ -24,6 +24,7 @@ REM Odin side needs to match set TIER_GNU=false set TIER_F16=false set TIER_I128=false +clang --version || exit /b clang -E tiers.c 2>nul | findstr /C:"ABI_YES_GNU" >nul && set TIER_GNU=true clang -E tiers.c 2>nul | findstr /C:"ABI_YES_F16" >nul && set TIER_F16=true clang -E tiers.c 2>nul | findstr /C:"ABI_YES_I128" >nul && set TIER_I128=true From ddf3f6ea1512efd2496356945b0359eae9f77428 Mon Sep 17 00:00:00 2001 From: bplu4t2f Date: Sat, 10 Oct 2026 12:47:21 +0200 Subject: [PATCH 08/12] Rename `test_slim` -> `run_tests` --- test_slim.bat => run_tests.bat | 0 test_slim.sh => run_tests.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename test_slim.bat => run_tests.bat (100%) rename test_slim.sh => run_tests.sh (100%) diff --git a/test_slim.bat b/run_tests.bat similarity index 100% rename from test_slim.bat rename to run_tests.bat diff --git a/test_slim.sh b/run_tests.sh similarity index 100% rename from test_slim.sh rename to run_tests.sh From 561fdf5125007f862f701cc9a1315e4765d08bed Mon Sep 17 00:00:00 2001 From: bplu4t2f Date: Sat, 10 Oct 2026 13:22:16 +0200 Subject: [PATCH 09/12] Fix missing `-define:ODIN_TEST_FANCY=false` in CI. --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4d780782..0575e016c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -146,11 +146,11 @@ jobs: - name: Optimized Core library tests run: ./odin test tests/core/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 - name: Wycheproof tests - run: ./odin test tests/core/crypto/wycheproof -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -o:speed + run: ./odin test tests/core/crypto/wycheproof -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed - name: Noise Protocol Framework tests - run: ./odin test tests/core/crypto/noise -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -o:speed + run: ./odin test tests/core/crypto/noise -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed - name: X.509 limbo tests - run: ./odin test tests/core/crypto/x509_limbo -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -o:speed + run: ./odin test tests/core/crypto/x509_limbo -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed - name: Vendor library tests run: ./odin test tests/vendor -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 -sanitize:address if: matrix.os != 'macos-latest' @@ -255,17 +255,17 @@ jobs: shell: cmd run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - odin test tests/core/crypto/wycheproof -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -o:speed + odin test tests/core/crypto/wycheproof -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed - name: Noise Protocol Framework tests shell: cmd run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - odin test tests/core/crypto/noise -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -o:speed + odin test tests/core/crypto/noise -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed - name: X.509 limbo tests shell: cmd run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - odin test tests/core/crypto/x509_limbo -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -o:speed + odin test tests/core/crypto/x509_limbo -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed - name: Vendor library tests shell: cmd run: | From 4c331405ae5d62828b5955d96aba9a89cfcc9785 Mon Sep 17 00:00:00 2001 From: Franz Date: Fri, 9 Oct 2026 21:57:24 +0200 Subject: [PATCH 10/12] Fix escape analysis for init statements of ranged loops --- src/check_escape.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/check_escape.cpp b/src/check_escape.cpp index 24a8e5abb..1484271ef 100644 --- a/src/check_escape.cpp +++ b/src/check_escape.cpp @@ -3396,6 +3396,7 @@ gb_internal void escape_stmt(EscapeAnalysis *ea, Ast *node) { case_end; case_ast_node(rs, RangeStmt, node); + escape_stmt(ea, rs->init); Ast *val0 = nullptr; Ast *val1 = nullptr; if (rs->vals.count > 0) { @@ -3416,9 +3417,11 @@ gb_internal void escape_stmt(EscapeAnalysis *ea, Ast *node) { escape_nil_scan(ea, rs->expr); } escape_loop(ea, node, nullptr, nullptr, rs->body, val0, val1, rs->expr); + escape_forget(ea, rs->init); case_end; case_ast_node(rs, UnrollRangeStmt, node); + escape_stmt(ea, rs->init); bool by_ref = false; Ast *vals[2] = {rs->val0, rs->val1}; for (Ast *val : vals) { @@ -3431,6 +3434,7 @@ gb_internal void escape_stmt(EscapeAnalysis *ea, Ast *node) { escape_nil_scan(ea, rs->expr); } escape_loop(ea, node, nullptr, nullptr, rs->body, rs->val0, rs->val1, rs->expr); + escape_forget(ea, rs->init); case_end; case_ast_node(ss, SwitchStmt, node); From 0f3f4bf73c75cfe40407b341903c8380a9b8d81d Mon Sep 17 00:00:00 2001 From: bplu4t2f Date: Sat, 10 Oct 2026 13:29:53 +0200 Subject: [PATCH 11/12] 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 From f254e28068abc85b722f9af2f2a0770d95e2baaa Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 10 Oct 2026 15:27:18 +0100 Subject: [PATCH 12/12] Zero the extra bytes when widening a value in `OdinLLVMBuildTransmute` --- src/llvm_backend_general.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp index 504a22ee9..d6593a85a 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -3885,6 +3885,10 @@ general_end:; max_align = gb_max(max_align, 16); LLVMValueRef ptr = llvm_alloca(p, dst_type, max_align); + if (dst_size > src_size) { + // NOTE(bill): the bytes past `src` are padding and must read as zero + LLVMBuildStore(p->builder, LLVMConstNull(dst_type), ptr); + } LLVMValueRef nptr = LLVMBuildPointerCast(p->builder, ptr, LLVMPointerType(src_type, 0), ""); LLVMBuildStore(p->builder, val, nptr);