balloon: fix segfault and harden the stats queue
[qemu/kevin.git] / tests / pxe-test.c
blob875e4c4a263233c9a4da73d4e6a2dc4ee690fa5d
1 /*
2 * PXE test cases.
4 * Copyright (c) 2016 Red Hat Inc.
6 * Authors:
7 * Michael S. Tsirkin <mst@redhat.com>,
8 * Victor Kaplansky <victork@redhat.com>
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.
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"
21 #define NETNAME "net0"
23 static const char *disk = "tests/pxe-test-disk.raw";
25 static void test_pxe_one(const char *params)
27 char *args;
29 args = g_strdup_printf("-machine accel=tcg "
30 "-netdev user,id=" NETNAME ",tftp=./,bootfile=%s "
31 "%s ",
32 disk, params);
34 qtest_start(args);
35 boot_sector_test();
36 qtest_quit(global_qtest);
37 g_free(args);
40 static void test_pxe_e1000(void)
42 test_pxe_one("-device e1000,netdev=" NETNAME);
45 static void test_pxe_virtio_pci(void)
47 test_pxe_one("-device virtio-net-pci,netdev=" NETNAME);
50 int main(int argc, char *argv[])
52 int ret;
53 const char *arch = qtest_get_arch();
55 ret = boot_sector_init(disk);
56 if(ret)
57 return ret;
59 g_test_init(&argc, &argv, NULL);
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);
65 ret = g_test_run();
66 boot_sector_cleanup(disk);
67 return ret;