@@ -211,6 +211,117 @@ TEST_F(ZesPciFixture, GivenValidSysmanHandleWhenCallingzetSysmanPciGetBarsThenVe
211211 }
212212}
213213
214+ TEST_F (ZesPciFixture, GivenValidSysmanHandleWhenCallingzetSysmanPciGetBarsThenVerifyzetSysmanPciGetBarsCallSucceedsWith1_2Extension) {
215+ uint32_t count = 0 ;
216+ EXPECT_EQ (ZE_RESULT_SUCCESS, zesDevicePciGetBars (device, &count, nullptr ));
217+ EXPECT_NE (count, 0u );
218+
219+ zes_pci_bar_properties_t *pBarProps = new zes_pci_bar_properties_t [count];
220+ zes_pci_bar_properties_1_2_t *props1_2 = new zes_pci_bar_properties_1_2_t ;
221+ memset (props1_2, 0 , sizeof (zes_pci_bar_properties_1_2_t ));
222+
223+ for (uint32_t i = 0 ; i < count; i++) {
224+ pBarProps[i].pNext = static_cast <void *>(props1_2);
225+ pBarProps[i].stype = zes_structure_type_t ::ZES_STRUCTURE_TYPE_PCI_BAR_PROPERTIES_1_2;
226+ }
227+
228+ EXPECT_EQ (ZE_RESULT_SUCCESS, zesDevicePciGetBars (device, &count, pBarProps));
229+
230+ for (uint32_t i = 0 ; i < count; i++) {
231+ EXPECT_EQ (pBarProps[i].stype , zes_structure_type_t ::ZES_STRUCTURE_TYPE_PCI_BAR_PROPERTIES_1_2);
232+ EXPECT_LE (pBarProps[i].type , ZES_PCI_BAR_TYPE_MEM);
233+ EXPECT_NE (pBarProps[i].base , 0u );
234+ EXPECT_NE (pBarProps[i].size , 0u );
235+ }
236+
237+ EXPECT_EQ (props1_2->resizableBarSupported , false );
238+ EXPECT_EQ (props1_2->resizableBarEnabled , false );
239+ EXPECT_LE (props1_2->type , ZES_PCI_BAR_TYPE_MEM);
240+ EXPECT_NE (props1_2->base , 0u );
241+ EXPECT_NE (props1_2->size , 0u );
242+
243+ delete[] pBarProps;
244+ delete props1_2;
245+ }
246+
247+ TEST_F (ZesPciFixture, GivenValidSysmanHandleWhenCallingzetSysmanPciGetBarsThenVerifyzetSysmanPciGetBarsCallSucceedsWith1_2ExtensionWrongType) {
248+ uint32_t count = 0 ;
249+ EXPECT_EQ (ZE_RESULT_SUCCESS, zesDevicePciGetBars (device, &count, nullptr ));
250+ EXPECT_NE (count, 0u );
251+
252+ zes_pci_bar_properties_t *pBarProps = new zes_pci_bar_properties_t [count];
253+ zes_pci_bar_properties_1_2_t *props1_2 = new zes_pci_bar_properties_1_2_t ;
254+ memset (props1_2, 0 , sizeof (zes_pci_bar_properties_1_2_t ));
255+
256+ for (uint32_t i = 0 ; i < count; i++) {
257+ pBarProps[i].pNext = static_cast <void *>(props1_2);
258+ pBarProps[i].stype = ZES_STRUCTURE_TYPE_PCI_STATE;
259+ }
260+
261+ EXPECT_EQ (ZE_RESULT_SUCCESS, zesDevicePciGetBars (device, &count, pBarProps));
262+
263+ for (uint32_t i = 0 ; i < count; i++) {
264+ EXPECT_LE (pBarProps[i].type , ZES_PCI_BAR_TYPE_MEM);
265+ EXPECT_NE (pBarProps[i].base , 0u );
266+ EXPECT_NE (pBarProps[i].size , 0u );
267+ }
268+
269+ EXPECT_EQ (props1_2->resizableBarSupported , false );
270+ EXPECT_EQ (props1_2->resizableBarEnabled , false );
271+ EXPECT_EQ (props1_2->type , ZES_PCI_BAR_TYPE_MMIO);
272+ EXPECT_EQ (props1_2->base , 0u );
273+ EXPECT_EQ (props1_2->size , 0u );
274+
275+ delete[] pBarProps;
276+ delete props1_2;
277+ }
278+
279+ TEST_F (ZesPciFixture, GivenValidSysmanHandleWhenCallingzetSysmanPciGetBarsThenVerifyzetSysmanPciGetBarsCallSucceedsWith1_2ExtensionWithNullPtr) {
280+ uint32_t count = 0 ;
281+ EXPECT_EQ (ZE_RESULT_SUCCESS, zesDevicePciGetBars (device, &count, nullptr ));
282+ EXPECT_NE (count, 0u );
283+
284+ zes_pci_bar_properties_t *pBarProps = new zes_pci_bar_properties_t [count];
285+
286+ for (uint32_t i = 0 ; i < count; i++) {
287+ pBarProps[i].pNext = nullptr ;
288+ pBarProps[i].stype = zes_structure_type_t ::ZES_STRUCTURE_TYPE_PCI_BAR_PROPERTIES_1_2;
289+ }
290+
291+ EXPECT_EQ (ZE_RESULT_SUCCESS, zesDevicePciGetBars (device, &count, pBarProps));
292+
293+ for (uint32_t i = 0 ; i < count; i++) {
294+ EXPECT_LE (pBarProps[i].type , ZES_PCI_BAR_TYPE_MEM);
295+ EXPECT_NE (pBarProps[i].base , 0u );
296+ EXPECT_NE (pBarProps[i].size , 0u );
297+ }
298+
299+ delete[] pBarProps;
300+ }
301+
302+ TEST_F (ZesPciFixture, GivenValidSysmanHandleWhenCallingzetSysmanPciGetBarsThenVerifyzetSysmanPciGetBarsCallSucceedsWith1_2ExtensionWithWrongtypeNullPtr) {
303+ uint32_t count = 0 ;
304+ EXPECT_EQ (ZE_RESULT_SUCCESS, zesDevicePciGetBars (device, &count, nullptr ));
305+ EXPECT_NE (count, 0u );
306+
307+ zes_pci_bar_properties_t *pBarProps = new zes_pci_bar_properties_t [count];
308+
309+ for (uint32_t i = 0 ; i < count; i++) {
310+ pBarProps[i].pNext = nullptr ;
311+ pBarProps[i].stype = ZES_STRUCTURE_TYPE_PCI_STATE;
312+ }
313+
314+ EXPECT_EQ (ZE_RESULT_SUCCESS, zesDevicePciGetBars (device, &count, pBarProps));
315+
316+ for (uint32_t i = 0 ; i < count; i++) {
317+ EXPECT_LE (pBarProps[i].type , ZES_PCI_BAR_TYPE_MEM);
318+ EXPECT_NE (pBarProps[i].base , 0u );
319+ EXPECT_NE (pBarProps[i].size , 0u );
320+ }
321+
322+ delete[] pBarProps;
323+ }
324+
214325TEST_F (ZesPciFixture, GivenValidSysmanHandleWhenCallingzetSysmanPciGetStateThenVerifyzetSysmanPciGetStateCallReturnNotSupported) {
215326 zes_pci_state_t state;
216327 EXPECT_EQ (ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesDevicePciGetState (device, &state));
0 commit comments