SWDEV-277697 - [CatchTest] Fix Documentation, Add test to AMD specific, Add HIP Macros, New Binary for multiproc tests

Change-Id: I3783caf85c694b724ed55b778220b8ef9a39f84b
This commit is contained in:
Jatin Chaudhary authored and Jatin Chaudhary committed 2021-05-25 07:12:54 -04:00
1 parent f088812b6f
commit da360c2aab
17 files changed
+603 -130

No files matched your search

+24 -6
View File
@@ -1,11 +1,29 @@
if(CMAKE_BUILD_TYPE MATCHES "^Debug$")
add_definitions(-DHT_LOG_ENABLE)
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTAO_PEGTL_STD_EXPERIMENTAL_FILESYSTEM=1")
add_library(ht_context SHARED EXCLUDE_FROM_ALL hip_test_context.cc)
set_property(TARGET ht_context PROPERTY CXX_STANDARD 17)
target_link_libraries(ht_context PRIVATE stdc++fs)
add_executable(UnitTests EXCLUDE_FROM_ALL main.cc)
target_link_libraries(UnitTests PRIVATE ht_context DeviceLibs MemoryTest Kernels stdc++fs)
add_executable(UnitTests EXCLUDE_FROM_ALL main.cc hip_test_context.cc)
set_property(TARGET UnitTests PROPERTY CXX_STANDARD 17)
target_link_libraries(UnitTests PRIVATE DeviceLibs
MemoryTest
Kernels
stdc++fs)
# Add AMD Only Tests
if(HIP_PLATFORM MATCHES "amd")
target_link_libraries(UnitTests PRIVATE RTC)
endif()
catch_discover_tests(UnitTests PROPERTIES SKIP_REGULAR_EXPRESSION "HIP_SKIP_THIS_TEST")
add_dependencies(build_tests UnitTests)
# Add Multiproc tests as seperate binary
if(UNIX)
add_executable(MultiProcTests EXCLUDE_FROM_ALL main.cc hip_test_context.cc)
set_property(TARGET MultiProcTests PROPERTY CXX_STANDARD 17)
target_link_libraries(MultiProcTests PRIVATE MultiProc
stdc++fs)
catch_discover_tests(MultiProcTests PROPERTIES SKIP_REGULAR_EXPRESSION "HIP_SKIP_THIS_TEST")
add_dependencies(build_tests MultiProcTests)
endif()
+7 -56
View File
@@ -15,26 +15,6 @@ namespace fs = std::experimental::filesystem;
#include <regex>
static std::string getValue(std::string option, const std::string& opt_str) {
std::string s_opt = opt_str;
return s_opt.erase(0, option.size());
}
static std::string trimName(std::string input, char trim) {
auto pos_ = input.find(trim);
auto res = input;
if (pos_ == std::string::npos) {
input = "";
} else {
res = input.substr(0, pos_);
input = input.substr(pos_);
}
return res;
}
const std::vector<std::string>& TestContext::getDevices() const { return config_.devices; }
const std::vector<std::string>& TestContext::getTargetId() const { return config_.targetId; }
void TestContext::detectOS() {
#if (HT_WIN == 1)
p_windows = true;
@@ -57,18 +37,21 @@ void TestContext::fillConfig() {
(env_config != nullptr) ? env_config : "Not found, using default config");
// Check if path has been provided
std::string def_config_json = "config.json";
std::string config_str;
if (env_config != nullptr) {
config_str = env_config;
} else {
config_str = "config.json";
config_str = def_config_json;
}
fs::path config_path = config_str;
if (config_path.has_parent_path()) {
if (config_path.has_parent_path() && config_path.has_filename()) {
config_.json_file = config_str;
} else if (config_path.has_parent_path()) {
config_.json_file = config_path / def_config_json;
} else {
config_.json_file = exe_path + config_str;
config_.json_file = exe_path + def_config_json;
}
LogPrintf("Config file path: %s", config_.json_file.c_str());
@@ -79,37 +62,6 @@ void TestContext::fillConfig() {
LogPrintf("%s", "Either Config or Os is unknown, this wont end well");
abort();
}
int deviceCount = 0;
auto res = hipGetDeviceCount(&deviceCount);
if (res != hipSuccess) {
LogPrintf("HIP Device Count query failed with: %s", hipGetErrorString(res));
abort();
}
if (deviceCount == 0) {
LogPrintf("%s", "No hip devices found");
abort();
}
config_.devices.reserve(deviceCount);
for (int i = 0; i < deviceCount; i++) {
hipDeviceProp_t props;
res = hipGetDeviceProperties(&props, i);
if (res != hipSuccess) {
LogPrintf("HIP Device Count query failed with: %s", hipGetErrorString(res));
abort();
}
if (amd) {
std::string tid = std::string(props.gcnArchName);
config_.targetId.push_back(tid);
std::string dev = trimName(tid, ':');
config_.devices.push_back(dev);
} else if (nvidia) {
config_.devices.push_back(std::string(props.name));
} else {
LogPrintf("%s", "Unknown platform");
abort();
}
}
}
TestContext::TestContext(int argc, char** argv) {
@@ -122,6 +74,7 @@ TestContext::TestContext(int argc, char** argv) {
}
void TestContext::setExePath(int argc, char** argv) {
if (argc == 0) return;
fs::path p = std::string(argv[0]);
if (p.has_filename()) p.remove_filename();
exe_path = p.string();
@@ -168,8 +121,6 @@ bool TestContext::parseJsonFile() {
picojson::value v;
std::string err;
const char* json_end =
picojson::parse(v, json_str.data(), json_str.data() + json_str.size(), &err);
if (err.size() > 1) {
LogPrintf("Error from PicoJson: %s", err.data());
return false;
+1 -1
View File
@@ -6,7 +6,7 @@ int main(int argc, char** argv) {
auto& context = TestContext::get(argc, argv);
if (context.skipTest()) {
// CTest uses this regex to figure out if the test has been skipped
std::cout << "HIP_SKIP_THIS_TEST" << context.getCurrentTest() << std::endl;
std::cout << "HIP_SKIP_THIS_TEST" << std::endl;
return 0;
}
return Catch::Session().run(argc, argv);