@samitouri / QOSamiQemu / commits / d81885d242

tests/qtest/pnv_spi: Test Power11 PNV_SPI

Currently pnv-spi-seeprom-test was hardcoded to test the 4th chip in pnv_chips (power10 as of now). This requires ensuring to update the index when removing/adding entries in pnv_chips, such as when Power8E or Power11 gets removed/added in future commits. Iterate over all the chips instead, similar to other tests in pnv-xscom-test.c and pnv-host-i2c-test.c, but skip older chips, since TYPE_PNV_SPI only exists from Power10 onwards, hence skip older machines Tests all the pnv_chips similar to other qtests Tested-by: Misbah Anjum N <misanjum@linux.ibm.com> Reviewed-by: Nikhil Kumar Singh <nikhilks@linux.ibm.com> Signed-off-by: Aditya Gupta <adityag@linux.ibm.com> Link: https://lore.kernel.org/qemu-devel/20260703085955.2318600-3-adityag@linux.ibm.com Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>

Aditya Gupta committed Jul 3, 2026 at 14:29 UTC d81885d242ec25f68876b106b63d27ad69b43daa
1 file changed +14 -6
tests/qtest/pnv-spi-seeprom-test.c
+14 -6
@@ -77,6 +77,7 @@ static void test_spi_seeprom(const void *data)
77 const PnvChip *chip = data;
78 QTestState *qts = NULL;
79 g_autofree char *tmp_path = NULL;
80 + const char *machine = "powernv10";
81 int ret;
82 int fd;
83
@@ -87,11 +88,11 @@ static void test_spi_seeprom(const void *data)
88 g_assert(ret == 0);
89 close(fd);
90
90 - qts = qtest_initf("-machine powernv10 -smp 2,cores=2,"
91 + qts = qtest_initf("-machine %s -smp 2,cores=2,"
92 "threads=1 -accel tcg,thread=single -nographic "
93 "-blockdev node-name=pib_spic2,driver=file,"
94 "filename=%s -device 25csm04,bus=chip0.spi.2,cs=0,"
94 - "drive=pib_spic2", tmp_path);
95 + "drive=pib_spic2", machine, tmp_path);
96 spi_seeprom_transaction(qts, chip);
97 qtest_quit(qts);
98 unlink(tmp_path);
@@ -100,9 +101,16 @@ static void test_spi_seeprom(const void *data)
101 int main(int argc, char **argv)
102 {
103 g_test_init(&argc, &argv, NULL);
103 - char *tname = g_strdup_printf("pnv-xscom/spi-seeprom/%s",
104 - pnv_chips[3].cpu_model);
105 - qtest_add_data_func(tname, &pnv_chips[3], test_spi_seeprom);
106 - g_free(tname);
104 +
105 + for (int i = 0; i < ARRAY_SIZE(pnv_chips); i++) {
106 + /* TYPE_PNV_SPI is not instantiated for older Power8/9 machines */
107 + if (pnv_chips[i].chip_type < PNV_CHIP_POWER10) {
108 + continue;
109 + }
110 +
111 + g_autofree char *tname = g_strdup_printf("pnv-xscom/spi-seeprom/%s",
112 + pnv_chips[i].cpu_model);
113 + qtest_add_data_func(tname, &pnv_chips[i], test_spi_seeprom);
114 + }
115 return g_test_run();
116 }