2016-02-14 17:59:27 +01:00
|
|
|
/*
|
|
|
|
* PXE test cases.
|
|
|
|
*
|
2017-09-20 11:02:07 +02:00
|
|
|
* Copyright (c) 2016, 2017 Red Hat Inc.
|
2016-02-14 17:59:27 +01:00
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Michael S. Tsirkin <mst@redhat.com>,
|
|
|
|
* Victor Kaplansky <victork@redhat.com>
|
2017-09-20 11:02:07 +02:00
|
|
|
* Thomas Huth <thuth@redhat.com>
|
2016-02-14 17:59:27 +01:00
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
|
2016-02-23 13:00:47 +01:00
|
|
|
#include "qemu/osdep.h"
|
2016-02-14 17:59:27 +01:00
|
|
|
#include <glib/gstdio.h>
|
|
|
|
#include "qemu-common.h"
|
|
|
|
#include "libqtest.h"
|
|
|
|
#include "boot-sector.h"
|
|
|
|
|
|
|
|
#define NETNAME "net0"
|
|
|
|
|
2016-10-11 17:19:36 +02:00
|
|
|
static char disk[] = "tests/pxe-test-disk-XXXXXX";
|
2016-02-14 17:59:27 +01:00
|
|
|
|
2017-12-19 05:45:20 +01:00
|
|
|
typedef struct testdef {
|
|
|
|
const char *machine; /* Machine type */
|
|
|
|
const char *model; /* NIC device model */
|
|
|
|
} testdef_t;
|
|
|
|
|
|
|
|
static testdef_t x86_tests[] = {
|
|
|
|
{ "pc", "e1000" },
|
|
|
|
{ "pc", "virtio-net-pci" },
|
2017-12-19 05:45:22 +01:00
|
|
|
{ "q35", "e1000e" },
|
|
|
|
{ "q35", "virtio-net-pci", },
|
2017-12-19 05:45:20 +01:00
|
|
|
{ NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
static testdef_t x86_tests_slow[] = {
|
|
|
|
{ "pc", "ne2k_pci", },
|
|
|
|
{ "pc", "i82550", },
|
|
|
|
{ "pc", "rtl8139" },
|
|
|
|
{ "pc", "vmxnet3" },
|
|
|
|
{ NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
static testdef_t ppc64_tests[] = {
|
|
|
|
{ "pseries", "spapr-vlan" },
|
2017-12-19 05:45:22 +01:00
|
|
|
{ "pseries", "virtio-net-pci", },
|
2017-12-19 05:45:20 +01:00
|
|
|
{ NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
static testdef_t ppc64_tests_slow[] = {
|
|
|
|
{ "pseries", "e1000" },
|
|
|
|
{ NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
static testdef_t s390x_tests[] = {
|
|
|
|
{ "s390-ccw-virtio", "virtio-net-ccw" },
|
|
|
|
{ NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_pxe_one(const testdef_t *test, bool ipv6)
|
2016-02-14 17:59:27 +01:00
|
|
|
{
|
|
|
|
char *args;
|
|
|
|
|
2017-12-19 05:45:20 +01:00
|
|
|
args = g_strdup_printf(
|
|
|
|
"-machine %s,accel=kvm:tcg -nodefaults -boot order=n "
|
|
|
|
"-netdev user,id=" NETNAME ",tftp=./,bootfile=%s,ipv4=%s,ipv6=%s "
|
|
|
|
"-device %s,bootindex=1,netdev=" NETNAME,
|
|
|
|
test->machine, disk, ipv6 ? "off" : "on", ipv6 ? "on" : "off",
|
|
|
|
test->model);
|
2016-02-14 17:59:27 +01:00
|
|
|
|
|
|
|
qtest_start(args);
|
2017-09-11 19:20:07 +02:00
|
|
|
boot_sector_test(global_qtest);
|
2016-02-14 17:59:27 +01:00
|
|
|
qtest_quit(global_qtest);
|
|
|
|
g_free(args);
|
|
|
|
}
|
|
|
|
|
2017-09-20 11:02:07 +02:00
|
|
|
static void test_pxe_ipv4(gconstpointer data)
|
2016-02-14 17:59:27 +01:00
|
|
|
{
|
2017-12-19 05:45:20 +01:00
|
|
|
const testdef_t *test = data;
|
2016-02-14 17:59:27 +01:00
|
|
|
|
2017-12-19 05:45:20 +01:00
|
|
|
test_pxe_one(test, false);
|
|
|
|
}
|
|
|
|
|
2017-12-19 05:45:21 +01:00
|
|
|
static void test_pxe_ipv6(gconstpointer data)
|
|
|
|
{
|
|
|
|
const testdef_t *test = data;
|
|
|
|
|
|
|
|
test_pxe_one(test, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_batch(const testdef_t *tests, bool ipv6)
|
2017-12-19 05:45:20 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; tests[i].machine; i++) {
|
|
|
|
const testdef_t *test = &tests[i];
|
|
|
|
char *testname;
|
|
|
|
|
|
|
|
testname = g_strdup_printf("pxe/ipv4/%s/%s",
|
|
|
|
test->machine, test->model);
|
|
|
|
qtest_add_data_func(testname, test, test_pxe_ipv4);
|
|
|
|
g_free(testname);
|
2017-12-19 05:45:21 +01:00
|
|
|
|
|
|
|
if (ipv6) {
|
|
|
|
testname = g_strdup_printf("pxe/ipv6/%s/%s",
|
|
|
|
test->machine, test->model);
|
|
|
|
qtest_add_data_func(testname, test, test_pxe_ipv6);
|
|
|
|
g_free(testname);
|
|
|
|
}
|
2017-12-19 05:45:20 +01:00
|
|
|
}
|
2016-09-26 22:17:46 +02:00
|
|
|
}
|
|
|
|
|
2016-02-14 17:59:27 +01:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
const char *arch = qtest_get_arch();
|
|
|
|
|
|
|
|
ret = boot_sector_init(disk);
|
|
|
|
if(ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
g_test_init(&argc, &argv, NULL);
|
|
|
|
|
|
|
|
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
|
2017-12-19 05:45:21 +01:00
|
|
|
test_batch(x86_tests, false);
|
2017-09-20 11:02:07 +02:00
|
|
|
if (g_test_slow()) {
|
2017-12-19 05:45:21 +01:00
|
|
|
test_batch(x86_tests_slow, false);
|
2017-09-20 11:02:07 +02:00
|
|
|
}
|
2016-09-26 22:17:46 +02:00
|
|
|
} else if (strcmp(arch, "ppc64") == 0) {
|
2017-12-19 05:45:21 +01:00
|
|
|
test_batch(ppc64_tests, g_test_slow());
|
2017-09-20 11:02:07 +02:00
|
|
|
if (g_test_slow()) {
|
2017-12-19 05:45:21 +01:00
|
|
|
test_batch(ppc64_tests_slow, true);
|
2017-09-20 11:02:07 +02:00
|
|
|
}
|
2017-08-11 07:57:56 +02:00
|
|
|
} else if (g_str_equal(arch, "s390x")) {
|
2017-12-19 05:45:21 +01:00
|
|
|
test_batch(s390x_tests, g_test_slow());
|
2016-02-14 17:59:27 +01:00
|
|
|
}
|
|
|
|
ret = g_test_run();
|
|
|
|
boot_sector_cleanup(disk);
|
|
|
|
return ret;
|
|
|
|
}
|