[compiler-rt] 0f9f247 - [gcov][test] Add -dumpdir ./

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed May 17 11:54:44 PDT 2023


Author: Fangrui Song
Date: 2023-05-17T11:54:38-07:00
New Revision: 0f9f2473613519b18004158835914bc25fcb2b40

URL: https://github.com/llvm/llvm-project/commit/0f9f2473613519b18004158835914bc25fcb2b40
DIFF: https://github.com/llvm/llvm-project/commit/0f9f2473613519b18004158835914bc25fcb2b40.diff

LOG: [gcov][test] Add -dumpdir ./

These tests rely on an unintended behavior that when the driver performs both
compilation and linking phases, the .gcno & .gcda files are placed in PWD. The
behavior will be fixed to respect -o (match -ftime-trace, -gsplit-dwarf, and
GCC).

Add -dumpdir ./ so that the tests will work with or without the behavior change,
and make it easy to compare the coverage behavior with GCC.

Added: 
    

Modified: 
    compiler-rt/test/profile/Posix/gcov-destructor.c
    compiler-rt/test/profile/Posix/gcov-dlopen.c
    compiler-rt/test/profile/Posix/gcov-execlp.c
    compiler-rt/test/profile/Posix/gcov-fork.c
    compiler-rt/test/profile/Posix/gcov-shared-flush.c
    compiler-rt/test/profile/Posix/instrprof-gcov-parallel.test
    compiler-rt/test/profile/gcov-__gcov_flush-terminate.c
    compiler-rt/test/profile/gcov-basic.c
    compiler-rt/test/profile/gcov-complex-line.c
    compiler-rt/test/profile/gcov-dump-and-remove.c
    compiler-rt/test/profile/instrprof-gcov-exceptions.test
    compiler-rt/test/profile/instrprof-gcov-multiple-bbs-single-line.test
    compiler-rt/test/profile/instrprof-gcov-multithread_fork.test
    compiler-rt/test/profile/instrprof-gcov-one-line-function.test
    compiler-rt/test/profile/instrprof-gcov-switch.test

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/profile/Posix/gcov-destructor.c b/compiler-rt/test/profile/Posix/gcov-destructor.c
index c6fa144bcb39f..bd1e0d2dde079 100644
--- a/compiler-rt/test/profile/Posix/gcov-destructor.c
+++ b/compiler-rt/test/profile/Posix/gcov-destructor.c
@@ -1,6 +1,6 @@
 /// Test that destructors and destructors whose priorities are greater than 100 are tracked.
 // RUN: mkdir -p %t.dir && cd %t.dir
-// RUN: %clang --coverage %s -o %t
+// RUN: %clang --coverage %s -o %t -dumpdir ./
 // RUN: rm -f gcov-destructor.gcda && %run %t
 // RUN: llvm-cov gcov -t gcov-destructor.gcda | FileCheck %s
 // UNSUPPORTED: darwin

diff  --git a/compiler-rt/test/profile/Posix/gcov-dlopen.c b/compiler-rt/test/profile/Posix/gcov-dlopen.c
index 86b4550139cf6..ceac6ac355ee6 100644
--- a/compiler-rt/test/profile/Posix/gcov-dlopen.c
+++ b/compiler-rt/test/profile/Posix/gcov-dlopen.c
@@ -6,10 +6,10 @@
 // RUN: echo 'void func1(int k) {}' > func1.c
 // RUN: echo 'void func2(int k) {}' > func2.c
 // RUN: echo 'void func3(int k) {}' > func3.c
-// RUN: %clang --coverage -fPIC -shared func1.c -o func1.so
-// RUN: %clang --coverage -fPIC -shared func2.c -o func2.so
-// RUN: %clang --coverage -fPIC -shared func3.c -o func3.so
-// RUN: %clang --coverage -fPIC -rpath %t.d %s -o %t
+// RUN: %clang --coverage -fPIC -shared func1.c -o func1.so -dumpdir ./
+// RUN: %clang --coverage -fPIC -shared func2.c -o func2.so -dumpdir ./
+// RUN: %clang --coverage -fPIC -shared func3.c -o func3.so -dumpdir ./
+// RUN: %clang --coverage -fPIC -rpath %t.d %s -o %t -dumpdir ./
 
 /// Test with two dlopened libraries.
 // RUN: rm -f gcov-dlopen.gcda func1.gcda func2.gcda
@@ -22,7 +22,7 @@
 // FUNC2:     1:    1:void func2(int k) {}
 
 /// Test with three dlopened libraries.
