]> git.proxmox.com Git - mirror_qemu.git/blob - tests/pxe-test.c
Merge remote-tracking branch 'remotes/mjt/tags/pull-trivial-patches-2016-06-07' into...
[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/gstdio.h>
16 #include "qemu-common.h"
17 #include "libqtest.h"
18 #include "boot-sector.h"
19
20 #define NETNAME "net0"
21
22 static const char *disk = "tests/pxe-test-disk.raw";
23
24 static void test_pxe_one(const char *params)
25 {
26 char *args;
27
28 args = g_strdup_printf("-machine accel=tcg "
29 "-netdev user,id=" NETNAME ",tftp=./,bootfile=%s "
30 "%s ",
31 disk, params);
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 {
41 test_pxe_one("-device e1000,netdev=" NETNAME);
42 }
43
44 static void test_pxe_virtio_pci(void)
45 {
46 test_pxe_one("-device virtio-net-pci,netdev=" NETNAME);
47 }
48
49 int main(int argc, char *argv[])
50 {
51 int ret;
52 const char *arch = qtest_get_arch();
53
54 ret = boot_sector_init(disk);
55 if(ret)
56 return ret;
57
58 g_test_init(&argc, &argv, NULL);
59
60 if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
61 qtest_add_func("pxe/e1000", test_pxe_e1000);
62 qtest_add_func("pxe/virtio", test_pxe_virtio_pci);
63 }
64 ret = g_test_run();
65 boot_sector_cleanup(disk);
66 return ret;
67 }