11e8a1faeSThomas Huth /*
21e8a1faeSThomas Huth * Test serial output of some machines.
31e8a1faeSThomas Huth *
41e8a1faeSThomas Huth * Copyright 2016 Thomas Huth, Red Hat Inc.
51e8a1faeSThomas Huth *
61e8a1faeSThomas Huth * This work is licensed under the terms of the GNU GPL, version 2
71e8a1faeSThomas Huth * or later. See the COPYING file in the top-level directory.
81e8a1faeSThomas Huth *
91e8a1faeSThomas Huth * This test is used to check that the serial output of the firmware
101e8a1faeSThomas Huth * (that we provide for some machines) or some small mini-kernels that
111e8a1faeSThomas Huth * we provide here contains an expected string. Thus we check that the
121e8a1faeSThomas Huth * firmware/kernel still boots at least to a certain point and so we
131e8a1faeSThomas Huth * know that the machine is not completely broken.
141e8a1faeSThomas Huth */
151e8a1faeSThomas Huth
161e8a1faeSThomas Huth #include "qemu/osdep.h"
17907b5105SMarc-André Lureau #include "libqtest.h"
183e40bdb1SNicholas Piggin #include "ppc-util.h"
191e8a1faeSThomas Huth
2036838e5fSMichael Rolnik static const uint8_t bios_avr[] = {
2136838e5fSMichael Rolnik 0x88, 0xe0, /* ldi r24, 0x08 */
2236838e5fSMichael Rolnik 0x80, 0x93, 0xc1, 0x00, /* sts 0x00C1, r24 ; Enable tx */
2336838e5fSMichael Rolnik 0x86, 0xe0, /* ldi r24, 0x06 */
2436838e5fSMichael Rolnik 0x80, 0x93, 0xc2, 0x00, /* sts 0x00C2, r24 ; Set the data bits to 8 */
2536838e5fSMichael Rolnik 0x84, 0xe5, /* ldi r24, 0x54 */
2636838e5fSMichael Rolnik 0x80, 0x93, 0xc6, 0x00, /* sts 0x00C6, r24 ; Output 'T' */
2736838e5fSMichael Rolnik };
2836838e5fSMichael Rolnik
290d497106SBibo Mao static const uint8_t bios_loongarch64[] = {
300d497106SBibo Mao 0x0c, 0xc0, 0x3f, 0x14, /* lu12i.w $t0, 0x1fe00 */
310d497106SBibo Mao 0x8c, 0x81, 0x87, 0x03, /* ori $t0, $t0, 0x1e0 */
320d497106SBibo Mao 0x0d, 0x50, 0x81, 0x03, /* li.w $t1, 'T' */
330d497106SBibo Mao 0x8d, 0x01, 0x00, 0x29, /* st.b $t1, $t0, 0 */
340d497106SBibo Mao 0xff, 0xf3, 0xff, 0x53, /* b -16 # loop */
350d497106SBibo Mao };
360d497106SBibo Mao
371e8a1faeSThomas Huth static const uint8_t kernel_mcf5208[] = {
381e8a1faeSThomas Huth 0x41, 0xf9, 0xfc, 0x06, 0x00, 0x00, /* lea 0xfc060000,%a0 */
391e8a1faeSThomas Huth 0x10, 0x3c, 0x00, 0x54, /* move.b #'T',%d0 */
401e8a1faeSThomas Huth 0x11, 0x7c, 0x00, 0x04, 0x00, 0x08, /* move.b #4,8(%a0) Enable TX */
411e8a1faeSThomas Huth 0x11, 0x40, 0x00, 0x0c, /* move.b %d0,12(%a0) Print 'T' */
421e8a1faeSThomas Huth 0x60, 0xfa /* bra.s loop */
431e8a1faeSThomas Huth };
441e8a1faeSThomas Huth
451e8a1faeSThomas Huth static const uint8_t bios_nextcube[] = {
461e8a1faeSThomas Huth 0x06, 0x00, 0x00, 0x00, /* Initial SP */
471e8a1faeSThomas Huth 0x01, 0x00, 0x00, 0x08, /* Initial PC */
481e8a1faeSThomas Huth 0x41, 0xf9, 0x02, 0x11, 0x80, 0x00, /* lea 0x02118000,%a0 */
491e8a1faeSThomas Huth 0x10, 0x3c, 0x00, 0x54, /* move.b #'T',%d0 */
501e8a1faeSThomas Huth 0x11, 0x7c, 0x00, 0x05, 0x00, 0x01, /* move.b #5,1(%a0) Sel TXCTRL */
511e8a1faeSThomas Huth 0x11, 0x7c, 0x00, 0x68, 0x00, 0x01, /* move.b #0x68,1(%a0) Enable TX */
521e8a1faeSThomas Huth 0x11, 0x40, 0x00, 0x03, /* move.b %d0,3(%a0) Print 'T' */
531e8a1faeSThomas Huth 0x60, 0xfa /* bra.s loop */
541e8a1faeSThomas Huth };
551e8a1faeSThomas Huth
561e8a1faeSThomas Huth static const uint8_t kernel_pls3adsp1800[] = {
571e8a1faeSThomas Huth 0xb0, 0x00, 0x84, 0x00, /* imm 0x8400 */
581e8a1faeSThomas Huth 0x30, 0x60, 0x00, 0x04, /* addik r3,r0,4 */
591e8a1faeSThomas Huth 0x30, 0x80, 0x00, 0x54, /* addik r4,r0,'T' */
601e8a1faeSThomas Huth 0xf0, 0x83, 0x00, 0x00, /* sbi r4,r3,0 */
611e8a1faeSThomas Huth 0xb8, 0x00, 0xff, 0xfc /* bri -4 loop */
621e8a1faeSThomas Huth };
631e8a1faeSThomas Huth
641e8a1faeSThomas Huth static const uint8_t kernel_plml605[] = {
651e8a1faeSThomas Huth 0xe0, 0x83, 0x00, 0xb0, /* imm 0x83e0 */
661e8a1faeSThomas Huth 0x00, 0x10, 0x60, 0x30, /* addik r3,r0,0x1000 */
671e8a1faeSThomas Huth 0x54, 0x00, 0x80, 0x30, /* addik r4,r0,'T' */
681e8a1faeSThomas Huth 0x00, 0x00, 0x83, 0xf0, /* sbi r4,r3,0 */
691e8a1faeSThomas Huth 0xfc, 0xff, 0x00, 0xb8 /* bri -4 loop */
701e8a1faeSThomas Huth };
711e8a1faeSThomas Huth
721e8a1faeSThomas Huth static const uint8_t bios_raspi2[] = {
731e8a1faeSThomas Huth 0x08, 0x30, 0x9f, 0xe5, /* ldr r3,[pc,#8] Get base */
741e8a1faeSThomas Huth 0x54, 0x20, 0xa0, 0xe3, /* mov r2,#'T' */
751e8a1faeSThomas Huth 0x00, 0x20, 0xc3, 0xe5, /* strb r2,[r3] */
761e8a1faeSThomas Huth 0xfb, 0xff, 0xff, 0xea, /* b loop */
771e8a1faeSThomas Huth 0x00, 0x10, 0x20, 0x3f, /* 0x3f201000 = UART0 base addr */
781e8a1faeSThomas Huth };
791e8a1faeSThomas Huth
801e8a1faeSThomas Huth static const uint8_t kernel_aarch64[] = {
811e8a1faeSThomas Huth 0x81, 0x0a, 0x80, 0x52, /* mov w1, #0x54 */
821e8a1faeSThomas Huth 0x02, 0x20, 0xa1, 0xd2, /* mov x2, #0x9000000 */
831e8a1faeSThomas Huth 0x41, 0x00, 0x00, 0x39, /* strb w1, [x2] */
841e8a1faeSThomas Huth 0xfd, 0xff, 0xff, 0x17, /* b -12 (loop) */
851e8a1faeSThomas Huth };
861e8a1faeSThomas Huth
871e8a1faeSThomas Huth static const uint8_t kernel_nrf51[] = {
881e8a1faeSThomas Huth 0x00, 0x00, 0x00, 0x00, /* Stack top address */
891e8a1faeSThomas Huth 0x09, 0x00, 0x00, 0x00, /* Reset handler address */
901e8a1faeSThomas Huth 0x04, 0x4a, /* ldr r2, [pc, #16] Get ENABLE */
911e8a1faeSThomas Huth 0x04, 0x21, /* movs r1, #4 */
921e8a1faeSThomas Huth 0x11, 0x60, /* str r1, [r2] */
931e8a1faeSThomas Huth 0x04, 0x4a, /* ldr r2, [pc, #16] Get STARTTX */
941e8a1faeSThomas Huth 0x01, 0x21, /* movs r1, #1 */
951e8a1faeSThomas Huth 0x11, 0x60, /* str r1, [r2] */
961e8a1faeSThomas Huth 0x03, 0x4a, /* ldr r2, [pc, #12] Get TXD */
971e8a1faeSThomas Huth 0x54, 0x21, /* movs r1, 'T' */
981e8a1faeSThomas Huth 0x11, 0x60, /* str r1, [r2] */
991e8a1faeSThomas Huth 0xfe, 0xe7, /* b . */
1001e8a1faeSThomas Huth 0x00, 0x25, 0x00, 0x40, /* 0x40002500 = UART ENABLE */
1011e8a1faeSThomas Huth 0x08, 0x20, 0x00, 0x40, /* 0x40002008 = UART STARTTX */
1021e8a1faeSThomas Huth 0x1c, 0x25, 0x00, 0x40 /* 0x4000251c = UART TXD */
1031e8a1faeSThomas Huth };
1041e8a1faeSThomas Huth
1057cb4097fSAlexandre Iooss static const uint8_t kernel_stm32vldiscovery[] = {
1067cb4097fSAlexandre Iooss 0x00, 0x00, 0x00, 0x00, /* Stack top address */
1077cb4097fSAlexandre Iooss 0x1d, 0x00, 0x00, 0x00, /* Reset handler address */
1087cb4097fSAlexandre Iooss 0x00, 0x00, 0x00, 0x00, /* NMI */
1097cb4097fSAlexandre Iooss 0x00, 0x00, 0x00, 0x00, /* Hard fault */
1107cb4097fSAlexandre Iooss 0x00, 0x00, 0x00, 0x00, /* Memory management fault */
1117cb4097fSAlexandre Iooss 0x00, 0x00, 0x00, 0x00, /* Bus fault */
1127cb4097fSAlexandre Iooss 0x00, 0x00, 0x00, 0x00, /* Usage fault */
1137cb4097fSAlexandre Iooss 0x0b, 0x4b, /* ldr r3, [pc, #44] Get RCC */
1147cb4097fSAlexandre Iooss 0x44, 0xf2, 0x04, 0x02, /* movw r2, #16388 */
1157cb4097fSAlexandre Iooss 0x1a, 0x60, /* str r2, [r3] */
1167cb4097fSAlexandre Iooss 0x0a, 0x4b, /* ldr r3, [pc, #40] Get GPIOA */
1177cb4097fSAlexandre Iooss 0x1a, 0x68, /* ldr r2, [r3] */
1187cb4097fSAlexandre Iooss 0x22, 0xf0, 0xf0, 0x02, /* bic r2, r2, #240 */
1197cb4097fSAlexandre Iooss 0x1a, 0x60, /* str r2, [r3] */
1207cb4097fSAlexandre Iooss 0x1a, 0x68, /* ldr r2, [r3] */
1217cb4097fSAlexandre Iooss 0x42, 0xf0, 0xb0, 0x02, /* orr r2, r2, #176 */
1227cb4097fSAlexandre Iooss 0x1a, 0x60, /* str r2, [r3] */
1237cb4097fSAlexandre Iooss 0x07, 0x4b, /* ldr r3, [pc, #26] Get BAUD */
1247cb4097fSAlexandre Iooss 0x45, 0x22, /* movs r2, #69 */
1257cb4097fSAlexandre Iooss 0x1a, 0x60, /* str r2, [r3] */
1267cb4097fSAlexandre Iooss 0x06, 0x4b, /* ldr r3, [pc, #24] Get ENABLE */
1277cb4097fSAlexandre Iooss 0x42, 0xf2, 0x08, 0x02, /* movw r2, #8200 */
1287cb4097fSAlexandre Iooss 0x1a, 0x60, /* str r2, [r3] */
1297cb4097fSAlexandre Iooss 0x05, 0x4b, /* ldr r3, [pc, #20] Get TXD */
1307cb4097fSAlexandre Iooss 0x54, 0x22, /* movs r2, 'T' */
1317cb4097fSAlexandre Iooss 0x1a, 0x60, /* str r2, [r3] */
1327cb4097fSAlexandre Iooss 0xfe, 0xe7, /* b . */
1337cb4097fSAlexandre Iooss 0x18, 0x10, 0x02, 0x40, /* 0x40021018 = RCC */
1347cb4097fSAlexandre Iooss 0x04, 0x08, 0x01, 0x40, /* 0x40010804 = GPIOA */
1357cb4097fSAlexandre Iooss 0x08, 0x38, 0x01, 0x40, /* 0x40013808 = USART1 BAUD */
1367cb4097fSAlexandre Iooss 0x0c, 0x38, 0x01, 0x40, /* 0x4001380c = USART1 ENABLE */
1377cb4097fSAlexandre Iooss 0x04, 0x38, 0x01, 0x40 /* 0x40013804 = USART1 TXD */
1387cb4097fSAlexandre Iooss };
1397cb4097fSAlexandre Iooss
1401e8a1faeSThomas Huth typedef struct testdef {
1411e8a1faeSThomas Huth const char *arch; /* Target architecture */
1421e8a1faeSThomas Huth const char *machine; /* Name of the machine */
1431e8a1faeSThomas Huth const char *extra; /* Additional parameters */
1441e8a1faeSThomas Huth const char *expect; /* Expected string in the serial output */
1451e8a1faeSThomas Huth size_t codesize; /* Size of the kernel or bios data */
1461e8a1faeSThomas Huth const uint8_t *kernel; /* Set in case we use our own mini kernel */
1471e8a1faeSThomas Huth const uint8_t *bios; /* Set in case we use our own mini bios */
1481e8a1faeSThomas Huth } testdef_t;
1491e8a1faeSThomas Huth
150a4267f00SPhilippe Mathieu-Daudé static const testdef_t tests[] = {
1511e8a1faeSThomas Huth { "alpha", "clipper", "", "PCI:" },
15236838e5fSMichael Rolnik { "avr", "arduino-duemilanove", "", "T", sizeof(bios_avr), NULL, bios_avr },
15336838e5fSMichael Rolnik { "avr", "arduino-mega-2560-v3", "", "T", sizeof(bios_avr), NULL, bios_avr},
1541e8a1faeSThomas Huth { "ppc", "ppce500", "", "U-Boot" },
1551e8a1faeSThomas Huth { "ppc", "40p", "-vga none -boot d", "Trying cd:," },
1561e8a1faeSThomas Huth { "ppc", "g3beige", "", "PowerPC,750" },
1571e8a1faeSThomas Huth { "ppc", "mac99", "", "PowerPC,G4" },
1581e8a1faeSThomas Huth { "ppc", "sam460ex", "-m 256", "DRAM: 256 MiB" },
1591e8a1faeSThomas Huth { "ppc64", "ppce500", "", "U-Boot" },
1601e8a1faeSThomas Huth { "ppc64", "40p", "-m 192", "Memory: 192M" },
1611e8a1faeSThomas Huth { "ppc64", "mac99", "", "PowerPC,970FX" },
1621e8a1faeSThomas Huth { "ppc64", "pseries",
16363d57c8fSGreg Kurz "-machine " PSERIES_DEFAULT_CAPABILITIES,
1641e8a1faeSThomas Huth "Open Firmware" },
1651e8a1faeSThomas Huth { "ppc64", "powernv8", "", "OPAL" },
1661e8a1faeSThomas Huth { "ppc64", "powernv9", "", "OPAL" },
1671172428fSThomas Huth { "ppc64", "sam460ex", "-device pci-bridge,chassis_nr=2", "1b36 0001" },
168046da5efSThomas Huth { "i386", "isapc", "-cpu qemu32 -M graphics=off", "SeaBIOS" },
169046da5efSThomas Huth { "i386", "pc", "-M graphics=off", "SeaBIOS" },
170046da5efSThomas Huth { "i386", "q35", "-M graphics=off", "SeaBIOS" },
171046da5efSThomas Huth { "x86_64", "isapc", "-cpu qemu32 -M graphics=off", "SeaBIOS" },
172046da5efSThomas Huth { "x86_64", "q35", "-M graphics=off", "SeaBIOS" },
1731e8a1faeSThomas Huth { "sparc", "LX", "", "TMS390S10" },
1741e8a1faeSThomas Huth { "sparc", "SS-4", "", "MB86904" },
1751e8a1faeSThomas Huth { "sparc", "SS-600MP", "", "TMS390Z55" },
1761e8a1faeSThomas Huth { "sparc64", "sun4u", "", "UltraSPARC" },
1771e8a1faeSThomas Huth { "s390x", "s390-ccw-virtio", "", "device" },
1780d497106SBibo Mao { "loongarch64", "virt", "-cpu max", "TT", sizeof(bios_loongarch64),
1790d497106SBibo Mao NULL, bios_loongarch64 },
1801e8a1faeSThomas Huth { "m68k", "mcf5208evb", "", "TT", sizeof(kernel_mcf5208), kernel_mcf5208 },
1811e8a1faeSThomas Huth { "m68k", "next-cube", "", "TT", sizeof(bios_nextcube), 0, bios_nextcube },
1821e8a1faeSThomas Huth { "microblaze", "petalogix-s3adsp1800", "", "TT",
1831e8a1faeSThomas Huth sizeof(kernel_pls3adsp1800), kernel_pls3adsp1800 },
1841e8a1faeSThomas Huth { "microblazeel", "petalogix-ml605", "", "TT",
1851e8a1faeSThomas Huth sizeof(kernel_plml605), kernel_plml605 },
186cd066eeaSPhilippe Mathieu-Daudé { "arm", "raspi2b", "", "TT", sizeof(bios_raspi2), 0, bios_raspi2 },
1874765384cSSven Schnelle /* For hppa, force bios to output to serial by disabling graphics. */
188*3b9b5cbeSPhilippe Mathieu-Daudé { "hppa", "B160L", "-vga none", "SeaBIOS wants SYSTEM HALT" },
189421954f4SPhilippe Mathieu-Daudé { "aarch64", "virt", "-cpu max", "TT", sizeof(kernel_aarch64),
1901e8a1faeSThomas Huth kernel_aarch64 },
1911e8a1faeSThomas Huth { "arm", "microbit", "", "T", sizeof(kernel_nrf51), kernel_nrf51 },
1927cb4097fSAlexandre Iooss { "arm", "stm32vldiscovery", "", "T",
1937cb4097fSAlexandre Iooss sizeof(kernel_stm32vldiscovery), kernel_stm32vldiscovery },
1941e8a1faeSThomas Huth
1951e8a1faeSThomas Huth { NULL }
1961e8a1faeSThomas Huth };
1971e8a1faeSThomas Huth
check_guest_output(QTestState * qts,const testdef_t * test,int fd)1981e8a1faeSThomas Huth static bool check_guest_output(QTestState *qts, const testdef_t *test, int fd)
1991e8a1faeSThomas Huth {
2001e8a1faeSThomas Huth int nbr = 0, pos = 0, ccnt;
2011e8a1faeSThomas Huth time_t now, start = time(NULL);
2021e8a1faeSThomas Huth char ch;
2031e8a1faeSThomas Huth
2041e8a1faeSThomas Huth /* Poll serial output... */
2051e8a1faeSThomas Huth while (1) {
2061e8a1faeSThomas Huth ccnt = 0;
2071e8a1faeSThomas Huth while (ccnt++ < 512 && (nbr = read(fd, &ch, 1)) == 1) {
2081e8a1faeSThomas Huth if (ch == test->expect[pos]) {
2091e8a1faeSThomas Huth pos += 1;
2101e8a1faeSThomas Huth if (test->expect[pos] == '\0') {
2111e8a1faeSThomas Huth /* We've reached the end of the expected string! */
2121e8a1faeSThomas Huth return true;
2131e8a1faeSThomas Huth }
2141e8a1faeSThomas Huth } else {
2151e8a1faeSThomas Huth pos = 0;
2161e8a1faeSThomas Huth }
2171e8a1faeSThomas Huth }
2181e8a1faeSThomas Huth g_assert(nbr >= 0);
2191e8a1faeSThomas Huth /* Wait only if the child is still alive. */
2201e8a1faeSThomas Huth if (!qtest_probe_child(qts)) {
2211e8a1faeSThomas Huth break;
2221e8a1faeSThomas Huth }
2231e8a1faeSThomas Huth /* Wait at most 360 seconds. */
2241e8a1faeSThomas Huth now = time(NULL);
2251e8a1faeSThomas Huth if (now - start >= 360) {
2261e8a1faeSThomas Huth break;
2271e8a1faeSThomas Huth }
2281e8a1faeSThomas Huth g_usleep(10000);
2291e8a1faeSThomas Huth }
2301e8a1faeSThomas Huth
2311e8a1faeSThomas Huth return false;
2321e8a1faeSThomas Huth }
2331e8a1faeSThomas Huth
test_machine(const void * data)2341e8a1faeSThomas Huth static void test_machine(const void *data)
2351e8a1faeSThomas Huth {
2361e8a1faeSThomas Huth const testdef_t *test = data;
2374bcea44bSBin Meng g_autofree char *serialtmp = NULL;
2384bcea44bSBin Meng g_autofree char *codetmp = NULL;
2391e8a1faeSThomas Huth const char *codeparam = "";
2401e8a1faeSThomas Huth const uint8_t *code = NULL;
2411e8a1faeSThomas Huth QTestState *qts;
2421e8a1faeSThomas Huth int ser_fd;
2431e8a1faeSThomas Huth
2444bcea44bSBin Meng ser_fd = g_file_open_tmp("qtest-boot-serial-sXXXXXX", &serialtmp, NULL);
2451e8a1faeSThomas Huth g_assert(ser_fd != -1);
24665a2eff0SBin Meng close(ser_fd);
2471e8a1faeSThomas Huth
2481e8a1faeSThomas Huth if (test->kernel) {
2491e8a1faeSThomas Huth code = test->kernel;
2501e8a1faeSThomas Huth codeparam = "-kernel";
2511e8a1faeSThomas Huth } else if (test->bios) {
2521e8a1faeSThomas Huth code = test->bios;
2531e8a1faeSThomas Huth codeparam = "-bios";
2541e8a1faeSThomas Huth }
2551e8a1faeSThomas Huth
2561e8a1faeSThomas Huth if (code) {
2571e8a1faeSThomas Huth ssize_t wlen;
2581e8a1faeSThomas Huth int code_fd;
2591e8a1faeSThomas Huth
2604bcea44bSBin Meng code_fd = g_file_open_tmp("qtest-boot-serial-cXXXXXX", &codetmp, NULL);
2611e8a1faeSThomas Huth g_assert(code_fd != -1);
2621e8a1faeSThomas Huth wlen = write(code_fd, code, test->codesize);
2631e8a1faeSThomas Huth g_assert(wlen == test->codesize);
2641e8a1faeSThomas Huth close(code_fd);
2651e8a1faeSThomas Huth }
2661e8a1faeSThomas Huth
2671e8a1faeSThomas Huth /*
2681e8a1faeSThomas Huth * Make sure that this test uses tcg if available: It is used as a
2691e8a1faeSThomas Huth * fast-enough smoketest for that.
2701e8a1faeSThomas Huth */
2711e8a1faeSThomas Huth qts = qtest_initf("%s %s -M %s -no-shutdown "
2721e8a1faeSThomas Huth "-chardev file,id=serial0,path=%s "
2731e8a1faeSThomas Huth "-serial chardev:serial0 -accel tcg -accel kvm %s",
2741e8a1faeSThomas Huth codeparam, code ? codetmp : "", test->machine,
2751e8a1faeSThomas Huth serialtmp, test->extra);
2761e8a1faeSThomas Huth if (code) {
2771e8a1faeSThomas Huth unlink(codetmp);
2781e8a1faeSThomas Huth }
2791e8a1faeSThomas Huth
28065a2eff0SBin Meng ser_fd = open(serialtmp, O_RDONLY);
28165a2eff0SBin Meng g_assert(ser_fd != -1);
2821e8a1faeSThomas Huth if (!check_guest_output(qts, test, ser_fd)) {
2831e8a1faeSThomas Huth g_error("Failed to find expected string. Please check '%s'",
2841e8a1faeSThomas Huth serialtmp);
2851e8a1faeSThomas Huth }
2861e8a1faeSThomas Huth unlink(serialtmp);
2871e8a1faeSThomas Huth
2881e8a1faeSThomas Huth qtest_quit(qts);
2891e8a1faeSThomas Huth
2901e8a1faeSThomas Huth close(ser_fd);
2911e8a1faeSThomas Huth }
2921e8a1faeSThomas Huth
main(int argc,char * argv[])2931e8a1faeSThomas Huth int main(int argc, char *argv[])
2941e8a1faeSThomas Huth {
2951e8a1faeSThomas Huth const char *arch = qtest_get_arch();
2961e8a1faeSThomas Huth int i;
2971e8a1faeSThomas Huth
2981e8a1faeSThomas Huth g_test_init(&argc, &argv, NULL);
2991e8a1faeSThomas Huth
3000c1ae3ffSFabiano Rosas if (!qtest_has_accel("tcg") && !qtest_has_accel("kvm")) {
3010c1ae3ffSFabiano Rosas g_test_skip("No KVM or TCG accelerator available");
3020c1ae3ffSFabiano Rosas return 0;
3030c1ae3ffSFabiano Rosas }
3040c1ae3ffSFabiano Rosas
3051e8a1faeSThomas Huth for (i = 0; tests[i].arch != NULL; i++) {
306719051caSThomas Huth if (g_str_equal(arch, tests[i].arch) &&
307719051caSThomas Huth qtest_has_machine(tests[i].machine)) {
3081e8a1faeSThomas Huth char *name = g_strdup_printf("boot-serial/%s", tests[i].machine);
3091e8a1faeSThomas Huth qtest_add_data_func(name, &tests[i], test_machine);
3101e8a1faeSThomas Huth g_free(name);
3111e8a1faeSThomas Huth }
3121e8a1faeSThomas Huth }
3131e8a1faeSThomas Huth
3141e8a1faeSThomas Huth return g_test_run();
3151e8a1faeSThomas Huth }
316