llvm-project/compiler-rt/test/rtsan/deduplicate_errors.cpp
Chris Apple 595e484c08
[rtsan] Add option to allow printing of duplicate stacks (suppress_equal_stacks) (#117069)
Following the example of tsan, where we took the name

This would allow users to determine if they want to see ALL output from
rtsan.

Additionally, remove the UNLIKELY hint, as it is now up to the flag whether or
not it is likely that we go through this conditional.
2024-11-21 06:32:05 -08:00

44 lines
1.1 KiB
C++

// RUN: %clangxx -fsanitize=realtime %s -o %t
// RUN: env RTSAN_OPTIONS="halt_on_error=false,print_stats_on_exit=true" %run %t 2>&1 | FileCheck %s
// RUN: env RTSAN_OPTIONS="halt_on_error=false,suppress_equal_stacks=false" %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-DUPLICATES
// UNSUPPORTED: ios
// Intent: Ensure all errors are deduplicated.
#include <unistd.h>
const int kNumViolations = 10;
void violation() [[clang::nonblocking]] {
for (int i = 0; i < kNumViolations; i++)
usleep(1);
}
void violation2() [[clang::nonblocking]] {
for (int i = 0; i < kNumViolations; i++)
violation();
}
void double_violation() [[clang::nonblocking]] {
violation();
violation2();
}
int main() {
violation(); // 1 unique errors here, but 10 total
violation2(); // 1 unique errors here, but 100 total
double_violation(); // 2 unique errors here, but 110 total
return 0;
}
// CHECK-COUNT-4: ==ERROR:
// CHECK-NOT: ==ERROR:
// CHECK: RealtimeSanitizer exit stats:
// CHECK-NEXT: Total error count: 220
// CHECK-NEXT: Unique error count: 4
// CHECK-DUPLICATES-COUNT-220: ==ERROR:
// CHECK-DUPLICATES-NOT: ==ERROR: