summaryrefslogtreecommitdiff
path: root/lib/asan/tests
diff options
context:
space:
mode:
authorKamil Rytarowski <n54@gmx.com>2017-08-07 23:38:14 +0000
committerKamil Rytarowski <n54@gmx.com>2017-08-07 23:38:14 +0000
commit0f9a6a534e6e1d44676a06c37061522a75edab38 (patch)
treeb60541860e25e10d9615347b4b8a2ada7a852997 /lib/asan/tests
parentc1c4d6655443998352adcfeb89e593c07f7be243 (diff)
Fix asan_test.cc build on NetBSD
Summary: Include <stdarg.h> for variable argument list macros (va_list, va_start etc). Add fallback definition of _LIBCPP_GET_C_LOCALE, this is required for GNU libstdc++ compatibility. Define new macro SANITIZER_GET_C_LOCALE. This value is currently required for FreeBSD and NetBSD for printf_l(3) tests. Sponsored by <The NetBSD Foundation> Reviewers: joerg, kcc, vitalybuka, filcab, fjricci Reviewed By: vitalybuka Subscribers: llvm-commits, emaste, kubamracek, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36406 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@310323 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/asan/tests')
-rw-r--r--lib/asan/tests/asan_test.cc30
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/asan/tests/asan_test.cc b/lib/asan/tests/asan_test.cc
index 7e9cf3bab..ed000327f 100644
--- a/lib/asan/tests/asan_test.cc
+++ b/lib/asan/tests/asan_test.cc
@@ -13,6 +13,17 @@
#include "asan_test_utils.h"
#include <errno.h>
+#include <stdarg.h>
+
+#ifdef _LIBCPP_GET_C_LOCALE
+#define SANITIZER_GET_C_LOCALE _LIBCPP_GET_C_LOCALE
+#else
+#if defined(__FreeBSD__)
+#define SANITIZER_GET_C_LOCALE 0
+#elif defined(__NetBSD__)
+#define SANITIZER_GET_C_LOCALE LC_C_LOCALE
+#endif
+#endif
NOINLINE void *malloc_fff(size_t size) {
void *res = malloc/**/(size); break_optimization(0); return res;}
@@ -1328,19 +1339,18 @@ static int vsnprintf_l_wrapper(char *s, size_t n,
TEST(AddressSanitizer, snprintf_l) {
char buff[5];
// Check that snprintf_l() works fine with Asan.
- int res = snprintf_l(buff, 5,
- _LIBCPP_GET_C_LOCALE, "%s", "snprintf_l()");
+ int res = snprintf_l(buff, 5, SANITIZER_GET_C_LOCALE, "%s", "snprintf_l()");
EXPECT_EQ(12, res);
// Check that vsnprintf_l() works fine with Asan.
- res = vsnprintf_l_wrapper(buff, 5,
- _LIBCPP_GET_C_LOCALE, "%s", "vsnprintf_l()");
+ res = vsnprintf_l_wrapper(buff, 5, SANITIZER_GET_C_LOCALE, "%s",
+ "vsnprintf_l()");
EXPECT_EQ(13, res);
- EXPECT_DEATH(snprintf_l(buff, 10,
- _LIBCPP_GET_C_LOCALE, "%s", "snprintf_l()"),
- "AddressSanitizer: stack-buffer-overflow");
- EXPECT_DEATH(vsnprintf_l_wrapper(buff, 10,
- _LIBCPP_GET_C_LOCALE, "%s", "vsnprintf_l()"),
- "AddressSanitizer: stack-buffer-overflow");
+ EXPECT_DEATH(
+ snprintf_l(buff, 10, SANITIZER_GET_C_LOCALE, "%s", "snprintf_l()"),
+ "AddressSanitizer: stack-buffer-overflow");
+ EXPECT_DEATH(vsnprintf_l_wrapper(buff, 10, SANITIZER_GET_C_LOCALE, "%s",
+ "vsnprintf_l()"),
+ "AddressSanitizer: stack-buffer-overflow");
}
#endif