xref: /llvm-project/compiler-rt/test/rtsan/exit_stats.cpp (revision f5b95db4c3ea266489a68a7655425b18ce5805f6)
1c3334dadSChris Apple // RUN: %clangxx -fsanitize=realtime %s -o %t
2c3334dadSChris Apple // RUN: env RTSAN_OPTIONS="halt_on_error=false,print_stats_on_exit=true" %run %t 2>&1 | FileCheck %s
3c3334dadSChris Apple 
4c3334dadSChris Apple // UNSUPPORTED: ios
5c3334dadSChris Apple 
6c3334dadSChris Apple // Intent: Ensure exits stats are printed on exit.
7c3334dadSChris Apple 
8c3334dadSChris Apple #include <unistd.h>
9c3334dadSChris Apple 
10c3334dadSChris Apple void violation() [[clang::nonblocking]] {
11c3334dadSChris Apple   const int kNumViolations = 10;
12c3334dadSChris Apple   for (int i = 0; i < kNumViolations; i++) {
13c3334dadSChris Apple     usleep(1);
14c3334dadSChris Apple   }
15c3334dadSChris Apple }
16c3334dadSChris Apple 
17c3334dadSChris Apple int main() {
18c3334dadSChris Apple   violation();
19c3334dadSChris Apple   return 0;
20c3334dadSChris Apple }
21c3334dadSChris Apple 
22c3334dadSChris Apple // CHECK: RealtimeSanitizer exit stats:
23c3334dadSChris Apple // CHECK-NEXT: Total error count: 10
24*f5b95db4SChris Apple // CHECK-NEXT: Unique error count: 1
25