-// RUN: %clang -DUSE_LIB3 --coverage -fPIC -rpath %t.d %s -o %t
+// RUN: %clang -DUSE_LIB3 --coverage -fPIC -rpath %t.d %s -o %t -dumpdir ./
 // RUN: rm -f gcov-dlopen.gcda func1.gcda func2.gcda func3.gcda
 // RUN: %run %t
 // RUN: llvm-cov gcov -t gcov-dlopen.gcda | FileCheck %s --check-prefix=LIB3

diff  --git a/compiler-rt/test/profile/Posix/gcov-execlp.c b/compiler-rt/test/profile/Posix/gcov-execlp.c
index 362f59516d217..4eba1c114b3ce 100644
--- a/compiler-rt/test/profile/Posix/gcov-execlp.c
+++ b/compiler-rt/test/profile/Posix/gcov-execlp.c
@@ -2,12 +2,12 @@
 /// fork/exec* so the lines before exec* are counted once while succeeding
 /// lines are not counted.
 // RUN: mkdir -p %t.d && cd %t.d
-// RUN: %clang --coverage %s -o %t
+// RUN: %clang --coverage %s -o %t -dumpdir ./
 // RUN: test -f gcov-execlp.gcno
 // RUN: rm -f gcov-execlp.gcda && %run %t
 // RUN: llvm-cov gcov -t gcov-execlp.gcda | FileCheck %s --check-prefixes=CHECK,EXECLP
 
-// RUN: %clang --coverage -DEXECVP %s -o %t
+// RUN: %clang --coverage -DEXECVP %s -o %t -dumpdir ./
 // RUN: rm -f gcov-execlp.gcda && %run %t
 // RUN: llvm-cov gcov -t gcov-execlp.gcda | FileCheck %s --check-prefixes=CHECK,EXECVP
 

diff  --git a/compiler-rt/test/profile/Posix/gcov-fork.c b/compiler-rt/test/profile/Posix/gcov-fork.c
index e66690a961e2e..824f1fdf599f4 100644
--- a/compiler-rt/test/profile/Posix/gcov-fork.c
+++ b/compiler-rt/test/profile/Posix/gcov-fork.c
@@ -2,7 +2,7 @@
 /// fork/exec* so the lines before fork are counted once while succeeding
 /// lines are counted twice.
 // RUN: mkdir -p %t.d && cd %t.d
-// RUN: %clang --coverage %s -o %t
+// RUN: %clang --coverage %s -o %t -dumpdir ./
 // RUN: test -f gcov-fork.gcno
 
 // RUN: rm -f gcov-fork.gcda && %run %t

diff  --git a/compiler-rt/test/profile/Posix/gcov-shared-flush.c b/compiler-rt/test/profile/Posix/gcov-shared-flush.c
index 5604558509f91..40e3159dcb281 100644
--- a/compiler-rt/test/profile/Posix/gcov-shared-flush.c
+++ b/compiler-rt/test/profile/Posix/gcov-shared-flush.c
@@ -3,12 +3,12 @@
 
 // RUN: mkdir -p %t.d && cd %t.d
 
-// RUN: %clang -E -DSHARED %s -o shared.c
-// RUN: %clang --coverage -fPIC -shared shared.c -o libfunc.so
+// RUN: %clang -E -DSHARED %s -o shared.c -dumpdir ./
+// RUN: %clang --coverage -fPIC -shared shared.c -o libfunc.so -dumpdir ./
 // RUN: test -f shared.gcno
 
 /// Test the case where we exit abruptly after calling __gcov_dump, which means we don't write out the counters at exit.
-// RUN: %clang -DEXIT_ABRUPTLY -DSHARED_CALL_BEFORE_FLUSH -DSHARED_CALL_AFTER_FLUSH --coverage %s -L%t.d -rpath %t.d -lfunc -o %t
+// RUN: %clang -DEXIT_ABRUPTLY -DSHARED_CALL_BEFORE_FLUSH -DSHARED_CALL_AFTER_FLUSH --coverage %s -L%t.d -rpath %t.d -lfunc -o %t -dumpdir ./
 // RUN: test -f gcov-shared-flush.gcno
 
 // RUN: rm -f gcov-shared-flush.gcda shared.gcda
@@ -22,7 +22,7 @@
 // SHARED: 1: {{[[0-9]+}}:void foo(int n)
 
 /// Test the case where we exit normally and we have a call to the shared library function before __gcov_dump.
-// RUN: %clang -DSHARED_CALL_BEFORE_FLUSH --coverage %s -L%t.d -rpath %t.d -lfunc -o %t
+// RUN: %clang -DSHARED_CALL_BEFORE_FLUSH --coverage %s -L%t.d -rpath %t.d -lfunc -o %t -dumpdir ./
 // RUN: test -f gcov-shared-flush.gcno
 
 // RUN: rm -f gcov-shared-flush.gcda shared.gcda
