Skip to content

Commit 4c1357b

Browse files
committed
Update: Creating single parameterized test with two different params GFX and
OptionROM firmwares Related-To: VLCLJ-2532 Removing GivenValidFirmwareHandleWhenFlashingOptionRomThenExpectFirmwareFlashingSuccess and creating single parameterized test with two different params GFX and OptionROM. Signed-off-by: Alle, Kalyan <[email protected]>
1 parent b12e62f commit 4c1357b

File tree

1 file changed

+60
-46
lines changed

1 file changed

+60
-46
lines changed

conformance_tests/sysman/test_sysman_firmware/src/test_sysman_firmware.cpp

Lines changed: 60 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -168,52 +168,6 @@ LZT_TEST_F(
168168
}
169169
}
170170

171-
LZT_TEST_F(
172-
FIRMWARE_TEST,
173-
GivenValidFirmwareHandleWhenFlashingFirmwareThenExpectFirmwareFlashingSuccess) {
174-
auto fwDirEnv = getenv("ZE_LZT_FIRMWARE_DIRECTORY");
175-
if (nullptr == fwDirEnv) {
176-
LOG_INFO << "Skipping test as ZE_LZT_FIRMWARE_DIRECTORY not set";
177-
GTEST_SKIP();
178-
}
179-
std::vector<char> testFwImage;
180-
std::string fwDir(fwDirEnv);
181-
for (auto device : devices) {
182-
uint32_t count = 0;
183-
count = lzt::get_firmware_handle_count(device);
184-
if (count > 0) {
185-
is_firmware_supported = true;
186-
LOG_INFO << "Firmware handles are available on this device! ";
187-
auto firmware_handles = lzt::get_firmware_handles(device, count);
188-
for (auto firmware_handle : firmware_handles) {
189-
ASSERT_NE(nullptr, firmware_handle);
190-
auto propFw = lzt::get_firmware_properties(firmware_handle);
191-
if (propFw.canControl == true) {
192-
std::string fwName(reinterpret_cast<char *>(propFw.name));
193-
std::string fwToLoad = fwDir + "/" + fwName + ".bin";
194-
std::ifstream inFileStream(fwToLoad,
195-
std::ios::binary | std::ios::ate);
196-
if (!inFileStream.is_open()) {
197-
LOG_INFO << "Skipping test as firmware image not found";
198-
GTEST_SKIP();
199-
}
200-
testFwImage.resize(inFileStream.tellg());
201-
inFileStream.seekg(0, inFileStream.beg);
202-
inFileStream.read(testFwImage.data(), testFwImage.size());
203-
lzt::flash_firmware(firmware_handle,
204-
static_cast<void *>(testFwImage.data()),
205-
testFwImage.size());
206-
}
207-
}
208-
} else {
209-
LOG_INFO << "No firmware handles found for this device! ";
210-
}
211-
}
212-
if (!is_firmware_supported) {
213-
FAIL() << "No firmware handles found on any of the devices! ";
214-
}
215-
}
216-
217171
void flash_firmware(zes_firmware_handle_t firmware_handle, std::string fw_dir) {
218172
std::vector<char> test_fw_image;
219173
ASSERT_NE(nullptr, firmware_handle);
@@ -303,4 +257,64 @@ LZT_TEST_F(
303257
}
304258
}
305259

260+
class FirmwareFlashParamTest
261+
: public FIRMWARE_TEST,
262+
public ::testing::WithParamInterface<std::string> {
263+
public:
264+
bool is_firmware_supported = false;
265+
};
266+
267+
INSTANTIATE_TEST_SUITE_P(FirmwareTypes, FirmwareFlashParamTest,
268+
::testing::Values("GFX", "OptionROM"));
269+
270+
LZT_TEST_P(
271+
FirmwareFlashParamTest,
272+
GivenValidFirmwareHandleWhenFlashingFirmwareTypeThenExpectFirmwareFlashingSuccess) {
273+
auto fwDirEnv = getenv("ZE_LZT_FIRMWARE_DIRECTORY");
274+
if (nullptr == fwDirEnv) {
275+
LOG_INFO << "Skipping test as ZE_LZT_FIRMWARE_DIRECTORY not set";
276+
GTEST_SKIP();
277+
}
278+
std::string fwDir(fwDirEnv);
279+
std::string fwType = GetParam();
280+
281+
for (auto device : devices) {
282+
uint32_t count = 0;
283+
count = lzt::get_firmware_handle_count(device);
284+
if (count > 0) {
285+
is_firmware_supported = true;
286+
auto firmware_handles = lzt::get_firmware_handles(device, count);
287+
for (auto firmware_handle : firmware_handles) {
288+
ASSERT_NE(nullptr, firmware_handle);
289+
auto propFw = lzt::get_firmware_properties(firmware_handle);
290+
291+
if (propFw.canControl == true &&
292+
std::string(reinterpret_cast<char *>(propFw.name)) == fwType) {
293+
std::string fwName(reinterpret_cast<char *>(propFw.name));
294+
std::string fwToLoad = fwDir + "/" + fwName + ".bin";
295+
LOG_INFO << " Firmware Name: " << fwName;
296+
LOG_INFO << " Firmware Path: " << fwToLoad;
297+
std::ifstream inFileStream(fwToLoad,
298+
std::ios::binary | std::ios::ate);
299+
if (!inFileStream.is_open()) {
300+
LOG_INFO << "Skipping test as firmware image not found";
301+
GTEST_SKIP();
302+
}
303+
std::vector<char> testFwImage(inFileStream.tellg());
304+
inFileStream.seekg(0, inFileStream.beg);
305+
inFileStream.read(testFwImage.data(), testFwImage.size());
306+
lzt::flash_firmware(firmware_handle,
307+
static_cast<void *>(testFwImage.data()),
308+
testFwImage.size());
309+
}
310+
}
311+
} else {
312+
LOG_INFO << "No firmware handles found for this device!";
313+
}
314+
}
315+
if (!is_firmware_supported) {
316+
FAIL() << "No firmware handles found on any of the devices!";
317+
}
318+
}
319+
306320
} // namespace

0 commit comments

Comments
 (0)