xref: /openbmc/qemu/tests/qtest/boot-serial-test.c (revision 0c1ae3ff)
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"
1863d57c8fSGreg Kurz #include "libqos/libqos-spapr.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 
291e8a1faeSThomas Huth static const uint8_t kernel_mcf5208[] = {
301e8a1faeSThomas Huth     0x41, 0xf9, 0xfc, 0x06, 0x00, 0x00,     /* lea 0xfc060000,%a0 */
311e8a1faeSThomas Huth     0x10, 0x3c, 0x00, 0x54,                 /* move.b #'T',%d0 */
321e8a1faeSThomas Huth     0x11, 0x7c, 0x00, 0x04, 0x00, 0x08,     /* move.b #4,8(%a0)     Enable TX */
331e8a1faeSThomas Huth     0x11, 0x40, 0x00, 0x0c,                 /* move.b %d0,12(%a0)   Print 'T' */
341e8a1faeSThomas Huth     0x60, 0xfa                              /* bra.s  loop */
351e8a1faeSThomas Huth };
361e8a1faeSThomas Huth 
371e8a1faeSThomas Huth static const uint8_t bios_nextcube[] = {
381e8a1faeSThomas Huth     0x06, 0x00, 0x00, 0x00,                 /* Initial SP */
391e8a1faeSThomas Huth     0x01, 0x00, 0x00, 0x08,                 /* Initial PC */
401e8a1faeSThomas Huth     0x41, 0xf9, 0x02, 0x11, 0x80, 0x00,     /* lea 0x02118000,%a0 */
411e8a1faeSThomas Huth     0x10, 0x3c, 0x00, 0x54,                 /* move.b #'T',%d0 */
421e8a1faeSThomas Huth     0x11, 0x7c, 0x00, 0x05, 0x00, 0x01,     /* move.b #5,1(%a0)    Sel TXCTRL */
431e8a1faeSThomas Huth     0x11, 0x7c, 0x00, 0x68, 0x00, 0x01,     /* move.b #0x68,1(%a0) Enable TX */
441e8a1faeSThomas Huth     0x11, 0x40, 0x00, 0x03,                 /* move.b %d0,3(%a0)   Print 'T' */
451e8a1faeSThomas Huth     0x60, 0xfa                              /* bra.s  loop */
461e8a1faeSThomas Huth };
471e8a1faeSThomas Huth 
481e8a1faeSThomas Huth static const uint8_t kernel_pls3adsp1800[] = {
491e8a1faeSThomas Huth     0xb0, 0x00, 0x84, 0x00,                 /* imm   0x8400 */
501e8a1faeSThomas Huth     0x30, 0x60, 0x00, 0x04,                 /* addik r3,r0,4 */
511e8a1faeSThomas Huth     0x30, 0x80, 0x00, 0x54,                 /* addik r4,r0,'T' */
521e8a1faeSThomas Huth     0xf0, 0x83, 0x00, 0x00,                 /* sbi   r4,r3,0 */
531e8a1faeSThomas Huth     0xb8, 0x00, 0xff, 0xfc                  /* bri   -4  loop */
541e8a1faeSThomas Huth };
551e8a1faeSThomas Huth 
561e8a1faeSThomas Huth static const uint8_t kernel_plml605[] = {
571e8a1faeSThomas Huth     0xe0, 0x83, 0x00, 0xb0,                 /* imm   0x83e0 */
581e8a1faeSThomas Huth     0x00, 0x10, 0x60, 0x30,                 /* addik r3,r0,0x1000 */
591e8a1faeSThomas Huth     0x54, 0x00, 0x80, 0x30,                 /* addik r4,r0,'T' */
601e8a1faeSThomas Huth     0x00, 0x00, 0x83, 0xf0,                 /* sbi   r4,r3,0 */
611e8a1faeSThomas Huth     0xfc, 0xff, 0x00, 0xb8                  /* bri   -4  loop */
621e8a1faeSThomas Huth };
631e8a1faeSThomas Huth 
641e8a1faeSThomas Huth static const uint8_t bios_raspi2[] = {
651e8a1faeSThomas Huth     0x08, 0x30, 0x9f, 0xe5,                 /* ldr   r3,[pc,#8]    Get base */
661e8a1faeSThomas Huth     0x54, 0x20, 0xa0, 0xe3,                 /* mov     r2,#'T' */
671e8a1faeSThomas Huth     0x00, 0x20, 0xc3, 0xe5,                 /* strb    r2,[r3] */
681e8a1faeSThomas Huth     0xfb, 0xff, 0xff, 0xea,                 /* b       loop */
691e8a1faeSThomas Huth     0x00, 0x10, 0x20, 0x3f,                 /* 0x3f201000 = UART0 base addr */
701e8a1faeSThomas Huth };
711e8a1faeSThomas Huth 
721e8a1faeSThomas Huth static const uint8_t kernel_aarch64[] = {
731e8a1faeSThomas Huth     0x81, 0x0a, 0x80, 0x52,                 /* mov     w1, #0x54 */
741e8a1faeSThomas Huth     0x02, 0x20, 0xa1, 0xd2,                 /* mov     x2, #0x9000000 */
751e8a1faeSThomas Huth     0x41, 0x00, 0x00, 0x39,                 /* strb    w1, [x2] */
761e8a1faeSThomas Huth     0xfd, 0xff, 0xff, 0x17,                 /* b       -12 (loop) */
771e8a1faeSThomas Huth };
781e8a1faeSThomas Huth 
791e8a1faeSThomas Huth static const uint8_t kernel_nrf51[] = {
801e8a1faeSThomas Huth     0x00, 0x00, 0x00, 0x00,                 /* Stack top address */
811e8a1faeSThomas Huth     0x09, 0x00, 0x00, 0x00,                 /* Reset handler address */
821e8a1faeSThomas Huth     0x04, 0x4a,                             /* ldr  r2, [pc, #16] Get ENABLE */
831e8a1faeSThomas Huth     0x04, 0x21,                             /* movs r1, #4 */
841e8a1faeSThomas Huth     0x11, 0x60,                             /* str  r1, [r2] */
851e8a1faeSThomas Huth     0x04, 0x4a,                             /* ldr  r2, [pc, #16] Get STARTTX */
861e8a1faeSThomas Huth     0x01, 0x21,                             /* movs r1, #1 */
871e8a1faeSThomas Huth     0x11, 0x60,                             /* str  r1, [r2] */
881e8a1faeSThomas Huth     0x03, 0x4a,                             /* ldr  r2, [pc, #12] Get TXD */
891e8a1faeSThomas Huth     0x54, 0x21,                             /* movs r1, 'T' */
901e8a1faeSThomas Huth     0x11, 0x60,                             /* str  r1, [r2] */
911e8a1faeSThomas Huth     0xfe, 0xe7,                             /* b    . */
921e8a1faeSThomas Huth     0x00, 0x25, 0x00, 0x40,                 /* 0x40002500 = UART ENABLE */
931e8a1faeSThomas Huth     0x08, 0x20, 0x00, 0x40,                 /* 0x40002008 = UART STARTTX */
941e8a1faeSThomas Huth     0x1c, 0x25, 0x00, 0x40                  /* 0x4000251c = UART TXD */
951e8a1faeSThomas Huth };
961e8a1faeSThomas Huth 
977cb4097fSAlexandre Iooss static const uint8_t kernel_stm32vldiscovery[] = {
987cb4097fSAlexandre Iooss     0x00, 0x00, 0x00, 0x00,                 /* Stack top address */
997cb4097fSAlexandre Iooss     0x1d, 0x00, 0x00, 0x00,                 /* Reset handler address */
1007cb4097fSAlexandre Iooss     0x00, 0x00, 0x00, 0x00,                 /* NMI */
1017cb4097fSAlexandre Iooss     0x00, 0x00, 0x00, 0x00,                 /* Hard fault */
1027cb4097fSAlexandre Iooss     0x00, 0x00, 0x00, 0x00,                 /* Memory management fault */
1037cb4097fSAlexandre Iooss     0x00, 0x00, 0x00, 0x00,                 /* Bus fault */
1047cb4097fSAlexandre Iooss     0x00, 0x00, 0x00, 0x00,                 /* Usage fault */
1057cb4097fSAlexandre Iooss     0x0b, 0x4b,                             /* ldr  r3, [pc, #44] Get RCC */
1067cb4097fSAlexandre Iooss     0x44, 0xf2, 0x04, 0x02,                 /* movw r2, #16388 */
1077cb4097fSAlexandre Iooss     0x1a, 0x60,                             /* str  r2, [r3] */
1087cb4097fSAlexandre Iooss     0x0a, 0x4b,                             /* ldr  r3, [pc, #40] Get GPIOA */
1097cb4097fSAlexandre Iooss     0x1a, 0x68,                             /* ldr  r2, [r3] */
1107cb4097fSAlexandre Iooss     0x22, 0xf0, 0xf0, 0x02,                 /* bic  r2, r2, #240 */
1117cb4097fSAlexandre Iooss     0x1a, 0x60,                             /* str  r2, [r3] */
1127cb4097fSAlexandre Iooss     0x1a, 0x68,                             /* ldr  r2, [r3] */
1137cb4097fSAlexandre Iooss     0x42, 0xf0, 0xb0, 0x02,                 /* orr  r2, r2, #176 */
1147cb4097fSAlexandre Iooss     0x1a, 0x60,                             /* str  r2, [r3] */
1157cb4097fSAlexandre Iooss     0x07, 0x4b,                             /* ldr  r3, [pc, #26] Get BAUD */
1167cb4097fSAlexandre Iooss     0x45, 0x22,                             /* movs r2, #69 */
1177cb4097fSAlexandre Iooss     0x1a, 0x60,                             /* str  r2, [r3] */
1187cb4097fSAlexandre Iooss     0x06, 0x4b,                             /* ldr  r3, [pc, #24] Get ENABLE */
1197cb4097fSAlexandre Iooss     0x42, 0xf2, 0x08, 0x02,                 /* movw r2, #8200 */
1207cb4097fSAlexandre Iooss     0x1a, 0x60,                             /* str  r2, [r3] */
1217cb4097fSAlexandre Iooss     0x05, 0x4b,                             /* ldr  r3, [pc, #20] Get TXD */
1227cb4097fSAlexandre Iooss     0x54, 0x22,                             /* movs r2, 'T' */
1237cb4097fSAlexandre Iooss     0x1a, 0x60,                             /* str  r2, [r3] */
1247cb4097fSAlexandre Iooss     0xfe, 0xe7,                             /* b    . */
1257cb4097fSAlexandre Iooss     0x18, 0x10, 0x02, 0x40,                 /* 0x40021018 = RCC */
1267cb4097fSAlexandre Iooss     0x04, 0x08, 0x01, 0x40,                 /* 0x40010804 = GPIOA */
1277cb4097fSAlexandre Iooss     0x08, 0x38, 0x01, 0x40,                 /* 0x40013808 = USART1 BAUD */
1287cb4097fSAlexandre Iooss     0x0c, 0x38, 0x01, 0x40,                 /* 0x4001380c = USART1 ENABLE */
1297cb4097fSAlexandre Iooss     0x04, 0x38, 0x01, 0x40                  /* 0x40013804 = USART1 TXD */
1307cb4097fSAlexandre Iooss };
1317cb4097fSAlexandre Iooss 
1321e8a1faeSThomas Huth typedef struct testdef {
1331e8a1faeSThomas Huth     const char *arch;       /* Target architecture */
1341e8a1faeSThomas Huth     const char *machine;    /* Name of the machine */
1351e8a1faeSThomas Huth     const char *extra;      /* Additional parameters */
1361e8a1faeSThomas Huth     const char *expect;     /* Expected string in the serial output */
1371e8a1faeSThomas Huth     size_t codesize;        /* Size of the kernel or bios data */
1381e8a1faeSThomas Huth     const uint8_t *kernel;  /* Set in case we use our own mini kernel */
1391e8a1faeSThomas Huth     const uint8_t *bios;    /* Set in case we use our own mini bios */
1401e8a1faeSThomas Huth } testdef_t;
1411e8a1faeSThomas Huth 
142a4267f00SPhilippe Mathieu-Daudé static const testdef_t tests[] = {
1431e8a1faeSThomas Huth     { "alpha", "clipper", "", "PCI:" },
14436838e5fSMichael Rolnik     { "avr", "arduino-duemilanove", "", "T", sizeof(bios_avr), NULL, bios_avr },
14536838e5fSMichael Rolnik     { "avr", "arduino-mega-2560-v3", "", "T", sizeof(bios_avr), NULL, bios_avr},
1461e8a1faeSThomas Huth     { "ppc", "ppce500", "", "U-Boot" },
1471e8a1faeSThomas Huth     { "ppc", "40p", "-vga none -boot d", "Trying cd:," },
1481e8a1faeSThomas Huth     { "ppc", "g3beige", "", "PowerPC,750" },
1491e8a1faeSThomas Huth     { "ppc", "mac99", "", "PowerPC,G4" },
1501e8a1faeSThomas Huth     { "ppc", "sam460ex", "-m 256", "DRAM:  256 MiB" },
1511e8a1faeSThomas Huth     { "ppc64", "ppce500", "", "U-Boot" },
1521e8a1faeSThomas Huth     { "ppc64", "40p", "-m 192", "Memory: 192M" },
1531e8a1faeSThomas Huth     { "ppc64", "mac99", "", "PowerPC,970FX" },
1541e8a1faeSThomas Huth     { "ppc64", "pseries",
15563d57c8fSGreg Kurz       "-machine " PSERIES_DEFAULT_CAPABILITIES,
1561e8a1faeSThomas Huth       "Open Firmware" },
1571e8a1faeSThomas Huth     { "ppc64", "powernv8", "", "OPAL" },
1581e8a1faeSThomas Huth     { "ppc64", "powernv9", "", "OPAL" },
1591e8a1faeSThomas Huth     { "ppc64", "sam460ex", "-device e1000", "8086  100e" },
160046da5efSThomas Huth     { "i386", "isapc", "-cpu qemu32 -M graphics=off", "SeaBIOS" },
161046da5efSThomas Huth     { "i386", "pc", "-M graphics=off", "SeaBIOS" },
162046da5efSThomas Huth     { "i386", "q35", "-M graphics=off", "SeaBIOS" },
163046da5efSThomas Huth     { "x86_64", "isapc", "-cpu qemu32 -M graphics=off", "SeaBIOS" },
164046da5efSThomas Huth     { "x86_64", "q35", "-M graphics=off", "SeaBIOS" },
1651e8a1faeSThomas Huth     { "sparc", "LX", "", "TMS390S10" },
1661e8a1faeSThomas Huth     { "sparc", "SS-4", "", "MB86904" },
1671e8a1faeSThomas Huth     { "sparc", "SS-600MP", "", "TMS390Z55" },
1681e8a1faeSThomas Huth     { "sparc64", "sun4u", "", "UltraSPARC" },
1691e8a1faeSThomas Huth     { "s390x", "s390-ccw-virtio", "", "device" },
1701e8a1faeSThomas Huth     { "m68k", "mcf5208evb", "", "TT", sizeof(kernel_mcf5208), kernel_mcf5208 },
1711e8a1faeSThomas Huth     { "m68k", "next-cube", "", "TT", sizeof(bios_nextcube), 0, bios_nextcube },
1721e8a1faeSThomas Huth     { "microblaze", "petalogix-s3adsp1800", "", "TT",
1731e8a1faeSThomas Huth       sizeof(kernel_pls3adsp1800), kernel_pls3adsp1800 },
1741e8a1faeSThomas Huth     { "microblazeel", "petalogix-ml605", "", "TT",
1751e8a1faeSThomas Huth       sizeof(kernel_plml605), kernel_plml605 },
176cd066eeaSPhilippe Mathieu-Daudé     { "arm", "raspi2b", "", "TT", sizeof(bios_raspi2), 0, bios_raspi2 },
1774765384cSSven Schnelle     /* For hppa, force bios to output to serial by disabling graphics. */
1784765384cSSven Schnelle     { "hppa", "hppa", "-vga none", "SeaBIOS wants SYSTEM HALT" },
179421954f4SPhilippe Mathieu-Daudé     { "aarch64", "virt", "-cpu max", "TT", sizeof(kernel_aarch64),
1801e8a1faeSThomas Huth       kernel_aarch64 },
1811e8a1faeSThomas Huth     { "arm", "microbit", "", "T", sizeof(kernel_nrf51), kernel_nrf51 },
1827cb4097fSAlexandre Iooss     { "arm", "stm32vldiscovery", "", "T",
1837cb4097fSAlexandre Iooss       sizeof(kernel_stm32vldiscovery), kernel_stm32vldiscovery },
1841e8a1faeSThomas Huth 
1851e8a1faeSThomas Huth     { NULL }
1861e8a1faeSThomas Huth };
1871e8a1faeSThomas Huth 
check_guest_output(QTestState * qts,const testdef_t * test,int fd)1881e8a1faeSThomas Huth static bool check_guest_output(QTestState *qts, const testdef_t *test, int fd)
1891e8a1faeSThomas Huth {
1901e8a1faeSThomas Huth     int nbr = 0, pos = 0, ccnt;
1911e8a1faeSThomas Huth     time_t now, start = time(NULL);
1921e8a1faeSThomas Huth     char ch;
1931e8a1faeSThomas Huth 
1941e8a1faeSThomas Huth     /* Poll serial output... */
1951e8a1faeSThomas Huth     while (1) {
1961e8a1faeSThomas Huth         ccnt = 0;
1971e8a1faeSThomas Huth         while (ccnt++ < 512 && (nbr = read(fd, &ch, 1)) == 1) {
1981e8a1faeSThomas Huth             if (ch == test->expect[pos]) {
1991e8a1faeSThomas Huth                 pos += 1;
2001e8a1faeSThomas Huth                 if (test->expect[pos] == '\0') {
2011e8a1faeSThomas Huth                     /* We've reached the end of the expected string! */
2021e8a1faeSThomas Huth                     return true;
2031e8a1faeSThomas Huth                 }
2041e8a1faeSThomas Huth             } else {
2051e8a1faeSThomas Huth                 pos = 0;
2061e8a1faeSThomas Huth             }
2071e8a1faeSThomas Huth         }
2081e8a1faeSThomas Huth         g_assert(nbr >= 0);
2091e8a1faeSThomas Huth         /* Wait only if the child is still alive.  */
2101e8a1faeSThomas Huth         if (!qtest_probe_child(qts)) {
2111e8a1faeSThomas Huth             break;
2121e8a1faeSThomas Huth         }
2131e8a1faeSThomas Huth         /* Wait at most 360 seconds.  */
2141e8a1faeSThomas Huth         now = time(NULL);
2151e8a1faeSThomas Huth         if (now - start >= 360) {
2161e8a1faeSThomas Huth             break;
2171e8a1faeSThomas Huth         }
2181e8a1faeSThomas Huth         g_usleep(10000);
2191e8a1faeSThomas Huth     }
2201e8a1faeSThomas Huth 
2211e8a1faeSThomas Huth     return false;
2221e8a1faeSThomas Huth }
2231e8a1faeSThomas Huth 
test_machine(const void * data)2241e8a1faeSThomas Huth static void test_machine(const void *data)
2251e8a1faeSThomas Huth {
2261e8a1faeSThomas Huth     const testdef_t *test = data;
2274bcea44bSBin Meng     g_autofree char *serialtmp = NULL;
2284bcea44bSBin Meng     g_autofree char *codetmp = NULL;
2291e8a1faeSThomas Huth     const char *codeparam = "";
2301e8a1faeSThomas Huth     const uint8_t *code = NULL;
2311e8a1faeSThomas Huth     QTestState *qts;
2321e8a1faeSThomas Huth     int ser_fd;
2331e8a1faeSThomas Huth 
2344bcea44bSBin Meng     ser_fd = g_file_open_tmp("qtest-boot-serial-sXXXXXX", &serialtmp, NULL);
2351e8a1faeSThomas Huth     g_assert(ser_fd != -1);
23665a2eff0SBin Meng     close(ser_fd);
2371e8a1faeSThomas Huth 
2381e8a1faeSThomas Huth     if (test->kernel) {
2391e8a1faeSThomas Huth         code = test->kernel;
2401e8a1faeSThomas Huth         codeparam = "-kernel";
2411e8a1faeSThomas Huth     } else if (test->bios) {
2421e8a1faeSThomas Huth         code = test->bios;
2431e8a1faeSThomas Huth         codeparam = "-bios";
2441e8a1faeSThomas Huth     }
2451e8a1faeSThomas Huth 
2461e8a1faeSThomas Huth     if (code) {
2471e8a1faeSThomas Huth         ssize_t wlen;
2481e8a1faeSThomas Huth         int code_fd;
2491e8a1faeSThomas Huth 
2504bcea44bSBin Meng         code_fd = g_file_open_tmp("qtest-boot-serial-cXXXXXX", &codetmp, NULL);
2511e8a1faeSThomas Huth         g_assert(code_fd != -1);
2521e8a1faeSThomas Huth         wlen = write(code_fd, code, test->codesize);
2531e8a1faeSThomas Huth         g_assert(wlen == test->codesize);
2541e8a1faeSThomas Huth         close(code_fd);
2551e8a1faeSThomas Huth     }
2561e8a1faeSThomas Huth 
2571e8a1faeSThomas Huth     /*
2581e8a1faeSThomas Huth      * Make sure that this test uses tcg if available: It is used as a
2591e8a1faeSThomas Huth      * fast-enough smoketest for that.
2601e8a1faeSThomas Huth      */
2611e8a1faeSThomas Huth     qts = qtest_initf("%s %s -M %s -no-shutdown "
2621e8a1faeSThomas Huth                       "-chardev file,id=serial0,path=%s "
2631e8a1faeSThomas Huth                       "-serial chardev:serial0 -accel tcg -accel kvm %s",
2641e8a1faeSThomas Huth                       codeparam, code ? codetmp : "", test->machine,
2651e8a1faeSThomas Huth                       serialtmp, test->extra);
2661e8a1faeSThomas Huth     if (code) {
2671e8a1faeSThomas Huth         unlink(codetmp);
2681e8a1faeSThomas Huth     }
2691e8a1faeSThomas Huth 
27065a2eff0SBin Meng     ser_fd = open(serialtmp, O_RDONLY);
27165a2eff0SBin Meng     g_assert(ser_fd != -1);
2721e8a1faeSThomas Huth     if (!check_guest_output(qts, test, ser_fd)) {
2731e8a1faeSThomas Huth         g_error("Failed to find expected string. Please check '%s'",
2741e8a1faeSThomas Huth                 serialtmp);
2751e8a1faeSThomas Huth     }
2761e8a1faeSThomas Huth     unlink(serialtmp);
2771e8a1faeSThomas Huth 
2781e8a1faeSThomas Huth     qtest_quit(qts);
2791e8a1faeSThomas Huth 
2801e8a1faeSThomas Huth     close(ser_fd);
2811e8a1faeSThomas Huth }
2821e8a1faeSThomas Huth 
main(int argc,char * argv[])2831e8a1faeSThomas Huth int main(int argc, char *argv[])
2841e8a1faeSThomas Huth {
2851e8a1faeSThomas Huth     const char *arch = qtest_get_arch();
2861e8a1faeSThomas Huth     int i;
2871e8a1faeSThomas Huth 
2881e8a1faeSThomas Huth     g_test_init(&argc, &argv, NULL);
2891e8a1faeSThomas Huth 
290*0c1ae3ffSFabiano Rosas     if (!qtest_has_accel("tcg") && !qtest_has_accel("kvm")) {
291*0c1ae3ffSFabiano Rosas         g_test_skip("No KVM or TCG accelerator available");
292*0c1ae3ffSFabiano Rosas         return 0;
293*0c1ae3ffSFabiano Rosas     }
294*0c1ae3ffSFabiano Rosas 
2951e8a1faeSThomas Huth     for (i = 0; tests[i].arch != NULL; i++) {
296719051caSThomas Huth         if (g_str_equal(arch, tests[i].arch) &&
297719051caSThomas Huth             qtest_has_machine(tests[i].machine)) {
2981e8a1faeSThomas Huth             char *name = g_strdup_printf("boot-serial/%s", tests[i].machine);
2991e8a1faeSThomas Huth             qtest_add_data_func(name, &tests[i], test_machine);
3001e8a1faeSThomas Huth             g_free(name);
3011e8a1faeSThomas Huth         }
3021e8a1faeSThomas Huth     }
3031e8a1faeSThomas Huth 
3041e8a1faeSThomas Huth     return g_test_run();
3051e8a1faeSThomas Huth }
306