From a05b828b189e495fc0132b18317ff9d2787573b0 Mon Sep 17 00:00:00 2001 From: gbMattN Date: Tue, 19 Nov 2024 13:21:40 +0000 Subject: [PATCH] Tidied up the test further --- compiler-rt/test/tsan/many_held_mutex.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/compiler-rt/test/tsan/many_held_mutex.cpp b/compiler-rt/test/tsan/many_held_mutex.cpp index 36a599904ffe310..94ef02a24628fb3 100644 --- a/compiler-rt/test/tsan/many_held_mutex.cpp +++ b/compiler-rt/test/tsan/many_held_mutex.cpp @@ -1,23 +1,22 @@ -// RUN: %clangxx_tsan %s -fsanitize=thread -o %t && %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_tsan %s -fsanitize=thread -o %t +// RUN: %run %t 128 +// RUN: not %run %t 129 #include -#include +#include -int main() { - const unsigned short NUM_OF_MTX = 128; - std::mutex mutexes[NUM_OF_MTX]; +int main(int argc, char *argv[]) { + int num_of_mtx = std::stoi(argv[1]); - for (int i = 0; i < NUM_OF_MTX; i++) { + std::mutex* mutexes = new std::mutex[num_of_mtx]; + + for (int i = 0; i < num_of_mtx; i++) { mutexes[i].lock(); } - for (int i = 0; i < NUM_OF_MTX; i++) { + for (int i = 0; i < num_of_mtx; i++) { mutexes[i].unlock(); } - printf("Success\n"); - + delete[] mutexes; return 0; } - -// CHECK: Success -// CHECK-NOT: ThreadSanitizer: CHECK failed