hw/sd: sd: Bypass the RCA check for CMD13 in SPI mode
[qemu/ar7.git] / tests / qtest / pxe-test.c
blob32bbae33c5977c700402c6381a8c1d562c32b601
1 /*
2 * PXE test cases.
4 * Copyright (c) 2016, 2017 Red Hat Inc.
6 * Authors:
7 * Michael S. Tsirkin <mst@redhat.com>,
8 * Victor Kaplansky <victork@redhat.com>
9 * Thomas Huth <thuth@redhat.com>
11 * This work is licensed under the terms of the GNU GPL, version 2 or later.
12 * See the COPYING file in the top-level directory.
15 #include "qemu/osdep.h"
16 #include <glib/gstdio.h>
17 #include "qemu-common.h"
18 #include "libqos/libqtest.h"
19 #include "boot-sector.h"
20 #include "libqos/libqos-spapr.h"
22 #define NETNAME "net0"
24 static char disk[] = "tests/pxe-test-disk-XXXXXX";
26 typedef struct testdef {
27 const char *machine; /* Machine type */
28 const char *model; /* NIC device model */
29 const char *extra; /* Any additional parameters */
30 } testdef_t;
32 static testdef_t x86_tests[] = {
33 { "pc", "e1000" },
34 { "pc", "virtio-net-pci" },
35 { "q35", "e1000e" },
36 { "q35", "virtio-net-pci", },
37 { NULL },
40 static testdef_t x86_tests_slow[] = {
41 { "pc", "ne2k_pci", },
42 { "pc", "i82550", },
43 { "pc", "rtl8139" },
44 { "pc", "vmxnet3" },
45 { NULL },
48 static testdef_t ppc64_tests[] = {
49 { "pseries", "spapr-vlan",
50 "-machine vsmt=8," PSERIES_DEFAULT_CAPABILITIES },
51 { "pseries", "virtio-net-pci",
52 "-machine vsmt=8," PSERIES_DEFAULT_CAPABILITIES },
53 { NULL },
56 static testdef_t ppc64_tests_slow[] = {
57 { "pseries", "e1000",
58 "-machine vsmt=8," PSERIES_DEFAULT_CAPABILITIES },
59 { NULL },
62 static testdef_t s390x_tests[] = {
63 { "s390-ccw-virtio", "virtio-net-ccw" },
64 { NULL },
67 static void test_pxe_one(const testdef_t *test, bool ipv6)
69 QTestState *qts;
70 char *args;
71 const char *extra = test->extra;
73 if (!extra) {
74 extra = "";
77 args = g_strdup_printf(
78 "-accel kvm -accel tcg -machine %s -nodefaults -boot order=n "
79 "-netdev user,id=" NETNAME ",tftp=./,bootfile=%s,ipv4=%s,ipv6=%s "
80 "-device %s,bootindex=1,netdev=" NETNAME " %s",
81 test->machine, disk, ipv6 ? "off" : "on", ipv6 ? "on" : "off",
82 test->model, extra);
84 qts = qtest_init(args);
85 boot_sector_test(qts);
86 qtest_quit(qts);
87 g_free(args);
90 static void test_pxe_ipv4(gconstpointer data)
92 const testdef_t *test = data;
94 test_pxe_one(test, false);
97 static void test_pxe_ipv6(gconstpointer data)
99 const testdef_t *test = data;
101 test_pxe_one(test, true);
104 static void test_batch(const testdef_t *tests, bool ipv6)
106 int i;
108 for (i = 0; tests[i].machine; i++) {
109 const testdef_t *test = &tests[i];
110 char *testname;
112 testname = g_strdup_printf("pxe/ipv4/%s/%s",
113 test->machine, test->model);
114 qtest_add_data_func(testname, test, test_pxe_ipv4);
115 g_free(testname);
117 if (ipv6) {
118 testname = g_strdup_printf("pxe/ipv6/%s/%s",
119 test->machine, test->model);
120 qtest_add_data_func(testname, test, test_pxe_ipv6);
121 g_free(testname);
126 int main(int argc, char *argv[])
128 int ret;
129 const char *arch = qtest_get_arch();
131 ret = boot_sector_init(disk);
132 if(ret)
133 return ret;
135 g_test_init(&argc, &argv, NULL);
137 if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
138 test_batch(x86_tests, false);
139 if (g_test_slow()) {
140 test_batch(x86_tests_slow, false);
142 } else if (strcmp(arch, "ppc64") == 0) {
143 test_batch(ppc64_tests, g_test_slow());
144 if (g_test_slow()) {
145 test_batch(ppc64_tests_slow, true);
147 } else if (g_str_equal(arch, "s390x")) {
148 test_batch(s390x_tests, g_test_slow());
150 ret = g_test_run();
151 boot_sector_cleanup(disk);
152 return ret;