diff --git a/projects/rdc/tests/rdc_tests/CMakeLists.txt b/projects/rdc/tests/rdc_tests/CMakeLists.txt index 91995d1b3e..a9891099aa 100755 --- a/projects/rdc/tests/rdc_tests/CMakeLists.txt +++ b/projects/rdc/tests/rdc_tests/CMakeLists.txt @@ -42,11 +42,8 @@ endif() # Required Defines first: -set(RDC_INC_DIR ${RDC_DIR}/include) -set(RDC_LIB_DIR ${RDC_DIR}/build/rdc_libs) -set(RSMI_INC_DIR ${ROCM_DIR}/rocm_smi/include) -set(RSMI_LIB_DIR ${ROCM_DIR}/rocm_smi/lib) - +set(RDC_INC_DIR ${ROCM_DIR}/include) +set(RDC_LIB_DIR ${ROCM_DIR}/rdc/lib) # # Determine RDC Header files are present @@ -75,6 +72,7 @@ message("Build Configuration:") message("-----------BuildType: " ${BUILD_TYPE}) message("------------Compiler: " ${CMAKE_CXX_COMPILER}) message("-------------Version: " ${CMAKE_CXX_COMPILER_VERSION}) +message("------------ROCM_DIR: " ${ROCM_DIR}) message("--------Proj Src Dir: " ${PROJECT_SOURCE_DIR}) message("--------Proj Bld Dir: " ${PROJECT_BINARY_DIR}) message("--------Proj Lib Dir: " ${PROJECT_BINARY_DIR}/lib) @@ -156,7 +154,6 @@ add_executable(${RDCTST} ${rdctstSources} ${functionalSources}) # Header file include path target_include_directories(${RDCTST} PRIVATE ${RDC_INC_DIR} - PRIVATE ${RSMI_INC_DIR} PRIVATE ${RDCTST_ROOT}/.. PRIVATE ${RDCTST_ROOT}/gtest/include) diff --git a/projects/rdc/tests/rdc_tests/main.cc b/projects/rdc/tests/rdc_tests/main.cc index 3616f10bfb..19c70d9b22 100755 --- a/projects/rdc/tests/rdc_tests/main.cc +++ b/projects/rdc/tests/rdc_tests/main.cc @@ -47,7 +47,6 @@ static void SetFlags(TestBase *test) { test->set_verbosity(sRDCGlvalues->verbosity); test->set_dont_fail(sRDCGlvalues->dont_fail); - test->set_init_options(sRDCGlvalues->init_options); test->set_monitor_server_ip(sRDCGlvalues->monitor_server_ip); test->set_monitor_server_port(sRDCGlvalues->monitor_server_port); test->set_secure(sRDCGlvalues->secure); @@ -175,13 +174,13 @@ static int killRDCD(int pid = 0) { return -1; } -static int startRDCD(std::string *rdcd_path) { +static int startRDCD(std::string *rdcd_path, char *envp[]) { assert(rdcd_path != nullptr); const char *rdcd_cl[128] = {rdcd_path->c_str(), "-u", NULL}; int pid = fork(); if (pid == 0) { - if (-1 == execve(rdcd_cl[0], (char **)rdcd_cl , NULL)) { // NOLINT + if (-1 == execve(rdcd_cl[0], (char **)rdcd_cl , envp)) { // NOLINT perror("child process failed to start rdcd"); return -1; } @@ -192,7 +191,7 @@ static int startRDCD(std::string *rdcd_path) { return pid; } -int main(int argc, char** argv) { +int main(int argc, char** argv, char* envp[]) { ::testing::InitGoogleTest(&argc, argv); RDCTstGlobals settings; @@ -204,18 +203,19 @@ int main(int argc, char** argv) { settings.monitor_verbosity = 1; settings.num_iterations = 1; settings.dont_fail = false; - settings.init_options = 0; - settings.rdcd_path = "../../../build/server/rdcd"; + settings.rdcd_path = "/usr/sbin/rdcd"; settings.monitor_server_ip = ""; settings.monitor_server_port = ""; settings.secure = false; settings.standalone = false; + settings.batch_mode = false; if (ProcessCmdline(&settings, argc, argv)) { return 1; } - // Select the embedded mode and standalone mode dynamically. + if (!settings.batch_mode) { + // Select the embedded mode and standalone mode dynamically. std::cout << "Start rdci in: \n"; std::cout << "0 - Embedded mode \n"; std::cout << "1 - Standalone mode \n"; @@ -227,16 +227,48 @@ int main(int argc, char** argv) { std::cout << std::endl; std::cout << (settings.standalone? "Standalone mode selected.\n":"Embedded mode selected.\n"); + } + sRDCGlvalues = &settings; + + if (!settings.standalone || settings.batch_mode) { + if (settings.batch_mode) { + // The test needs to know to run Embedded if we are in batch mode + sRDCGlvalues->standalone = false; + } + std::cout << "****************************************" << std::endl; + std::cout << "****************************************" << std::endl; + std::cout << "****************************************" << std::endl; + std::cout << "Running tests in Embedded mode (no rdcd)" << std::endl; + std::cout << "****************************************" << std::endl; + std::cout << "****************************************" << std::endl; + std::cout << "****************************************" << std::endl; + ret = RUN_ALL_TESTS(); + } + + if (settings.standalone || settings.batch_mode) { + if (settings.batch_mode) { + settings.standalone = true; + } + std::cout << "*********************************************" << std::endl; + std::cout << "*********************************************" << std::endl; + std::cout << "*********************************************" << std::endl; + std::cout << "Running tests in Stand-alone mode (with rdcd)" << std::endl; + std::cout << "*********************************************" << std::endl; + std::cout << "*********************************************" << std::endl; + std::cout << "*********************************************" << std::endl; - if (settings.standalone){ if (settings.monitor_server_ip == "") { if (settings.rdcd_path != "") { if (killRDCD()) { return -1; } - rdcd_pid = startRDCD(&settings.rdcd_path); + rdcd_pid = startRDCD(&settings.rdcd_path, envp); assert(rdcd_pid == getPIDFromName("rdcd")); + if (rdcd_pid != getPIDFromName("rdcd")) { + std::cout << "Failed to start rdcd. Exiting" << std::endl; + return -1; + } } else { if (getPIDFromName("rdcd") == -1) { std::cout << @@ -246,31 +278,16 @@ int main(int argc, char** argv) { } } } - } - sRDCGlvalues = &settings; - ret = RUN_ALL_TESTS(); - - if (ret) { - return ret; - } - - std::cout << "****************************************" << std::endl; - std::cout << "****************************************" << std::endl; - std::cout << "****************************************" << std::endl; - std::cout << "Re-running tests with init options: " << std::hex << - settings.init_options << std::endl; - std::cout << "****************************************" << std::endl; - std::cout << "****************************************" << std::endl; - std::cout << "****************************************" << std::endl; - settings.init_options = RSMI_INIT_FLAG_ALL_GPUS; - ret = RUN_ALL_TESTS(); - - if (settings.standalone){ + ret = RUN_ALL_TESTS(); if (rdcd_pid != -1) { if (killRDCD(rdcd_pid)) { return -1; } } + if (ret) { + return ret; + } } + return ret; } diff --git a/projects/rdc/tests/rdc_tests/rsmitst.exclude b/projects/rdc/tests/rdc_tests/rdctst.exclude similarity index 87% rename from projects/rdc/tests/rdc_tests/rsmitst.exclude rename to projects/rdc/tests/rdc_tests/rdctst.exclude index 2acd16d589..81aa0d218c 100644 --- a/projects/rdc/tests/rdc_tests/rsmitst.exclude +++ b/projects/rdc/tests/rdc_tests/rdctst.exclude @@ -23,6 +23,10 @@ fi FILTER[vega10]=\ $BLACKLIST_ALL_ASICS +# Leave the remaining commands in this RDC version of a blacklist +# as an example, until there are actual tests to blacklist. +return 0 + # SWDEV-207510 FILTER[vega20]=\ $BLACKLIST_ALL_ASICS\ diff --git a/projects/rdc/tests/rdc_tests/test_base.h b/projects/rdc/tests/rdc_tests/test_base.h index 9cddf05f6a..6b6745da31 100755 --- a/projects/rdc/tests/rdc_tests/test_base.h +++ b/projects/rdc/tests/rdc_tests/test_base.h @@ -77,13 +77,6 @@ class TestBase { uint32_t num_monitor_devs(void) const { return num_monitor_devs_; } - void set_init_options(uint64_t x) { - init_options_ = x; - } - uint64_t init_options(void) const { - return init_options_; - } - void set_monitor_server_ip(std::string ip) { monitor_server_ip_ = ip; } @@ -102,7 +95,7 @@ class TestBase { bool secure(void) const { return secure_; } - bool set_mode(bool standalone) { + void set_mode(bool standalone) { standalone_ = standalone; } rdc_handle_t rdc_handle; @@ -118,7 +111,6 @@ class TestBase { std::string title_; ///< Displayed title of test uint32_t verbosity_; ///< How much additional output to produce bool dont_fail_; ///< Don't quit test on individual failure if true - uint64_t init_options_; ///< rsmi initialization options std::string monitor_server_ip_; std::string monitor_server_port_; bool secure_; // Use authenticated comms. (SSL/TSL) diff --git a/projects/rdc/tests/rdc_tests/test_common.cc b/projects/rdc/tests/rdc_tests/test_common.cc index ffe1208994..2e39ba41e7 100755 --- a/projects/rdc/tests/rdc_tests/test_common.cc +++ b/projects/rdc/tests/rdc_tests/test_common.cc @@ -105,17 +105,19 @@ static const struct option long_options[] = { {"remote_server_ip", required_argument, nullptr, 's'}, {"remote_server_port", required_argument, nullptr, 'p'}, {"start_rdcd", optional_argument, nullptr, 'd'}, + {"batch_mode", no_argument, nullptr, 'b'}, {"dont_fail", no_argument, nullptr, 'f'}, {"unauth_comm", no_argument, nullptr, 'u'}, {"rdctst_help", no_argument, nullptr, 'r'}, {nullptr, 0, nullptr, 0} }; -static const char* short_options = "i:v:m:s:p:d:fur"; +static const char* short_options = "i:v:m:s:p:d:bfur"; static void PrintHelp(void) { std::cout << "Optional rdctst Arguments:\n" + "--batch_mode, -b run in embedded mode with no interactive prompts\n" "--dont_fail, -f if set, don't fail test when individual test fails; " "default is to fail when an individual test fails\n" "--rdctst_help, -r print this help message\n" @@ -136,10 +138,25 @@ static void PrintHelp(void) { "default is with authentication\n"; } +static bool CheckArgs(RDCTstGlobals *test) { + if (test->batch_mode) { + if ( + (test->monitor_server_ip != "") || + (test->monitor_server_port != "") || + test->secure) { + std::cout << "--batch_mode option is incompatible with " + "--remote_server_ip, --remote_server_port and --unauth_comm" << + std::endl; + return false; + } + } + return true; +} + uint32_t ProcessCmdline(RDCTstGlobals* test, int arg_cnt, char** arg_list) { int a; int ind = -1; - + uint32_t arg_ind = 1; // Skip the program name assert(test != nullptr); while (true) { @@ -190,14 +207,24 @@ uint32_t ProcessCmdline(RDCTstGlobals* test, int arg_cnt, char** arg_list) { test->secure = false; break; + case 'b': + test->batch_mode = true; + test->standalone = false; + break; + default: - std::cout << "Unknown command line option: \"" << a << - "\". Ignoring..." << std::endl; + std::cout << "Unknown command line option: \"" << + arg_list[arg_ind] << "\"" << std::endl; PrintHelp(); - return 0; + return 1; } + ++arg_ind; } - return 0; + + if (CheckArgs(test)) { + return 0; + } + return 1; } const char *GetBlockNameStr(rsmi_gpu_block_t id) { diff --git a/projects/rdc/tests/rdc_tests/test_common.h b/projects/rdc/tests/rdc_tests/test_common.h index 2f3bd0a2a3..a6cd5b1804 100755 --- a/projects/rdc/tests/rdc_tests/test_common.h +++ b/projects/rdc/tests/rdc_tests/test_common.h @@ -36,10 +36,10 @@ struct RDCTstGlobals { std::string monitor_server_port; std::string monitor_server_ip; uint32_t num_iterations; - uint64_t init_options; bool dont_fail; bool secure; bool standalone; + bool batch_mode; }; uint32_t ProcessCmdline(RDCTstGlobals* test, int arg_cnt, char** arg_list);