[llvm-commits] [compiler-rt] r172723 - /compiler-rt/trunk/lib/asan/tests/asan_test.cc
Kostya Serebryany
kcc at google.com
Thu Jan 17 06:58:29 PST 2013
Author: kcc
Date: Thu Jan 17 08:58:29 2013
New Revision: 172723
URL: http://llvm.org/viewvc/llvm-project?rev=172723&view=rev
Log:
[asan] restructure read/pread/pread64 tests
Modified:
compiler-rt/trunk/lib/asan/tests/asan_test.cc
Modified: compiler-rt/trunk/lib/asan/tests/asan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_test.cc?rev=172723&r1=172722&r2=172723&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_test.cc (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_test.cc Thu Jan 17 08:58:29 2013
@@ -1667,44 +1667,30 @@
CallMemTransferByPointer(&memmove);
}
-#if defined(__linux__) && !defined(ANDROID) && !defined(__ANDROID__)
+#if defined(__linux__) && !defined(ANDROID)
+#define READ_TEST(READ_N_BYTES) \
+ char *x = new char[10]; \
+ int fd = open("/proc/self/stat", O_RDONLY); \
+ ASSERT_GT(fd, 0); \
+ EXPECT_DEATH(READ_N_BYTES, \
+ ASAN_PCRE_DOTALL \
+ "AddressSanitizer: heap-buffer-overflow" \
+ ".* is located 0 bytes to the right of 10-byte region"); \
+ close(fd); \
+ delete [] x; \
+
TEST(AddressSanitizer, pread) {
- char *x = new char[10];
- int fd = open("/proc/self/stat", O_RDONLY);
- ASSERT_GT(fd, 0);
- EXPECT_DEATH(pread(fd, x, 15, 0),
- ASAN_PCRE_DOTALL
- "AddressSanitizer: heap-buffer-overflow"
- ".* is located 0 bytes to the right of 10-byte region");
- close(fd);
- delete [] x;
+ READ_TEST(pread(fd, x, 15, 0));
}
TEST(AddressSanitizer, pread64) {
- char *x = new char[10];
- int fd = open("/proc/self/stat", O_RDONLY);
- ASSERT_GT(fd, 0);
- EXPECT_DEATH(pread64(fd, x, 15, 0),
- ASAN_PCRE_DOTALL
- "AddressSanitizer: heap-buffer-overflow"
- ".* is located 0 bytes to the right of 10-byte region");
- close(fd);
- delete [] x;
+ READ_TEST(pread64(fd, x, 15, 0));
}
TEST(AddressSanitizer, read) {
- char *x = new char[10];
- int fd = open("/proc/self/stat", O_RDONLY);
- ASSERT_GT(fd, 0);
- EXPECT_DEATH(read(fd, x, 15),
- ASAN_PCRE_DOTALL
- "AddressSanitizer: heap-buffer-overflow"
- ".* is located 0 bytes to the right of 10-byte region");
- close(fd);
- delete [] x;
+ READ_TEST(read(fd, x, 15));
}
-
-#endif // defined(__linux__) && !defined(ANDROID) && !defined(__ANDROID__)
+#endif // defined(__linux__) && !defined(ANDROID)
// This test case fails
// Clang optimizes memcpy/memset calls which lead to unaligned access
More information about the llvm-commits
mailing list