-
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
|
||||||||||||||||||||||||||||||||||||||||||
| 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, | |
| std::string fw_name(reinterpret_cast<char *>(propFw.name)); | |
| std::string fw_to_load = fwDir + "/" + fw_name + ".bin"; | |
| LOG_INFO << " Firmware Name: " << fw_name; | |
| LOG_INFO << " Firmware Path: " << fw_to_load; | |
| std::ifstream inFileStream(fw_to_load, |
Copilot
AI
Sep 8, 2025
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.
The variable name inFileStream uses inconsistent camelCase naming compared to the existing flash_firmware function which uses in_filestream (snake_case). Consider using in_filestream for consistency.
| 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(); | |
| } | |
| std::vector<char> testFwImage( | |
| static_cast<size_t>(inFileStream.tellg())); | |
| inFileStream.seekg(0, inFileStream.beg); | |
| inFileStream.read(testFwImage.data(), testFwImage.size()); | |
| std::ifstream in_filestream(fwToLoad, | |
| std::ios::binary | std::ios::ate); | |
| if (!in_filestream.is_open()) { | |
| LOG_INFO << "Skipping test as firmware image not found"; | |
| GTEST_SKIP(); | |
| } | |
| std::vector<char> testFwImage( | |
| static_cast<size_t>(in_filestream.tellg())); | |
| in_filestream.seekg(0, in_filestream.beg); | |
| in_filestream.read(testFwImage.data(), testFwImage.size()); |
Copilot
AI
Sep 8, 2025
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.
The variable name testFwImage uses inconsistent naming compared to the existing flash_firmware function which uses test_fw_image (snake_case). Consider using test_fw_image for consistency.
| std::vector<char> testFwImage( | |
| static_cast<size_t>(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()); | |
| std::vector<char> test_fw_image( | |
| static_cast<size_t>(inFileStream.tellg())); | |
| inFileStream.seekg(0, inFileStream.beg); | |
| inFileStream.read(test_fw_image.data(), test_fw_image.size()); | |
| lzt::flash_firmware(firmware_handle, | |
| static_cast<void *>(test_fw_image.data()), | |
| test_fw_image.size()); |
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