[PATCH] D60591: [TSan][libdispatch] Replace NSTemporaryDirectory in tests
Julian Lettner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 11 16:44:04 PDT 2019
yln created this revision.
Herald added subscribers: llvm-commits, Sanitizers, kubamracek.
Herald added projects: Sanitizers, LLVM.
After this change, most tests don't have a dependency on Foundation.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D60591
Files:
compiler-rt/test/tsan/Darwin/gcd-fd.mm
compiler-rt/test/tsan/Darwin/gcd-io-barrier-race.mm
compiler-rt/test/tsan/Darwin/gcd-io-barrier.mm
compiler-rt/test/tsan/Darwin/gcd-io-cleanup.mm
compiler-rt/test/tsan/Darwin/gcd-io-race.mm
compiler-rt/test/tsan/Darwin/gcd-io.mm
Index: compiler-rt/test/tsan/Darwin/gcd-io.mm
===================================================================
--- compiler-rt/test/tsan/Darwin/gcd-io.mm
+++ compiler-rt/test/tsan/Darwin/gcd-io.mm
@@ -98,8 +98,7 @@
queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL);
sem = dispatch_semaphore_create(0);
- NSString *ns_path = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"temp-gcd-io.%d", getpid()]];
- path = ns_path.fileSystemRepresentation;
+ path = tempnam(NULL, "libdispatch-io-");
char buf[1000];
data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
Index: compiler-rt/test/tsan/Darwin/gcd-io-race.mm
===================================================================
--- compiler-rt/test/tsan/Darwin/gcd-io-race.mm
+++ compiler-rt/test/tsan/Darwin/gcd-io-race.mm
@@ -21,8 +21,7 @@
queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
sem = dispatch_semaphore_create(0);
- NSString *ns_path = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"temp-gcd-io.%d", getpid()]];
- path = ns_path.fileSystemRepresentation;
+ path = tempnam(NULL, "libdispatch-io-race");
char buf[1000];
data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
Index: compiler-rt/test/tsan/Darwin/gcd-io-cleanup.mm
===================================================================
--- compiler-rt/test/tsan/Darwin/gcd-io-cleanup.mm
+++ compiler-rt/test/tsan/Darwin/gcd-io-cleanup.mm
@@ -10,8 +10,7 @@
dispatch_queue_t queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- NSString *ns_path = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"temp-gcd-io.%d", getpid()]];
- const char *path = ns_path.fileSystemRepresentation;
+ const char *path = tempnam(NULL, "libdispatch-io-cleanup-");
dispatch_io_t channel;
dispatch_fd_t fd = open(path, O_CREAT | O_WRONLY, 0666);
Index: compiler-rt/test/tsan/Darwin/gcd-io-barrier.mm
===================================================================
--- compiler-rt/test/tsan/Darwin/gcd-io-barrier.mm
+++ compiler-rt/test/tsan/Darwin/gcd-io-barrier.mm
@@ -15,8 +15,7 @@
queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
sem = dispatch_semaphore_create(0);
- NSString *ns_path = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"temp-gcd-io.%d", getpid()]];
- path = ns_path.fileSystemRepresentation;
+ path = tempnam(NULL, "libdispatch-io-barrier");
char buf[1000];
data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
Index: compiler-rt/test/tsan/Darwin/gcd-io-barrier-race.mm
===================================================================
--- compiler-rt/test/tsan/Darwin/gcd-io-barrier-race.mm
+++ compiler-rt/test/tsan/Darwin/gcd-io-barrier-race.mm
@@ -19,8 +19,7 @@
queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
sem = dispatch_semaphore_create(0);
- NSString *ns_path = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"temp-gcd-io.%d", getpid()]];
- path = ns_path.fileSystemRepresentation;
+ path = tempnam(NULL, "libdispatch-io-barrier-race-");
char buf[1000];
data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
Index: compiler-rt/test/tsan/Darwin/gcd-fd.mm
===================================================================
--- compiler-rt/test/tsan/Darwin/gcd-fd.mm
+++ compiler-rt/test/tsan/Darwin/gcd-fd.mm
@@ -11,9 +11,9 @@
dispatch_queue_t queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL);
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"temp-gcd-io.%d", getpid()]];
+ const char *path = tempnam(NULL, "libdispatch-fd-");
- dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path.fileSystemRepresentation, O_CREAT | O_WRONLY,
+ dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY,
0666, queue, ^(int error) { });
dispatch_io_set_high_water(channel, 1);
@@ -34,7 +34,7 @@
dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
my_global++;
dispatch_io_close(channel, 0);
- channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path.fileSystemRepresentation, O_RDONLY,
+ channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_RDONLY,
0, queue, ^(int error) { });
dispatch_io_set_high_water(channel, 1);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60591.194785.patch
Type: text/x-patch
Size: 4778 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190411/bc183dcc/attachment.bin>
More information about the llvm-commits
mailing list