Skip to content

Commit 90a3b13

Browse files
committed
Update: Adding tests for flashing GFX, OptionROM firmwares
Related-To: VLCLJ-2532 Signed-off-by: Alle, Kalyan <[email protected]>
1 parent b12e62f commit 90a3b13

File tree

1 file changed

+138
-0
lines changed

1 file changed

+138
-0
lines changed

conformance_tests/sysman/test_sysman_firmware/src/test_sysman_firmware.cpp

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,4 +303,142 @@ LZT_TEST_F(
303303
}
304304
}
305305

306+
LZT_TEST_F(
307+
FIRMWARE_TEST,
308+
GivenValidFirmwareHandleWhenFlashingGfxFirmwareThenExpectFirmwareFlashingSuccess) {
309+
auto fwDirEnv = getenv("ZE_LZT_FIRMWARE_DIRECTORY");
310+
if (nullptr == fwDirEnv) {
311+
LOG_INFO << "Skipping test as ZE_LZT_FIRMWARE_DIRECTORY not set";
312+
GTEST_SKIP();
313+
}
314+
std::string fwDir(fwDirEnv);
315+
std::vector<char> testFwImage;
316+
for (auto device : devices) {
317+
uint32_t count = 0;
318+
count = lzt::get_firmware_handle_count(device);
319+
if (count > 0) {
320+
is_firmware_supported = true;
321+
LOG_INFO << "Firmware handles are available on this device! ";
322+
auto firmware_handles = lzt::get_firmware_handles(device, count);
323+
for (auto firmware_handle : firmware_handles) {
324+
ASSERT_NE(nullptr, firmware_handle);
325+
auto propFw = lzt::get_firmware_properties(firmware_handle);
326+
if (propFw.canControl == true &&
327+
std::string(reinterpret_cast<char *>(propFw.name)) == "GFX") {
328+
std::string fwName(reinterpret_cast<char *>(propFw.name));
329+
std::string fwToLoad = fwDir + "/" + fwName + ".bin";
330+
std::ifstream inFileStream(fwToLoad,
331+
std::ios::binary | std::ios::ate);
332+
if (!inFileStream.is_open()) {
333+
LOG_INFO << "Skipping test as firmware image not found";
334+
GTEST_SKIP();
335+
}
336+
testFwImage.resize(inFileStream.tellg());
337+
inFileStream.seekg(0, inFileStream.beg);
338+
inFileStream.read(testFwImage.data(), testFwImage.size());
339+
lzt::flash_firmware(firmware_handle,
340+
static_cast<void *>(testFwImage.data()),
341+
testFwImage.size());
342+
}
343+
}
344+
} else {
345+
LOG_INFO << "No firmware handles found for this device!";
346+
}
347+
}
348+
if (!is_firmware_supported) {
349+
FAIL() << "No firmware handles found on any of the devices!";
350+
}
351+
}
352+
353+
LZT_TEST_F(
354+
FIRMWARE_TEST,
355+
GivenValidFirmwareHandleWhenFlashingOptionRomCodeThenExpectFirmwareFlashingSuccess) {
356+
auto fwDirEnv = getenv("ZE_LZT_FIRMWARE_DIRECTORY");
357+
if (nullptr == fwDirEnv) {
358+
LOG_INFO << "Skipping test as ZE_LZT_FIRMWARE_DIRECTORY not set";
359+
GTEST_SKIP();
360+
}
361+
std::string fwDir(fwDirEnv);
362+
std::vector<char> testFwImage;
363+
for (auto device : devices) {
364+
uint32_t count = 0;
365+
count = lzt::get_firmware_handle_count(device);
366+
if (count > 0) {
367+
is_firmware_supported = true;
368+
auto firmware_handles = lzt::get_firmware_handles(device, count);
369+
for (auto firmware_handle : firmware_handles) {
370+
ASSERT_NE(nullptr, firmware_handle);
371+
auto propFw = lzt::get_firmware_properties(firmware_handle);
372+
if (propFw.canControl == true &&
373+
std::string(reinterpret_cast<char *>(propFw.name)) == "OptionROM") {
374+
std::string fwName(reinterpret_cast<char *>(propFw.name));
375+
std::string fwToLoad = fwDir + "/" + fwName + ".bin";
376+
std::ifstream inFileStream(fwToLoad,
377+
std::ios::binary | std::ios::ate);
378+
if (!inFileStream.is_open()) {
379+
LOG_INFO << "Skipping test as firmware image not found";
380+
GTEST_SKIP();
381+
}
382+
testFwImage.resize(inFileStream.tellg());
383+
inFileStream.seekg(0, inFileStream.beg);
384+
inFileStream.read(testFwImage.data(), testFwImage.size());
385+
lzt::flash_firmware(firmware_handle,
386+
static_cast<void *>(testFwImage.data()),
387+
testFwImage.size());
388+
}
389+
}
390+
} else {
391+
LOG_INFO << "No firmware handles found for this device!";
392+
}
393+
}
394+
if (!is_firmware_supported) {
395+
FAIL() << "No firmware handles found on any of the devices!";
396+
}
397+
}
398+
399+
LZT_TEST_F(
400+
FIRMWARE_TEST,
401+
GivenValidFirmwareHandleWhenFlashingOptionRomDataThenExpectFirmwareFlashingSuccess) {
402+
auto fwDirEnv = getenv("ZE_LZT_FIRMWARE_DIRECTORY");
403+
if (nullptr == fwDirEnv) {
404+
LOG_INFO << "Skipping test as ZE_LZT_FIRMWARE_DIRECTORY not set";
405+
GTEST_SKIP();
406+
}
407+
std::string fwDir(fwDirEnv);
408+
std::vector<char> testFwImage;
409+
for (auto device : devices) {
410+
uint32_t count = 0;
411+
count = lzt::get_firmware_handle_count(device);
412+
if (count > 0) {
413+
is_firmware_supported = true;
414+
auto firmware_handles = lzt::get_firmware_handles(device, count);
415+
for (auto firmware_handle : firmware_handles) {
416+
ASSERT_NE(nullptr, firmware_handle);
417+
auto propFw = lzt::get_firmware_properties(firmware_handle);
418+
if (propFw.canControl == true &&
419+
std::string(reinterpret_cast<char *>(propFw.name)) == "OptionROM") {
420+
std::string fwName(reinterpret_cast<char *>(propFw.name));
421+
std::string fwToLoad = fwDir + "/" + fwName + ".bin";
422+
std::ifstream inFileStream(fwToLoad,
423+
std::ios::binary | std::ios::ate);
424+
if (!inFileStream.is_open()) {
425+
LOG_INFO << "Skipping test as firmware image not found";
426+
GTEST_SKIP();
427+
}
428+
testFwImage.resize(inFileStream.tellg());
429+
inFileStream.seekg(0, inFileStream.beg);
430+
inFileStream.read(testFwImage.data(), testFwImage.size());
431+
lzt::flash_firmware(firmware_handle,
432+
static_cast<void *>(testFwImage.data()),
433+
testFwImage.size());
434+
}
435+
}
436+
} else {
437+
LOG_INFO << "No firmware handles found for this device!";
438+
}
439+
}
440+
if (!is_firmware_supported) {
441+
FAIL() << "No firmware handles found on any of the devices!";
442+
}
443+
}
306444
} // namespace

0 commit comments

Comments
 (0)