]> git.proxmox.com Git - mirror_qemu.git/blob - tests/pxe-test.c
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
[mirror_qemu.git] / tests / pxe-test.c
1 /*
2 * PXE test cases.
3 *
4 * Copyright (c) 2016 Red Hat Inc.
5 *
6 * Authors:
7 * Michael S. Tsirkin <mst@redhat.com>,
8 * Victor Kaplansky <victork@redhat.com>
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
14 #include "qemu/osdep.h"
15 #include <glib.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 const char *disk = "tests/pxe-test-disk.raw";
24
25 static void test_pxe_one(const char *params)
26 {
27 char *args;
28
29 args = g_strdup_printf("-machine accel=tcg "
30 "-netdev user,id=" NETNAME ",tftp=./,bootfile=%s "
31 "%s ",
32 disk, 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_e1000(void)
41 {
42 test_pxe_one("-device e1000,netdev=" NETNAME);
43 }
44
45 static void test_pxe_virtio_pci(void)
46 {
47 test_pxe_one("-device virtio-net-pci,netdev=" NETNAME);
48 }
49
50 int main(int argc, char *argv[])
51 {
52 int ret;
53 const char *arch = qtest_get_arch();
54
55 ret = boot_sector_init(disk);
56 if(ret)
57 return ret;
58
59 g_test_init(&argc, &argv, NULL);
60
61 if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
62 qtest_add_func("pxe/e1000", test_pxe_e1000);
63 qtest_add_func("pxe/virtio", test_pxe_virtio_pci);
64 }
65 ret = g_test_run();
66 boot_sector_cleanup(disk);
67 return ret;
68 }