Skip to content

Commit 428f851

Browse files
committed
Update: Adding tests for flashing GFX, OptionROM firmwares
Related-To: VLCLJ-2532 Removing GivenValidFirmwareHandleWhenFlashingOptionRomThenExpectFirmwareFlashingSuccess since this commit is splitting the same into two different tests Signed-off-by: Alle, Kalyan <[email protected]>
1 parent b12e62f commit 428f851

File tree

1 file changed

+93
-46
lines changed

1 file changed

+93
-46
lines changed

conformance_tests/sysman/test_sysman_firmware/src/test_sysman_firmware.cpp

Lines changed: 93 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,97 @@ LZT_TEST_F(
303257
}
304258
}
305259

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

0 commit comments

Comments
 (0)