]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Fix debug_prefix_map suite
authorTimofei Kushnir <timophey@rdp.ru>
Wed, 28 Feb 2018 07:48:10 +0000 (10:48 +0300)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 6 Mar 2018 19:47:04 +0000 (20:47 +0100)
test/suites/debug_prefix_map.bash

index a3a22a8e0721be3919834760dc9243436c321fde..256d4cbc23c12b1eff27c3a4f55dd662622fd820 100644 (file)
@@ -19,6 +19,22 @@ EOF
     backdate dir1/include/test.h dir2/include/test.h
 }
 
+objdump_cmd() {
+    if $HOST_OS_APPLE; then
+        xcrun dwarfdump -r0 $1
+    else
+        objdump -g $1
+    fi
+}
+
+grep_cmd() {
+    if $HOST_OS_APPLE; then
+        grep "( \"$1\" )"
+    else
+        grep ": $1[[:space:]]*$"
+    fi
+}
+
 SUITE_debug_prefix_map() {
     # -------------------------------------------------------------------------
     TEST "Mapping of debug info CWD"
@@ -29,7 +45,7 @@ SUITE_debug_prefix_map() {
     expect_stat 'cache hit (preprocessed)' 0
     expect_stat 'cache miss' 1
     expect_stat 'files in cache' 2
-    if grep -E "[^=]`pwd`[^=]" test.o >/dev/null 2>&1; then
+    if objdump_cmd test.o | grep_cmd "`pwd`" >/dev/null 2>&1; then
         test_failed "Source dir (`pwd`) found in test.o"
     fi
 
@@ -39,7 +55,7 @@ SUITE_debug_prefix_map() {
     expect_stat 'cache hit (preprocessed)' 0
     expect_stat 'cache miss' 1
     expect_stat 'files in cache' 2
-    if grep -E "[^=]`pwd`[^=]" test.o >/dev/null 2>&1; then
+    if objdump_cmd test.o | grep_cmd "`pwd`" >/dev/null 2>&1; then
         test_failed "Source dir (`pwd`) found in test.o"
     fi
 
@@ -52,10 +68,10 @@ SUITE_debug_prefix_map() {
     expect_stat 'cache hit (preprocessed)' 0
     expect_stat 'cache miss' 1
     expect_stat 'files in cache' 2
-    if grep -E "[^=]`pwd`[^=]" test.o >/dev/null 2>&1; then
+    if objdump_cmd test.o | grep_cmd "`pwd`" >/dev/null 2>&1; then
         test_failed "Source dir (`pwd`) found in test.o"
     fi
-    if ! grep "name" test.o >/dev/null 2>&1; then
+    if ! objdump_cmd test.o | grep_cmd "name" >/dev/null 2>&1; then
         test_failed "Relocation (name) not found in test.o"
     fi
 
@@ -65,7 +81,7 @@ SUITE_debug_prefix_map() {
     expect_stat 'cache hit (preprocessed)' 0
     expect_stat 'cache miss' 1
     expect_stat 'files in cache' 2
-    if grep -E "[^=]`pwd`[^=]" test.o >/dev/null 2>&1; then
+    if objdump_cmd test.o | grep_cmd "`pwd`" >/dev/null 2>&1; then
         test_failed "Source dir (`pwd`) found in test.o"
     fi
 }