44 lines · cpp
1// RUN: %clangxx -fsanitize=realtime %s -o %t2// RUN: env RTSAN_OPTIONS="halt_on_error=false,print_stats_on_exit=true" %run %t 2>&1 | FileCheck %s3// RUN: env RTSAN_OPTIONS="halt_on_error=false,suppress_equal_stacks=false" %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-DUPLICATES4 5// UNSUPPORTED: ios6 7// Intent: Ensure all errors are deduplicated.8 9#include <unistd.h>10 11const int kNumViolations = 10;12 13void violation() [[clang::nonblocking]] {14 for (int i = 0; i < kNumViolations; i++)15 usleep(1);16}17 18void violation2() [[clang::nonblocking]] {19 for (int i = 0; i < kNumViolations; i++)20 violation();21}22 23void double_violation() [[clang::nonblocking]] {24 violation();25 violation2();26}27 28int main() {29 violation(); // 1 unique errors here, but 10 total30 violation2(); // 1 unique errors here, but 100 total31 double_violation(); // 2 unique errors here, but 110 total32 return 0;33}34 35// CHECK-COUNT-4: ==ERROR:36// CHECK-NOT: ==ERROR:37 38// CHECK: RealtimeSanitizer exit stats:39// CHECK-NEXT: Total error count: 22040// CHECK-NEXT: Unique error count: 441 42// CHECK-DUPLICATES-COUNT-220: ==ERROR:43// CHECK-DUPLICATES-NOT: ==ERROR:44