2016-02-14 19:59:27 +03:00
|
|
|
/*
|
|
|
|
* PXE test cases.
|
|
|
|
*
|
2017-09-20 12:02:07 +03:00
|
|
|
* Copyright (c) 2016, 2017 Red Hat Inc.
|
2016-02-14 19:59:27 +03:00
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Michael S. Tsirkin <mst@redhat.com>,
|
|
|
|
* Victor Kaplansky <victork@redhat.com>
|
2017-09-20 12:02:07 +03:00
|
|
|
* Thomas Huth <thuth@redhat.com>
|
2016-02-14 19:59:27 +03: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 15:00:47 +03:00
|
|
|
#include "qemu/osdep.h"
|
2016-02-14 19:59:27 +03:00
|
|
|
#include <glib/gstdio.h>
|
2022-03-30 12:39:05 +03:00
|
|
|
#include "libqtest.h"
|
2016-02-14 19:59:27 +03:00
|
|
|
#include "boot-sector.h"
|
2020-02-02 01:46:16 +03:00
|
|
|
#include "libqos/libqos-spapr.h"
|
2016-02-14 19:59:27 +03:00
|
|
|
|
|
|
|
#define NETNAME "net0"
|
|
|
|
|
2016-10-11 18:19:36 +03:00
|
|
|
static char disk[] = "tests/pxe-test-disk-XXXXXX";
|
2016-02-14 19:59:27 +03:00
|
|
|
|
2017-12-19 07:45:20 +03:00
|
|
|
typedef struct testdef {
|
|
|
|
const char *machine; /* Machine type */
|
|
|
|
const char *model; /* NIC device model */
|
2019-03-12 08:07:14 +03:00
|
|
|
const char *extra; /* Any additional parameters */
|
2017-12-19 07:45:20 +03:00
|
|
|
} testdef_t;
|
|
|
|
|
|
|
|
static testdef_t x86_tests[] = {
|
|
|
|
{ "pc", "e1000" },
|
|
|
|
{ "pc", "virtio-net-pci" },
|
2017-12-19 07:45:22 +03:00
|
|
|
{ "q35", "e1000e" },
|
|
|
|
{ "q35", "virtio-net-pci", },
|
2017-12-19 07:45:20 +03:00
|
|
|
{ NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
static testdef_t x86_tests_slow[] = {
|
|
|
|
{ "pc", "ne2k_pci", },
|
|
|
|
{ "pc", "i82550", },
|
|
|
|
{ "pc", "rtl8139" },
|
|
|
|
{ "pc", "vmxnet3" },
|
|
|
|
{ NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
static testdef_t ppc64_tests[] = {
|
2019-03-12 08:07:14 +03:00
|
|
|
{ "pseries", "spapr-vlan",
|
2020-02-02 01:46:16 +03:00
|
|
|
"-machine vsmt=8," PSERIES_DEFAULT_CAPABILITIES },
|
2019-03-12 08:07:14 +03:00
|
|
|
{ "pseries", "virtio-net-pci",
|
2020-02-02 01:46:16 +03:00
|
|
|
"-machine vsmt=8," PSERIES_DEFAULT_CAPABILITIES },
|
2017-12-19 07:45:20 +03:00
|
|
|
{ NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
static testdef_t ppc64_tests_slow[] = {
|
2019-03-12 08:07:14 +03:00
|
|
|
{ "pseries", "e1000",
|
2020-02-02 01:46:16 +03:00
|
|
|
"-machine vsmt=8," PSERIES_DEFAULT_CAPABILITIES },
|
2017-12-19 07:45:20 +03:00
|
|
|
{ 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 19:59:27 +03:00
|
|
|
{
|
2018-11-19 18:40:44 +03:00
|
|
|
QTestState *qts;
|
2016-02-14 19:59:27 +03:00
|
|
|
char *args;
|
2019-03-12 08:07:14 +03:00
|
|
|
const char *extra = test->extra;
|
|
|
|
|
|
|
|
if (!extra) {
|
|
|
|
extra = "";
|
|
|
|
}
|
2016-02-14 19:59:27 +03:00
|
|
|
|
2017-12-19 07:45:20 +03:00
|
|
|
args = g_strdup_printf(
|
2019-11-13 12:10:47 +03:00
|
|
|
"-accel kvm -accel tcg -machine %s -nodefaults -boot order=n "
|
2017-12-19 07:45:20 +03:00
|
|
|
"-netdev user,id=" NETNAME ",tftp=./,bootfile=%s,ipv4=%s,ipv6=%s "
|
2019-03-12 08:07:14 +03:00
|
|
|
"-device %s,bootindex=1,netdev=" NETNAME " %s",
|
2017-12-19 07:45:20 +03:00
|
|
|
test->machine, disk, ipv6 ? "off" : "on", ipv6 ? "on" : "off",
|
2019-03-12 08:07:14 +03:00
|
|
|
test->model, extra);
|
2016-02-14 19:59:27 +03:00
|
|
|
|
2018-11-19 18:40:44 +03:00
|
|
|
qts = qtest_init(args);
|
|
|
|
boot_sector_test(qts);
|
|
|
|
qtest_quit(qts);
|
2016-02-14 19:59:27 +03:00
|
|
|
g_free(args);
|
|
|
|
}
|
|
|
|
|
2017-09-20 12:02:07 +03:00
|
|
|
static void test_pxe_ipv4(gconstpointer data)
|
2016-02-14 19:59:27 +03:00
|
|
|
{
|
2017-12-19 07:45:20 +03:00
|
|
|
const testdef_t *test = data;
|
2016-02-14 19:59:27 +03:00
|
|
|
|
2017-12-19 07:45:20 +03:00
|
|
|
test_pxe_one(test, false);
|
|
|
|
}
|
|
|
|
|
2017-12-19 07:45:21 +03: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 07:45:20 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; tests[i].machine; i++) {
|
|
|
|
const testdef_t *test = &tests[i];
|
|
|
|
char *testname;
|
|
|
|
|
2023-02-08 22:46:49 +03:00
|
|
|
if (!qtest_has_device(test->model)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-12-19 07:45:20 +03:00
|
|
|
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 07:45:21 +03: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 07:45:20 +03:00
|
|
|
}
|
2016-09-26 23:17:46 +03:00
|
|
|
}
|
|
|
|
|
2016-02-14 19:59:27 +03:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
const char *arch = qtest_get_arch();
|
|
|
|
|
2023-04-26 21:00:08 +03:00
|
|
|
g_test_init(&argc, &argv, NULL);
|
|
|
|
|
|
|
|
if (!qtest_has_accel("tcg") && !qtest_has_accel("kvm")) {
|
|
|
|
g_test_skip("No KVM or TCG accelerator available");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-02-14 19:59:27 +03:00
|
|
|
ret = boot_sector_init(disk);
|
|
|
|
if(ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
|
|
|
|
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
|
2017-12-19 07:45:21 +03:00
|
|
|
test_batch(x86_tests, false);
|
2017-09-20 12:02:07 +03:00
|
|
|
if (g_test_slow()) {
|
2017-12-19 07:45:21 +03:00
|
|
|
test_batch(x86_tests_slow, false);
|
2017-09-20 12:02:07 +03:00
|
|
|
}
|
2016-09-26 23:17:46 +03:00
|
|
|
} else if (strcmp(arch, "ppc64") == 0) {
|
2017-12-19 07:45:21 +03:00
|
|
|
test_batch(ppc64_tests, g_test_slow());
|
2017-09-20 12:02:07 +03:00
|
|
|
if (g_test_slow()) {
|
2017-12-19 07:45:21 +03:00
|
|
|
test_batch(ppc64_tests_slow, true);
|
2017-09-20 12:02:07 +03:00
|
|
|
}
|
2017-08-11 08:57:56 +03:00
|
|
|
} else if (g_str_equal(arch, "s390x")) {
|
2017-12-19 07:45:21 +03:00
|
|
|
test_batch(s390x_tests, g_test_slow());
|
2016-02-14 19:59:27 +03:00
|
|
|
}
|
|
|
|
ret = g_test_run();
|
|
|
|
boot_sector_cleanup(disk);
|
|
|
|
return ret;
|
|
|
|
}
|