]>
Commit | Line | Data |
---|---|---|
4e082566 VK |
1 | /* |
2 | * PXE test cases. | |
3 | * | |
4 | * Copyright (c) 2016 Red Hat Inc. | |
5 | * | |
6 | * Authors: | |
7 | * Michael S. Tsirkin <[email protected]>, | |
8 | * Victor Kaplansky <[email protected]> | |
9 | * | |
10 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | |
11 | * See the COPYING file in the top-level directory. | |
12 | */ | |
13 | ||
974dc73d | 14 | #include "qemu/osdep.h" |
4e082566 VK |
15 | #include <glib/gstdio.h> |
16 | #include "qemu-common.h" | |
17 | #include "libqtest.h" | |
18 | #include "boot-sector.h" | |
19 | ||
20 | #define NETNAME "net0" | |
21 | ||
3e353773 | 22 | static char disk[] = "tests/pxe-test-disk-XXXXXX"; |
4e082566 | 23 | |
1485ef1c | 24 | static void test_pxe_one(const char *params, bool ipv6) |
4e082566 VK |
25 | { |
26 | char *args; | |
27 | ||
ef6c47f1 | 28 | args = g_strdup_printf("-machine accel=tcg -nodefaults -boot order=n " |
1485ef1c TH |
29 | "-netdev user,id=" NETNAME ",tftp=./,bootfile=%s," |
30 | "ipv4=%s,ipv6=%s %s", disk, ipv6 ? "off" : "on", | |
31 | ipv6 ? "on" : "off", params); | |
4e082566 VK |
32 | |
33 | qtest_start(args); | |
34 | boot_sector_test(); | |
35 | qtest_quit(global_qtest); | |
36 | g_free(args); | |
37 | } | |
38 | ||
39 | static void test_pxe_e1000(void) | |
40 | { | |
1485ef1c | 41 | test_pxe_one("-device e1000,netdev=" NETNAME, false); |
4e082566 VK |
42 | } |
43 | ||
44 | static void test_pxe_virtio_pci(void) | |
45 | { | |
1485ef1c TH |
46 | test_pxe_one("-device virtio-net-pci,netdev=" NETNAME, false); |
47 | } | |
48 | ||
49 | static void test_pxe_spapr_vlan(void) | |
50 | { | |
ef6c47f1 | 51 | test_pxe_one("-device spapr-vlan,netdev=" NETNAME, true); |
4e082566 VK |
52 | } |
53 | ||
54 | int main(int argc, char *argv[]) | |
55 | { | |
56 | int ret; | |
57 | const char *arch = qtest_get_arch(); | |
58 | ||
59 | ret = boot_sector_init(disk); | |
60 | if(ret) | |
61 | return ret; | |
62 | ||
63 | g_test_init(&argc, &argv, NULL); | |
64 | ||
65 | if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { | |
66 | qtest_add_func("pxe/e1000", test_pxe_e1000); | |
67 | qtest_add_func("pxe/virtio", test_pxe_virtio_pci); | |
1485ef1c TH |
68 | } else if (strcmp(arch, "ppc64") == 0) { |
69 | qtest_add_func("pxe/virtio", test_pxe_virtio_pci); | |
70 | qtest_add_func("pxe/spapr-vlan", test_pxe_spapr_vlan); | |
4e082566 VK |
71 | } |
72 | ret = g_test_run(); | |
73 | boot_sector_cleanup(disk); | |
74 | return ret; | |
75 | } |