| 1 | // RUN: %clangxx -fsanitize=realtime %s -o %t |
| 2 | // RUN: %env_rtsan_opts="halt_on_error=false,print_stats_on_exit=true" %run %t 2>&1 | FileCheck %s |
| 3 | // RUN: %env_rtsan_opts="halt_on_error=true,print_stats_on_exit=true" not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-HALT |
| 4 | // RUN: %env_rtsan_opts="suppressions=%s.supp,print_stats_on_exit=true" not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUPPRESSIONS |
| 5 | |
| 6 | // UNSUPPORTED: ios |
| 7 | |
| 8 | // Intent: Ensure exits stats are printed on exit. |
| 9 | |
| 10 | #include <unistd.h> |
| 11 | |
| 12 | void violation() [[clang::nonblocking]] { |
| 13 | const int kNumViolations = 10; |
| 14 | for (int i = 0; i < kNumViolations; i++) { |
| 15 | usleep(useconds: 1); |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | int main() { |
| 20 | violation(); |
| 21 | return 0; |
| 22 | } |
| 23 | |
| 24 | // CHECK: RealtimeSanitizer exit stats: |
| 25 | // CHECK-NEXT: Total error count: 10 |
| 26 | // CHECK-NEXT: Unique error count: 1 |
| 27 | // CHECK-NOT: Suppression count |
| 28 | |
| 29 | // CHECK-HALT: RealtimeSanitizer exit stats: |
| 30 | // CHECK-HALT-NEXT: Total error count: 1 |
| 31 | // CHECK-HALT-NEXT: Unique error count: 1 |
| 32 | // CHECK-HALT-NOT: Suppression count |
| 33 | |
| 34 | // We pass in intentionally_non_existant_function in the suppressions file |
| 35 | // This is just to ensure we only get the "Suppression count" metric if this |
| 36 | // file is passed at runtime, otherwise that statistic is omitted |
| 37 | // CHECK-SUPPRESSIONS: RealtimeSanitizer exit stats: |
| 38 | // CHECK-SUPPRESSIONS-NEXT: Total error count: 1 |
| 39 | // CHECK-SUPPRESSIONS-NEXT: Unique error count: 1 |
| 40 | // CHECK-SUPPRESSIONS-NEXT: Suppression count: 0 |
| 41 | |