@@ -41,7 +41,7 @@
 // SHARED_ONCE: 1: {{[0-9]+}}:void foo(int n)
 
 // # Test the case where we exit normally and we have a call to the shared library function after __gcov_dump.
-// RUN: %clang -DSHARED_CALL_AFTER_FLUSH --coverage %s -L%t.d -rpath %t.d -lfunc -o %t
+// RUN: %clang -DSHARED_CALL_AFTER_FLUSH --coverage %s -L%t.d -rpath %t.d -lfunc -o %t -dumpdir ./
 // RUN: test -f gcov-shared-flush.gcno
 
 // RUN: rm -f gcov-shared-flush.gcda shared.gcda
@@ -58,7 +58,7 @@
 // AFTER:      1: {{[0-9]+}}:  bar(5);
 
 // # Test the case where we exit normally and we have calls to the shared library function before and after __gcov_dump.
-// RUN: %clang -DSHARED_CALL_BEFORE_FLUSH -DSHARED_CALL_AFTER_FLUSH --coverage %s -L%t.d -rpath %t.d -lfunc -o %t
+// RUN: %clang -DSHARED_CALL_BEFORE_FLUSH -DSHARED_CALL_AFTER_FLUSH --coverage %s -L%t.d -rpath %t.d -lfunc -o %t -dumpdir ./
 // RUN: test -f gcov-shared-flush.gcno
 
 // RUN: rm -f gcov-shared-flush.gcda shared.gcda

diff  --git a/compiler-rt/test/profile/Posix/instrprof-gcov-parallel.test b/compiler-rt/test/profile/Posix/instrprof-gcov-parallel.test
index 0c7198e3c4e9e..df10f35359a80 100644
--- a/compiler-rt/test/profile/Posix/instrprof-gcov-parallel.test
+++ b/compiler-rt/test/profile/Posix/instrprof-gcov-parallel.test
@@ -1,8 +1,8 @@
 RUN: mkdir -p %t.d
 RUN: cd %t.d
 
-RUN: %clang -o %t.driver %S/../Inputs/instrprof-gcov-parallel.driver.c
-RUN: %clang --coverage -o %t.target %S/../Inputs/instrprof-gcov-parallel.target.c
+RUN: %clang -o %t.driver %S/../Inputs/instrprof-gcov-parallel.driver.c -dumpdir ./
+RUN: %clang --coverage -o %t.target %S/../Inputs/instrprof-gcov-parallel.target.c -dumpdir ./
 RUN: test -f instrprof-gcov-parallel.target.gcno
 
 RUN: rm -f instrprof-gcov-parallel.target.gcda

diff  --git a/compiler-rt/test/profile/gcov-__gcov_flush-terminate.c b/compiler-rt/test/profile/gcov-__gcov_flush-terminate.c
index 649538dc2aaf1..ca13a0896a7b2 100644
--- a/compiler-rt/test/profile/gcov-__gcov_flush-terminate.c
+++ b/compiler-rt/test/profile/gcov-__gcov_flush-terminate.c
@@ -1,7 +1,7 @@
 /// https://bugs.llvm.org/show_bug.cgi?id=38067
 /// An abnormal exit does not clear execution counts of subsequent instructions.
 // RUN: mkdir -p %t.dir && cd %t.dir
-// RUN: %clang --coverage %s -o %t
+// RUN: %clang --coverage %s -o %t -dumpdir ./
 // RUN: test -f gcov-__gcov_flush-terminate.gcno
 
 // RUN: rm -f gcov-__gcov_flush-terminate.gcda && %expect_crash %run %t

diff  --git a/compiler-rt/test/profile/gcov-basic.c b/compiler-rt/test/profile/gcov-basic.c
index 0d8be6d7de087..a44ffd7f61fa2 100644
--- a/compiler-rt/test/profile/gcov-basic.c
+++ b/compiler-rt/test/profile/gcov-basic.c
@@ -1,27 +1,27 @@
 // RUN: mkdir -p %t.dir && cd %t.dir
 
 /// gcov 3.4 redesigned the format and changed the extension from .da to .gcda
-// RUN: %clang --coverage -Xclang -coverage-version='304*' %s -o %t
+// RUN: %clang --coverage -Xclang -coverage-version='304*' %s -o %t -dumpdir ./
 // RUN: rm -f gcov-basic.gcda && %run %t && %run %t a
 // RUN: llvm-cov gcov -t gcov-basic.gcno | FileCheck %s
 
 /// r173147: split checksum into cfg checksum and line checksum.
