Docs., error checking and test improvements

* Update doc. on api-support function
* Check for valid integer value when reading a monitor int. val.
* If fan-write test attempts to set speed higher than max.
   possible, then skip the test

Change-Id: I01ad0ab1f4caffdb0d2c26e9575f278c35a6b017
This commit is contained in:
Chris Freehill
2019-11-04 13:45:47 -06:00
parent 3a26a7270c
commit 52dfa4bcca
5 changed files with 37 additions and 0 deletions
+6
View File
@@ -408,6 +408,12 @@ static rsmi_status_t get_dev_mon_value(amd::smi::MonitorTypes type,
return errno_to_rsmi_status(ret);
}
if (!amd::smi::IsInteger(val_str)) {
std::cerr << "Expected integer value, but got \"" << val_str << "\"" <<
std::endl;
}
assert(amd::smi::IsInteger(val_str));
*val = std::stoul(val_str);
return RSMI_STATUS_SUCCESS;
+12
View File
@@ -140,5 +140,17 @@ int ReadSysfsStr(std::string path, std::string *retStr) {
return ret;
}
bool IsInteger(const std::string & n_str)
{
if(n_str.empty() || ((!isdigit(n_str[0])) && (n_str[0] != '-')
&& (n_str[0] != '+'))) {
return false;
}
char * tmp;
strtol(n_str.c_str(), &tmp, 10);
return (*tmp == 0);
}
} // namespace smi
} // namespace amd