diff options
author | Julian Lettner <jlettner@apple.com> | 2019-04-12 20:27:02 +0000 |
---|---|---|
committer | Julian Lettner <jlettner@apple.com> | 2019-04-12 20:27:02 +0000 |
commit | 2d04195645031e1a4c6fd9b1c2b5371631257947 (patch) | |
tree | 5f54cf9763044f9c54dc095c4804d3457c321f95 /test | |
parent | 31b0a28a5949cbbe87ddf2d6f71c5761bee557f4 (diff) | |
download | compiler-rt-2d04195645031e1a4c6fd9b1c2b5371631257947.tar.gz |
[TSan][libdispatch] Replace NSTemporaryDirectory in tests
After this change, most tests don't have a dependency on Foundation.
Note: To hold the file name `tempnam` allocates a new buffer. We leak
this buffer (omit the free), but I don't think we need to care.
Reviewed By: kubamracek
Differential Revision: https://reviews.llvm.org/D60591
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@358308 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/tsan/Darwin/gcd-fd.mm | 6 | ||||
-rw-r--r-- | test/tsan/Darwin/gcd-io-barrier-race.mm | 3 | ||||
-rw-r--r-- | test/tsan/Darwin/gcd-io-barrier.mm | 3 | ||||
-rw-r--r-- | test/tsan/Darwin/gcd-io-cleanup.mm | 3 | ||||
-rw-r--r-- | test/tsan/Darwin/gcd-io-race.mm | 3 | ||||
-rw-r--r-- | test/tsan/Darwin/gcd-io.mm | 3 |
6 files changed, 8 insertions, 13 deletions
diff --git a/test/tsan/Darwin/gcd-fd.mm b/test/tsan/Darwin/gcd-fd.mm index 21e5b07f1..1a67358ed 100644 --- a/test/tsan/Darwin/gcd-fd.mm +++ b/test/tsan/Darwin/gcd-fd.mm @@ -11,9 +11,9 @@ int main(int argc, const char *argv[]) { 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 @@ int main(int argc, const char *argv[]) { 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); diff --git a/test/tsan/Darwin/gcd-io-barrier-race.mm b/test/tsan/Darwin/gcd-io-barrier-race.mm index 742267b98..c8e019e41 100644 --- a/test/tsan/Darwin/gcd-io-barrier-race.mm +++ b/test/tsan/Darwin/gcd-io-barrier-race.mm @@ -19,8 +19,7 @@ int main(int argc, const char *argv[]) { 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); diff --git a/test/tsan/Darwin/gcd-io-barrier.mm b/test/tsan/Darwin/gcd-io-barrier.mm index 6fd6e4902..b7c55e90c 100644 --- a/test/tsan/Darwin/gcd-io-barrier.mm +++ b/test/tsan/Darwin/gcd-io-barrier.mm @@ -15,8 +15,7 @@ int main(int argc, const char *argv[]) { 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); diff --git a/test/tsan/Darwin/gcd-io-cleanup.mm b/test/tsan/Darwin/gcd-io-cleanup.mm index 570e37dd0..03d1160f9 100644 --- a/test/tsan/Darwin/gcd-io-cleanup.mm +++ b/test/tsan/Darwin/gcd-io-cleanup.mm @@ -10,8 +10,7 @@ int main(int argc, const char *argv[]) { 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); diff --git a/test/tsan/Darwin/gcd-io-race.mm b/test/tsan/Darwin/gcd-io-race.mm index 39dd806ee..482d98745 100644 --- a/test/tsan/Darwin/gcd-io-race.mm +++ b/test/tsan/Darwin/gcd-io-race.mm @@ -21,8 +21,7 @@ int main(int argc, const char *argv[]) { 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); diff --git a/test/tsan/Darwin/gcd-io.mm b/test/tsan/Darwin/gcd-io.mm index 07df71875..60ed8a9f2 100644 --- a/test/tsan/Darwin/gcd-io.mm +++ b/test/tsan/Darwin/gcd-io.mm @@ -98,8 +98,7 @@ int main(int argc, const char *argv[]) { 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); |