@@ -26,10 +26,16 @@ namespace {
26
26
uint32_t get_prop_length (char *prop) { return std::strlen (prop); }
27
27
28
28
#ifdef USE_ZESINIT
29
- class FirmwareZesTest : public lzt ::ZesSysmanCtsClass {};
29
+ class FirmwareZesTest : public lzt ::ZesSysmanCtsClass {
30
+ public:
31
+ bool is_firmware_supported = false ;
32
+ };
30
33
#define FIRMWARE_TEST FirmwareZesTest
31
34
#else // USE_ZESINIT
32
- class FirmwareTest : public lzt ::SysmanCtsClass {};
35
+ class FirmwareTest : public lzt ::SysmanCtsClass {
36
+ public:
37
+ bool is_firmware_supported = false ;
38
+ };
33
39
#define FIRMWARE_TEST FirmwareTest
34
40
#endif // USE_ZESINIT
35
41
@@ -39,44 +45,59 @@ LZT_TEST_F(
39
45
for (auto device : devices) {
40
46
uint32_t count = 0 ;
41
47
count = lzt::get_firmware_handle_count (device);
42
- if (count == 0 ) {
43
- FAIL () << " No handles found: "
44
- << _ze_result_t (ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
48
+ if (count > 0 ) {
49
+ is_firmware_supported = true ;
50
+ LOG_INFO << " Firmware handles are available on this device! " ;
51
+ } else {
52
+ LOG_INFO << " No firmware handles found for this device! " ;
45
53
}
46
54
}
55
+ if (!is_firmware_supported) {
56
+ FAIL () << " No firmware handles found on any of the devices! " ;
57
+ }
47
58
}
48
59
LZT_TEST_F (
49
60
FIRMWARE_TEST,
50
61
GivenComponentCountZeroWhenRetrievingFirmwareHandlesThenNotNullFirmwareHandlesAreReturned) {
51
62
for (auto device : devices) {
52
63
uint32_t count = 0 ;
53
- auto firmware_handles = lzt::get_firmware_handles (device, count);
54
- if (count == 0 ) {
55
- FAIL () << " No handles found: "
56
- << _ze_result_t (ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
57
- }
58
-
59
- ASSERT_EQ (firmware_handles.size (), count);
60
- for (auto firmware_handle : firmware_handles) {
61
- ASSERT_NE (nullptr , firmware_handle);
64
+ count = lzt::get_firmware_handle_count (device);
65
+ if (count > 0 ) {
66
+ is_firmware_supported = true ;
67
+ LOG_INFO << " Firmware handles are available on this device! " ;
68
+ auto firmware_handles = lzt::get_firmware_handles (device, count);
69
+ ASSERT_EQ (firmware_handles.size (), count);
70
+ for (auto firmware_handle : firmware_handles) {
71
+ ASSERT_NE (nullptr , firmware_handle);
72
+ }
73
+ } else {
74
+ LOG_INFO << " No firmware handles found for this device! " ;
62
75
}
63
76
}
77
+ if (!is_firmware_supported) {
78
+ FAIL () << " No firmware handles found on any of the devices! " ;
79
+ }
64
80
}
65
81
66
82
LZT_TEST_F (
67
83
FIRMWARE_TEST,
68
84
GivenInvalidComponentCountWhenRetrievingSysmanFirmwareHandlesThenActualComponentCountIsUpdated) {
69
85
for (auto device : devices) {
70
86
uint32_t actual_count = 0 ;
71
- auto firmware_handles = lzt::get_firmware_handles (device, actual_count);
72
- if (actual_count == 0 ) {
73
- FAIL () << " No handles found: "
74
- << _ze_result_t (ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
87
+ actual_count = lzt::get_firmware_handle_count (device);
88
+ if (actual_count > 0 ) {
89
+ is_firmware_supported = true ;
90
+ LOG_INFO << " Firmware handles are available on this device! " ;
91
+ auto firmware_handles = lzt::get_firmware_handles (device, actual_count);
92
+ uint32_t test_count = actual_count + 1 ;
93
+ firmware_handles = lzt::get_firmware_handles (device, test_count);
94
+ EXPECT_EQ (test_count, actual_count);
95
+ } else {
96
+ LOG_INFO << " No firmware handles found for this device! " ;
75
97
}
76
-
77
- uint32_t test_count = actual_count + 1 ;
78
- firmware_handles = lzt::get_firmware_handles (device, test_count);
79
- EXPECT_EQ (test_count, actual_count);
98
+ }
99
+ if (!is_firmware_supported) {
100
+ FAIL () << " No firmware handles found on any of the devices! " ;
80
101
}
81
102
}
82
103
LZT_TEST_F (
@@ -85,53 +106,66 @@ LZT_TEST_F(
85
106
for (auto device : devices) {
86
107
auto deviceProperties = lzt::get_sysman_device_properties (device);
87
108
uint32_t count = 0 ;
88
- auto firmware_handles = lzt::get_firmware_handles (device, count);
89
- if (count == 0 ) {
90
- FAIL () << " No handles found: "
91
- << _ze_result_t (ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
92
- }
93
-
94
- for (auto firmware_handle : firmware_handles) {
95
- ASSERT_NE (nullptr , firmware_handle);
96
- auto properties = lzt::get_firmware_properties (firmware_handle);
97
- if (properties.onSubdevice ) {
98
- EXPECT_LT (properties.subdeviceId , deviceProperties.numSubdevices );
109
+ count = lzt::get_firmware_handle_count (device);
110
+ if (count > 0 ) {
111
+ is_firmware_supported = true ;
112
+ LOG_INFO << " Firmware handles are available on this device! " ;
113
+ auto firmware_handles = lzt::get_firmware_handles (device, count);
114
+ for (auto firmware_handle : firmware_handles) {
115
+ ASSERT_NE (nullptr , firmware_handle);
116
+ auto properties = lzt::get_firmware_properties (firmware_handle);
117
+ if (properties.onSubdevice ) {
118
+ EXPECT_LT (properties.subdeviceId , deviceProperties.numSubdevices );
119
+ }
120
+ EXPECT_LT (get_prop_length (properties.name ), ZES_STRING_PROPERTY_SIZE);
121
+ EXPECT_GT (get_prop_length (properties.name ), 0 );
122
+ EXPECT_LT (get_prop_length (properties.version ),
123
+ ZES_STRING_PROPERTY_SIZE);
99
124
}
100
- EXPECT_LT (get_prop_length (properties.name ), ZES_STRING_PROPERTY_SIZE);
101
- EXPECT_GT (get_prop_length (properties.name ), 0 );
102
- EXPECT_LT (get_prop_length (properties.version ), ZES_STRING_PROPERTY_SIZE);
125
+ } else {
126
+ LOG_INFO << " No firmware handles found for this device! " ;
103
127
}
104
128
}
129
+ if (!is_firmware_supported) {
130
+ FAIL () << " No firmware handles found on any of the devices! " ;
131
+ }
105
132
}
106
133
107
134
LZT_TEST_F (
108
135
FIRMWARE_TEST,
109
136
GivenValidFirmwareHandleWhenRetrievingFirmwarePropertiesThenExpectSamePropertiesReturnedTwice) {
110
137
for (auto device : devices) {
111
138
uint32_t count = 0 ;
112
- auto firmware_handles = lzt::get_firmware_handles (device, count);
113
- if (count == 0 ) {
114
- FAIL () << " No handles found: "
115
- << _ze_result_t (ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
116
- }
117
-
118
- for (auto firmware_handle : firmware_handles) {
119
- ASSERT_NE (nullptr , firmware_handle);
120
- auto properties_initial = lzt::get_firmware_properties (firmware_handle);
121
- auto properties_later = lzt::get_firmware_properties (firmware_handle);
122
- EXPECT_EQ (properties_initial.onSubdevice , properties_later.onSubdevice );
123
- if (properties_initial.onSubdevice && properties_later.onSubdevice ) {
124
- EXPECT_EQ (properties_initial.subdeviceId , properties_later.subdeviceId );
139
+ count = lzt::get_firmware_handle_count (device);
140
+ if (count > 0 ) {
141
+ is_firmware_supported = true ;
142
+ LOG_INFO << " Firmware handles are available on this device! " ;
143
+ auto firmware_handles = lzt::get_firmware_handles (device, count);
144
+ for (auto firmware_handle : firmware_handles) {
145
+ ASSERT_NE (nullptr , firmware_handle);
146
+ auto properties_initial = lzt::get_firmware_properties (firmware_handle);
147
+ auto properties_later = lzt::get_firmware_properties (firmware_handle);
148
+ EXPECT_EQ (properties_initial.onSubdevice , properties_later.onSubdevice );
149
+ if (properties_initial.onSubdevice && properties_later.onSubdevice ) {
150
+ EXPECT_EQ (properties_initial.subdeviceId ,
151
+ properties_later.subdeviceId );
152
+ }
153
+ EXPECT_TRUE (
154
+ 0 == std::strcmp (reinterpret_cast <char *>(properties_initial.name ),
155
+ reinterpret_cast <char *>(properties_later.name )));
156
+ EXPECT_TRUE (
157
+ 0 ==
158
+ std::strcmp (reinterpret_cast <char *>(properties_initial.version ),
159
+ reinterpret_cast <char *>(properties_later.version )));
160
+ EXPECT_EQ (properties_initial.canControl , properties_later.canControl );
125
161
}
126
- EXPECT_TRUE (0 ==
127
- std::strcmp (reinterpret_cast <char *>(properties_initial.name ),
128
- reinterpret_cast <char *>(properties_later.name )));
129
- EXPECT_TRUE (
130
- 0 == std::strcmp (reinterpret_cast <char *>(properties_initial.version ),
131
- reinterpret_cast <char *>(properties_later.version )));
132
- EXPECT_EQ (properties_initial.canControl , properties_later.canControl );
162
+ } else {
163
+ LOG_INFO << " No firmware handles found for this device! " ;
133
164
}
134
165
}
166
+ if (!is_firmware_supported) {
167
+ FAIL () << " No firmware handles found on any of the devices! " ;
168
+ }
135
169
}
136
170
137
171
LZT_TEST_F (
@@ -146,32 +180,38 @@ LZT_TEST_F(
146
180
std::string fwDir (fwDirEnv);
147
181
for (auto device : devices) {
148
182
uint32_t count = 0 ;
149
- auto firmware_handles = lzt::get_firmware_handles (device, count);
150
- if (count == 0 ) {
151
- FAIL () << " No handles found: "
152
- << _ze_result_t (ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
153
- }
154
-
155
- for (auto firmware_handle : firmware_handles) {
156
- ASSERT_NE (nullptr , firmware_handle);
157
- auto propFw = lzt::get_firmware_properties (firmware_handle);
158
- if (propFw.canControl == true ) {
159
- std::string fwName (reinterpret_cast <char *>(propFw.name ));
160
- std::string fwToLoad = fwDir + " /" + fwName + " .bin" ;
161
- std::ifstream inFileStream (fwToLoad, std::ios::binary | std::ios::ate);
162
- if (!inFileStream.is_open ()) {
163
- LOG_INFO << " Skipping test as firmware image not found" ;
164
- GTEST_SKIP ();
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 ());
165
206
}
166
- testFwImage.resize (inFileStream.tellg ());
167
- inFileStream.seekg (0 , inFileStream.beg );
168
- inFileStream.read (testFwImage.data (), testFwImage.size ());
169
- lzt::flash_firmware (firmware_handle,
170
- static_cast <void *>(testFwImage.data ()),
171
- testFwImage.size ());
172
207
}
208
+ } else {
209
+ LOG_INFO << " No firmware handles found for this device! " ;
173
210
}
174
211
}
212
+ if (!is_firmware_supported) {
213
+ FAIL () << " No firmware handles found on any of the devices! " ;
214
+ }
175
215
}
176
216
177
217
void flash_firmware (zes_firmware_handle_t firmware_handle, std::string fw_dir) {
@@ -243,20 +283,24 @@ LZT_TEST_F(
243
283
std::string fw_dir (fw_dir_env);
244
284
for (auto device : devices) {
245
285
uint32_t count = 0 ;
246
- auto firmware_handles = lzt::get_firmware_handles (device, count);
247
- if (count == 0 ) {
248
- FAIL () << " No handles found: "
249
- << _ze_result_t (ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
250
- }
251
-
252
- for (auto firmware_handle : firmware_handles) {
253
- std::thread firmware_flasher (flash_firmware, firmware_handle, fw_dir);
254
- std::thread progress_tracker (track_firmware_flash, firmware_handle);
255
-
256
- firmware_flasher.join ();
257
- progress_tracker.join ();
286
+ count = lzt::get_firmware_handle_count (device);
287
+ if (count > 0 ) {
288
+ is_firmware_supported = true ;
289
+ LOG_INFO << " Firmware handles are available on this device! " ;
290
+ auto firmware_handles = lzt::get_firmware_handles (device, count);
291
+ for (auto firmware_handle : firmware_handles) {
292
+ std::thread firmware_flasher (flash_firmware, firmware_handle, fw_dir);
293
+ std::thread progress_tracker (track_firmware_flash, firmware_handle);
294
+ firmware_flasher.join ();
295
+ progress_tracker.join ();
296
+ }
297
+ } else {
298
+ LOG_INFO << " No firmware handles found for this device! " ;
258
299
}
259
300
}
301
+ if (!is_firmware_supported) {
302
+ FAIL () << " No firmware handles found on any of the devices! " ;
303
+ }
260
304
}
261
305
262
306
} // namespace
0 commit comments