-// RUN: %clang --coverage -Xclang -coverage-version='407*' %s -o %t
+// RUN: %clang --coverage -Xclang -coverage-version='407*' %s -o %t -dumpdir ./
 // RUN: rm -f gcov-basic.gcda && %run %t && %run %t a
 // RUN: llvm-cov gcov -t gcov-basic.gcno | FileCheck %s
 
 /// r189778: the exit block moved from the last to the second.
-// RUN: %clang --coverage -Xclang -coverage-version='408*' %s -o %t
+// RUN: %clang --coverage -Xclang -coverage-version='408*' %s -o %t -dumpdir ./
 // RUN: rm -f gcov-basic.gcda && %run %t && %run %t a
 // RUN: llvm-cov gcov -t gcov-basic.gcno
 
 /// PR gcov-profile/48463
-// RUN: %clang --coverage -Xclang -coverage-version='800*' %s -o %t
+// RUN: %clang --coverage -Xclang -coverage-version='800*' %s -o %t -dumpdir ./
 // RUN: rm -f gcov-basic.gcda && %run %t && %run %t a
 // RUN: llvm-cov gcov -t gcov-basic.gcno
 
 /// PR gcov-profile/84846, r269678
-// RUN: %clang --coverage -Xclang -coverage-version='900*' %s -o %t
+// RUN: %clang --coverage -Xclang -coverage-version='900*' %s -o %t -dumpdir ./
 // RUN: rm -f gcov-basic.gcda && %run %t && %run %t a
 // RUN: llvm-cov gcov -t gcov-basic.gcno
 

diff  --git a/compiler-rt/test/profile/gcov-complex-line.c b/compiler-rt/test/profile/gcov-complex-line.c
index 86286c4a93a58..12384ae797253 100644
--- a/compiler-rt/test/profile/gcov-complex-line.c
+++ b/compiler-rt/test/profile/gcov-complex-line.c
@@ -2,7 +2,7 @@
 // handle complex block graphs by skipping zero count cycles.
 //
 // RUN: mkdir -p %t.dir && cd %t.dir
-// RUN: %clang --coverage %s -o %t
+// RUN: %clang --coverage %s -o %t -dumpdir ./
 // RUN: rm -f gcov-complex-line.gcda && %run %t
 // RUN: llvm-cov gcov -t gcov-complex-line.c | FileCheck %s
 

diff  --git a/compiler-rt/test/profile/gcov-dump-and-remove.c b/compiler-rt/test/profile/gcov-dump-and-remove.c
index c35640f93b3de..f0e1af3f22a12 100644
--- a/compiler-rt/test/profile/gcov-dump-and-remove.c
+++ b/compiler-rt/test/profile/gcov-dump-and-remove.c
@@ -2,7 +2,7 @@
 /// Windows while the process is still running. In addition, test we create
 /// a new .gcda on flush, so there is a file when the process exists.
 // RUN: mkdir -p %t.d && cd %t.d
-// RUN: %clang --coverage -o %t %s
+// RUN: %clang --coverage -o %t %s -dumpdir ./
 // RUN: test -f gcov-dump-and-remove.gcno
 
 // RUN: rm -f gcov-dump-and-remove.gcda && %run %t

diff  --git a/compiler-rt/test/profile/instrprof-gcov-exceptions.test b/compiler-rt/test/profile/instrprof-gcov-exceptions.test
index a3dcc55aaf5b6..528ba70d657a7 100644
--- a/compiler-rt/test/profile/instrprof-gcov-exceptions.test
+++ b/compiler-rt/test/profile/instrprof-gcov-exceptions.test
@@ -2,7 +2,7 @@ RUN: mkdir -p %t.d
 RUN: cd %t.d
 
 # Test with exceptions disabled.
-RUN: %clangxx --coverage -o %t %S/Inputs/instrprof-gcov-exceptions.cpp -fno-exceptions
+RUN: %clangxx --coverage -o %t %S/Inputs/instrprof-gcov-exceptions.cpp -fno-exceptions -dumpdir ./
 RUN: test -f instrprof-gcov-exceptions.gcno
 
 RUN: rm -f instrprof-gcov-exceptions.gcda
@@ -11,7 +11,7 @@ RUN: llvm-cov gcov instrprof-gcov-exceptions.gcda
 RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-gcov-exceptions.cpp.gcov %S/Inputs/instrprof-gcov-exceptions.cpp.gcov
 
 # Test with exceptions enabled, the result in terms of line counts should be the same.
