-
Notifications
You must be signed in to change notification settings - Fork 68
Refactor: Split firmware flash test in multiple tests for different fw types #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -168,52 +168,6 @@ LZT_TEST_F( | |||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
LZT_TEST_F( | ||||||||||||||||||||||||||||||||||||||||||
FIRMWARE_TEST, | ||||||||||||||||||||||||||||||||||||||||||
GivenValidFirmwareHandleWhenFlashingFirmwareThenExpectFirmwareFlashingSuccess) { | ||||||||||||||||||||||||||||||||||||||||||
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 = 0; | ||||||||||||||||||||||||||||||||||||||||||
count = lzt::get_firmware_handle_count(device); | ||||||||||||||||||||||||||||||||||||||||||
if (count > 0) { | ||||||||||||||||||||||||||||||||||||||||||
is_firmware_supported = true; | ||||||||||||||||||||||||||||||||||||||||||
LOG_INFO << "Firmware handles are available on this device! "; | ||||||||||||||||||||||||||||||||||||||||||
auto firmware_handles = lzt::get_firmware_handles(device, count); | ||||||||||||||||||||||||||||||||||||||||||
for (auto firmware_handle : firmware_handles) { | ||||||||||||||||||||||||||||||||||||||||||
ASSERT_NE(nullptr, firmware_handle); | ||||||||||||||||||||||||||||||||||||||||||
auto propFw = lzt::get_firmware_properties(firmware_handle); | ||||||||||||||||||||||||||||||||||||||||||
if (propFw.canControl == true) { | ||||||||||||||||||||||||||||||||||||||||||
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(firmware_handle, | ||||||||||||||||||||||||||||||||||||||||||
static_cast<void *>(testFwImage.data()), | ||||||||||||||||||||||||||||||||||||||||||
testFwImage.size()); | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||
LOG_INFO << "No firmware handles found for this device! "; | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
if (!is_firmware_supported) { | ||||||||||||||||||||||||||||||||||||||||||
FAIL() << "No firmware handles found on any of the devices! "; | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
void flash_firmware(zes_firmware_handle_t firmware_handle, std::string fw_dir) { | ||||||||||||||||||||||||||||||||||||||||||
std::vector<char> test_fw_image; | ||||||||||||||||||||||||||||||||||||||||||
ASSERT_NE(nullptr, firmware_handle); | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -303,4 +257,66 @@ LZT_TEST_F( | |||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
class FirmwareFlashParamTest | ||||||||||||||||||||||||||||||||||||||||||
: public FIRMWARE_TEST, | ||||||||||||||||||||||||||||||||||||||||||
public ::testing::WithParamInterface<std::string> { | ||||||||||||||||||||||||||||||||||||||||||
public: | ||||||||||||||||||||||||||||||||||||||||||
bool is_firmware_supported = false; | ||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
INSTANTIATE_TEST_SUITE_P(FirmwareTypes, FirmwareFlashParamTest, | ||||||||||||||||||||||||||||||||||||||||||
::testing::Values("GFX", "OptionROM")); | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
LZT_TEST_P( | ||||||||||||||||||||||||||||||||||||||||||
FirmwareFlashParamTest, | ||||||||||||||||||||||||||||||||||||||||||
GivenValidFirmwareHandleWhenFlashingFirmwareTypeThenExpectFirmwareFlashingSuccess) { | ||||||||||||||||||||||||||||||||||||||||||
auto fwDirEnv = getenv("ZE_LZT_FIRMWARE_DIRECTORY"); | ||||||||||||||||||||||||||||||||||||||||||
if (nullptr == fwDirEnv) { | ||||||||||||||||||||||||||||||||||||||||||
LOG_INFO << "Skipping test as ZE_LZT_FIRMWARE_DIRECTORY not set"; | ||||||||||||||||||||||||||||||||||||||||||
GTEST_SKIP(); | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
std::string fwDir(fwDirEnv); | ||||||||||||||||||||||||||||||||||||||||||
std::string fwType = GetParam(); | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
for (auto device : devices) { | ||||||||||||||||||||||||||||||||||||||||||
uint32_t count = 0; | ||||||||||||||||||||||||||||||||||||||||||
count = lzt::get_firmware_handle_count(device); | ||||||||||||||||||||||||||||||||||||||||||
if (count > 0) { | ||||||||||||||||||||||||||||||||||||||||||
is_firmware_supported = true; | ||||||||||||||||||||||||||||||||||||||||||
LOG_INFO << "Firmware handles are available on this device! "; | ||||||||||||||||||||||||||||||||||||||||||
auto firmware_handles = lzt::get_firmware_handles(device, count); | ||||||||||||||||||||||||||||||||||||||||||
for (auto firmware_handle : firmware_handles) { | ||||||||||||||||||||||||||||||||||||||||||
ASSERT_NE(nullptr, firmware_handle); | ||||||||||||||||||||||||||||||||||||||||||
auto propFw = lzt::get_firmware_properties(firmware_handle); | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
if (propFw.canControl == true && | ||||||||||||||||||||||||||||||||||||||||||
std::string(reinterpret_cast<char *>(propFw.name)) == fwType) { | ||||||||||||||||||||||||||||||||||||||||||
std::string fwName(reinterpret_cast<char *>(propFw.name)); | ||||||||||||||||||||||||||||||||||||||||||
std::string fwToLoad = fwDir + "/" + fwName + ".bin"; | ||||||||||||||||||||||||||||||||||||||||||
LOG_INFO << " Firmware Name: " << fwName; | ||||||||||||||||||||||||||||||||||||||||||
LOG_INFO << " Firmware Path: " << fwToLoad; | ||||||||||||||||||||||||||||||||||||||||||
std::ifstream inFileStream(fwToLoad, | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+294
to
+298
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable names
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||||||||||||||
std::ios::binary | std::ios::ate); | ||||||||||||||||||||||||||||||||||||||||||
if (!inFileStream.is_open()) { | ||||||||||||||||||||||||||||||||||||||||||
LOG_INFO << "Skipping test as firmware image not found"; | ||||||||||||||||||||||||||||||||||||||||||
GTEST_SKIP(); | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
std::vector<char> testFwImage( | ||||||||||||||||||||||||||||||||||||||||||
static_cast<size_t>(inFileStream.tellg())); | ||||||||||||||||||||||||||||||||||||||||||
inFileStream.seekg(0, inFileStream.beg); | ||||||||||||||||||||||||||||||||||||||||||
inFileStream.read(testFwImage.data(), testFwImage.size()); | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+298
to
+307
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable name
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||||||||||||||
lzt::flash_firmware(firmware_handle, | ||||||||||||||||||||||||||||||||||||||||||
static_cast<void *>(testFwImage.data()), | ||||||||||||||||||||||||||||||||||||||||||
testFwImage.size()); | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+304
to
+310
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable name
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||
LOG_INFO << "No firmware handles found for this device!"; | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
if (!is_firmware_supported) { | ||||||||||||||||||||||||||||||||||||||||||
FAIL() << "No firmware handles found on any of the devices!"; | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
} // namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this LOG_INFO << "Firmware handles are available on this device! "; could be added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done