Return NOT_SUPPORT for set function in VM guest
Fix the unit tests which are fail in VM guest environment. Change-Id: Id7c58887692bbdecba54f5d2d8463b292e19b4ad
这个提交包含在:
@@ -277,6 +277,10 @@ class ScopedAcquire {
|
||||
DISALLOW_COPY_AND_ASSIGN(ScopedAcquire)
|
||||
};
|
||||
|
||||
// The best effort way to decide whether it is in VM guest environment:
|
||||
// In VM environment, the /proc/cpuinfo set hypervisor flag by default
|
||||
bool is_vm_guest();
|
||||
|
||||
} // namespace smi
|
||||
} // namespace amd
|
||||
|
||||
|
||||
@@ -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+"), "");
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
#include "rocm_smi_test/functional/power_cap_read_write.h"
|
||||
#include "rocm_smi/rocm_smi_utils.h"
|
||||
#include "rocm_smi_test/test_common.h"
|
||||
|
||||
|
||||
@@ -121,6 +122,11 @@ void TestPowerCapReadWrite::Run(void) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (amd::smi::is_vm_guest()) {
|
||||
std::cout << "VM guest is not supported for power cap test. Skipping test for " << dv_ind << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
new_cap = (max + min)/2;
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
|
||||
在新工单中引用
屏蔽一个用户