From: Anders Björklund Date: Sun, 28 Jul 2019 09:41:09 +0000 (+0200) Subject: Added remaining changes to make tests run on MSYS (#246) X-Git-Tag: v4.0~865 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=93e1c97f0010e35795b642a58314090b12473adf;p=thirdparty%2Fccache.git Added remaining changes to make tests run on MSYS (#246) * Skip test that require symlinks, on Windows/Cygwin * Don't use symlinks for lockfiles on Cygwin * Seems like objdump has issues on Windows/Cygwin * Make it possible to run suite in isolation --- diff --git a/src/lockfile.c b/src/lockfile.c index aa4502972..d0b840025 100644 --- a/src/lockfile.c +++ b/src/lockfile.c @@ -42,7 +42,7 @@ lockfile_acquire(const char *path, unsigned staleness_limit) free(my_content); my_content = format("%s:%d:%d", hostname, (int)getpid(), (int)time(NULL)); -#ifdef _WIN32 +#if defined(_WIN32) || defined(__CYGWIN__) int fd = open(lockfile, O_WRONLY|O_CREAT|O_EXCL|O_BINARY, 0666); if (fd == -1) { int saved_errno = errno; diff --git a/test/run b/test/run index 3c0136c16..aa47df835 100755 --- a/test/run +++ b/test/run @@ -117,6 +117,8 @@ objdump_cmd() { xcrun dwarfdump -r0 $1 elif $HOST_OS_FREEBSD; then objdump -W $1 + elif $HOST_OS_WINDOWS || $HOST_OS_CYGWIN; then + strings $1 # for some reason objdump only shows the basename of the file, so fall back to brute force and ignorance else objdump -g $1 fi @@ -326,6 +328,7 @@ HOST_OS_APPLE=false HOST_OS_LINUX=false HOST_OS_FREEBSD=false HOST_OS_WINDOWS=false +HOST_OS_CYGWIN=false compiler_version="`$COMPILER --version 2>&1 | head -1`" case $compiler_version in @@ -354,6 +357,9 @@ case $(uname -s) in *MINGW*|*mingw*) HOST_OS_WINDOWS=true ;; + *CYGWIN*|*MSYS*) + HOST_OS_CYGWIN=true + ;; *Darwin*) HOST_OS_APPLE=true ;; diff --git a/test/suites/base.bash b/test/suites/base.bash index f031e9b8d..34e8deb86 100644 --- a/test/suites/base.bash +++ b/test/suites/base.bash @@ -968,6 +968,7 @@ EOF expect_stat 'cache miss' 1 # ------------------------------------------------------------------------- +if ! $HOST_OS_WINDOWS && ! $HOST_OS_CYGWIN; then TEST "Symlink to source directory" mkdir dir @@ -988,7 +989,9 @@ EOF test_failed "Incorrect header file used" fi +fi # ------------------------------------------------------------------------- +if ! $HOST_OS_WINDOWS && ! $HOST_OS_CYGWIN; then TEST "Symlink to source file" mkdir dir @@ -1009,6 +1012,7 @@ EOF test_failed "Incorrect header file used" fi +fi # ------------------------------------------------------------------------- TEST ".incbin" diff --git a/test/suites/basedir.bash b/test/suites/basedir.bash index 4660dc29e..ba623a8fc 100644 --- a/test/suites/basedir.bash +++ b/test/suites/basedir.bash @@ -45,6 +45,7 @@ SUITE_basedir() { expect_stat 'cache miss' 2 # ------------------------------------------------------------------------- + if ! $HOST_OS_WINDOWS && ! $HOST_OS_CYGWIN; then TEST "Path normalization" cd dir1 @@ -64,6 +65,7 @@ SUITE_basedir() { expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 + fi # ------------------------------------------------------------------------- TEST "Rewriting in stderr" diff --git a/test/suites/debug_prefix_map.bash b/test/suites/debug_prefix_map.bash index b68cf462a..553d7ffe5 100644 --- a/test/suites/debug_prefix_map.bash +++ b/test/suites/debug_prefix_map.bash @@ -23,6 +23,8 @@ EOF grep_cmd() { if $HOST_OS_APPLE; then grep "( \"$1\" )" + elif $HOST_OS_WINDOWS || $HOST_OS_CYGWIN; then + test -n "$2" && grep -E "$1|$2" || grep "$1" # accept a relative path for source code, in addition to relocation dir else grep ": $1[[:space:]]*$" fi @@ -41,6 +43,9 @@ SUITE_debug_prefix_map() { if objdump_cmd test.o | grep_cmd "`pwd`" >/dev/null 2>&1; then test_failed "Source dir (`pwd`) found in test.o" fi + if ! objdump_cmd test.o | grep_cmd "dir" src/test.c >/dev/null 2>&1; then + test_failed "Relocation (dir) not found in test.o" + fi cd ../dir2 CCACHE_BASEDIR=`pwd` $CCACHE_COMPILE -I`pwd`/include -g -fdebug-prefix-map=`pwd`=dir -c `pwd`/src/test.c -o `pwd`/test.o @@ -64,7 +69,7 @@ SUITE_debug_prefix_map() { if objdump_cmd test.o | grep_cmd "`pwd`" >/dev/null 2>&1; then test_failed "Source dir (`pwd`) found in test.o" fi - if ! objdump_cmd test.o | grep_cmd "name" >/dev/null 2>&1; then + if ! objdump_cmd test.o | grep_cmd "name" src/test.c >/dev/null 2>&1; then test_failed "Relocation (name) not found in test.o" fi diff --git a/test/suites/masquerading.bash b/test/suites/masquerading.bash index fbbb78f27..1ce32044e 100644 --- a/test/suites/masquerading.bash +++ b/test/suites/masquerading.bash @@ -4,6 +4,10 @@ SUITE_masquerading_PROBE() { if [ "$(dirname $compiler_binary)" != . ]; then echo "compiler ($compiler_binary) not taken from PATH" fi + if $HOST_OS_WINDOWS || $HOST_OS_CYGWIN; then + echo "symlinks not supported on $(uname -s)" + return + fi } SUITE_masquerading_SETUP() { diff --git a/test/suites/upgrade.bash b/test/suites/upgrade.bash index 202dcd2de..81fd13364 100644 --- a/test/suites/upgrade.bash +++ b/test/suites/upgrade.bash @@ -1,7 +1,7 @@ SUITE_upgrade() { TEST "Keep maxfiles and maxsize settings" - rm $CCACHE_CONFIGPATH + rm -f $CCACHE_CONFIGPATH mkdir -p $CCACHE_DIR/0 echo "0 0 0 0 0 0 0 0 0 0 0 0 0 2000 131072" >$CCACHE_DIR/0/stats expect_stat 'max files' 32000 diff --git a/unittest/test_lockfile.c b/unittest/test_lockfile.c index 62b36e483..3b8cfba1d 100644 --- a/unittest/test_lockfile.c +++ b/unittest/test_lockfile.c @@ -28,7 +28,7 @@ TEST(acquire_should_create_symlink) { lockfile_acquire("test", 1000); -#ifdef _WIN32 +#if defined(_WIN32) || defined(__CYGWIN__) CHECK(path_exists("test.lock")); #else CHECK(is_symlink("test.lock")); @@ -47,7 +47,7 @@ TEST(lock_breaking) { char *p; -#ifdef _WIN32 +#if defined(_WIN32) || defined(__CYGWIN__) create_file("test.lock", "foo"); create_file("test.lock.lock", "foo"); #else @@ -56,7 +56,7 @@ TEST(lock_breaking) #endif CHECK(lockfile_acquire("test", 1000)); -#ifdef _WIN32 +#if defined(_WIN32) || defined(__CYGWIN__) p = read_text_file("test.lock", 0); #else p = x_readlink("test.lock"); @@ -68,7 +68,7 @@ TEST(lock_breaking) free(p); } -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__CYGWIN__) TEST(failed_lock_breaking) { create_file("test.lock", "");