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