Move files from shared/test/unit_test to /common (preamble, utilities)

unit_test/preamble/preamble_fixture.h -> common/fixtures
unit_test/source_level_debugger -> common/
unit_test/utilities/base_object_utils.h -> common/utilities
unit_test/utilities/destructor_counted.h -> common/utilities
unit_test/utilities/logger_tests.h -> common/utilities

Related-To: NEO-6524
Signed-off-by: Warchulski, Jaroslaw <jaroslaw.warchulski@intel.com>
This commit is contained in:
Warchulski, Jaroslaw
2022-08-11 15:58:56 +00:00
committed by Compute-Runtime-Automation
parent 649cd3441a
commit d795182eae
93 changed files with 175 additions and 211 deletions

View File

@@ -4,21 +4,18 @@
# SPDX-License-Identifier: MIT
#
target_sources(${TARGET_NAME} PRIVATE
target_sources(neo_shared_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}debug_file_reader_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/base_object_utils.h
${CMAKE_CURRENT_SOURCE_DIR}/const_stringref_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/containers_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/containers_tests_helpers.h
${CMAKE_CURRENT_SOURCE_DIR}/cpuintrinsics_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debug_file_reader_tests.inl
${CMAKE_CURRENT_SOURCE_DIR}/debug_settings_reader_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/destructor_counted.h
${CMAKE_CURRENT_SOURCE_DIR}/heap_allocator_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/io_functions_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/logger_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/logger_tests.h
${CMAKE_CURRENT_SOURCE_DIR}/numeric_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/perf_profiler_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/reference_tracked_object_tests.cpp
@@ -30,4 +27,4 @@ target_sources(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/wait_util_tests.cpp
)
add_subdirectories()
add_subdirectories()

View File

@@ -5,8 +5,8 @@
#
if(${NEO_TARGET_PROCESSOR} STREQUAL "aarch64")
target_sources(${TARGET_NAME} PRIVATE
target_sources(neo_shared_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/cpuinfo_tests_aarch64.cpp
)
endif()
endif()

View File

@@ -1,34 +0,0 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <memory>
namespace NEO {
template <typename T>
struct ReleaseObject {
void operator()(T *t) {
if (t != nullptr) {
t->release();
}
}
};
template <typename T>
using ReleaseableObjectPtr = std::unique_ptr<T, ReleaseObject<T>>;
template <typename T>
static ReleaseableObjectPtr<T> clUniquePtr(T *object) {
return ReleaseableObjectPtr<T>{object};
}
template <class _Ty, class... _Types>
inline ReleaseableObjectPtr<_Ty> makeReleaseable(_Types &&...args) {
return (ReleaseableObjectPtr<_Ty>(new _Ty(std::forward<_Types>(args)...)));
}
} // namespace NEO

View File

@@ -1,26 +0,0 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
namespace NEO {
template <typename BaseType, uint32_t ordinal>
struct DestructorCounted : public BaseType {
template <typename... Args>
DestructorCounted(uint32_t &destructorId, Args &&...args) : BaseType(std::forward<Args>(args)...),
destructorId(destructorId) {}
~DestructorCounted() override {
EXPECT_EQ(ordinal, destructorId);
destructorId++;
}
private:
uint32_t &destructorId;
};
} // namespace NEO

View File

@@ -1,16 +1,12 @@
#
# Copyright (C) 2021 Intel Corporation
# Copyright (C) 2021-2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(UTILITIES_CPUINFO_TESTS_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/cpuinfo_tests_linux.cpp
)
if(UNIX)
target_sources(${TARGET_NAME} PRIVATE
${UTILITIES_CPUINFO_TESTS_LINUX}
target_sources(neo_shared_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/cpuinfo_tests_linux.cpp
)
endif()
endif()

View File

@@ -5,7 +5,7 @@
*
*/
#include "shared/test/unit_test/utilities/logger_tests.h"
#include "shared/test/common/utilities/logger_tests.h"
#include "shared/source/memory_manager/allocation_type.h"
#include "shared/source/memory_manager/memory_manager.h"
@@ -13,7 +13,7 @@
#include "shared/source/utilities/logger.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/gtest_helpers.h"
#include "shared/test/unit_test/utilities/base_object_utils.h"
#include "shared/test/common/utilities/base_object_utils.h"
#include "gtest/gtest.h"

View File

@@ -1,59 +0,0 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/helpers/file_io.h"
#include "shared/source/helpers/string_helpers.h"
#include "shared/source/utilities/directory.h"
#include "shared/source/utilities/logger.h"
#include <map>
template <DebugFunctionalityLevel DebugLevel>
class TestFileLogger : public NEO::FileLogger<DebugLevel> {
public:
using NEO::FileLogger<DebugLevel>::FileLogger;
~TestFileLogger() override {
std::remove(NEO::FileLogger<DebugLevel>::logFileName.c_str());
}
void useRealFiles(bool value) {
mockFileSystem = !value;
}
void writeToFile(std::string filename,
const char *str,
size_t length,
std::ios_base::openmode mode) override {
savedFiles[filename] << std::string(str, str + length);
if (mockFileSystem == false) {
NEO::FileLogger<DebugLevel>::writeToFile(filename, str, length, mode);
}
};
int32_t createdFilesCount() {
return static_cast<int32_t>(savedFiles.size());
}
bool wasFileCreated(std::string filename) {
return savedFiles.find(filename) != savedFiles.end();
}
std::string getFileString(std::string filename) {
return savedFiles[filename].str();
}
protected:
bool mockFileSystem = true;
std::map<std::string, std::stringstream> savedFiles;
};
using FullyEnabledFileLogger = TestFileLogger<DebugFunctionalityLevel::Full>;
using FullyDisabledFileLogger = TestFileLogger<DebugFunctionalityLevel::None>;

View File

@@ -1,16 +1,12 @@
#
# Copyright (C) 2021 Intel Corporation
# Copyright (C) 2021-2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(UTILITIES_CPUINFO_TESTS_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/cpuinfo_tests_windows.cpp
)
if(WIN32)
target_sources(${TARGET_NAME} PRIVATE
${UTILITIES_CPUINFO_TESTS_WINDOWS}
target_sources(neo_shared_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/cpuinfo_tests_windows.cpp
)
endif()
endif()

View File

@@ -5,10 +5,10 @@
#
if(${NEO_TARGET_PROCESSOR} STREQUAL "x86_64")
target_sources(${TARGET_NAME} PRIVATE
target_sources(neo_shared_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/cpuinfo_tests_x86_64.cpp
)
add_subdirectories()
endif()
endif()

View File

@@ -5,7 +5,5 @@
#
if(UNIX)
target_sources(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/cpuinfo_tests_x86_64_linux.cpp
)
endif()
target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/cpuinfo_tests_x86_64_linux.cpp)
endif()