4 * Copyright (c) 2016, 2017 Red Hat Inc.
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"
19 #include "boot-sector.h"
21 #define NETNAME "net0"
23 static char disk
[] = "tests/pxe-test-disk-XXXXXX";
25 typedef struct testdef
{
26 const char *machine
; /* Machine type */
27 const char *model
; /* NIC device model */
30 static testdef_t x86_tests
[] = {
32 { "pc", "virtio-net-pci" },
36 static testdef_t x86_tests_slow
[] = {
37 { "pc", "ne2k_pci", },
44 static testdef_t ppc64_tests
[] = {
45 { "pseries", "spapr-vlan" },
49 static testdef_t ppc64_tests_slow
[] = {
50 { "pseries", "virtio-net-pci", },
51 { "pseries", "e1000" },
55 static testdef_t s390x_tests
[] = {
56 { "s390-ccw-virtio", "virtio-net-ccw" },
60 static void test_pxe_one(const testdef_t
*test
, bool ipv6
)
64 args
= g_strdup_printf(
65 "-machine %s,accel=kvm:tcg -nodefaults -boot order=n "
66 "-netdev user,id=" NETNAME
",tftp=./,bootfile=%s,ipv4=%s,ipv6=%s "
67 "-device %s,bootindex=1,netdev=" NETNAME
,
68 test
->machine
, disk
, ipv6
? "off" : "on", ipv6
? "on" : "off",
73 qtest_quit(global_qtest
);
77 static void test_pxe_ipv4(gconstpointer data
)
79 const testdef_t
*test
= data
;
81 test_pxe_one(test
, false);
84 static void test_batch(const testdef_t
*tests
)
88 for (i
= 0; tests
[i
].machine
; i
++) {
89 const testdef_t
*test
= &tests
[i
];
92 testname
= g_strdup_printf("pxe/ipv4/%s/%s",
93 test
->machine
, test
->model
);
94 qtest_add_data_func(testname
, test
, test_pxe_ipv4
);
99 int main(int argc
, char *argv
[])
102 const char *arch
= qtest_get_arch();
104 ret
= boot_sector_init(disk
);
108 g_test_init(&argc
, &argv
, NULL
);
110 if (strcmp(arch
, "i386") == 0 || strcmp(arch
, "x86_64") == 0) {
111 test_batch(x86_tests
);
113 test_batch(x86_tests_slow
);
115 } else if (strcmp(arch
, "ppc64") == 0) {
116 test_batch(ppc64_tests
);
118 test_batch(ppc64_tests_slow
);
120 } else if (g_str_equal(arch
, "s390x")) {
121 test_batch(s390x_tests
);
124 boot_sector_cleanup(disk
);