Add dont_fail option to not fail entire test on a single failure

[ROCm/rocm_smi_lib commit: dd450e963c]
This commit is contained in:
Chris Freehill
2019-02-09 12:18:49 -06:00
parent 301aaa28ab
commit bd3b84e353
6 changed files with 38 additions and 7 deletions
+6 -1
View File
@@ -551,7 +551,12 @@ static rsmi_status_t get_frequencies(amd::smi::DevInfoTypes type,
}
}
assert(f->current < f->num_supported);
// Some older drivers will not have the current frequency set
// assert(f->current < f->num_supported);
if (f->current >= f->num_supported) {
return RSMI_STATUS_NOT_SUPPORTED;
}
return RSMI_STATUS_SUCCESS;
CATCH
}
@@ -56,6 +56,7 @@
static const uint32_t kNumBufferElements = 256;
static uint32_t gVerbosity = 3;
static bool gDontFail = false;
#define DISPLAY_RSMI_ERR(RET) { \
if (RET != RSMI_STATUS_SUCCESS) { \
@@ -77,7 +78,15 @@ static uint32_t gVerbosity = 3;
#define CHK_ERR_ASRT(RET) { \
DISPLAY_RSMI_ERR(RET) \
ASSERT_EQ((RET), RSMI_STATUS_SUCCESS); \
if (gDontFail && ((RET) != RSMI_STATUS_SUCCESS)) { \
std::cout << "========> TEST FAILURE."; \
DISPLAY_RSMI_ERR(RET); \
std::cout << \
"Abort is over-ridden due to dont_fail command line option." \
<< std::endl; \
} else { \
ASSERT_EQ(RSMI_STATUS_SUCCESS, (RET)); \
} \
}
#define CHK_RSMI_PERM_ERR(RET) { \
@@ -599,6 +608,7 @@ void TestSanity::SetUp(void) {
TestBase::SetUp();
gVerbosity = verbosity();
gDontFail = dont_fail();
err = rsmi_init(0);
ASSERT_EQ(err, RSMI_STATUS_SUCCESS);
@@ -60,6 +60,7 @@ static void SetFlags(TestBase *test) {
test->set_num_iteration(sRSMIGlvalues->num_iterations);
test->set_verbosity(sRSMIGlvalues->verbosity);
test->set_dont_fail(sRSMIGlvalues->dont_fail);
}
@@ -113,7 +114,7 @@ int main(int argc, char** argv) {
settings.verbosity = 1;
settings.monitor_verbosity = 1;
settings.num_iterations = 1;
settings.dont_fail = false;
if (ProcessCmdline(&settings, argc, argv)) {
return 1;
@@ -87,19 +87,25 @@ class TestBase {
std::string title(void) const {
return title_;
}
void set_verbosity(uint32_t v) {
verbosity_ = v;
}
uint32_t verbosity(void) const {
return verbosity_;
}
void set_dont_fail(bool f) {
dont_fail_ = f;
}
bool dont_fail(void) const {
return dont_fail_;
}
private:
uint64_t num_iteration_; ///< Number of times to execute test
std::string description_;
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
};
#endif // TESTS_ROCM_SMI_TEST_TEST_BASE_H_
@@ -57,17 +57,21 @@ static const struct option long_options[] = {
{"iterations", required_argument, nullptr, 'i'},
{"verbose", required_argument, nullptr, 'v'},
{"monitor_verbose", required_argument, nullptr, 'm'},
{"dont_fail", no_argument, nullptr, 'f'},
{"rsmitst_help", no_argument, nullptr, 'r'},
{nullptr, 0, nullptr, 0}
};
static const char* short_options = "i:v:m:r";
static const char* short_options = "i:v:m:fr";
static void PrintHelp(void) {
std::cout <<
"Optional RocRTst Arguments:\n"
"Optional rsmitst Arguments:\n"
"--dont_fail, -f if set, don't fail test when individual test fails; "
"default is to fail when an individual test fails\n"
"--iterations, -i <number of iterations to execute>; override default, "
"which varies for each test\n"
"--rocrtst_help, -r print this help message\n"
"--rsmitst_help, -r print this help message\n"
"--verbosity, -v <verbosity level>\n"
" Verbosity levels:\n"
" 0 -- minimal; just summary information\n"
@@ -113,6 +117,10 @@ uint32_t ProcessCmdline(RSMITstGlobals* test, int arg_cnt, char** arg_list) {
PrintHelp();
return 1;
case 'f':
test->dont_fail = true;
break;
default:
PrintHelp();
return 1;
@@ -55,6 +55,7 @@ struct RSMITstGlobals {
uint32_t verbosity;
uint32_t monitor_verbosity;
uint32_t num_iterations;
bool dont_fail;
};
uint32_t ProcessCmdline(RSMITstGlobals* test, int arg_cnt, char** arg_list);