]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Added remaining changes to make tests run on MSYS (#246)
authorAnders Björklund <anders.f.bjorklund@gmail.com>
Sun, 28 Jul 2019 09:41:09 +0000 (11:41 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 28 Jul 2019 09:41:09 +0000 (11:41 +0200)
* 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

src/lockfile.c
test/run
test/suites/base.bash
test/suites/basedir.bash
test/suites/debug_prefix_map.bash
test/suites/masquerading.bash
test/suites/upgrade.bash
unittest/test_lockfile.c

index aa45029727f37ec911c338a78e78e47c1d0b2b83..d0b8400257678113a36a8447edb4caf6dfdd756b 100644 (file)
@@ -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;
index 3c0136c1642a0d5766ef3418eba3fb693ec0abcc..aa47df83548c269f11d02457f2c205520e0980e1 100755 (executable)
--- 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
         ;;
index f031e9b8ddbcf2cdcceaa71d9053f304a2c72ab1..34e8deb860ce69a2eb311c7606e0f90faecef80b 100644 (file)
@@ -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"
 
index 4660dc29ee601a9197872a4cf1639051498a5eb5..ba623a8fc9294eaeef097a5c6c2af83eb4f9bb86 100644 (file)
@@ -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"
 
index b68cf462ab6f25fb4b1b68816d30a96d953ab475..553d7ffe5c4951cb19ae95629ac05cb2d09ecfeb 100644 (file)
@@ -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
 
index fbbb78f27cdb84446d063bdc3f24993d94645071..1ce32044ecc604545e9ea185bb7835a7ec85702f 100644 (file)
@@ -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() {
index 202dcd2de61e3d8f31c429cc5763101ca6cb67a9..81fd133640c2aeaac49d1bb1fbf7c7f62d08ff38 100644 (file)
@@ -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
index 62b36e48323a7da2995445cc63ed604587671fea..3b8cfba1d670ad1759ada8e8aa711acabafbe0c7 100644 (file)
@@ -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", "");