-RUN: %clangxx --coverage -o %t %S/Inputs/instrprof-gcov-exceptions.cpp
+RUN: %clangxx --coverage -o %t %S/Inputs/instrprof-gcov-exceptions.cpp -dumpdir ./
 RUN: test -f instrprof-gcov-exceptions.gcno
 
 RUN: rm -f instrprof-gcov-exceptions.gcda

diff  --git a/compiler-rt/test/profile/instrprof-gcov-multiple-bbs-single-line.test b/compiler-rt/test/profile/instrprof-gcov-multiple-bbs-single-line.test
index 66b6429208a0f..db0dd14be76b0 100644
--- a/compiler-rt/test/profile/instrprof-gcov-multiple-bbs-single-line.test
+++ b/compiler-rt/test/profile/instrprof-gcov-multiple-bbs-single-line.test
@@ -1,7 +1,7 @@
 RUN: mkdir -p %t.d
 RUN: cd %t.d
 
-RUN: %clang --coverage -o %t %S/Inputs/instrprof-gcov-multiple-bbs-single-line.c
+RUN: %clang --coverage -o %t %S/Inputs/instrprof-gcov-multiple-bbs-single-line.c -dumpdir ./
 RUN: test -f instrprof-gcov-multiple-bbs-single-line.gcno
 
 RUN: rm -f instrprof-gcov-multiple-bbs-single-line.gcda

diff  --git a/compiler-rt/test/profile/instrprof-gcov-multithread_fork.test b/compiler-rt/test/profile/instrprof-gcov-multithread_fork.test
index e416a3077b19b..24dfccf39aa0b 100644
--- a/compiler-rt/test/profile/instrprof-gcov-multithread_fork.test
+++ b/compiler-rt/test/profile/instrprof-gcov-multithread_fork.test
@@ -3,7 +3,7 @@ UNSUPPORTED: target={{.*windows.*}}
 RUN: mkdir -p %t.d
 RUN: cd %t.d
 
-RUN: %clangxx --coverage -lpthread -o %t %S/Inputs/instrprof-gcov-multithread_fork.cpp
+RUN: %clangxx --coverage -lpthread -o %t %S/Inputs/instrprof-gcov-multithread_fork.cpp -dumpdir ./
 RUN: test -f instrprof-gcov-multithread_fork.gcno
 
 RUN: rm -f instrprof-gcov-multithread_fork.gcda

diff  --git a/compiler-rt/test/profile/instrprof-gcov-one-line-function.test b/compiler-rt/test/profile/instrprof-gcov-one-line-function.test
index d67c21a863bfc..fc3bde56720b7 100644
--- a/compiler-rt/test/profile/instrprof-gcov-one-line-function.test
+++ b/compiler-rt/test/profile/instrprof-gcov-one-line-function.test
@@ -1,7 +1,7 @@
 RUN: mkdir -p %t.d
 RUN: cd %t.d
 
-RUN: %clang --coverage -o %t %S/Inputs/instrprof-gcov-one-line-function.c
+RUN: %clang --coverage -o %t %S/Inputs/instrprof-gcov-one-line-function.c -dumpdir ./
 RUN: test -f instrprof-gcov-one-line-function.gcno
 RUN: rm -f instrprof-gcov-one-line-function.gcda
 RUN: %run %t

diff  --git a/compiler-rt/test/profile/instrprof-gcov-switch.test b/compiler-rt/test/profile/instrprof-gcov-switch.test
index 9c43a93dc646a..736d737d9fbbc 100644
--- a/compiler-rt/test/profile/instrprof-gcov-switch.test
+++ b/compiler-rt/test/profile/instrprof-gcov-switch.test
@@ -1,14 +1,14 @@
 RUN: mkdir -p %t.d
 RUN: cd %t.d
 
-RUN: %clang --coverage -o %t %S/Inputs/instrprof-gcov-switch1.c
+RUN: %clang --coverage -o %t %S/Inputs/instrprof-gcov-switch1.c -dumpdir ./
 RUN: test -f instrprof-gcov-switch1.gcno
 RUN: rm -f instrprof-gcov-switch1.gcda
 RUN: %run %t
 RUN: llvm-cov gcov instrprof-gcov-switch1.gcda
 RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-gcov-switch1.c.gcov %S/Inputs/instrprof-gcov-switch1.c.gcov
 
-RUN: %clang --coverage -o %t %S/Inputs/instrprof-gcov-switch2.c
+RUN: %clang --coverage -o %t %S/Inputs/instrprof-gcov-switch2.c -dumpdir ./
 RUN: test -f instrprof-gcov-switch2.gcno
 RUN: rm -f instrprof-gcov-switch2.gcda
 RUN: %run %t


        


More information about the llvm-commits mailing list