]>
Commit | Line | Data |
---|---|---|
4e082566 VK |
1 | /* |
2 | * PXE test cases. | |
3 | * | |
ab06ec43 | 4 | * Copyright (c) 2016, 2017 Red Hat Inc. |
4e082566 VK |
5 | * |
6 | * Authors: | |
7 | * Michael S. Tsirkin <mst@redhat.com>, | |
8 | * Victor Kaplansky <victork@redhat.com> | |
ab06ec43 | 9 | * Thomas Huth <thuth@redhat.com> |
4e082566 VK |
10 | * |
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. | |
13 | */ | |
14 | ||
974dc73d | 15 | #include "qemu/osdep.h" |
4e082566 VK |
16 | #include <glib/gstdio.h> |
17 | #include "qemu-common.h" | |
18 | #include "libqtest.h" | |
19 | #include "boot-sector.h" | |
63d57c8f | 20 | #include "libqos/libqos-spapr.h" |
4e082566 VK |
21 | |
22 | #define NETNAME "net0" | |
23 | ||
3e353773 | 24 | static char disk[] = "tests/pxe-test-disk-XXXXXX"; |
4e082566 | 25 | |
1e88989f DG |
26 | typedef struct testdef { |
27 | const char *machine; /* Machine type */ | |
28 | const char *model; /* NIC device model */ | |
ba3b40de | 29 | const char *extra; /* Any additional parameters */ |
1e88989f DG |
30 | } testdef_t; |
31 | ||
32 | static testdef_t x86_tests[] = { | |
33 | { "pc", "e1000" }, | |
34 | { "pc", "virtio-net-pci" }, | |
18b20bb4 DG |
35 | { "q35", "e1000e" }, |
36 | { "q35", "virtio-net-pci", }, | |
1e88989f DG |
37 | { NULL }, |
38 | }; | |
39 | ||
40 | static testdef_t x86_tests_slow[] = { | |
41 | { "pc", "ne2k_pci", }, | |
42 | { "pc", "i82550", }, | |
43 | { "pc", "rtl8139" }, | |
44 | { "pc", "vmxnet3" }, | |
45 | { NULL }, | |
46 | }; | |
47 | ||
48 | static testdef_t ppc64_tests[] = { | |
ba3b40de | 49 | { "pseries", "spapr-vlan", |
63d57c8f | 50 | "-machine vsmt=8," PSERIES_DEFAULT_CAPABILITIES }, |
ba3b40de | 51 | { "pseries", "virtio-net-pci", |
63d57c8f | 52 | "-machine vsmt=8," PSERIES_DEFAULT_CAPABILITIES }, |
1e88989f DG |
53 | { NULL }, |
54 | }; | |
55 | ||
56 | static testdef_t ppc64_tests_slow[] = { | |
ba3b40de | 57 | { "pseries", "e1000", |
63d57c8f | 58 | "-machine vsmt=8," PSERIES_DEFAULT_CAPABILITIES }, |
1e88989f DG |
59 | { NULL }, |
60 | }; | |
61 | ||
62 | static testdef_t s390x_tests[] = { | |
63 | { "s390-ccw-virtio", "virtio-net-ccw" }, | |
64 | { NULL }, | |
65 | }; | |
66 | ||
67 | static void test_pxe_one(const testdef_t *test, bool ipv6) | |
4e082566 | 68 | { |
43497c43 | 69 | QTestState *qts; |
4e082566 | 70 | char *args; |
ba3b40de DG |
71 | const char *extra = test->extra; |
72 | ||
73 | if (!extra) { | |
74 | extra = ""; | |
75 | } | |
4e082566 | 76 | |
1e88989f | 77 | args = g_strdup_printf( |
6f6e1698 | 78 | "-accel kvm -accel tcg -machine %s -nodefaults -boot order=n " |
1e88989f | 79 | "-netdev user,id=" NETNAME ",tftp=./,bootfile=%s,ipv4=%s,ipv6=%s " |
ba3b40de | 80 | "-device %s,bootindex=1,netdev=" NETNAME " %s", |
1e88989f | 81 | test->machine, disk, ipv6 ? "off" : "on", ipv6 ? "on" : "off", |
ba3b40de | 82 | test->model, extra); |
4e082566 | 83 | |
43497c43 TH |
84 | qts = qtest_init(args); |
85 | boot_sector_test(qts); | |
86 | qtest_quit(qts); | |
4e082566 VK |
87 | g_free(args); |
88 | } | |
89 | ||
ab06ec43 | 90 | static void test_pxe_ipv4(gconstpointer data) |
4e082566 | 91 | { |
1e88989f | 92 | const testdef_t *test = data; |
4e082566 | 93 | |
1e88989f DG |
94 | test_pxe_one(test, false); |
95 | } | |
96 | ||
d23895d9 DG |
97 | static void test_pxe_ipv6(gconstpointer data) |
98 | { | |
99 | const testdef_t *test = data; | |
100 | ||
101 | test_pxe_one(test, true); | |
102 | } | |
103 | ||
104 | static void test_batch(const testdef_t *tests, bool ipv6) | |
1e88989f DG |
105 | { |
106 | int i; | |
107 | ||
108 | for (i = 0; tests[i].machine; i++) { | |
109 | const testdef_t *test = &tests[i]; | |
110 | char *testname; | |
111 | ||
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); | |
d23895d9 DG |
116 | |
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); | |
122 | } | |
1e88989f | 123 | } |
1485ef1c TH |
124 | } |
125 | ||
4e082566 VK |
126 | int main(int argc, char *argv[]) |
127 | { | |
128 | int ret; | |
129 | const char *arch = qtest_get_arch(); | |
130 | ||
131 | ret = boot_sector_init(disk); | |
132 | if(ret) | |
133 | return ret; | |
134 | ||
135 | g_test_init(&argc, &argv, NULL); | |
136 | ||
137 | if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { | |
d23895d9 | 138 | test_batch(x86_tests, false); |
ab06ec43 | 139 | if (g_test_slow()) { |
d23895d9 | 140 | test_batch(x86_tests_slow, false); |
ab06ec43 | 141 | } |
1485ef1c | 142 | } else if (strcmp(arch, "ppc64") == 0) { |
d23895d9 | 143 | test_batch(ppc64_tests, g_test_slow()); |
ab06ec43 | 144 | if (g_test_slow()) { |
d23895d9 | 145 | test_batch(ppc64_tests_slow, true); |
ab06ec43 | 146 | } |
b1b2feac | 147 | } else if (g_str_equal(arch, "s390x")) { |
d23895d9 | 148 | test_batch(s390x_tests, g_test_slow()); |
4e082566 VK |
149 | } |
150 | ret = g_test_run(); | |
151 | boot_sector_cleanup(disk); | |
152 | return ret; | |
153 | } |