From 6fda7ea5377149c37c0eb91ed8ddc62fa89798e0 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Fri, 16 Apr 2010 08:21:23 +0200 Subject: [PATCH] tests: Add tests for CPU selection in qemu driver --- tests/qemuxml2argvdata/qemu.sh | 64 +++++++++++++++++++ .../qemuxml2argv-cpu-exact1.args | 1 + .../qemuxml2argv-cpu-exact1.xml | 28 ++++++++ .../qemuxml2argv-cpu-exact2.args | 1 + .../qemuxml2argv-cpu-exact2.xml | 35 ++++++++++ .../qemuxml2argv-cpu-minimum1.args | 1 + .../qemuxml2argv-cpu-minimum1.xml | 21 ++++++ .../qemuxml2argv-cpu-minimum2.args | 1 + .../qemuxml2argv-cpu-minimum2.xml | 25 ++++++++ .../qemuxml2argv-cpu-strict1.args | 1 + .../qemuxml2argv-cpu-strict1.xml | 38 +++++++++++ .../qemuxml2argv-cpu-topology1.args | 1 + .../qemuxml2argv-cpu-topology1.xml | 21 ++++++ .../qemuxml2argv-cpu-topology2.args | 1 + .../qemuxml2argv-cpu-topology2.xml | 22 +++++++ .../qemuxml2argv-cpu-topology3.args | 1 + .../qemuxml2argv-cpu-topology3.xml | 21 ++++++ tests/qemuxml2argvtest.c | 20 ++++++ 18 files changed, 303 insertions(+) create mode 100755 tests/qemuxml2argvdata/qemu.sh create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.xml diff --git a/tests/qemuxml2argvdata/qemu.sh b/tests/qemuxml2argvdata/qemu.sh new file mode 100755 index 0000000000..6d5d354361 --- /dev/null +++ b/tests/qemuxml2argvdata/qemu.sh @@ -0,0 +1,64 @@ +#! /bin/sh + +candidates="/usr/bin/qemu-kvm + /usr/libexec/qemu-kvm + /usr/bin/qemu-system-x86_64 + /usr/bin/qemu" +qemu= +for candidate in $candidates; do + if test -x $candidate; then + qemu=$candidate + break + fi +done + +real_qemu() +{ + if test x$qemu != x; then + exec $qemu "$@" + else + return 1 + fi +} + +faked_machine() +{ + echo "pc" +} + +faked_cpu() +{ + cat < + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 6 + + hvm + + + + qemu64 + + + + + + + + + + destroy + restart + destroy + + /./qemu.sh + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args new file mode 100644 index 0000000000..637f2e1b7d --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc -cpu core2duo,+lahf_lm,+3dnowext,+xtpr,+ds_cpl,+tm,+ht,+ds,-nx -m 214 -smp 6 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -net none -serial none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml new file mode 100644 index 0000000000..cd2a506304 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml @@ -0,0 +1,35 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 6 + + hvm + + + + core2duo + + + + + + + + + + + + + + + + + destroy + restart + destroy + + /./qemu.sh + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.args new file mode 100644 index 0000000000..80940f8a94 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc -cpu core2duo,+lahf_lm,+xtpr,+cx16,+tm2,+est,+vmx,+ds_cpl,+pbe,+tm,+ht,+ss,+acpi,+ds -m 214 -smp 6 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -net none -serial none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml new file mode 100644 index 0000000000..2a163d673c --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml @@ -0,0 +1,21 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 6 + + hvm + + + + 486 + + + destroy + restart + destroy + + /./qemu.sh + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.args new file mode 100644 index 0000000000..7f4aeeefe1 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc -cpu core2duo,+lahf_lm,+xtpr,+cx16,+tm2,+est,+vmx,+ds_cpl,+pbe,+tm,+ht,+ss,+acpi,+ds,-lm,-nx,-syscall -m 214 -smp 6 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -net none -serial none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml new file mode 100644 index 0000000000..b3baed7bef --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml @@ -0,0 +1,25 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 6 + + hvm + + + + qemu64 + + + + + + + destroy + restart + destroy + + /./qemu.sh + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.args new file mode 100644 index 0000000000..a680840cef --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc -cpu core2duo,+lahf_lm,+3dnowext,+xtpr,+est,+vmx,+ds_cpl,+tm,+ht,+acpi,+ds,-nx -m 214 -smp 6 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -net none -serial none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml new file mode 100644 index 0000000000..55f6b3c57a --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml @@ -0,0 +1,38 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 6 + + hvm + + + + core2duo + + + + + + + + + + + + + + + + + + + + destroy + restart + destroy + + /./qemu.sh + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.args new file mode 100644 index 0000000000..afe39e889f --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc -m 214 -smp 6,sockets=3,cores=2,threads=1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -net none -serial none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.xml new file mode 100644 index 0000000000..ca336b8c7e --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.xml @@ -0,0 +1,21 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 6 + + hvm + + + + + + + destroy + restart + destroy + + /./qemu.sh + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.args new file mode 100644 index 0000000000..8e8cd824f6 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc -cpu core2duo -m 214 -smp 6,sockets=1,cores=2,threads=3 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -net none -serial none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.xml new file mode 100644 index 0000000000..33089657da --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.xml @@ -0,0 +1,22 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 6 + + hvm + + + + core2duo + + + + destroy + restart + destroy + + /./qemu.sh + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.args new file mode 100644 index 0000000000..d295238731 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc -m 214 -smp 6 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -net none -serial none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.xml new file mode 100644 index 0000000000..ca336b8c7e --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.xml @@ -0,0 +1,21 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 6 + + hvm + + + + + + + destroy + restart + destroy + + /./qemu.sh + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d2b5e24991..c6bd2520df 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -15,11 +15,13 @@ # include "testutils.h" # include "qemu/qemu_conf.h" # include "datatypes.h" +# include "cpu/cpu_map.h" # include "testutilsqemu.h" static char *progname; static char *abs_srcdir; +static const char *abs_top_srcdir; static struct qemud_driver driver; # define MAX_FILE 4096 @@ -221,6 +223,7 @@ mymain(int argc, char **argv) { int ret = 0; char cwd[PATH_MAX]; + char map[PATH_MAX]; progname = argv[0]; @@ -233,6 +236,10 @@ mymain(int argc, char **argv) if (!abs_srcdir) abs_srcdir = getcwd(cwd, sizeof(cwd)); + abs_top_srcdir = getenv("abs_top_srcdir"); + if (!abs_top_srcdir) + abs_top_srcdir = ".."; + if ((driver.caps = testQemuCapsInit()) == NULL) return EXIT_FAILURE; if ((driver.stateDir = strdup("/nowhere")) == NULL) @@ -247,6 +254,10 @@ mymain(int argc, char **argv) if (!(driver.spicePassword = strdup("123456"))) return EXIT_FAILURE; + snprintf(map, PATH_MAX, "%s/src/cpu/cpu_map.xml", abs_top_srcdir); + if (cpuMapOverride(map) < 0) + return EXIT_FAILURE; + # define DO_TEST_FULL(name, extraFlags, migrateFrom, expectError) \ do { \ const struct testInfo info = { \ @@ -452,6 +463,15 @@ mymain(int argc, char **argv) DO_TEST("smp", QEMUD_CMD_FLAG_SMP_TOPOLOGY, false); + DO_TEST("cpu-topology1", QEMUD_CMD_FLAG_SMP_TOPOLOGY, false); + DO_TEST("cpu-topology2", QEMUD_CMD_FLAG_SMP_TOPOLOGY, false); + DO_TEST("cpu-topology3", 0, false); + DO_TEST("cpu-minimum1", 0, false); + DO_TEST("cpu-minimum2", 0, false); + DO_TEST("cpu-exact1", 0, false); + DO_TEST("cpu-exact2", 0, false); + DO_TEST("cpu-strict1", 0, false); + free(driver.stateDir); virCapabilitiesFree(driver.caps);