File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change 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
2
4
3
5
#include < mutex>
4
- #include < stdio.h >
6
+ #include < string >
5
7
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 ]);
9
10
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++) {
11
14
mutexes[i].lock ();
12
15
}
13
- for (int i = 0 ; i < NUM_OF_MTX ; i++) {
16
+ for (int i = 0 ; i < num_of_mtx ; i++) {
14
17
mutexes[i].unlock ();
15
18
}
16
19
17
- printf (" Success\n " );
18
-
20
+ delete[] mutexes;
19
21
return 0 ;
20
22
}
21
-
22
- // CHECK: Success
23
- // CHECK-NOT: ThreadSanitizer: CHECK failed
You can’t perform that action at this time.
0 commit comments