]> git.proxmox.com Git - mirror_qemu.git/blame - tests/pxe-test.c
tests/libqos/e1000e: Make e1000e libqos functions independent from global_qtest
[mirror_qemu.git] / tests / pxe-test.c
CommitLineData
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"
20
21#define NETNAME "net0"
22
3e353773 23static char disk[] = "tests/pxe-test-disk-XXXXXX";
4e082566 24
1e88989f
DG
25typedef struct testdef {
26 const char *machine; /* Machine type */
27 const char *model; /* NIC device model */
ba3b40de 28 const char *extra; /* Any additional parameters */
1e88989f
DG
29} testdef_t;
30
31static testdef_t x86_tests[] = {
32 { "pc", "e1000" },
33 { "pc", "virtio-net-pci" },
18b20bb4
DG
34 { "q35", "e1000e" },
35 { "q35", "virtio-net-pci", },
1e88989f
DG
36 { NULL },
37};
38
39static testdef_t x86_tests_slow[] = {
40 { "pc", "ne2k_pci", },
41 { "pc", "i82550", },
42 { "pc", "rtl8139" },
43 { "pc", "vmxnet3" },
44 { NULL },
45};
46
47static testdef_t ppc64_tests[] = {
ba3b40de
DG
48 { "pseries", "spapr-vlan",
49 "-machine cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken" },
50 { "pseries", "virtio-net-pci",
51 "-machine cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken" },
1e88989f
DG
52 { NULL },
53};
54
55static testdef_t ppc64_tests_slow[] = {
ba3b40de
DG
56 { "pseries", "e1000",
57 "-machine cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken" },
1e88989f
DG
58 { NULL },
59};
60
61static testdef_t s390x_tests[] = {
62 { "s390-ccw-virtio", "virtio-net-ccw" },
63 { NULL },
64};
65
66static void test_pxe_one(const testdef_t *test, bool ipv6)
4e082566 67{
43497c43 68 QTestState *qts;
4e082566 69 char *args;
ba3b40de
DG
70 const char *extra = test->extra;
71
72 if (!extra) {
73 extra = "";
74 }
4e082566 75
1e88989f
DG
76 args = g_strdup_printf(
77 "-machine %s,accel=kvm:tcg -nodefaults -boot order=n "
78 "-netdev user,id=" NETNAME ",tftp=./,bootfile=%s,ipv4=%s,ipv6=%s "
ba3b40de 79 "-device %s,bootindex=1,netdev=" NETNAME " %s",
1e88989f 80 test->machine, disk, ipv6 ? "off" : "on", ipv6 ? "on" : "off",
ba3b40de 81 test->model, extra);
4e082566 82
43497c43
TH
83 qts = qtest_init(args);
84 boot_sector_test(qts);
85 qtest_quit(qts);
4e082566
VK
86 g_free(args);
87}
88
ab06ec43 89static void test_pxe_ipv4(gconstpointer data)
4e082566 90{
1e88989f 91 const testdef_t *test = data;
4e082566 92
1e88989f
DG
93 test_pxe_one(test, false);
94}
95
d23895d9
DG
96static void test_pxe_ipv6(gconstpointer data)
97{
98 const testdef_t *test = data;
99
100 test_pxe_one(test, true);
101}
102
103static void test_batch(const testdef_t *tests, bool ipv6)
1e88989f
DG
104{
105 int i;
106
107 for (i = 0; tests[i].machine; i++) {
108 const testdef_t *test = &tests[i];
109 char *testname;
110
111 testname = g_strdup_printf("pxe/ipv4/%s/%s",
112 test->machine, test->model);
113 qtest_add_data_func(testname, test, test_pxe_ipv4);
114 g_free(testname);
d23895d9
DG
115
116 if (ipv6) {
117 testname = g_strdup_printf("pxe/ipv6/%s/%s",
118 test->machine, test->model);
119 qtest_add_data_func(testname, test, test_pxe_ipv6);
120 g_free(testname);
121 }
1e88989f 122 }
1485ef1c
TH
123}
124
4e082566
VK
125int main(int argc, char *argv[])
126{
127 int ret;
128 const char *arch = qtest_get_arch();
129
130 ret = boot_sector_init(disk);
131 if(ret)
132 return ret;
133
134 g_test_init(&argc, &argv, NULL);
135
136 if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
d23895d9 137 test_batch(x86_tests, false);
ab06ec43 138 if (g_test_slow()) {
d23895d9 139 test_batch(x86_tests_slow, false);
ab06ec43 140 }
1485ef1c 141 } else if (strcmp(arch, "ppc64") == 0) {
d23895d9 142 test_batch(ppc64_tests, g_test_slow());
ab06ec43 143 if (g_test_slow()) {
d23895d9 144 test_batch(ppc64_tests_slow, true);
ab06ec43 145 }
b1b2feac 146 } else if (g_str_equal(arch, "s390x")) {
d23895d9 147 test_batch(s390x_tests, g_test_slow());
4e082566
VK
148 }
149 ret = g_test_run();
150 boot_sector_cleanup(disk);
151 return ret;
152}