[PATCH] D47292: [libFuzzer] [NFC] Generalize DSO tests to work even when files are moved.

George Karpenkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 12 15:45:26 PDT 2018


george.karpenkov updated this revision to Diff 151052.
george.karpenkov added a comment.

@vitalybuka Turns out the simple trick I was using for Darwin did not work for the Linux linker, and more invasive changes were required.
What do you think? I don't see a way to do this without introducing extra substitutions, even though they are ugly.
I don't really mind the ugliness in testing configuration scripts here.


https://reviews.llvm.org/D47292

Files:
  test/fuzzer/dso.test
  test/fuzzer/dump_coverage.test
  test/lit.common.cfg


Index: test/lit.common.cfg
===================================================================
--- test/lit.common.cfg
+++ test/lit.common.cfg
@@ -310,16 +310,24 @@
 
 
 if config.host_os == 'Darwin':
+  config.substitutions.append( ("%ld_flags_rpath_exe2", '-Wl,-rpath, at executable_path/ %dynamiclib2') )
   config.substitutions.append( ("%ld_flags_rpath_exe", '-Wl,-rpath, at executable_path/ %dynamiclib') )
+  config.substitutions.append( ("%ld_flags_rpath_so2", '-install_name @rpath/`basename %dynamiclib2`') )
   config.substitutions.append( ("%ld_flags_rpath_so", '-install_name @rpath/`basename %dynamiclib`') )
 elif config.host_os == 'FreeBSD' or config.host_os == 'NetBSD':
+  config.substitutions.append( ("%ld_flags_rpath_exe2", "-Wl,-z,origin -Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec2") )
   config.substitutions.append( ("%ld_flags_rpath_exe", "-Wl,-z,origin -Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec") )
+  config.substitutions.append( ("%ld_flags_rpath_so2", '') )
   config.substitutions.append( ("%ld_flags_rpath_so", '') )
 elif config.host_os == 'Linux':
+  config.substitutions.append( ("%ld_flags_rpath_exe2", "-Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec2") )
   config.substitutions.append( ("%ld_flags_rpath_exe", "-Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec") )
+  config.substitutions.append( ("%ld_flags_rpath_so2", '') )
   config.substitutions.append( ("%ld_flags_rpath_so", '') )
 elif config.host_os == 'SunOS':
+  config.substitutions.append( ("%ld_flags_rpath_exe2", "-Wl,-R\$ORIGIN -L%T -l%xdynamiclib_namespec2") )
   config.substitutions.append( ("%ld_flags_rpath_exe", "-Wl,-R\$ORIGIN -L%T -l%xdynamiclib_namespec") )
+  config.substitutions.append( ("%ld_flags_rpath_so2", '') )
   config.substitutions.append( ("%ld_flags_rpath_so", '') )
 
 # Provide a substituion that can be used to tell Clang to use a static libstdc++.
@@ -331,7 +339,9 @@
   config.substitutions.append( ("%linux_static_libstdcplusplus", "") )
 
 # Must be defined after the substitutions that use %dynamiclib.
+config.substitutions.append( ("%dynamiclib2", '%T/%xdynamiclib_filename2') )
 config.substitutions.append( ("%dynamiclib", '%T/%xdynamiclib_filename') )
+config.substitutions.append( ("%xdynamiclib_filename2", 'lib%xdynamiclib_namespec2.so') )
 config.substitutions.append( ("%xdynamiclib_filename", 'lib%xdynamiclib_namespec.so') )
 config.substitutions.append( ("%xdynamiclib_namespec", '%basename_t.dynamic') )
 
Index: test/fuzzer/dump_coverage.test
===================================================================
--- test/fuzzer/dump_coverage.test
+++ test/fuzzer/dump_coverage.test
@@ -1,7 +1,7 @@
 UNSUPPORTED: freebsd
-RUN: %cpp_compiler -fsanitize-coverage=0 -fsanitize-coverage=trace-pc-guard %S/DSO1.cpp -fPIC -shared -o %t-DSO1.so
-RUN: %cpp_compiler -fsanitize-coverage=0 -fsanitize-coverage=trace-pc-guard %S/DSO2.cpp -fPIC -shared -o %t-DSO2.so
-RUN: %cpp_compiler -fsanitize-coverage=0 -fsanitize-coverage=trace-pc-guard %S/DSOTestMain.cpp %S/DSOTestExtra.cpp -L. %t-DSO1.so %t-DSO2.so -o %t-DSOTest
+RUN: %cpp_compiler -fsanitize-coverage=0 -fsanitize-coverage=trace-pc-guard %S/DSO1.cpp -fPIC -shared -o %dynamiclib %ld_flags_rpath_so
+RUN: %cpp_compiler -fsanitize-coverage=0 -fsanitize-coverage=trace-pc-guard %S/DSO2.cpp -fPIC -shared -o %dynamiclib2 %ld_flags_rpath_so2
+RUN: %cpp_compiler -fsanitize-coverage=0 -fsanitize-coverage=trace-pc-guard %S/DSOTestMain.cpp %S/DSOTestExtra.cpp %ld_flags_rpath_exe %ld_flags_rpath_exe2 -o %t-DSOTest
 
 RUN: %cpp_compiler -fsanitize-coverage=0 -fsanitize-coverage=trace-pc-guard %S/NullDerefTest.cpp -o %t-NullDerefTest
 
@@ -15,7 +15,7 @@
 SANCOV: LLVMFuzzerTestOneInput
 
 DSO: SanitizerCoverage: {{.*}}DSOTest.{{.*}}.sancov: {{.*}} PCs written
-DSO-DAG: SanitizerCoverage: {{.*}}DSO1.{{.*}}.sancov: {{.*}} PCs written
-DSO-DAG: SanitizerCoverage: {{.*}}DSO2.{{.*}}.sancov: {{.*}} PCs written
+DSO-DAG: SanitizerCoverage: {{.*}}.{{.*}}.sancov: {{.*}} PCs written
+DSO-DAG: SanitizerCoverage: {{.*}}2.{{.*}}.sancov: {{.*}} PCs written
 
 NOCOV-NOT: SanitizerCoverage: {{.*}} PCs written
Index: test/fuzzer/dso.test
===================================================================
--- test/fuzzer/dso.test
+++ test/fuzzer/dso.test
@@ -1,6 +1,6 @@
-RUN: %cpp_compiler %S/DSO1.cpp -fPIC -shared -o %t-DSO1.so
-RUN: %cpp_compiler %S/DSO2.cpp -fPIC -shared -o %t-DSO2.so
-RUN: %cpp_compiler %S/DSOTestMain.cpp %S/DSOTestExtra.cpp -L. %t-DSO1.so %t-DSO2.so -o %t-DSOTest
+RUN: %cpp_compiler %S/DSO1.cpp -fPIC %ld_flags_rpath_so -shared -o %dynamiclib
+RUN: %cpp_compiler %S/DSO2.cpp -fPIC %ld_flags_rpath_so2 -shared -o %dynamiclib2
+RUN: %cpp_compiler %S/DSOTestMain.cpp %S/DSOTestExtra.cpp %ld_flags_rpath_exe %ld_flags_rpath_exe2 -o %t-DSOTest
 
 RUN: not %run %t-DSOTest 2>&1 | FileCheck %s --check-prefix=DSO
 DSO: INFO: Loaded 3 modules


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47292.151052.patch
Type: text/x-patch
Size: 4854 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180612/43064c91/attachment.bin>


More information about the llvm-commits mailing list