From ae21e5229d095de733234d0acbc7d66bba0eefe4 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Tue, 2 Aug 2016 17:30:41 +0100 Subject: [PATCH] Rework the pv-iopl test using variations The hypercall and vmassist tests are logically separate, and while the hypercall version has been around for a very long time, vmassist was only introduced in Xen 4.7. To be able to sensibly test the hypercall part on older versions of Xen, they should be treated separately, so the skip from vmassist detection doesn't influence the results from the hypercall test. To test them independently, introduce variations which alter the cmdline passed to the guest. Signed-off-by: Andrew Cooper --- tests/pv-iopl/Makefile | 2 ++ tests/pv-iopl/hypercall.cfg.in | 1 + tests/pv-iopl/main.c | 38 ++++++++++++++++++++++++---------- tests/pv-iopl/vmassist.cfg.in | 1 + 4 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 tests/pv-iopl/hypercall.cfg.in create mode 100644 tests/pv-iopl/vmassist.cfg.in diff --git a/tests/pv-iopl/Makefile b/tests/pv-iopl/Makefile index be3e980..ec2f829 100644 --- a/tests/pv-iopl/Makefile +++ b/tests/pv-iopl/Makefile @@ -4,6 +4,8 @@ NAME := pv-iopl CATEGORY := functional TEST-ENVS := $(PV_ENVIRONMENTS) +VARY-CFG := hypercall vmassist + obj-perenv += main.o asm.o include $(ROOT)/build/gen.mk diff --git a/tests/pv-iopl/hypercall.cfg.in b/tests/pv-iopl/hypercall.cfg.in new file mode 100644 index 0000000..7212651 --- /dev/null +++ b/tests/pv-iopl/hypercall.cfg.in @@ -0,0 +1 @@ +cmdline="hypercall" diff --git a/tests/pv-iopl/main.c b/tests/pv-iopl/main.c index f3a57f0..1b620c1 100644 --- a/tests/pv-iopl/main.c +++ b/tests/pv-iopl/main.c @@ -145,6 +145,8 @@ static void run_test(const struct test *t) { unsigned int i, iopl; + xtf_exlog_start(); + for ( iopl = 0; iopl <= 3; ++iopl ) { /* vIOPL 2 is not interesting to test. */ @@ -169,6 +171,8 @@ static void run_test(const struct test *t) check(); } } + + xtf_exlog_stop(); } static void hypercall_set_iopl(unsigned int iopl) @@ -242,21 +246,33 @@ static const struct test vmassist = void test_main(void) { - printk("PV IOPL emulation\n"); - - xtf_exlog_start(); + const struct test *test; - printk("Test: PHYSDEVOP_set_iopl\n"); - run_test(&hypercall); + printk("PV IOPL emulation\n"); - if ( hypercall_vm_assist(VMASST_CMD_enable, - VMASST_TYPE_architectural_iopl) ) - return xtf_skip("VMASST_TYPE_architectural_iopl not detected\n"); + /** + * @todo Implement better command line infrastructure, but this will do + * for now. + */ + if ( !strcmp((char *)start_info->cmd_line, "hypercall") ) + { + printk("Test: PHYSDEVOP_set_iopl\n"); + test = &hypercall; + } + else if ( !strcmp((char *)start_info->cmd_line, "vmassist") ) + { + if ( hypercall_vm_assist(VMASST_CMD_enable, + VMASST_TYPE_architectural_iopl) ) + return xtf_skip("VMASST_TYPE_architectural_iopl not detected\n"); - printk("Test: VMASST_TYPE_architectural_iopl\n"); - run_test(&vmassist); + printk("Test: VMASST_TYPE_architectural_iopl\n"); + test = &vmassist; + } + else + return xtf_error("Unknown test to run\n"); - xtf_exlog_stop(); + /* Run the chosen test. */ + run_test(test); xtf_success(NULL); } diff --git a/tests/pv-iopl/vmassist.cfg.in b/tests/pv-iopl/vmassist.cfg.in new file mode 100644 index 0000000..7e8287b --- /dev/null +++ b/tests/pv-iopl/vmassist.cfg.in @@ -0,0 +1 @@ +cmdline="vmassist" -- 2.39.5