Prepare rdctst for automated test runs

Mostly this involves creating a "batch mode" which does not
have any interactive prompts. Also, in batch mode, both stand-
alone and embedded modes are run.

Change-Id: I9703e501ab1f853e992b6b401fa0215681ab69f0


[ROCm/rdc commit: 5f947270c1]
This commit is contained in:
Chris Freehill
2020-06-10 18:16:06 -05:00
parent b94b3489c7
commit cd5f37a3aa
6 changed files with 88 additions and 51 deletions
+3 -6
View File
@@ -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)
+46 -29
View File
@@ -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;
}
@@ -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\
+1 -9
View File
@@ -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)
+33 -6
View File
@@ -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) {
+1 -1
View File
@@ -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);