]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Add more tests for dependency file content
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 7 Jun 2020 18:04:05 +0000 (20:04 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 7 Jun 2020 18:05:43 +0000 (20:05 +0200)
test/run
test/suites/direct.bash

index 6eb0100d94fcca8895bac3a537149e48f20e3525..2bb03e65042055a1f877c1c0aebf0e6be42d401b 100755 (executable)
--- a/test/run
+++ b/test/run
@@ -168,6 +168,18 @@ expect_equal_files() {
     fi
 }
 
+expect_equal_text_files() {
+    if [ ! -e "$1" ]; then
+        test_failed "expect_equal_files: $1 missing"
+    fi
+    if [ ! -e "$2" ]; then
+        test_failed "expect_equal_files: $2 missing"
+    fi
+    if ! cmp -s "$1" "$2"; then
+        test_failed "$1 and $2 differ: $(echo; diff -u "$1" "$2")"
+    fi
+}
+
 expect_different_files() {
     if [ ! -e "$1" ]; then
         test_failed "expect_different_files: $1 missing"
index 1d3a384dc7e3cf729eeb50d4233cfbdc918024df..34f78e8cd1af26caa0f1e491bf99aa64f1cdef04 100644 (file)
@@ -183,6 +183,47 @@ EOF
     $CCACHE_COMPILE -MMD -c a/source.c -o a/source.o
     expect_file_content a/source.d "a/source.o: a/source.c"
 
+    # -------------------------------------------------------------------------
+    for dep_args in "-MMD" "-MMD -MF foo.d" "-Wp,-MMD,foo.d"; do
+        for obj_args in "" "-o bar.o"; do
+            if [ "$dep_args" != "-MMD" ]; then
+                dep_file=foo.d
+                another_dep_file=foo.d
+            elif [ -z "$obj_args" ]; then
+                dep_file=test.d
+                another_dep_file=another.d
+            else
+                dep_file=bar.d
+                another_dep_file=another.d
+            fi
+
+            TEST "Dependency file content, $dep_args $obj_args"
+            # -----------------------------------------------------------------
+
+            $REAL_COMPILER -c test.c $dep_args $obj_args
+            mv $dep_file $dep_file.real
+
+            $REAL_COMPILER -c test.c $dep_args -o another.o
+            mv $another_dep_file another.d.real
+
+            # cache miss
+            $CCACHE_COMPILE -c test.c $dep_args $obj_args
+            expect_stat 'cache hit (direct)' 0
+            expect_stat 'cache miss' 1
+            expect_equal_text_files $dep_file.real $dep_file
+
+            # cache hit
+            $CCACHE_COMPILE -c test.c $dep_args $obj_args
+            expect_stat 'cache hit (direct)' 1
+            expect_stat 'cache miss' 1
+            expect_equal_text_files $dep_file.real $dep_file
+
+            # change object file name
+            $CCACHE_COMPILE -c test.c $dep_args -o another.o
+            expect_equal_text_files another.d.real $another_dep_file
+        done
+    done
+
     # -------------------------------------------------------------------------
     TEST "Dependency file content"