diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2022-10-12 21:49:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-12 20:49:07 +0200 |
commit | de5778ac6a7c4722454f6032822c2bb76533ebde (patch) | |
tree | 70f4f9982dbca4b7cd733ff3cb5942e7c133ea33 | |
parent | 3748f828abee586e41bd18b8441d17e298de8d14 (diff) | |
download | ccache-de5778ac6a7c4722454f6032822c2bb76533ebde.tar.gz |
test: Make the integration tests work under Windows (#1133)
Adapted the integration test scripts to be able to run on Windows.
- Added the ".sh" extension to most shell scripts. It looks like Windows needs
this to run the scripts.
- Added special handling of carriage return characters.
- Tests that fail are deactivated for the moment.
- Added additional runners in different Msys2 environments.
- Disabled the remote_http tests "Basic auth required" and "Basic auth failed"
due to intermittent failures.
- Disabled PCH tests for MSYS/Clang.
Co-authored-by: R. Voggenauer <rvogg@users.noreply.github.com>
-rw-r--r-- | .github/workflows/build.yaml | 75 | ||||
-rwxr-xr-x | test/run | 49 | ||||
-rw-r--r-- | test/suites/base.bash | 141 | ||||
-rw-r--r-- | test/suites/basedir.bash | 44 | ||||
-rw-r--r-- | test/suites/color_diagnostics.bash | 5 | ||||
-rw-r--r-- | test/suites/cpp1.bash | 4 | ||||
-rw-r--r-- | test/suites/debug_prefix_map.bash | 5 | ||||
-rw-r--r-- | test/suites/depend.bash | 4 | ||||
-rw-r--r-- | test/suites/direct.bash | 15 | ||||
-rw-r--r-- | test/suites/hardlink.bash | 8 | ||||
-rw-r--r-- | test/suites/modules.bash | 6 | ||||
-rw-r--r-- | test/suites/nocpp2.bash | 7 | ||||
-rw-r--r-- | test/suites/pch.bash | 14 | ||||
-rw-r--r-- | test/suites/profiling.bash | 12 | ||||
-rw-r--r-- | test/suites/profiling_gcc.bash | 8 | ||||
-rw-r--r-- | test/suites/remote_file.bash | 6 | ||||
-rw-r--r-- | test/suites/remote_http.bash | 13 | ||||
-rw-r--r-- | test/suites/remote_only.bash | 6 | ||||
-rw-r--r-- | test/suites/remote_url.bash | 2 | ||||
-rw-r--r-- | test/suites/serialize_diagnostics.bash | 4 | ||||
-rw-r--r-- | test/suites/split_dwarf.bash | 3 | ||||
-rw-r--r-- | test/suites/upgrade.bash | 7 |
22 files changed, 343 insertions, 95 deletions
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 93714230..e1775c4f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -124,6 +124,79 @@ jobs: name: ${{ matrix.config.os }}-${{ matrix.config.compiler }}-${{ matrix.config.version }}-testdir.tar.xz path: testdir.tar.xz + build_and_test_msys: + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + config: + - sys: mingw64 + env: x86_64 + compiler: gcc + + - sys: mingw64 + env: x86_64 + compiler: clang + + - sys: clang64 + env: clang-x86_64 + compiler: clang + + name: 'Windows ${{ matrix.config.sys }} ${{ matrix.config.compiler }}' + defaults: + run: + shell: msys2 {0} + steps: + - name: '${{ matrix.config.sys }} Setup MSYS2' + uses: msys2/setup-msys2@v2 + with: + msystem: ${{matrix.config.sys}} + update: true + install: >- + git + diffutils + tar + mingw-w64-${{matrix.config.env}}-toolchain + mingw-w64-${{matrix.config.env}}-cmake + mingw-w64-${{matrix.config.env}}-ninja + mingw-w64-${{matrix.config.env}}-hiredis + mingw-w64-${{matrix.config.env}}-lld + mingw-w64-${{matrix.config.env}}-${{matrix.config.compiler}} + + - name: setup env + run: | + if [ "${{ matrix.config.compiler }}" = "gcc" ]; then + echo "CC=gcc" >> $GITHUB_ENV + echo "CXX=g++" >> $GITHUB_ENV + else + echo "CC=clang" >> $GITHUB_ENV + echo "CXX=clang++" >> $GITHUB_ENV + fi + + - name: Get source + uses: actions/checkout@v2 + + - name: Build and test + run: ci/build + continue-on-error: ${{ matrix.config.allow_test_failures == true && + steps.build-and-test.outputs.exit_status == 8 }} + env: + ENABLE_CACHE_CLEANUP_TESTS: 1 + CMAKE_GENERATOR: Ninja + CMAKE_PARAMS: -DCMAKE_BUILD_TYPE=CI + TEST_CC: gcc + + - name: Collect testdir from failed tests + if: failure() + run: ci/collect-testdir + + - name: Upload testdir from failed tests + if: failure() + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.config.sys}}-${{ matrix.config.env }}-${{ matrix.config.compiler }}-testdir.tar.xz + path: testdir.tar.xz + specific_tests: name: ${{ matrix.config.name }} runs-on: ${{ matrix.config.os }} @@ -181,7 +254,6 @@ jobs: - name: Windows VS2019 32-bit Ninja os: windows-2019 msvc_arch: x64_x86 - allow_test_failures: true # For now, don't fail the build on failure CC: cl CXX: cl ENABLE_CACHE_CLEANUP_TESTS: 1 @@ -203,7 +275,6 @@ jobs: - name: Windows VS2019 64-bit Ninja os: windows-2019 msvc_arch: x64 - allow_test_failures: true # For now, don't fail the build on failure CC: cl CXX: cl ENABLE_CACHE_CLEANUP_TESTS: 1 @@ -162,6 +162,8 @@ objdump_cmd() { objdump_grep_cmd() { if $HOST_OS_APPLE; then fgrep -q "\"$1\"" + elif $HOST_OS_WINDOWS || $HOST_OS_CYGWIN; then + fgrep -q "$1" else fgrep -q ": $1" fi @@ -173,11 +175,17 @@ expect_stat() { local line local value="" + if $HOST_OS_WINDOWS ; then + filter="sed -e s/\r//g" + else + filter=cat + fi + while read -r key value; do if [[ $key == $stat ]]; then break fi - done < <($CCACHE --print-stats) + done < <($CCACHE --print-stats | $filter ) if [ "$expected_value" != "$value" ]; then test_failed_internal "Expected $stat to be $expected_value, actual $value" @@ -204,7 +212,23 @@ expect_equal_content() { test_failed_internal "expect_equal_content: $2 missing" fi if ! cmp -s "$1" "$2"; then - test_failed_internal "$1 and $2 differ: $(echo; diff -u "$1" "$2")" + test_failed_internal "$1 and $2 differ" + fi +} + +expect_equal_text_content() { + if [ ! -e "$1" ]; then + test_failed_internal "expect_equal_text_content: $1 missing" + fi + if [ ! -e "$2" ]; then + test_failed_internal "expect_equal_text_content: $2 missing" + fi + if ! cmp -s "$1" "$2"; then + if $HOST_OS_WINDOWS && diff -u --strip-trailing-cr "$1" "$2" > /dev/null ; then + test_failed_internal "$1 and $2 with differ line endings." + else + test_failed_internal "$1 and $2 differ: $(echo; diff -u "$1" "$2")" + fi fi } @@ -499,6 +523,7 @@ COMPILER_TYPE_GCC=false COMPILER_USES_LLVM=false COMPILER_USES_MINGW=false +COMPILER_USES_MSVC=false ABS_ROOT_DIR="$(cd $(dirname "$0"); pwd)" readonly HTTP_CLIENT="${ABS_ROOT_DIR}/http-client" @@ -511,6 +536,7 @@ HOST_OS_WINDOWS=false HOST_OS_CYGWIN=false compiler_version="`$CC --version 2>/dev/null | head -1`" + case $compiler_version in *gcc*|*g++*|2.95*) COMPILER_TYPE_GCC=true @@ -525,6 +551,12 @@ case $compiler_version in ;; esac +case $CC in + *MSVC*|*msvc*) + COMPILER_USES_MSVC=true + ;; +esac + case $compiler_version in *llvm*|*LLVM*) COMPILER_USES_LLVM=true @@ -532,6 +564,9 @@ case $compiler_version in *MINGW*|*mingw*) COMPILER_USES_MINGW=true ;; + *MSVC*|*msvc*) + COMPILER_USES_MSVC=true + ;; esac case $(uname -s) in @@ -557,6 +592,12 @@ if $HOST_OS_WINDOWS; then else PATH_DELIM=":" fi +RUN_WIN_XFAIL=true +if $HOST_OS_WINDOWS && [ -z "${RUN_FAULTY_TESTS}" ] ; then + RUN_WIN_XFAIL=false +fi + + if [[ $OSTYPE = msys* ]]; then # Native symlink support for Windows. @@ -622,7 +663,11 @@ echo cd $TESTDIR || exit 1 mkdir compiler + COMPILER="$(pwd)/compiler/$(basename "$REAL_COMPILER_BIN")" +if $HOST_OS_WINDOWS; then + COMPILER="$COMPILER.sh" +fi cat >"$COMPILER" <<EOF #!/bin/sh diff --git a/test/suites/base.bash b/test/suites/base.bash index db3389dc..67a5d42a 100644 --- a/test/suites/base.bash +++ b/test/suites/base.bash @@ -386,11 +386,13 @@ fi expect_exists test1.o.*.ccache-log # ------------------------------------------------------------------------- +if $RUN_WIN_XFAIL;then +# TODO: Leading slash is missing. (debugdirC/... instead of debugdir/C/... ) TEST "CCACHE_DEBUGDIR" CCACHE_DEBUG=1 CCACHE_DEBUGDIR=debugdir $CCACHE_COMPILE -c test1.c expect_contains debugdir"$(pwd -P)"/test1.o.*.ccache-log "Result: cache_miss" - +fi # ------------------------------------------------------------------------- TEST "CCACHE_DISABLE" @@ -563,29 +565,35 @@ fi fi # ------------------------------------------------------------------------- - TEST "Directory is not hashed if using -gz=zlib" - $COMPILER -E test1.c -gz=zlib >preprocessed.i 2>/dev/null - if [ -s preprocessed.i ] && ! fgrep -q $PWD preprocessed.i; then - mkdir dir1 dir2 - cp test1.c dir1 - cp test1.c dir2 - - cd dir1 - $CCACHE_COMPILE -c test1.c -gz=zlib - expect_stat preprocessed_cache_hit 0 - expect_stat cache_miss 1 - $CCACHE_COMPILE -c test1.c -gz=zlib - expect_stat preprocessed_cache_hit 1 - expect_stat cache_miss 1 + TEST "Directory is not hashed if using -gz=zlib" - cd ../dir2 - $CCACHE_COMPILE -c test1.c -gz=zlib - expect_stat preprocessed_cache_hit 2 - expect_stat cache_miss 1 + $COMPILER test1.c -gz=zlib -o /dev/null 2>/dev/null + if [ $? -eq 0 ]; then + # run test only if -gz=zlib is supported + $COMPILER -E test1.c -gz=zlib >preprocessed.i 2>/dev/null + if [ "$exit_code" == "0" ] && [ -s preprocessed.i ] && ! fgrep -q $PWD preprocessed.i; then + mkdir dir1 dir2 + cp test1.c dir1 + cp test1.c dir2 + + cd dir1 + $CCACHE_COMPILE -c test1.c -gz=zlib + expect_stat preprocessed_cache_hit 0 + expect_stat cache_miss 1 + $CCACHE_COMPILE -c test1.c -gz=zlib + expect_stat preprocessed_cache_hit 1 + expect_stat cache_miss 1 + + cd ../dir2 + $CCACHE_COMPILE -c test1.c -gz=zlib + expect_stat preprocessed_cache_hit 2 + expect_stat cache_miss 1 + fi fi # ------------------------------------------------------------------------- +if $RUN_WIN_XFAIL; then TEST "CCACHE_NOHASHDIR" mkdir dir1 dir2 @@ -604,6 +612,7 @@ fi CCACHE_NOHASHDIR=1 $CCACHE_COMPILE -c test1.c -g expect_stat preprocessed_cache_hit 2 expect_stat cache_miss 1 +fi # ------------------------------------------------------------------------- TEST "CCACHE_EXTRAFILES" @@ -644,29 +653,28 @@ fi # ------------------------------------------------------------------------- TEST "CCACHE_PREFIX" - - cat <<'EOF' >prefix-a + cat <<'EOF' >prefix-a.sh #!/bin/sh echo a >prefix.result exec "$@" EOF - cat <<'EOF' >prefix-b + cat <<'EOF' >prefix-b.sh #!/bin/sh echo b >>prefix.result exec "$@" EOF - chmod +x prefix-a prefix-b + chmod +x prefix-a.sh prefix-b.sh cat <<'EOF' >file.c int foo; EOF - PATH=.:$PATH CCACHE_PREFIX="prefix-a prefix-b" $CCACHE_COMPILE -c file.c + PATH=.:$PATH CCACHE_PREFIX="prefix-a.sh prefix-b.sh" $CCACHE_COMPILE -c file.c expect_stat direct_cache_hit 0 expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 1 expect_content prefix.result "a b" - PATH=.:$PATH CCACHE_PREFIX="prefix-a prefix-b" $CCACHE_COMPILE -c file.c + PATH=.:$PATH CCACHE_PREFIX="prefix-a.sh prefix-b.sh" $CCACHE_COMPILE -c file.c expect_stat direct_cache_hit 0 expect_stat preprocessed_cache_hit 1 expect_stat cache_miss 1 @@ -674,13 +682,12 @@ b" b" rm -f prefix.result - PATH=.:$PATH CCACHE_PREFIX_CPP="prefix-a prefix-b" $CCACHE_COMPILE -c file.c + PATH=.:$PATH CCACHE_PREFIX_CPP="prefix-a.sh prefix-b.sh" $CCACHE_COMPILE -c file.c expect_stat direct_cache_hit 0 expect_stat preprocessed_cache_hit 2 expect_stat cache_miss 1 expect_content prefix.result "a b" - # ------------------------------------------------------------------------- TEST "Files in cache" @@ -750,6 +757,7 @@ b" expect_stat unsupported_source_language 1 # ------------------------------------------------------------------------- +if ! $HOST_OS_WINDOWS; then TEST "-x c -c /dev/null" $CCACHE_COMPILE -x c -c /dev/null -o null.o 2>/dev/null @@ -759,7 +767,7 @@ b" $CCACHE_COMPILE -x c -c /dev/null -o null.o 2>/dev/null expect_stat preprocessed_cache_hit 1 expect_stat cache_miss 1 - +fi # ------------------------------------------------------------------------- TEST "-D not hashed" @@ -791,6 +799,7 @@ b" expect_stat cache_miss 2 # ------------------------------------------------------------------------- +if ! $HOST_OS_WINDOWS; then TEST "-frecord-gcc-switches" if $COMPILER -frecord-gcc-switches -c test1.c >&/dev/null; then @@ -810,6 +819,7 @@ b" expect_stat preprocessed_cache_hit 2 expect_stat cache_miss 2 fi +fi # ------------------------------------------------------------------------- TEST "CCACHE_DISABLE set when executing compiler" @@ -827,6 +837,7 @@ EOF expect_content CCACHE_DISABLE.value '11' # preprocessor + compiler # ------------------------------------------------------------------------- +if ! ( $HOST_OS_WINDOWS && $COMPILER_TYPE_CLANG ) && [ -n "$COMPILER_ARGS" ] ; then TEST "CCACHE_COMPILER" $COMPILER -c -o reference_test1.o test1.c @@ -861,17 +872,23 @@ EOF expect_stat cache_miss 1 expect_stat files_in_cache 1 expect_equal_object_files reference_test1.o test1.o - +fi # ------------------------------------------------------------------------- TEST "CCACHE_COMPILERTYPE" + if $HOST_OS_WINDOWS; then + FAKE_GCC=./gcc.sh + else + FAKE_GCC=./gcc + fi + $CCACHE_COMPILE -c test1.c - cat >gcc <<EOF + cat >$FAKE_GCC <<EOF #!/bin/sh EOF - chmod +x gcc + chmod +x $FAKE_GCC - CCACHE_DEBUG=1 $CCACHE ./gcc -c test1.c + CCACHE_DEBUG=1 $CCACHE $FAKE_GCC -c test1.c compiler_type=$(sed -En 's/.*Compiler type: (.*)/\1/p' test1.o.*.ccache-log) if [ "$compiler_type" != gcc ]; then test_failed "Compiler type $compiler_type != gcc" @@ -879,7 +896,7 @@ EOF rm test1.o.*.ccache-log - CCACHE_COMPILERTYPE=clang CCACHE_DEBUG=1 $CCACHE ./gcc -c test1.c + CCACHE_COMPILERTYPE=clang CCACHE_DEBUG=1 $CCACHE $FAKE_GCC -c test1.c compiler_type=$(sed -En 's/.*Compiler type: (.*)/\1/p' test1.o.*.ccache-log) if [ "$compiler_type" != clang ]; then test_failed "Compiler type $compiler_type != clang" @@ -887,7 +904,7 @@ EOF # ------------------------------------------------------------------------- TEST "CCACHE_PATH" - +if $RUN_WIN_XFAIL; then override_path=`pwd`/override_path mkdir $override_path cat >$override_path/cc <<EOF @@ -899,6 +916,7 @@ EOF if [ ! -f override_path_compiler_executed ]; then test_failed "CCACHE_PATH had no effect" fi +fi # ------------------------------------------------------------------------- TEST "CCACHE_COMPILERCHECK=mtime" @@ -998,7 +1016,7 @@ EOF # ------------------------------------------------------------------------- TEST "CCACHE_COMPILERCHECK=command" - +if $RUN_WIN_XFAIL; then cat >compiler.sh <<EOF #!/bin/sh exec $COMPILER "\$@" @@ -1027,6 +1045,7 @@ EOF CCACHE_COMPILERCHECK='echo foo; echo bar' $CCACHE ./compiler.sh -c test1.c expect_stat preprocessed_cache_hit 2 expect_stat cache_miss 2 +fi # ------------------------------------------------------------------------- TEST "CCACHE_COMPILERCHECK=unknown_command" @@ -1105,19 +1124,18 @@ fi # ------------------------------------------------------------------------- TEST "No object file due to bad prefix" - cat <<'EOF' >test_no_obj.c int test_no_obj; EOF - cat <<'EOF' >no-object-prefix + cat <<'EOF' >no-object-prefix.sh #!/bin/sh # Emulate no object file from the compiler. EOF - chmod +x no-object-prefix - CCACHE_PREFIX=$(pwd)/no-object-prefix $CCACHE_COMPILE -c test_no_obj.c + chmod +x no-object-prefix.sh + CCACHE_PREFIX=$(pwd)/no-object-prefix.sh $CCACHE_COMPILE -c test_no_obj.c expect_stat compiler_produced_no_output 1 - CCACHE_PREFIX=$(pwd)/no-object-prefix $CCACHE_COMPILE -c test1.c + CCACHE_PREFIX=$(pwd)/no-object-prefix.sh $CCACHE_COMPILE -c test1.c expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 0 expect_stat files_in_cache 0 @@ -1142,6 +1160,7 @@ EOF expect_missing test1.o # ------------------------------------------------------------------------- +if $RUN_WIN_XFAIL; then TEST "-fsyntax-only /dev/null" echo existing >null.o @@ -1172,33 +1191,33 @@ EOF expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 1 expect_stat files_in_cache 1 - expect_equal_content reference_stderr.txt stderr.txt + expect_equal_text_content reference_stderr.txt stderr.txt # Intentionally compiling with "-c" here but not above. $CCACHE_COMPILE -Wall -c stderr.c -fsyntax-only 2>stderr.txt expect_stat preprocessed_cache_hit 1 expect_stat cache_miss 1 expect_stat files_in_cache 1 - expect_equal_content reference_stderr.txt stderr.txt + expect_equal_text_content reference_stderr.txt stderr.txt +fi # ------------------------------------------------------------------------- TEST "Empty object file" - cat <<'EOF' >test_empty_obj.c int test_empty_obj; EOF - cat <<'EOF' >empty-object-prefix + cat <<'EOF' >empty-object-prefix.sh #!/bin/sh # Emulate empty object file from the compiler. touch test_empty_obj.o EOF - chmod +x empty-object-prefix - CCACHE_PREFIX=`pwd`/empty-object-prefix $CCACHE_COMPILE -c test_empty_obj.c + chmod +x empty-object-prefix.sh + CCACHE_PREFIX=`pwd`/empty-object-prefix.sh $CCACHE_COMPILE -c test_empty_obj.c expect_stat compiler_produced_empty_output 1 # ------------------------------------------------------------------------- TEST "Output to /dev/null" - +if ! $HOST_OS_WINDOWS; then $CCACHE_COMPILE -c test1.c expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 1 @@ -1206,7 +1225,7 @@ EOF $CCACHE_COMPILE -c test1.c -o /dev/null expect_stat preprocessed_cache_hit 1 expect_stat cache_miss 1 - +fi # ------------------------------------------------------------------------- mkdir dir @@ -1224,10 +1243,12 @@ EOF rm dir/test1.o chmod a-w dir +if $RUN_WIN_XFAIL; then $CCACHE_COMPILE -c test1.c -o dir/test1.o 2>/dev/null expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 1 expect_stat bad_output_file 1 +fi fi # ------------------------------------------------------------------------- @@ -1241,7 +1262,7 @@ int stderr(void) EOF $COMPILER -c -Wall -W -c stderr.c 2>reference_stderr.txt $CCACHE_COMPILE -Wall -W -c stderr.c 2>stderr.txt - expect_equal_content reference_stderr.txt stderr.txt + expect_equal_text_content reference_stderr.txt stderr.txt # ------------------------------------------------------------------------- TEST "Merging stderr" @@ -1283,13 +1304,13 @@ EOF $CCACHE_COMPILE -c test.c -MMD 2>test.stderr expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 1 - expect_equal_content reference.stderr test.stderr + expect_equal_text_content reference.stderr test.stderr expect_equal_content reference.d test.d $CCACHE_COMPILE -c test.c -MMD 2>test.stderr expect_stat preprocessed_cache_hit 1 expect_stat cache_miss 1 - expect_equal_content reference.stderr test.stderr + expect_equal_text_content reference.stderr test.stderr expect_equal_content reference.d test.d # ------------------------------------------------------------------------- @@ -1538,7 +1559,7 @@ EOF rm compiler.args # ------------------------------------------------------------------------- - +if ! $COMPILER_USES_MSVC; then for src in test1.c build/test1.c; do for obj in test1.o build/test1.o; do TEST "Dependency file content, $src -o $obj" @@ -1549,11 +1570,11 @@ EOF expect_content $dep "$obj: $src" done done - +fi # ------------------------------------------------------------------------- +if $RUN_WIN_XFAIL; then TEST "Buggy GCC 6 cpp" - - cat >buggy-cpp <<EOF + cat >buggy-cpp.sh <<EOF #!/bin/sh if echo "\$*" | grep -- -D >/dev/null; then $COMPILER "\$@" @@ -1569,20 +1590,19 @@ EOF cat <<'EOF' >file.c int foo; EOF - chmod +x buggy-cpp + chmod +x buggy-cpp.sh - $CCACHE ./buggy-cpp -c file.c + $CCACHE ./buggy-cpp.sh -c file.c expect_stat direct_cache_hit 0 expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 1 - $CCACHE ./buggy-cpp -DNOT_AFFECTING=1 -c file.c + $CCACHE ./buggy-cpp.sh -DNOT_AFFECTING=1 -c file.c expect_stat direct_cache_hit 0 expect_stat preprocessed_cache_hit 1 expect_stat cache_miss 1 - +fi # ------------------------------------------------------------------------- -if ! $HOST_OS_WINDOWS; then TEST ".incbin" touch empty.bin @@ -1629,7 +1649,6 @@ EOF expect_stat cache_miss 1 expect_stat unsupported_code_directive 3 fi -fi # ------------------------------------------------------------------------- if ! $HOST_OS_WINDOWS; then diff --git a/test/suites/basedir.bash b/test/suites/basedir.bash index bfadafd7..e739cf55 100644 --- a/test/suites/basedir.bash +++ b/test/suites/basedir.bash @@ -1,3 +1,9 @@ +SUITE_basedir_PROBE() { + if ! $RUN_WIN_XFAIL; then + echo "CCACHE_BASEDIR is broken on windows." + fi +} + SUITE_basedir_SETUP() { unset CCACHE_NODIRECT @@ -222,7 +228,12 @@ EOF fi # ------------------------------------------------------------------------- - for option in MF "MF "; do + if $HOST_OS_WINDOWS; then + additional_options= + else + additional_options=(MF) + fi + for option in "MF " $additional_options; do TEST "-${option}/absolute/path" cd dir1 @@ -243,10 +254,16 @@ EOF done # ------------------------------------------------------------------------- - for option in MQ "MQ " MT "MT "; do + if $HOST_OS_WINDOWS; then + additional_options= + else + additional_options=(MQ MT) + fi + for option in "MQ " "MT " $additional_options; do TEST "-${option}/absolute/path" cd dir1 + CCACHE_BASEDIR="$(pwd)" $CCACHE_COMPILE -I"$(pwd)/include" -MMD -${option}"$(pwd)/foo.o" -c src/test.c expect_stat direct_cache_hit 0 expect_stat preprocessed_cache_hit 0 @@ -262,17 +279,28 @@ EOF expect_content_pattern test.d "$(pwd)/foo.o:*" cd .. done - # ------------------------------------------------------------------------- # When BASEDIR is set to /, check that -MF, -MQ and -MT arguments with # absolute paths are rewritten to relative and that the dependency file # only contains relative paths. TEST "-MF/-MQ/-MT with absolute paths and BASEDIR set to /" - for option in MF "MF " MQ "MQ " MT "MT "; do + BASEDIR="/" + if $HOST_OS_WINDOWS; then + # Windows uses drives therefore "/" has no meaning, thus default to drive + BASEDIR=`cygpath -m "\\."` + fi + + if $HOST_OS_WINDOWS; then + additional_options= + else + additional_options=(MF MQ MT) + fi + for option in "MF " "MQ " "MT " $additional_options; do clear_cache cd dir1 - CCACHE_BASEDIR="/" $CCACHE_COMPILE -I`pwd`/include -MD -${option}`pwd`/test.d -c src/test.c + + CCACHE_BASEDIR=$BASEDIR $CCACHE_COMPILE -I`pwd`/include -MD -${option}`pwd`/test.d -c src/test.c expect_stat direct_cache_hit 0 expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 1 @@ -287,14 +315,14 @@ EOF cd .. cd dir2 - CCACHE_BASEDIR="/" $CCACHE_COMPILE -I`pwd`/include -MD -${option}`pwd`/test.d -c src/test.c + CCACHE_BASEDIR=$BASEDIR $CCACHE_COMPILE -I`pwd`/include -MD -${option}`pwd`/test.d -c src/test.c expect_stat direct_cache_hit 1 expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 1 cd .. done - # ------------------------------------------------------------------------- +if $RUN_WIN_XFAIL; then TEST "Absolute paths in stderr" cat <<EOF >test.c @@ -336,7 +364,7 @@ EOF expect_stat cache_miss 1 expect_equal_content reference.stderr ccache.stderr fi - +fi # ------------------------------------------------------------------------- TEST "Relative PWD" diff --git a/test/suites/color_diagnostics.bash b/test/suites/color_diagnostics.bash index d8db0484..8295eb1c 100644 --- a/test/suites/color_diagnostics.bash +++ b/test/suites/color_diagnostics.bash @@ -12,6 +12,11 @@ SUITE_color_diagnostics_PROBE() { return fi + if ! $RUN_WIN_XFAIL; then + echo "color_diagnostics tests are broken on Windows." + return + fi + # Probe that real compiler actually supports colored diagnostics. if [[ ! $color_diagnostics_enable || ! $color_diagnostics_disable ]]; then echo "compiler $COMPILER does not support colored diagnostics" diff --git a/test/suites/cpp1.bash b/test/suites/cpp1.bash index e472b285..26d1b5bc 100644 --- a/test/suites/cpp1.bash +++ b/test/suites/cpp1.bash @@ -10,6 +10,10 @@ SUITE_cpp1_PROBE() { echo "-frewrite-includes not supported by compiler" return fi + if $HOST_OS_WINDOWS && ! $COMPILER_USES_MSVC; then + echo "This test is broken on msys2 clang: Stores wrong file names like 'tmp.cpp_stdout.2Gq' instead of 'test1.c'." + return + fi else echo "Unknown compiler: $COMPILER" return diff --git a/test/suites/debug_prefix_map.bash b/test/suites/debug_prefix_map.bash index 5911cf61..af0cdaa0 100644 --- a/test/suites/debug_prefix_map.bash +++ b/test/suites/debug_prefix_map.bash @@ -3,6 +3,11 @@ SUITE_debug_prefix_map_PROBE() { if ! $COMPILER -c -fdebug-prefix-map=old=new test.c 2>/dev/null; then echo "-fdebug-prefix-map not supported by compiler" fi + + if ! $RUN_WIN_XFAIL; then + echo "debug_prefix_map tests are broken on Windows." + return + fi } SUITE_debug_prefix_map_SETUP() { diff --git a/test/suites/depend.bash b/test/suites/depend.bash index 88bf786d..03a14af6 100644 --- a/test/suites/depend.bash +++ b/test/suites/depend.bash @@ -185,13 +185,13 @@ EOF expect_stat direct_cache_hit 0 expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 1 - expect_content stderr-orig.txt "`cat stderr-baseline.txt`" + expect_equal_text_content stderr-orig.txt stderr-baseline.txt CCACHE_DEPEND=1 $CCACHE_COMPILE -MD -Wall -W -c cpp-warning.c 2>stderr-mf.txt expect_stat direct_cache_hit 1 expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 1 - expect_content stderr-mf.txt "`cat stderr-baseline.txt`" + expect_equal_text_content stderr-mf.txt stderr-baseline.txt # ------------------------------------------------------------------------- # This test case covers a case in depend mode with unchanged source file diff --git a/test/suites/direct.bash b/test/suites/direct.bash index 5fea53b1..67334eef 100644 --- a/test/suites/direct.bash +++ b/test/suites/direct.bash @@ -191,6 +191,7 @@ EOF done # ------------------------------------------------------------------------- +if ! $COMPILER_USES_MSVC; then TEST "-MMD for different source files" mkdir a b @@ -204,7 +205,7 @@ EOF $CCACHE_COMPILE -MMD -c a/source.c -o a/source.o expect_content a/source.d "a/source.o: a/source.c" - +fi # ------------------------------------------------------------------------- dep_args_combinations=( "-MMD" @@ -330,6 +331,7 @@ EOF done # ------------------------------------------------------------------------- +if ! $COMPILER_USES_MSVC; then TEST "Dependency file content" mkdir build @@ -343,8 +345,9 @@ EOF expect_content $dep "$obj: $src" done done - +fi # ------------------------------------------------------------------------- +if ! $COMPILER_USES_MSVC; then TEST "-MMD for different include file paths" mkdir a b @@ -359,7 +362,7 @@ EOF $CCACHE_COMPILE -MMD -Ia -c source.c expect_content source.d "source.o: source.c a/source.h" - +fi # ------------------------------------------------------------------------- TEST "-Wp,-MD" @@ -448,6 +451,7 @@ EOF expect_content source.d "source.o: source.c" # ------------------------------------------------------------------------- +if ! $COMPILER_USES_MSVC; then TEST "-MMD for different source files" mkdir a b @@ -460,7 +464,7 @@ EOF $CCACHE_COMPILE -MMD -c a/source.c expect_content source.d "source.o: a/source.c" - +fi # ------------------------------------------------------------------------- TEST "Multiple object entries in manifest" @@ -615,6 +619,7 @@ EOF rm -f third_name.d # ------------------------------------------------------------------------- +if $RUN_WIN_XFAIL; then TEST "MF /dev/null" $CCACHE_COMPILE -c -MD -MF /dev/null test.c @@ -644,7 +649,7 @@ EOF expect_stat cache_miss 2 expect_stat files_in_cache 4 expect_equal_content test.d expected.d - +fi # ------------------------------------------------------------------------- TEST "Handling of -MT/-MQ" diff --git a/test/suites/hardlink.bash b/test/suites/hardlink.bash index 31c58f0e..a49c9356 100644 --- a/test/suites/hardlink.bash +++ b/test/suites/hardlink.bash @@ -58,6 +58,7 @@ SUITE_hardlink() { expect_stat files_in_cache 2 # ------------------------------------------------------------------------- +if $RUN_WIN_XFAIL; then TEST "Overwrite assembler" generate_code 1 test1.c @@ -86,8 +87,9 @@ SUITE_hardlink() { expect_stat cache_miss 2 expect_stat files_in_cache 4 expect_equal_object_files reference_test1.o test1.o - +fi # ------------------------------------------------------------------------- +if $RUN_WIN_XFAIL; then TEST "Automake depend move" unset CCACHE_NODIRECT @@ -101,8 +103,9 @@ SUITE_hardlink() { CCACHE_HARDLINK=1 CCACHE_DEPEND=1 $CCACHE_COMPILE -c -MMD -MF test1.d.tmp test1.c expect_stat direct_cache_hit 1 mv test1.d.tmp test1.d || test_failed "second mv failed" - +fi # ------------------------------------------------------------------------- +if $RUN_WIN_XFAIL; then TEST ".d file corrupted by compiler" unset CCACHE_NODIRECT @@ -130,4 +133,5 @@ SUITE_hardlink() { expect_stat direct_cache_hit 1 expect_stat cache_miss 2 expect_content test1.d "test1.o: test1.c" +fi } diff --git a/test/suites/modules.bash b/test/suites/modules.bash index bd5ada92..ae5c0f31 100644 --- a/test/suites/modules.bash +++ b/test/suites/modules.bash @@ -1,9 +1,9 @@ SUITE_modules_PROBE() { - if ! $COMPILER_TYPE_CLANG; then + if ! $COMPILER_TYPE_CLANG || $COMPILER_USES_MSVC; then echo "-fmodules/-fcxx-modules not supported by compiler" else - touch test.c - $COMPILER -fmodules test.c -S || echo "compiler does not support modules" + echo '#include <string>' >testmodules.cpp + $COMPILER -x c++ -fmodules testmodules.cpp -S || echo "compiler does not support modules" fi } diff --git a/test/suites/nocpp2.bash b/test/suites/nocpp2.bash index 4187c3fe..67687767 100644 --- a/test/suites/nocpp2.bash +++ b/test/suites/nocpp2.bash @@ -1,3 +1,10 @@ +SUITE_nocpp2_PROBE() { + if $HOST_OS_WINDOWS; then + echo "CCACHE_NOCPP2 does not work correct on Windows" + return + fi +} + SUITE_nocpp2_SETUP() { export CCACHE_NOCPP2=1 generate_code 1 test1.c diff --git a/test/suites/pch.bash b/test/suites/pch.bash index 12968b41..fefaac6a 100644 --- a/test/suites/pch.bash +++ b/test/suites/pch.bash @@ -55,7 +55,9 @@ SUITE_pch() { pch_suite_common if $COMPILER_TYPE_CLANG; then - pch_suite_clang + if ! [ $COMPILER_BIN = "gcc" ] || $RUN_WIN_XFAIL; then + pch_suite_clang + fi else pch_suite_gcc fi @@ -173,6 +175,7 @@ pch_suite_common() { $COMPILER $SYSROOT -c pch.h backdate pch.h.gch +if $RUN_WIN_XFAIL; then CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c expect_stat direct_cache_hit 1 expect_stat preprocessed_cache_hit 0 @@ -182,6 +185,7 @@ pch_suite_common() { expect_stat direct_cache_hit 2 expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 2 +fi # ------------------------------------------------------------------------- TEST "Use .gch, preprocessor mode, -include" @@ -332,6 +336,7 @@ pch_suite_common() { $COMPILER $SYSROOT -c pch.h -o dir/pch.h.gch backdate dir/pch.h.gch +if $RUN_WIN_XFAIL; then CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include dir/pch.h pch2.c expect_stat direct_cache_hit 1 expect_stat preprocessed_cache_hit 0 @@ -341,6 +346,7 @@ pch_suite_common() { expect_stat direct_cache_hit 2 expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 2 +fi rm -rf dir # ------------------------------------------------------------------------- @@ -462,6 +468,7 @@ pch_suite_gcc() { $COMPILER $SYSROOT -c pch.h backdate pch.h.gch +if $RUN_WIN_XFAIL; then CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c expect_stat direct_cache_hit 1 expect_stat preprocessed_cache_hit 0 @@ -471,6 +478,7 @@ pch_suite_gcc() { expect_stat direct_cache_hit 2 expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 2 +fi # ------------------------------------------------------------------------- TEST "Use .gch, preprocessor mode, #include" @@ -494,6 +502,7 @@ pch_suite_gcc() { $COMPILER $SYSROOT -c pch.h backdate pch.h.gch +if $RUN_WIN_XFAIL; then CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c expect_stat direct_cache_hit 0 expect_stat preprocessed_cache_hit 1 @@ -503,6 +512,7 @@ pch_suite_gcc() { expect_stat direct_cache_hit 0 expect_stat preprocessed_cache_hit 2 expect_stat cache_miss 2 +fi # ------------------------------------------------------------------------- TEST "Create and use .gch directory" @@ -536,6 +546,7 @@ pch_suite_gcc() { echo "updated" >>pch.h.gch/foo # GCC seems to cope with this... backdate pch.h.gch/foo +if $RUN_WIN_XFAIL; then CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c expect_stat direct_cache_hit 2 expect_stat preprocessed_cache_hit 0 @@ -545,6 +556,7 @@ pch_suite_gcc() { expect_stat direct_cache_hit 3 expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 3 +fi # ------------------------------------------------------------------------- TEST "Use .gch, #include, PCH_EXTSUM=1" diff --git a/test/suites/profiling.bash b/test/suites/profiling.bash index e85ea43c..16dc7e0b 100644 --- a/test/suites/profiling.bash +++ b/test/suites/profiling.bash @@ -7,10 +7,13 @@ normalize_gcno_file() { SUITE_profiling_PROBE() { - touch test.c + echo 'int main(void) { return 0; }' >test.c if ! $COMPILER -fprofile-generate -c test.c 2>/dev/null; then echo "compiler does not support profiling" fi + if ! $COMPILER -fprofile-generate test.o -o test 2>/dev/null; then + echo "compiler cannot link with profiling" + fi if ! $COMPILER -fprofile-generate=data -c test.c 2>/dev/null; then echo "compiler does not support -fprofile-generate=path" fi @@ -75,8 +78,8 @@ SUITE_profiling() { $CCACHE_COMPILE -fprofile-use -c test.c expect_stat direct_cache_hit 1 expect_stat cache_miss 3 - # ------------------------------------------------------------------------- +if $RUN_WIN_XFAIL; then TEST "-fprofile-use=dir" mkdir data @@ -104,8 +107,9 @@ SUITE_profiling() { $CCACHE_COMPILE -fprofile-use=data -c test.c expect_stat direct_cache_hit 1 expect_stat cache_miss 3 - +fi # ------------------------------------------------------------------------- +if $RUN_WIN_XFAIL; then TEST "-fprofile-generate=dir in different directories" mkdir -p dir1/data dir2/data @@ -155,7 +159,7 @@ SUITE_profiling() { || test_failed "compilation error" # Note: No expect_stat here since GCC and Clang behave differently – just # check that the compiler doesn't warn about not finding the profile data. - +fi # ------------------------------------------------------------------------- if $COMPILER_TYPE_GCC; then # GCC 9 and newer creates a mangled .gcno filename (still in the current diff --git a/test/suites/profiling_gcc.bash b/test/suites/profiling_gcc.bash index cd012345..298dc162 100644 --- a/test/suites/profiling_gcc.bash +++ b/test/suites/profiling_gcc.bash @@ -36,6 +36,7 @@ SUITE_profiling_gcc() { expect_stat cache_miss 3 # ------------------------------------------------------------------------- +if $RUN_WIN_XFAIL; then TEST "-fprofile-dir=dir + -fprofile-use" mkdir data @@ -61,8 +62,9 @@ SUITE_profiling_gcc() { $CCACHE_COMPILE -fprofile-dir=data -fprofile-use -c test.c expect_stat direct_cache_hit 1 expect_stat cache_miss 3 - +fi # ------------------------------------------------------------------------- +if $RUN_WIN_XFAIL; then TEST "-fprofile-use + -fprofile-dir=dir" mkdir data @@ -88,8 +90,9 @@ SUITE_profiling_gcc() { $CCACHE_COMPILE -fprofile-use -fprofile-dir=data -c test.c expect_stat direct_cache_hit 1 expect_stat cache_miss 3 - +fi # ------------------------------------------------------------------------- +if $RUN_WIN_XFAIL; then TEST "-fprofile-dir=path1 + -fprofile-use=path2" mkdir data @@ -160,4 +163,5 @@ SUITE_profiling_gcc() { expect_stat direct_cache_hit 4 expect_stat cache_miss 3 fi +fi } diff --git a/test/suites/remote_file.bash b/test/suites/remote_file.bash index 3e23b57e..c4a8c1d2 100644 --- a/test/suites/remote_file.bash +++ b/test/suites/remote_file.bash @@ -1,6 +1,12 @@ # This test suite verified both the file storage backend and the remote # storage framework itself. +SUITE_remote_file_PROBE() { + if ! $RUN_WIN_XFAIL; then + echo "remote file is broken on windows." + fi +} + SUITE_remote_file_SETUP() { unset CCACHE_NODIRECT export CCACHE_REMOTE_STORAGE="file:$PWD/remote" diff --git a/test/suites/remote_http.bash b/test/suites/remote_http.bash index 4815c402..608448f8 100644 --- a/test/suites/remote_http.bash +++ b/test/suites/remote_http.bash @@ -149,6 +149,11 @@ SUITE_remote_http() { expect_not_contains test.o.*.ccache-log secret123 # ------------------------------------------------------------------------- + # This test fails sporadically. + # Mostly with MSVC 32 bit, but from time to time also with all other + # Windows test runs. + # Probably the http-server is doing something wrong here. +if $RUN_WIN_XFAIL; then TEST "Basic auth required" start_http_server 12780 remote "somebody:secret123" @@ -161,8 +166,14 @@ SUITE_remote_http() { expect_stat files_in_cache 2 expect_file_count 0 '*' remote # result + manifest expect_contains test.o.*.ccache-log "status code: 401" +fi # ------------------------------------------------------------------------- + # This test fails sporadically. + # Mostly with MSVC 32 bit, but from time to time also with all other + # Windows test runs. + # Probably the http-server is doing something wrong here. +if $RUN_WIN_XFAIL; then TEST "Basic auth failed" start_http_server 12780 remote "somebody:secret123" @@ -175,7 +186,7 @@ SUITE_remote_http() { expect_file_count 0 '*' remote # result + manifest expect_not_contains test.o.*.ccache-log secret123 expect_contains test.o.*.ccache-log "status code: 401" - +fi # ------------------------------------------------------------------------- TEST "IPv6 address" diff --git a/test/suites/remote_only.bash b/test/suites/remote_only.bash index 44e1e8b1..bba25609 100644 --- a/test/suites/remote_only.bash +++ b/test/suites/remote_only.bash @@ -1,3 +1,9 @@ +SUITE_remote_only_PROBE() { + if ! $RUN_WIN_XFAIL; then + echo "remote file is broken on windows." + fi +} + SUITE_remote_only_SETUP() { unset CCACHE_NODIRECT export CCACHE_REMOTE_STORAGE="file:$PWD/remote" diff --git a/test/suites/remote_url.bash b/test/suites/remote_url.bash index 9eba7ea5..d2c56ed8 100644 --- a/test/suites/remote_url.bash +++ b/test/suites/remote_url.bash @@ -25,6 +25,7 @@ SUITE_remote_url() { expect_contains stderr.log "Cannot parse URL" # ------------------------------------------------------------------------- +if $RUN_WIN_XFAIL; then TEST "Reject missing scheme" export CCACHE_REMOTE_STORAGE="/qwerty" @@ -44,4 +45,5 @@ SUITE_remote_url() { export CCACHE_REMOTE_STORAGE="file:foo:bar" $CCACHE_COMPILE -c test.c 2>stderr.log expect_contains stderr.log "The first segment of the relative path can't contain ':'" +fi } diff --git a/test/suites/serialize_diagnostics.bash b/test/suites/serialize_diagnostics.bash index cb610108..5a4df354 100644 --- a/test/suites/serialize_diagnostics.bash +++ b/test/suites/serialize_diagnostics.bash @@ -44,9 +44,10 @@ SUITE_serialize_diagnostics() { expect_stat cache_miss 0 expect_stat files_in_cache 0 expect_equal_content expected.dia test.dia - expect_equal_content expected.stderr test.stderr + expect_equal_text_content expected.stderr test.stderr # ------------------------------------------------------------------------- +if $RUN_WIN_XFAIL; then TEST "--serialize-diagnostics + CCACHE_BASEDIR" mkdir -p dir1/src dir1/include @@ -82,4 +83,5 @@ EOF expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 1 expect_stat files_in_cache 2 +fi } diff --git a/test/suites/split_dwarf.bash b/test/suites/split_dwarf.bash index 0b23ef87..ef75b9af 100644 --- a/test/suites/split_dwarf.bash +++ b/test/suites/split_dwarf.bash @@ -100,6 +100,7 @@ SUITE_split_dwarf() { # differs), so we can't verify filename hashing. # ------------------------------------------------------------------------- +if $RUN_WIN_XFAIL; then TEST "-fdebug-prefix-map and -gsplit-dwarf" cd dir1 @@ -117,7 +118,7 @@ SUITE_split_dwarf() { expect_stat cache_miss 1 expect_stat files_in_cache 2 expect_objdump_not_contains test.o "$(pwd)" 2>/dev/null - +fi # ------------------------------------------------------------------------- TEST "-gsplit-dwarf -g1" diff --git a/test/suites/upgrade.bash b/test/suites/upgrade.bash index 254f02e2..fd26494b 100644 --- a/test/suites/upgrade.bash +++ b/test/suites/upgrade.bash @@ -1,3 +1,10 @@ +SUITE_upgrade_PROBE() { + if ! $RUN_WIN_XFAIL; then + echo "upgrade tests are broken on Windows. (mix between windows and posix path)" + return + fi +} + SUITE_upgrade() { # ------------------------------------------------------------------------- TEST "Default cache config/directory without XDG variables" |