summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Potapenko <glider@google.com>2012-01-23 10:06:14 +0000
committerAlexander Potapenko <glider@google.com>2012-01-23 10:06:14 +0000
commitf9392011c871acc204901ad6b957d91e352b7ea5 (patch)
tree7992ac0664bea0e577bde935629e18b30ed0d99c
parent28ea8f523b9fdf14d43d0d3a8b3331fc8a87df49 (diff)
downloadbcm5719-llvm-f9392011c871acc204901ad6b957d91e352b7ea5.tar.gz
bcm5719-llvm-f9392011c871acc204901ad6b957d91e352b7ea5.zip
Add a test for CFStringCreateCopy.
Normally this function should not create copies of constant strings, but it does when the default CFAllocator is replaced (e.g. under AddressSanitizer) This test is related to http://code.google.com/p/address-sanitizer/issues/detail?id=10 llvm-svn: 148695
-rw-r--r--compiler-rt/lib/asan/tests/asan_test.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler-rt/lib/asan/tests/asan_test.cc b/compiler-rt/lib/asan/tests/asan_test.cc
index ee0f46d26f0..d8657bf0cf3 100644
--- a/compiler-rt/lib/asan/tests/asan_test.cc
+++ b/compiler-rt/lib/asan/tests/asan_test.cc
@@ -29,6 +29,8 @@
#ifndef __APPLE__
#include <malloc.h>
+#else
+#include <CoreFoundation/CFString.h>
#endif // __APPLE__
#ifdef __APPLE__
@@ -1894,6 +1896,14 @@ TEST(AddressSanitizerMac, DISABLED_TSDWorkqueueTest) {
pthread_join(th, NULL);
pthread_key_delete(test_key);
}
+
+// Test that CFStringCreateCopy does not copy constant strings.
+TEST(AddressSanitizerMac, DISABLED_CFStringCreateCopy) {
+ CFStringRef str = CFSTR("Hello world!\n");
+ CFStringRef str2 = CFStringCreateCopy(0, str);
+ EXPECT_EQ(str, str2);
+}
+
#endif // __APPLE__
int main(int argc, char **argv) {
OpenPOWER on IntegriCloud