Fix build with USE_ASAN=ON

Signed-off-by: Mateusz Tabaka <tab.debugteam@gmail.com>

https://github.com/intel/compute-runtime/pull/314

Change-Id: I2b699df3f158b961a1a329fb81de8cd7115d06bc
This commit is contained in:
8tab
2020-05-20 23:01:05 +02:00
committed by sys_ocldev
parent d291d61472
commit 7937da71f6
15 changed files with 40 additions and 17 deletions

View File

@ -656,6 +656,7 @@ else()
if(CMAKE_COMPILER_IS_GNUCC)
set(ASAN_FLAGS " -fsanitize=address -fno-omit-frame-pointer -DSANITIZER_BUILD")
set(ASAN_LIBS "asan")
set(GTEST_ENV ${GTEST_ENV} LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/opencl/test/unit_test/lsan_suppressions.txt)
else()
message(STATUS "Address sanitization with clang not yet support")
endif()

View File

@ -17,7 +17,7 @@ if(NOT SKIP_NEO_UNIT_TESTS)
POST_BUILD
COMMAND WORKING_DIRECTORY ${TargetDir}
COMMAND echo Running igdrcl_tests ${target} ${slices}x${subslices}x${eu_per_ss} in ${TargetDir}/${product}
COMMAND $<TARGET_FILE:igdrcl_tests> --product ${product} --slices ${slices} --subslices ${subslices} --eu_per_ss ${eu_per_ss} ${GTEST_EXCEPTION_OPTIONS} --gtest_repeat=${GTEST_REPEAT} ${GTEST_SHUFFLE} ${IGDRCL_TESTS_LISTENER_OPTION} ${GTEST_FILTER_OPTION}
COMMAND ${GTEST_ENV} $<TARGET_FILE:igdrcl_tests> --product ${product} --slices ${slices} --subslices ${subslices} --eu_per_ss ${eu_per_ss} ${GTEST_EXCEPTION_OPTIONS} --gtest_repeat=${GTEST_REPEAT} ${GTEST_SHUFFLE} ${IGDRCL_TESTS_LISTENER_OPTION} ${GTEST_FILTER_OPTION}
)
if(WIN32 AND ${CMAKE_BUILD_TYPE} STREQUAL "Debug" AND "${IGDRCL_OPTION__BITS}" STREQUAL "64" AND APPVERIFIER_ALLOWED)

View File

@ -389,7 +389,7 @@ target_sources(${TARGET_NAME_L0} PRIVATE $<TARGET_OBJECTS:${L0_RELEASE_LIB_NAME}
target_link_libraries(${TARGET_NAME_L0}
${NEO_STATICALLY_LINKED_LIBRARIES}
${OS_SPECIFIC_LIBS}
${OS_SPECIFIC_LIBS} ${ASAN_LIBS} ${TSAN_LIBS}
)
if(UNIX)

View File

@ -69,11 +69,14 @@ std::string getRunPath(char *argv0) {
res = res.substr(0, pos);
if (res == "." || pos == std::string::npos) {
char *cwd;
#if defined(__linux__)
res = getcwd(nullptr, 0);
cwd = getcwd(nullptr, 0);
#else
res = _getcwd(nullptr, 0);
cwd = _getcwd(nullptr, 0);
#endif
res = cwd;
free(cwd);
}
return res;

View File

@ -4,6 +4,8 @@
# SPDX-License-Identifier: MIT
#
link_libraries(${ASAN_LIBS} ${TSAN_LIBS})
set(TARGET_NAME ${TARGET_NAME_L0}_tools_tests)
append_sources_from_properties(L0_CORE_ENABLERS NEO_CORE_SRCS_LINK)

View File

@ -122,6 +122,10 @@ if(GTEST_FILTERING_PATTERN)
message(STATUS "GTest filter for regular tests: ${GTEST_FILTERING_PATTERN}")
endif()
if(USE_ASAN)
set(GTEST_ENV "LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/lsan_suppressions.txt")
endif()
if(NOT MSVC)
set_source_files_properties(helpers/uint16_sse4_tests.cpp PROPERTIES COMPILE_FLAGS -msse4.2)
endif()

View File

@ -28,6 +28,10 @@ class CCustomEventListener : public ::testing::TestEventListener {
[](unsigned char c) { return std::toupper(c); });
}
~CCustomEventListener() {
delete _listener;
}
private:
void OnTestProgramStart(const ::testing::UnitTest &unitTest) override {
}

View File

@ -31,7 +31,7 @@ class DrmNullDeviceTestsFixture {
void TearDown() {
}
Drm *drmNullDevice;
std::unique_ptr<Drm> drmNullDevice;
ExecutionEnvironment executionEnvironment;
protected:

View File

@ -15,10 +15,10 @@
class DrmWrap : public NEO::Drm {
public:
static NEO::Drm *createDrm(RootDeviceEnvironment &rootDeviceEnvironment) {
static std::unique_ptr<NEO::Drm> createDrm(RootDeviceEnvironment &rootDeviceEnvironment) {
auto hwDeviceIds = OSInterface::discoverDevices(rootDeviceEnvironment.executionEnvironment);
if (!hwDeviceIds.empty()) {
return NEO::Drm::create(std::move(hwDeviceIds[0]), rootDeviceEnvironment);
return std::unique_ptr<Drm>{NEO::Drm::create(std::move(hwDeviceIds[0]), rootDeviceEnvironment)};
}
return nullptr;
}

View File

@ -0,0 +1 @@
leak:OsAgnosticMemoryManager_pleaseDetectLeak_Test::TestBody()

View File

@ -167,11 +167,14 @@ std::string getRunPath(char *argv0) {
res = res.substr(0, pos);
if (res == "." || pos == std::string::npos) {
char *cwd;
#if defined(__linux__)
res = getcwd(nullptr, 0);
cwd = getcwd(nullptr, 0);
#else
res = _getcwd(nullptr, 0);
cwd = _getcwd(nullptr, 0);
#endif
res = cwd;
free(cwd);
}
return res;

View File

@ -22,12 +22,15 @@ const char *fSeparator = "/";
Environment *gEnvironment;
std::string getRunPath() {
std::string res;
char *cwd;
#if defined(__linux__)
res = getcwd(nullptr, 0);
cwd = getcwd(nullptr, 0);
#else
res = _getcwd(nullptr, 0);
cwd = _getcwd(nullptr, 0);
#endif
std::string res{cwd};
free(cwd);
return res;
}

View File

@ -73,6 +73,7 @@ OfflineCompiler::OfflineCompiler() = default;
OfflineCompiler::~OfflineCompiler() {
delete[] irBinary;
delete[] genBinary;
delete[] debugDataBinary;
}
OfflineCompiler *OfflineCompiler::create(size_t numArgs, const std::vector<std::string> &allArgs, bool dumpFiles, int &retVal, OclocArgHelper *helper) {

View File

@ -188,9 +188,7 @@ static void deallocate(void *p) {
deleteCallback(p);
if (!fastLeakDetectionEnabled) {
if (p) {
free(p);
}
free(p);
return;
}

View File

@ -165,11 +165,14 @@ std::string getRunPath(char *argv0) {
res = res.substr(0, pos);
if (res == "." || pos == std::string::npos) {
char *cwd;
#if defined(__linux__)
res = getcwd(nullptr, 0);
cwd = getcwd(nullptr, 0);
#else
res = _getcwd(nullptr, 0);
cwd = _getcwd(nullptr, 0);
#endif
res = cwd;
free(cwd);
}
return res;