Skip to content

Commit c173dde

Browse files
gbMattNvitalybuka
authored andcommitted
Tidied up the test further
1 parent 61954f9 commit c173dde

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
// RUN: %clangxx_tsan %s -fsanitize=thread -o %t && %run %t 2>&1 | FileCheck %s
1+
// RUN: %clangxx_tsan %s -fsanitize=thread -o %t
2+
// RUN: %run %t 128
3+
// RUN: not %run %t 129
24

35
#include <mutex>
4-
#include <stdio.h>
6+
#include <string>
57

6-
int main() {
7-
const unsigned short NUM_OF_MTX = 128;
8-
std::mutex mutexes[NUM_OF_MTX];
8+
int main(int argc, char *argv[]) {
9+
int num_of_mtx = std::stoi(argv[1]);
910

10-
for (int i = 0; i < NUM_OF_MTX; i++) {
11+
std::mutex* mutexes = new std::mutex[num_of_mtx];
12+
13+
for (int i = 0; i < num_of_mtx; i++) {
1114
mutexes[i].lock();
1215
}
13-
for (int i = 0; i < NUM_OF_MTX; i++) {
16+
for (int i = 0; i < num_of_mtx; i++) {
1417
mutexes[i].unlock();
1518
}
1619

17-
printf("Success\n");
18-
20+
delete[] mutexes;
1921
return 0;
2022
}
21-
22-
// CHECK: Success
23-
// CHECK-NOT: ThreadSanitizer: CHECK failed

0 commit comments

Comments
 (0)