From 90ca5315b2745fde3ccf9ce9d7106537cae566c8 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Tue, 17 Mar 2026 13:56:50 +0100 Subject: add sanitizer options to xmake (#847) - Improvement: Add easy access options for sanitizers with `xmake config` and `xmake test` as options - `--msan=[y|n]` Enable MemorySanitizer (Linux only, requires all deps instrumented) - `--asan=[y|n]` Enable AddressSanitizer (disables mimalloc and sentry) - `--tsan=[y|n]` Enable ThreadSanitizer (Linux/Mac only) --- scripts/test.lua | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'scripts/test.lua') diff --git a/scripts/test.lua b/scripts/test.lua index df1218ce8..3c18225fb 100644 --- a/scripts/test.lua +++ b/scripts/test.lua @@ -86,11 +86,22 @@ function main() arch = "x86_64" end + local want_asan = option.get("asan") == true + local have_asan = config.get("asan") == true + local want_tsan = option.get("tsan") == true + local have_tsan = config.get("tsan") == true + local want_msan = option.get("msan") == true + local have_msan = config.get("msan") == true + -- Only reconfigure if current config doesn't already match - if config.get("mode") ~= "debug" or config.get("plat") ~= plat or config.get("arch") ~= arch then + if config.get("mode") ~= "debug" or config.get("plat") ~= plat or config.get("arch") ~= arch + or want_asan ~= have_asan or want_tsan ~= have_tsan or want_msan ~= have_msan then local toolchain_flag = config.get("toolchain") and ("--toolchain=" .. config.get("toolchain")) or "" local sdk_flag = config.get("sdk") and ("--sdk=" .. config.get("sdk")) or "" - os.exec("xmake config -y -c -m debug -p %s -a %s %s %s", plat, arch, toolchain_flag, sdk_flag) + local asan_flag = want_asan and "--asan=y" or "" + local tsan_flag = want_tsan and "--tsan=y" or "" + local msan_flag = want_msan and "--msan=y" or "" + os.exec("xmake config -y -c -m debug -p %s -a %s %s %s %s %s %s", plat, arch, toolchain_flag, sdk_flag, asan_flag, tsan_flag, msan_flag) end -- Build targets we're going to run @@ -104,7 +115,7 @@ function main() local use_junit_reporting = option.get("junit") local use_noskip = option.get("noskip") - local use_verbose = option.get("verbose") + local use_verbose = option.get("output") local repeat_count = tonumber(option.get("repeat")) or 1 local extra_args = option.get("arguments") or {} local junit_report_files = {} -- cgit v1.2.3