]> Git Repo - qemu.git/blob - tests/pxe-test.c
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20190118' into staging
[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 <[email protected]>,
8  *  Victor Kaplansky <[email protected]>
9  *  Thomas Huth <[email protected]>
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 typedef struct testdef {
26     const char *machine;    /* Machine type */
27     const char *model;      /* NIC device model */
28 } testdef_t;
29
30 static testdef_t x86_tests[] = {
31     { "pc", "e1000" },
32     { "pc", "virtio-net-pci" },
33     { "q35", "e1000e" },
34     { "q35", "virtio-net-pci", },
35     { NULL },
36 };
37
38 static testdef_t x86_tests_slow[] = {
39     { "pc", "ne2k_pci", },
40     { "pc", "i82550", },
41     { "pc", "rtl8139" },
42     { "pc", "vmxnet3" },
43     { NULL },
44 };
45
46 static testdef_t ppc64_tests[] = {
47     { "pseries", "spapr-vlan" },
48     { "pseries", "virtio-net-pci", },
49     { NULL },
50 };
51
52 static testdef_t ppc64_tests_slow[] = {
53     { "pseries", "e1000" },
54     { NULL },
55 };
56
57 static testdef_t s390x_tests[] = {
58     { "s390-ccw-virtio", "virtio-net-ccw" },
59     { NULL },
60 };
61
62 static void test_pxe_one(const testdef_t *test, bool ipv6)
63 {
64     QTestState *qts;
65     char *args;
66
67     args = g_strdup_printf(
68         "-machine %s,accel=kvm:tcg -nodefaults -boot order=n "
69         "-netdev user,id=" NETNAME ",tftp=./,bootfile=%s,ipv4=%s,ipv6=%s "
70         "-device %s,bootindex=1,netdev=" NETNAME,
71         test->machine, disk, ipv6 ? "off" : "on", ipv6 ? "on" : "off",
72         test->model);
73
74     qts = qtest_init(args);
75     boot_sector_test(qts);
76     qtest_quit(qts);
77     g_free(args);
78 }
79
80 static void test_pxe_ipv4(gconstpointer data)
81 {
82     const testdef_t *test = data;
83
84     test_pxe_one(test, false);
85 }
86
87 static void test_pxe_ipv6(gconstpointer data)
88 {
89     const testdef_t *test = data;
90
91     test_pxe_one(test, true);
92 }
93
94 static void test_batch(const testdef_t *tests, bool ipv6)
95 {
96     int i;
97
98     for (i = 0; tests[i].machine; i++) {
99         const testdef_t *test = &tests[i];
100         char *testname;
101
102         testname = g_strdup_printf("pxe/ipv4/%s/%s",
103                                    test->machine, test->model);
104         qtest_add_data_func(testname, test, test_pxe_ipv4);
105         g_free(testname);
106
107         if (ipv6) {
108             testname = g_strdup_printf("pxe/ipv6/%s/%s",
109                                        test->machine, test->model);
110             qtest_add_data_func(testname, test, test_pxe_ipv6);
111             g_free(testname);
112         }
113     }
114 }
115
116 int main(int argc, char *argv[])
117 {
118     int ret;
119     const char *arch = qtest_get_arch();
120
121     ret = boot_sector_init(disk);
122     if(ret)
123         return ret;
124
125     g_test_init(&argc, &argv, NULL);
126
127     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
128         test_batch(x86_tests, false);
129         if (g_test_slow()) {
130             test_batch(x86_tests_slow, false);
131         }
132     } else if (strcmp(arch, "ppc64") == 0) {
133         test_batch(ppc64_tests, g_test_slow());
134         if (g_test_slow()) {
135             test_batch(ppc64_tests_slow, true);
136         }
137     } else if (g_str_equal(arch, "s390x")) {
138         test_batch(s390x_tests, g_test_slow());
139     }
140     ret = g_test_run();
141     boot_sector_cleanup(disk);
142     return ret;
143 }
This page took 0.033198 seconds and 4 git commands to generate.