Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ubsan][test] Enable Misc/Linux tests on all Posix systems #111497

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

rorth
Copy link
Collaborator

@rorth rorth commented Oct 8, 2024

When investigating PR #101634, it turned out that UBSan-Standalone-sparc :: TestCases/Misc/Linux/diag-stacktrace.cpp isn't Linux-specific at all. In fact, none of the ubsan/TestCases/Misc/Linux tests are.

Therefore this patch moves them to Misc/Posix instead.

Tested on sparc64-unknown-linux-gnu, sparcv9-sun-solaris2.11, x86_64-pc-linux-gnu, and amd64-pc-solaris2.11.

When investigating PR llvm#101634, it turned out that `UBSan-Standalone-sparc
:: TestCases/Misc/Linux/diag-stacktrace.cpp` isn't Linux-specific at all.
In fact, none of the `ubsan/TestCases/Misc/Linux` tests are.

Therefore this patch moves them to `Misc/Posix` instead.

Tested on `sparc64-unknown-linux-gnu`, `sparcv9-sun-solaris2.11`,
`x86_64-pc-linux-gnu`, and `amd64-pc-solaris2.11`.
@llvmbot
Copy link
Member

llvmbot commented Oct 8, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Rainer Orth (rorth)

Changes

When investigating PR #101634, it turned out that UBSan-Standalone-sparc :: TestCases/Misc/Linux/diag-stacktrace.cpp isn't Linux-specific at all. In fact, none of the ubsan/TestCases/Misc/Linux tests are.

Therefore this patch moves them to Misc/Posix instead.

Tested on sparc64-unknown-linux-gnu, sparcv9-sun-solaris2.11, x86_64-pc-linux-gnu, and amd64-pc-solaris2.11.


Full diff: https://github.com/llvm/llvm-project/pull/111497.diff

6 Files Affected:

  • (renamed) compiler-rt/test/ubsan/TestCases/Misc/Posix/diag-stacktrace.cpp ()
  • (renamed) compiler-rt/test/ubsan/TestCases/Misc/Posix/lit.local.cfg.py (+1-1)
  • (renamed) compiler-rt/test/ubsan/TestCases/Misc/Posix/print_stack_trace.cpp ()
  • (renamed) compiler-rt/test/ubsan/TestCases/Misc/Posix/sigaction.cpp ()
  • (renamed) compiler-rt/test/ubsan/TestCases/Misc/Posix/static-link.cpp ()
  • (renamed) compiler-rt/test/ubsan/TestCases/Misc/Posix/ubsan_options.cpp ()
diff --git a/compiler-rt/test/ubsan/TestCases/Misc/Linux/diag-stacktrace.cpp b/compiler-rt/test/ubsan/TestCases/Misc/Posix/diag-stacktrace.cpp
similarity index 100%
rename from compiler-rt/test/ubsan/TestCases/Misc/Linux/diag-stacktrace.cpp
rename to compiler-rt/test/ubsan/TestCases/Misc/Posix/diag-stacktrace.cpp
diff --git a/compiler-rt/test/ubsan/TestCases/Misc/Linux/lit.local.cfg.py b/compiler-rt/test/ubsan/TestCases/Misc/Posix/lit.local.cfg.py
similarity index 82%
rename from compiler-rt/test/ubsan/TestCases/Misc/Linux/lit.local.cfg.py
rename to compiler-rt/test/ubsan/TestCases/Misc/Posix/lit.local.cfg.py
index 603ca0365068f5..63240c39625656 100644
--- a/compiler-rt/test/ubsan/TestCases/Misc/Linux/lit.local.cfg.py
+++ b/compiler-rt/test/ubsan/TestCases/Misc/Posix/lit.local.cfg.py
@@ -6,5 +6,5 @@ def getRoot(config):
 
 root = getRoot(config)
 
-if root.host_os not in ["Linux"]:
+if root.host_os in ["Windows"]:
     config.unsupported = True
diff --git a/compiler-rt/test/ubsan/TestCases/Misc/Linux/print_stack_trace.cpp b/compiler-rt/test/ubsan/TestCases/Misc/Posix/print_stack_trace.cpp
similarity index 100%
rename from compiler-rt/test/ubsan/TestCases/Misc/Linux/print_stack_trace.cpp
rename to compiler-rt/test/ubsan/TestCases/Misc/Posix/print_stack_trace.cpp
diff --git a/compiler-rt/test/ubsan/TestCases/Misc/Linux/sigaction.cpp b/compiler-rt/test/ubsan/TestCases/Misc/Posix/sigaction.cpp
similarity index 100%
rename from compiler-rt/test/ubsan/TestCases/Misc/Linux/sigaction.cpp
rename to compiler-rt/test/ubsan/TestCases/Misc/Posix/sigaction.cpp
diff --git a/compiler-rt/test/ubsan/TestCases/Misc/Linux/static-link.cpp b/compiler-rt/test/ubsan/TestCases/Misc/Posix/static-link.cpp
similarity index 100%
rename from compiler-rt/test/ubsan/TestCases/Misc/Linux/static-link.cpp
rename to compiler-rt/test/ubsan/TestCases/Misc/Posix/static-link.cpp
diff --git a/compiler-rt/test/ubsan/TestCases/Misc/Linux/ubsan_options.cpp b/compiler-rt/test/ubsan/TestCases/Misc/Posix/ubsan_options.cpp
similarity index 100%
rename from compiler-rt/test/ubsan/TestCases/Misc/Linux/ubsan_options.cpp
rename to compiler-rt/test/ubsan/TestCases/Misc/Posix/ubsan_options.cpp

Copy link

github-actions bot commented Oct 8, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff a3a253d3c7780977077dd46493917b1949c0166d a5868ab1f3d4329efa767d0b3fd6a35b3d93d864 --extensions cpp -- compiler-rt/test/ubsan/TestCases/Misc/Posix/diag-stacktrace.cpp compiler-rt/test/ubsan/TestCases/Misc/Posix/print_stack_trace.cpp compiler-rt/test/ubsan/TestCases/Misc/Posix/sigaction.cpp compiler-rt/test/ubsan/TestCases/Misc/Posix/static-link.cpp compiler-rt/test/ubsan/TestCases/Misc/Posix/ubsan_options.cpp
View the diff from clang-format here.
diff --git a/compiler-rt/test/ubsan/TestCases/Misc/Posix/print_stack_trace.cpp b/compiler-rt/test/ubsan/TestCases/Misc/Posix/print_stack_trace.cpp
index 93c6bd66e1..66907be0bb 100644
--- a/compiler-rt/test/ubsan/TestCases/Misc/Posix/print_stack_trace.cpp
+++ b/compiler-rt/test/ubsan/TestCases/Misc/Posix/print_stack_trace.cpp
@@ -10,9 +10,7 @@
 
 #include <sanitizer/common_interface_defs.h>
 
-static inline void FooBarBaz() {
-  __sanitizer_print_stack_trace();
-}
+static inline void FooBarBaz() { __sanitizer_print_stack_trace(); }
 
 int main() {
   FooBarBaz();
diff --git a/compiler-rt/test/ubsan/TestCases/Misc/Posix/ubsan_options.cpp b/compiler-rt/test/ubsan/TestCases/Misc/Posix/ubsan_options.cpp
index 284b4ba0ab..f8018a3b84 100644
--- a/compiler-rt/test/ubsan/TestCases/Misc/Posix/ubsan_options.cpp
+++ b/compiler-rt/test/ubsan/TestCases/Misc/Posix/ubsan_options.cpp
@@ -6,13 +6,10 @@
 
 #include <stdint.h>
 
-extern "C" const char *__ubsan_default_options() {
-  return "halt_on_error=1";
-}
+extern "C" const char *__ubsan_default_options() { return "halt_on_error=1"; }
 
 int main() {
   (void)(uint64_t(10000000000000000000ull) + uint64_t(9000000000000000000ull));
   // CHECK: ubsan_options.cpp:[[@LINE-1]]:44: runtime error: unsigned integer overflow
   return 0;
 }
-

@rorth
Copy link
Collaborator Author

rorth commented Oct 8, 2024

I don't think it's a good idea to perform clang-format changes upon a rename. I suggest to leave the code as is in this patch.

@rorth
Copy link
Collaborator Author

rorth commented Oct 14, 2024

Ping? It's been a week.

@rorth rorth merged commit e290152 into llvm:main Oct 15, 2024
11 of 12 checks passed
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
When investigating PR llvm#101634, it turned out that
`UBSan-Standalone-sparc :: TestCases/Misc/Linux/diag-stacktrace.cpp`
isn't Linux-specific at all. In fact, none of the
`ubsan/TestCases/Misc/Linux` tests are.

Therefore this patch moves them to `Misc/Posix` instead.

Tested on `sparc64-unknown-linux-gnu`, `sparcv9-sun-solaris2.11`,
`x86_64-pc-linux-gnu`, and `amd64-pc-solaris2.11`.
zmodem added a commit that referenced this pull request Oct 17, 2024
After #111497 the test started
unexpectedly passing (https://crbug.com/373891811), probably because it
does actually work but wasn't run when it lived in the Misc/Linux/
directory.
bricknerb pushed a commit to bricknerb/llvm-project that referenced this pull request Oct 17, 2024
When investigating PR llvm#101634, it turned out that
`UBSan-Standalone-sparc :: TestCases/Misc/Linux/diag-stacktrace.cpp`
isn't Linux-specific at all. In fact, none of the
`ubsan/TestCases/Misc/Linux` tests are.

Therefore this patch moves them to `Misc/Posix` instead.

Tested on `sparc64-unknown-linux-gnu`, `sparcv9-sun-solaris2.11`,
`x86_64-pc-linux-gnu`, and `amd64-pc-solaris2.11`.
bricknerb pushed a commit to bricknerb/llvm-project that referenced this pull request Oct 17, 2024
After llvm#111497 the test started
unexpectedly passing (https://crbug.com/373891811), probably because it
does actually work but wasn't run when it lived in the Misc/Linux/
directory.
@vitalybuka
Copy link
Collaborator

vitalybuka commented Oct 18, 2024

@zmodem @rorth https://ci.chromium.org/ui/p/chromium/builders/try/mac_upload_clang/5978/overview
Something is missing on Darwin:

 FAIL: UBSan-Standalone-x86_64 :: TestCases/Misc/Posix/static-link.cpp (78401 of 81703)
 ******************** TEST 'UBSan-Standalone-x86_64 :: TestCases/Misc/Posix/static-link.cpp' FAILED ********************
 Exit Code: 1
 
 Command Output (stderr):
 --
 RUN: at line 4: /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/./bin/clang  --driver-mode=g++  -arch x86_64 -stdlib=libc++ -mmacosx-version-min=10.12 -isysroot /Volumes/Work/s/w/ir/cache/osx_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk -mlinker-version=1053.12  -fsanitize=bool -static  /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test/ubsan/TestCases/Misc/Posix/static-link.cpp -o /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/runtimes/runtimes-bins/compiler-rt/test/ubsan/Standalone-x86_64/TestCases/Misc/Posix/Output/static-link.cpp.tmp && env UBSAN_OPTIONS=handle_segv=0:handle_sigbus=0:handle_sigfpe=0  /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/runtimes/runtimes-bins/compiler-rt/test/ubsan/Standalone-x86_64/TestCases/Misc/Posix/Output/static-link.cpp.tmp 2>&1 | FileCheck /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test/ubsan/TestCases/Misc/Posix/static-link.cpp
 + /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/./bin/clang --driver-mode=g++ -arch x86_64 -stdlib=libc++ -mmacosx-version-min=10.12 -isysroot /Volumes/Work/s/w/ir/cache/osx_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk -mlinker-version=1053.12 -fsanitize=bool -static /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test/ubsan/TestCases/Misc/Posix/static-link.cpp -o /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/runtimes/runtimes-bins/compiler-rt/test/ubsan/Standalone-x86_64/TestCases/Misc/Posix/Output/static-link.cpp.tmp
 ld: library not found for -lcrt0.o
 clang: error: linker command failed with exit code 1 (use -v to see invocation)

vitalybuka added a commit that referenced this pull request Oct 18, 2024
EricWF pushed a commit to efcs/llvm-project that referenced this pull request Oct 22, 2024
When investigating PR llvm#101634, it turned out that
`UBSan-Standalone-sparc :: TestCases/Misc/Linux/diag-stacktrace.cpp`
isn't Linux-specific at all. In fact, none of the
`ubsan/TestCases/Misc/Linux` tests are.

Therefore this patch moves them to `Misc/Posix` instead.

Tested on `sparc64-unknown-linux-gnu`, `sparcv9-sun-solaris2.11`,
`x86_64-pc-linux-gnu`, and `amd64-pc-solaris2.11`.
EricWF pushed a commit to efcs/llvm-project that referenced this pull request Oct 22, 2024
After llvm#111497 the test started
unexpectedly passing (https://crbug.com/373891811), probably because it
does actually work but wasn't run when it lived in the Misc/Linux/
directory.
EricWF pushed a commit to efcs/llvm-project that referenced this pull request Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants