From 241a1cd148d5f7cbde2d89be78c739515dc18010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 20 Jan 2023 14:50:19 +0200 Subject: [PATCH] test: Prepare the test scripts for testing native Windows tools via WSL Use the TOOLEXT variable in run-tests.sh in the same way as in the Makefile. The Makefile sets this variable automatically if invoked by mingw32-make, but if running run-tests.sh in WSL with native Windows compilers, then we need to set TOOLEXT manually when calling run-tests.sh. Allow skipping the cfguard failure tests when run in such a configuration, since Linux make in WSL can't easily run cmd.exe like in MSYS2. --- run-tests.sh | 6 +++--- test/Makefile | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/run-tests.sh b/run-tests.sh index 23014d0..808a6bf 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -52,14 +52,14 @@ cat< is-ucrt.c #endif EOF ANY_ARCH=$(echo $ARCHS | awk '{print $1}') -if ! $ANY_ARCH-w64-mingw32-gcc -E is-ucrt.c > /dev/null 2>&1; then +if ! $ANY_ARCH-w64-mingw32-gcc$TOOLEXT -E is-ucrt.c > /dev/null 2>&1; then # If the default CRT isn't UCRT, we can't build for mingw32uwp. unset HAVE_UWP fi rm -f is-ucrt.c -if (echo "int main(){}" | $ANY_ARCH-w64-mingw32-clang -x c++ - -o has-cfguard-test.exe -mguard=cf); then - if llvm-readobj --coff-load-config has-cfguard-test.exe | grep -q 'CF_INSTRUMENTED (0x100)'; then +if (echo "int main(){}" | $ANY_ARCH-w64-mingw32-clang$TOOLEXT -x c++ - -o has-cfguard-test.exe -mguard=cf); then + if llvm-readobj$TOOLEXT --coff-load-config has-cfguard-test.exe | grep -q 'CF_INSTRUMENTED (0x100)'; then HAVE_CFGUARD=1 elif [ -n "$HAVE_CFGUARD" ]; then echo "error: Toolchain doesn't seem to include Control Flow Guard support." 1>&2 diff --git a/test/Makefile b/test/Makefile index 9a0d6ad..ebfa30a 100644 --- a/test/Makefile +++ b/test/Makefile @@ -252,8 +252,12 @@ ifeq ($(CMD),) FAILURE_TEST_TARGETS = $(addprefix .failtested., $(FAILURE_TESTS)) CUSTOM1_FAILURE_TEST_TARGETS = .customtest1.bufferoverflow-fortify$(EXEEXT) ifneq ($(HAVE_CFGUARD),) + ifeq ($(WSL),) + # These tests do special calling of cmd.exe, which don't quite + # work when running with Linux make in WSL. CUSTOM2_FAILURE_TEST_TARGETS = .customtest2.cfguard-test$(EXEEXT) endif + endif endif endif