Skip to content
This repository was archived by the owner on May 21, 2019. It is now read-only.

Commit 96bdefa

Browse files
committed
[asan] GCD tests on Mac: prevent optimization and enable. Patch by [email protected]
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@145953 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 5f9ee28 commit 96bdefa

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

lib/asan/tests/asan_mac_test.mm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ +(void) load {
5959
@end
6060

6161
void worker_do_alloc(int size) {
62-
char *mem = malloc(size);
62+
char * volatile mem = malloc(size);
6363
mem[0] = 0; // Ok
6464
free(mem);
6565
}
6666

6767
void worker_do_crash(int size) {
68-
char *mem = malloc(size);
68+
char * volatile mem = malloc(size);
6969
mem[size] = 0; // BOOM
7070
free(mem);
7171
}
@@ -160,7 +160,7 @@ void TestGCDSourceEvent() {
160160
dispatch_time(DISPATCH_TIME_NOW, 1LL * NSEC_PER_SEC);
161161

162162
dispatch_source_set_timer(timer, milestone, DISPATCH_TIME_FOREVER, 0);
163-
char *mem = malloc(10);
163+
char * volatile mem = malloc(10);
164164
dispatch_source_set_event_handler(timer, ^{
165165
mem[10] = 1;
166166
});
@@ -177,7 +177,7 @@ void TestGCDSourceCancel() {
177177
dispatch_time(DISPATCH_TIME_NOW, 1LL * NSEC_PER_SEC);
178178

179179
dispatch_source_set_timer(timer, milestone, DISPATCH_TIME_FOREVER, 0);
180-
char *mem = malloc(10);
180+
char * volatile mem = malloc(10);
181181
// Both dispatch_source_set_cancel_handler() and
182182
// dispatch_source_set_event_handler() use dispatch_barrier_async_f().
183183
// It's tricky to test dispatch_source_set_cancel_handler() separately,
@@ -195,7 +195,7 @@ void TestGCDSourceCancel() {
195195
void TestGCDGroupAsync() {
196196
dispatch_queue_t queue = dispatch_get_global_queue(0, 0);
197197
dispatch_group_t group = dispatch_group_create();
198-
char *mem = malloc(10);
198+
char * volatile mem = malloc(10);
199199
dispatch_group_async(group, queue, ^{
200200
mem[10] = 1;
201201
});

lib/asan/tests/asan_test.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,50 +1771,50 @@ TEST(AddressSanitizerMac, DISABLED_CFAllocatorMallocZoneDoubleFree) {
17711771
EXPECT_DEATH(CFAllocatorMallocZoneDoubleFree(), "attempting double-free");
17721772
}
17731773

1774-
TEST(AddressSanitizerMac, DISABLED_GCDDispatchAsync) {
1774+
TEST(AddressSanitizerMac, GCDDispatchAsync) {
17751775
// Make sure the whole ASan report is printed, i.e. that we don't die
17761776
// on a CHECK.
17771777
EXPECT_DEATH(TestGCDDispatchAsync(), "Shadow byte and word");
17781778
}
17791779

1780-
TEST(AddressSanitizerMac, DISABLED_GCDDispatchSync) {
1780+
TEST(AddressSanitizerMac, GCDDispatchSync) {
17811781
// Make sure the whole ASan report is printed, i.e. that we don't die
17821782
// on a CHECK.
17831783
EXPECT_DEATH(TestGCDDispatchSync(), "Shadow byte and word");
17841784
}
17851785

17861786

1787-
TEST(AddressSanitizerMac, DISABLED_GCDReuseWqthreadsAsync) {
1787+
TEST(AddressSanitizerMac, GCDReuseWqthreadsAsync) {
17881788
// Make sure the whole ASan report is printed, i.e. that we don't die
17891789
// on a CHECK.
17901790
EXPECT_DEATH(TestGCDReuseWqthreadsAsync(), "Shadow byte and word");
17911791
}
17921792

1793-
TEST(AddressSanitizerMac, DISABLED_GCDReuseWqthreadsSync) {
1793+
TEST(AddressSanitizerMac, GCDReuseWqthreadsSync) {
17941794
// Make sure the whole ASan report is printed, i.e. that we don't die
17951795
// on a CHECK.
17961796
EXPECT_DEATH(TestGCDReuseWqthreadsSync(), "Shadow byte and word");
17971797
}
17981798

1799-
TEST(AddressSanitizerMac, DISABLED_GCDDispatchAfter) {
1799+
TEST(AddressSanitizerMac, GCDDispatchAfter) {
18001800
// Make sure the whole ASan report is printed, i.e. that we don't die
18011801
// on a CHECK.
18021802
EXPECT_DEATH(TestGCDDispatchAfter(), "Shadow byte and word");
18031803
}
18041804

1805-
TEST(AddressSanitizerMac, DISABLED_GCDSourceEvent) {
1805+
TEST(AddressSanitizerMac, GCDSourceEvent) {
18061806
// Make sure the whole ASan report is printed, i.e. that we don't die
18071807
// on a CHECK.
18081808
EXPECT_DEATH(TestGCDSourceEvent(), "Shadow byte and word");
18091809
}
18101810

1811-
TEST(AddressSanitizerMac, DISABLED_GCDSourceCancel) {
1811+
TEST(AddressSanitizerMac, GCDSourceCancel) {
18121812
// Make sure the whole ASan report is printed, i.e. that we don't die
18131813
// on a CHECK.
18141814
EXPECT_DEATH(TestGCDSourceCancel(), "Shadow byte and word");
18151815
}
18161816

1817-
TEST(AddressSanitizerMac, DISABLED_GCDGroupAsync) {
1817+
TEST(AddressSanitizerMac, GCDGroupAsync) {
18181818
// Make sure the whole ASan report is printed, i.e. that we don't die
18191819
// on a CHECK.
18201820
EXPECT_DEATH(TestGCDGroupAsync(), "Shadow byte and word");

0 commit comments

Comments
 (0)