[compiler-rt] 273600b - [sanitizer] Second test fix to tolerate chmod not working as intended

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 13 17:03:14 PST 2022


Author: Teresa Johnson
Date: 2022-02-13T17:03:04-08:00
New Revision: 273600b6e3e2b056a893bfee8092ecee9dde37ab

URL: https://github.com/llvm/llvm-project/commit/273600b6e3e2b056a893bfee8092ecee9dde37ab
DIFF: https://github.com/llvm/llvm-project/commit/273600b6e3e2b056a893bfee8092ecee9dde37ab.diff

LOG: [sanitizer] Second test fix to tolerate chmod not working as intended

Second attempt to fix a bot failure from
634da7a1c61ee8c173e90a841eb1f4ea03caa20b on an Android bot:
https://lab.llvm.org/buildbot#builders/77/builds/14339

With the fix in 986afe847951a59cd66783e1377b13cec6412972 there was a
different issue, because we need the fully qualified path name to the
binary, which is only available in arg[0]. New failure:
https://lab.llvm.org/buildbot/#/builders/77/builds/14346/steps/16/logs/stdio

Restructure the test so both attempts are made from the same invocation,
which sets up the bad paths directly.

Added: 
    

Modified: 
    compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_test.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_test.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_test.cpp
index 6cd060ac703c8..acaa997c4d692 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_test.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_test.cpp
@@ -1,13 +1,9 @@
 // Test __sanitizer_set_report_path and __sanitizer_get_report_path:
-// RUN: rm -rf %t.report_path
 // RUN: %clangxx -O2 %s -o %t
-// RUN: %run %t %t | FileCheck %s
-// Try again with a directory without write access.
+// Create a directory without write access.
 // RUN: rm -rf %t.baddir && mkdir -p %t.baddir
 // RUN: chmod u-w %t.baddir || true
-// Use invalid characters in directory name in case chmod doesn't work as
-// intended.
-// RUN: not %run %t %t.baddir/?bad? 2>&1 | FileCheck %s --check-prefix=FAIL
+// RUN: not %run %t 2>&1 | FileCheck %s
 
 #include <assert.h>
 #include <sanitizer/common_interface_defs.h>
@@ -18,11 +14,21 @@ volatile int *null = 0;
 
 int main(int argc, char **argv) {
   char buff[1000];
-  sprintf(buff, "%s.report_path/report", argv[1]);
+  sprintf(buff, "%s.report_path/report", argv[0]);
+  __sanitizer_set_report_path(buff);
+  assert(strncmp(buff, __sanitizer_get_report_path(), strlen(buff)) == 0);
+  printf("Path %s\n", __sanitizer_get_report_path());
+  fflush(stdout);
+
+  // Try setting again with an invalid/inaccessible directory.
+  // Use invalid characters in directory name in case chmod doesn't work as
+  // intended.
+  sprintf(buff, "%s.baddir/?bad?/report", argv[0]);
   __sanitizer_set_report_path(buff);
   assert(strncmp(buff, __sanitizer_get_report_path(), strlen(buff)) == 0);
   printf("Path %s\n", __sanitizer_get_report_path());
 }
 
 // CHECK: Path {{.*}}Posix/Output/sanitizer_set_report_path_test.cpp.tmp.report_path/report.
-// FAIL: ERROR: Can't create directory: {{.*}}Posix/Output/sanitizer_set_report_path_test.cpp.tmp.baddir
+// CHECK: ERROR: Can't create directory: {{.*}}Posix/Output/sanitizer_set_report_path_test.cpp.tmp.baddir
+// CHECK-NOT: Path {{.*}}Posix/Output/sanitizer_set_report_path_test.cpp.tmp.baddir


        


More information about the llvm-commits mailing list