forked from OSchip/llvm-project
[NFC][sanitizer] Fix android bot after D102815
https://lab.llvm.org/buildbot/#/builders/77/builds/6519
This commit is contained in:
parent
4468e5b899
commit
f50b87e9ef
|
@ -54,6 +54,7 @@ endforeach()
|
||||||
set(SANITIZER_TEST_CFLAGS_COMMON
|
set(SANITIZER_TEST_CFLAGS_COMMON
|
||||||
${COMPILER_RT_UNITTEST_CFLAGS}
|
${COMPILER_RT_UNITTEST_CFLAGS}
|
||||||
${COMPILER_RT_GTEST_CFLAGS}
|
${COMPILER_RT_GTEST_CFLAGS}
|
||||||
|
${COMPILER_RT_GMOCK_CFLAGS}
|
||||||
-I${COMPILER_RT_SOURCE_DIR}/include
|
-I${COMPILER_RT_SOURCE_DIR}/include
|
||||||
-I${COMPILER_RT_SOURCE_DIR}/lib
|
-I${COMPILER_RT_SOURCE_DIR}/lib
|
||||||
-I${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common
|
-I${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common
|
||||||
|
@ -151,7 +152,7 @@ macro(add_sanitizer_tests_for_arch arch)
|
||||||
generate_compiler_rt_tests(SANITIZER_TEST_OBJECTS SanitizerUnitTests
|
generate_compiler_rt_tests(SANITIZER_TEST_OBJECTS SanitizerUnitTests
|
||||||
"Sanitizer-${arch}-Test" ${arch}
|
"Sanitizer-${arch}-Test" ${arch}
|
||||||
RUNTIME "${SANITIZER_COMMON_LIB}"
|
RUNTIME "${SANITIZER_COMMON_LIB}"
|
||||||
SOURCES ${SANITIZER_UNITTESTS} ${COMPILER_RT_GTEST_SOURCE}
|
SOURCES ${SANITIZER_UNITTESTS} ${COMPILER_RT_GTEST_SOURCE} ${COMPILER_RT_GMOCK_SOURCE}
|
||||||
COMPILE_DEPS ${SANITIZER_TEST_HEADERS}
|
COMPILE_DEPS ${SANITIZER_TEST_HEADERS}
|
||||||
DEPS gtest
|
DEPS gtest
|
||||||
CFLAGS ${SANITIZER_TEST_CFLAGS_COMMON} ${extra_flags}
|
CFLAGS ${SANITIZER_TEST_CFLAGS_COMMON} ${extra_flags}
|
||||||
|
@ -208,6 +209,7 @@ if(ANDROID)
|
||||||
add_executable(SanitizerTest
|
add_executable(SanitizerTest
|
||||||
${SANITIZER_UNITTESTS}
|
${SANITIZER_UNITTESTS}
|
||||||
${COMPILER_RT_GTEST_SOURCE}
|
${COMPILER_RT_GTEST_SOURCE}
|
||||||
|
${COMPILER_RT_GMOCK_SOURCE}
|
||||||
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
|
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
|
||||||
$<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
|
$<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
|
||||||
$<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>)
|
$<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>)
|
||||||
|
|
|
@ -14,8 +14,16 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "gmock/gmock.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "sanitizer_common/sanitizer_common.h"
|
#include "sanitizer_common/sanitizer_common.h"
|
||||||
|
#include "sanitizer_internal_defs.h"
|
||||||
|
|
||||||
|
using testing::ContainsRegex;
|
||||||
|
using testing::MatchesRegex;
|
||||||
|
|
||||||
namespace __sanitizer {
|
namespace __sanitizer {
|
||||||
|
|
||||||
|
@ -185,32 +193,9 @@ TEST_F(StackPrintTest, SKIP_ON_SPARC(ContainsFullTrace)) {
|
||||||
|
|
||||||
char buf[3000];
|
char buf[3000];
|
||||||
uptr len = trace.PrintTo(buf, sizeof(buf));
|
uptr len = trace.PrintTo(buf, sizeof(buf));
|
||||||
|
EXPECT_THAT(std::string(buf),
|
||||||
// This is the no-truncation case.
|
MatchesRegex("(#[0-9]+ 0x[0-9a-f]+\n){" +
|
||||||
ASSERT_LT(len, sizeof(buf));
|
std::to_string(trace.size) + "}\n"));
|
||||||
|
|
||||||
// Printed contents should always end with an empty line, unless truncated.
|
|
||||||
EXPECT_EQ(buf[len - 2], '\n');
|
|
||||||
EXPECT_EQ(buf[len - 1], '\n');
|
|
||||||
EXPECT_EQ(buf[len], '\0');
|
|
||||||
|
|
||||||
// Buffer contents are delimited by newlines, by default.
|
|
||||||
char *saveptr;
|
|
||||||
char *line = strtok_r(buf, "\n", &saveptr);
|
|
||||||
|
|
||||||
// Checks buffer contents line-by-line.
|
|
||||||
for (u32 i = 0; i < trace.size; ++i) {
|
|
||||||
char traceline[100];
|
|
||||||
|
|
||||||
// Should be synced with the stack trace format, set above.
|
|
||||||
snprintf(traceline, sizeof(traceline) - 1, "#%u 0x%lx", i,
|
|
||||||
trace.trace[i] - 1);
|
|
||||||
|
|
||||||
EXPECT_STREQ(line, traceline);
|
|
||||||
line = strtok_r(NULL, "\n", &saveptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
EXPECT_EQ(line, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(StackPrintTest, SKIP_ON_SPARC(TruncatesContents)) {
|
TEST_F(StackPrintTest, SKIP_ON_SPARC(TruncatesContents)) {
|
||||||
|
|
Loading…
Reference in New Issue