Return NOT_SUPPORT for set function in VM guest

Fix the unit tests which are fail in VM guest environment.

Change-Id: Id7c58887692bbdecba54f5d2d8463b292e19b4ad
This commit is contained in:
Bill(Shuzhou) Liu
2023-05-11 10:42:22 -05:00
committed by Galantsev, Dmitrii
parent 147af192b5
commit a0ec98c30d
3 changed files with 29 additions and 0 deletions
+19
View File
@@ -329,6 +329,25 @@ rsmi_status_t ErrnoToRsmiStatus(int err) {
}
}
bool is_vm_guest() {
// the cpuinfo will set hypervisor flag in VM guest
const std::string hypervisor = "hypervisor";
std::string line;
// default to false if cannot find the file
std::ifstream infile("/proc/cpuinfo");
if (infile.fail()) {
return false;
}
while (std::getline(infile, line)) {
if (line.find(hypervisor) != std::string::npos) {
return true;
}
}
return false;
}
std::string leftTrim(const std::string &s) {
if (!s.empty()) {
return std::regex_replace(s, std::regex("^\\s+"), "");