Skip to content

Commit

Permalink
Tidied up the test further
Browse files Browse the repository at this point in the history
  • Loading branch information
gbMattN committed Nov 19, 2024
1 parent d93e959 commit a05b828
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions compiler-rt/test/tsan/many_held_mutex.cpp
Original file line number Diff line number Diff line change
@@ -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 <mutex>
#include <stdio.h>
#include <string>

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

0 comments on commit a05b828

Please sign in to comment.