]> git.proxmox.com Git - mirror_qemu.git/blob - tests/pxe-test.c
tests/pxe: Test more NICs when running in SPEED=slow mode
[mirror_qemu.git] / tests / pxe-test.c
1 /*
2 * PXE test cases.
3 *
4 * Copyright (c) 2016, 2017 Red Hat Inc.
5 *
6 * Authors:
7 * Michael S. Tsirkin <mst@redhat.com>,
8 * Victor Kaplansky <victork@redhat.com>
9 * Thomas Huth <thuth@redhat.com>
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
15 #include "qemu/osdep.h"
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
23 static char disk[] = "tests/pxe-test-disk-XXXXXX";
24
25 static void test_pxe_one(const char *params, bool ipv6)
26 {
27 char *args;
28
29 args = g_strdup_printf("-machine accel=kvm:tcg -nodefaults -boot order=n "
30 "-netdev user,id=" NETNAME ",tftp=./,bootfile=%s,"
31 "ipv4=%s,ipv6=%s %s", disk, ipv6 ? "off" : "on",
32 ipv6 ? "on" : "off", params);
33
34 qtest_start(args);
35 boot_sector_test();
36 qtest_quit(global_qtest);
37 g_free(args);
38 }
39
40 static void test_pxe_ipv4(gconstpointer data)
41 {
42 const char *model = data;
43 char *dev_arg;
44
45 dev_arg = g_strdup_printf("-device %s,netdev=" NETNAME, model);
46 test_pxe_one(dev_arg, false);
47 g_free(dev_arg);
48 }
49
50 static void test_pxe_spapr_vlan(void)
51 {
52 test_pxe_one("-device spapr-vlan,netdev=" NETNAME, true);
53 }
54
55 static void test_pxe_virtio_ccw(void)
56 {
57 test_pxe_one("-device virtio-net-ccw,bootindex=1,netdev=" NETNAME, false);
58 }
59
60 int main(int argc, char *argv[])
61 {
62 int ret;
63 const char *arch = qtest_get_arch();
64
65 ret = boot_sector_init(disk);
66 if(ret)
67 return ret;
68
69 g_test_init(&argc, &argv, NULL);
70
71 if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
72 qtest_add_data_func("pxe/e1000", "e1000", test_pxe_ipv4);
73 qtest_add_data_func("pxe/virtio", "virtio-net-pci", test_pxe_ipv4);
74 if (g_test_slow()) {
75 qtest_add_data_func("pxe/ne2000", "ne2k_pci", test_pxe_ipv4);
76 qtest_add_data_func("pxe/eepro100", "i82550", test_pxe_ipv4);
77 qtest_add_data_func("pxe/pcnet", "pcnet", test_pxe_ipv4);
78 qtest_add_data_func("pxe/rtl8139", "rtl8139", test_pxe_ipv4);
79 qtest_add_data_func("pxe/vmxnet3", "vmxnet3", test_pxe_ipv4);
80 }
81 } else if (strcmp(arch, "ppc64") == 0) {
82 qtest_add_func("pxe/spapr-vlan", test_pxe_spapr_vlan);
83 if (g_test_slow()) {
84 qtest_add_data_func("pxe/virtio", "virtio-net-pci", test_pxe_ipv4);
85 qtest_add_data_func("pxe/e1000", "e1000", test_pxe_ipv4);
86 }
87 } else if (g_str_equal(arch, "s390x")) {
88 qtest_add_func("pxe/virtio-ccw", test_pxe_virtio_ccw);
89 }
90 ret = g_test_run();
91 boot_sector_cleanup(disk);
92 return ret;
93 }