On 6/23/26 16:19, Aditya Gupta wrote:
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
Signed-off-by: Aditya Gupta <[email protected]>
---
tests/qtest/pnv-spi-seeprom-test.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/tests/qtest/pnv-spi-seeprom-test.c
b/tests/qtest/pnv-spi-seeprom-test.c
index 44e0b92730b4..721129cd39ab 100644
--- a/tests/qtest/pnv-spi-seeprom-test.c
+++ b/tests/qtest/pnv-spi-seeprom-test.c
@@ -77,6 +77,7 @@ static void test_spi_seeprom(const void *data)
const PnvChip *chip = data;
QTestState *qts = NULL;
g_autofree char *tmp_path = NULL;
+ const char *machine = "powernv10";
int ret;
int fd;
@@ -87,11 +88,11 @@ static void test_spi_seeprom(const void *data)
g_assert(ret == 0);
close(fd);
- qts = qtest_initf("-machine powernv10 -smp 2,cores=2,"
+ qts = qtest_initf("-machine %s -smp 2,cores=2,"
"threads=1 -accel tcg,thread=single -nographic "
"-blockdev node-name=pib_spic2,driver=file,"
"filename=%s -device 25csm04,bus=chip0.spi.2,cs=0,"
- "drive=pib_spic2", tmp_path);
+ "drive=pib_spic2", machine, tmp_path);
spi_seeprom_transaction(qts, chip);
qtest_quit(qts);
unlink(tmp_path);
@@ -100,9 +101,17 @@ static void test_spi_seeprom(const void *data)
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
- char *tname = g_strdup_printf("pnv-xscom/spi-seeprom/%s",
- pnv_chips[3].cpu_model);
- qtest_add_data_func(tname, &pnv_chips[3], test_spi_seeprom);
- g_free(tname);
+
+ for (int i = 0; i < ARRAY_SIZE(pnv_chips); i++) {
+ /* TYPE_PNV_SPI is not instantiated for older Power8/9 machines */
+ if (pnv_chips[i].chip_type < PNV_CHIP_POWER10) {
Can we remove this chip_type field from the tests too ? see 248e4e924e87.
+ continue;
+ }
+
+ char *tname = g_strdup_printf("pnv-xscom/spi-seeprom/%s",
+ pnv_chips[i].cpu_model);
please consider g_autofree variables.
+ qtest_add_data_func(tname, &pnv_chips[i], test_spi_seeprom);
+ g_free(tname);
+ }
return g_test_run();
}