diff options
author | Alexey Samsonov <samsonov@google.com> | 2012-11-02 12:36:11 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2012-11-02 12:36:11 +0000 |
commit | a517641e8f4365fbc5e3cddf614ebc27efd69c35 (patch) | |
tree | 18f468d886ccd0100e76558ba437b8ad4632ecf8 /lib | |
parent | b1fe3021eca0843e37878d224ee7f32e32f40d99 (diff) | |
download | compiler-rt-a517641e8f4365fbc5e3cddf614ebc27efd69c35.tar.gz |
[Sanitizer] move unit test for Printf from tsan to sanitizer_common
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@167296 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sanitizer_common/sanitizer_common.cc | 2 | ||||
-rw-r--r-- | lib/sanitizer_common/tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lib/sanitizer_common/tests/sanitizer_printf_test.cc (renamed from lib/tsan/tests/unit/tsan_printf_test.cc) | 25 | ||||
-rw-r--r-- | lib/tsan/tests/unit/CMakeLists.txt | 1 |
4 files changed, 14 insertions, 15 deletions
diff --git a/lib/sanitizer_common/sanitizer_common.cc b/lib/sanitizer_common/sanitizer_common.cc index 96db316d1..d56cfdafd 100644 --- a/lib/sanitizer_common/sanitizer_common.cc +++ b/lib/sanitizer_common/sanitizer_common.cc @@ -143,7 +143,6 @@ void SortArray(uptr *array, uptr size) { using namespace __sanitizer; // NOLINT extern "C" { - void __sanitizer_set_report_path(const char *path) { if (!path) return; uptr len = internal_strlen(path); @@ -164,5 +163,4 @@ void __sanitizer_set_report_fd(int fd) { internal_close(report_fd); report_fd = fd; } - } // extern "C" diff --git a/lib/sanitizer_common/tests/CMakeLists.txt b/lib/sanitizer_common/tests/CMakeLists.txt index d4debc994..1c781a1bd 100644 --- a/lib/sanitizer_common/tests/CMakeLists.txt +++ b/lib/sanitizer_common/tests/CMakeLists.txt @@ -4,6 +4,7 @@ set(SANITIZER_UNITTESTS sanitizer_flags_test.cc sanitizer_libc_test.cc sanitizer_list_test.cc + sanitizer_printf_test.cc sanitizer_stackdepot_test.cc sanitizer_test_main.cc ) diff --git a/lib/tsan/tests/unit/tsan_printf_test.cc b/lib/sanitizer_common/tests/sanitizer_printf_test.cc index 0dfd1d2df..7a6a42ea9 100644 --- a/lib/tsan/tests/unit/tsan_printf_test.cc +++ b/lib/sanitizer_common/tests/sanitizer_printf_test.cc @@ -1,4 +1,4 @@ -//===-- tsan_printf_test.cc -----------------------------------------------===// +//===-- sanitizer_printf_test.cc ------------------------------------------===// // // The LLVM Compiler Infrastructure // @@ -7,16 +7,17 @@ // //===----------------------------------------------------------------------===// // -// This file is a part of ThreadSanitizer (TSan), a race detector. +// Tests for sanitizer_printf.cc // //===----------------------------------------------------------------------===// -#include "tsan_rtl.h" +#include "sanitizer_common/sanitizer_common.h" +#include "sanitizer_common/sanitizer_libc.h" #include "gtest/gtest.h" #include <string.h> #include <limits.h> -namespace __tsan { +namespace __sanitizer { TEST(Printf, Basic) { char buf[1024]; @@ -27,15 +28,15 @@ TEST(Printf, Basic) { (unsigned)10, (unsigned long)11, // NOLINT (void*)0x123, "_string_"); EXPECT_EQ(len, strlen(buf)); - EXPECT_EQ(0, strcmp(buf, "a-1b-2c4294967292e5fahbq" - "0x000000000123e_string_r")); + EXPECT_STREQ("a-1b-2c4294967292e5fahbq" + "0x000000000123e_string_r", buf); } TEST(Printf, OverflowStr) { char buf[] = "123456789"; uptr len = internal_snprintf(buf, 4, "%s", "abcdef"); // NOLINT EXPECT_EQ(len, (uptr)6); - EXPECT_EQ(0, strcmp(buf, "abc")); + EXPECT_STREQ("abc", buf); EXPECT_EQ(buf[3], 0); EXPECT_EQ(buf[4], '5'); EXPECT_EQ(buf[5], '6'); @@ -48,7 +49,7 @@ TEST(Printf, OverflowStr) { TEST(Printf, OverflowInt) { char buf[] = "123456789"; internal_snprintf(buf, 4, "%d", -123456789); // NOLINT - EXPECT_EQ(0, strcmp(buf, "-12")); + EXPECT_STREQ("-12", buf); EXPECT_EQ(buf[3], 0); EXPECT_EQ(buf[4], '5'); EXPECT_EQ(buf[5], '6'); @@ -61,7 +62,7 @@ TEST(Printf, OverflowInt) { TEST(Printf, OverflowUint) { char buf[] = "123456789"; internal_snprintf(buf, 4, "a%zx", (unsigned long)0x123456789); // NOLINT - EXPECT_EQ(0, strcmp(buf, "a12")); + EXPECT_STREQ("a12", buf); EXPECT_EQ(buf[3], 0); EXPECT_EQ(buf[4], '5'); EXPECT_EQ(buf[5], '6'); @@ -74,7 +75,7 @@ TEST(Printf, OverflowUint) { TEST(Printf, OverflowPtr) { char buf[] = "123456789"; internal_snprintf(buf, 4, "%p", (void*)0x123456789); // NOLINT - EXPECT_EQ(0, strcmp(buf, "0x0")); + EXPECT_STREQ("0x0", buf); EXPECT_EQ(buf[3], 0); EXPECT_EQ(buf[4], '5'); EXPECT_EQ(buf[5], '6'); @@ -91,7 +92,7 @@ static void TestMinMax(const char *fmt, T min, T max) { char buf2[1024]; snprintf(buf2, sizeof(buf2), fmt, min, max); EXPECT_EQ(len, strlen(buf)); - EXPECT_EQ(0, strcmp(buf, buf2)); + EXPECT_STREQ(buf2, buf); } TEST(Printf, MinMax) { @@ -103,4 +104,4 @@ TEST(Printf, MinMax) { TestMinMax<unsigned long>("%zx-%zx", 0, ULONG_MAX); // NOLINT } -} // namespace __tsan +} // namespace __sanitizer diff --git a/lib/tsan/tests/unit/CMakeLists.txt b/lib/tsan/tests/unit/CMakeLists.txt index 5608e2461..52ebdb826 100644 --- a/lib/tsan/tests/unit/CMakeLists.txt +++ b/lib/tsan/tests/unit/CMakeLists.txt @@ -4,7 +4,6 @@ set(TSAN_UNIT_TESTS tsan_mman_test.cc tsan_mutex_test.cc tsan_platform_test.cc - tsan_printf_test.cc tsan_shadow_test.cc tsan_stack_test.cc tsan_suppressions_test.cc |