Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ uint32_t get_prop_length(char *prop) { return std::strlen(prop); }
class FirmwareZesTest : public lzt::ZesSysmanCtsClass {
public:
bool is_firmware_supported = false;
bool is_VRConfig_supported = false;
bool is_fantable_supported = false;

};
#define FIRMWARE_TEST FirmwareZesTest
#else // USE_ZESINIT
Expand Down Expand Up @@ -303,4 +306,108 @@ LZT_TEST_F(
}
}

LZT_TEST_F(
FIRMWARE_TEST,
GivenValidFanTableFirmwareHandleWhenFirmwareIsFlashedThenFlashingIsSuccessful) {
auto fwDirEnv = getenv("ZE_LZT_FIRMWARE_DIRECTORY");
if (nullptr == fwDirEnv) {
LOG_INFO << "Skipping test as ZE_LZT_FIRMWARE_DIRECTORY not set";
GTEST_SKIP();
}
std::vector<char> testFwImage;
std::string fwDir(fwDirEnv);
for (auto device : devices) {
uint32_t count = lzt::get_firmware_handle_count(device);
auto firmware_handles = lzt::get_firmware_handles(device, count);
zes_firmware_handle_t fan_table_handle = nullptr;
for (auto fw_handle : firmware_handles) {
zes_firmware_properties_t props = {
ZES_STRUCTURE_TYPE_FIRMWARE_PROPERTIES};
zesFirmwareGetProperties(fw_handle, &props);
if (std::string(props.name) == "FanTable") {
is_fantable_supported = true;
fan_table_handle = fw_handle;
auto propFw = lzt::get_firmware_properties(fw_handle);
if (propFw.canControl) {
std::string fwName(reinterpret_cast<char *>(propFw.name));
std::string fwToLoad = fwDir + "/" + fwName + ".bin";
std::ifstream inFileStream(fwToLoad,
std::ios::binary | std::ios::ate);
if (!inFileStream.is_open()) {
LOG_INFO << "Skipping test as firmware image not found";
GTEST_SKIP();
}
testFwImage.resize(inFileStream.tellg());
inFileStream.seekg(0, inFileStream.beg);
inFileStream.read(testFwImage.data(), testFwImage.size());

lzt::flash_firmware(fan_table_handle,
static_cast<void *>(testFwImage.data()),
testFwImage.size());
}
}
}

if (!is_fantable_supported) {
LOG_INFO << "No fan table handles found for this device!";
}
}
if (!is_fantable_supported) {
FAIL() << "No fan table handles found on any of the devices!";
}
}

LZT_TEST_F(
FIRMWARE_TEST,
GivenValidVRConfigFirmwareHandleWhenFirmwareIsFlashedThenFlashingIsSuccessful) {
auto fwDirEnv = getenv("ZE_LZT_FIRMWARE_DIRECTORY");
if (nullptr == fwDirEnv) {
LOG_INFO << "Skipping test as ZE_LZT_FIRMWARE_DIRECTORY not set";
GTEST_SKIP();
}
std::vector<char> testFwImage;
std::string fwDir(fwDirEnv);
for (auto device : devices) {
uint32_t count = lzt::get_firmware_handle_count(device);
if (count > 0) {
is_VRConfig_supported = true;
LOG_INFO << "VR Config handles are available on this device!";
Comment on lines +372 to +374
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here this is not correct

auto firmware_handles = lzt::get_firmware_handles(device, count);
zes_firmware_handle_t vr_config_handle = nullptr;
for (auto fw_handle : firmware_handles) {
zes_firmware_properties_t props = {
ZES_STRUCTURE_TYPE_FIRMWARE_PROPERTIES};
zesFirmwareGetProperties(fw_handle, &props);
if (std::string(props.name) == "VRConfig") {
is_VRConfig_supported = true;
vr_config_handle = fw_handle;
auto propFw = lzt::get_firmware_properties(fw_handle);
if (propFw.canControl) {
std::string fwName(reinterpret_cast<char *>(propFw.name));
std::string fwToLoad = fwDir + "/" + fwName + ".bin";
std::ifstream inFileStream(fwToLoad,
std::ios::binary | std::ios::ate);
if (!inFileStream.is_open()) {
LOG_INFO << "Skipping test as firmware image not found";
GTEST_SKIP();
}
testFwImage.resize(inFileStream.tellg());
inFileStream.seekg(0, inFileStream.beg);
inFileStream.read(testFwImage.data(), testFwImage.size());

lzt::flash_firmware(vr_config_handle,
static_cast<void *>(testFwImage.data()),
testFwImage.size());
}
}
}
} else {
LOG_INFO << "No VR config handles found for this device!";
}
}
if (!is_VRConfig_supported) {
FAIL() << "No VR Config handles found on any of the devices!";
}
}

} // namespace
Loading