* [PATCH] KVM test: Add a subtest cpuflags
@ 2010-03-04 7:20 sshang
2011-07-29 5:27 ` Amos Kong
0 siblings, 1 reply; 2+ messages in thread
From: sshang @ 2010-03-04 7:20 UTC (permalink / raw)
To: lmr; +Cc: autotest, kvm, sshang
This test mainly tests whether all guest cpu flags are supported by host machine.
Signed-off-by: sshang <sshang@redhat.com>
---
client/tests/kvm/tests/cpuflags.py | 80 ++++++++++++++++++++++++++++++++
client/tests/kvm/tests_base.cfg.sample | 9 +++-
2 files changed, 88 insertions(+), 1 deletions(-)
create mode 100644 client/tests/kvm/tests/cpuflags.py
diff --git a/client/tests/kvm/tests/cpuflags.py b/client/tests/kvm/tests/cpuflags.py
new file mode 100644
index 0000000..5f51d65
--- /dev/null
+++ b/client/tests/kvm/tests/cpuflags.py
@@ -0,0 +1,80 @@
+import logging,os,commands
+from autotest_lib.client.common_lib import error
+import kvm_test_utils
+
+def run_cpuflags(test,params,env):
+ """
+ Check guest cpu extension flags supported by host
+ 1) Log into guest
+ 2) Get guest cpu information and host cpu information
+ 3) Compare with each other make sure host cpu extension flags
+ bits contain guest
+
+ @param test: kvm test object
+ @param params: Dictionary with the test parameters
+ @param env: Dictionary with test environment.
+ """
+ vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
+ session = kvm_test_utils.wait_for_login(vm,
+ timeout=int(params.get("login_timeout", 360)))
+
+ get_cpuflags_cmd = params.get("getcpuflags")
+ s, o = session.get_command_status_output(get_cpuflags_cmd)
+ if s != 0:
+ raise error.TestFail, "Could not read guest cpu flags"
+ guest_cpuflags_list = o.splitlines()[0].split(':')[1].split()
+ host_cpuflags_list = commands.getoutput(get_cpuflags_cmd).\
+ splitlines()[0].split(':')[1].split()
+
+ logging.debug("Host flags %s" % host_cpuflags_list)
+ logging.debug("Guest flags %s" % guest_cpuflags_list)
+
+ # There are some special flags, for example 'hypervisor', 'sep',
+ # present in guests but not in the hosts, exclude these flags from
+ # comparison.
+ ban_flags_list = params.get("ban_flags").split()
+
+ guest_cpuflags_set = set(guest_cpuflags_list)
+ host_cpuflags_set = set(host_cpuflags_list)
+
+ # If the excluded flags provided by the config file that exist in the
+ # host, remove them from the ban_flags_list, because we require kvm
+ # virtualize/simulate the host.
+ if params.get("strict_check") == "yes":
+ for flag in ban_flags_list:
+ if flag in host_cpuflags_list:
+ ban_flags_list.remove(flag)
+
+ # exclude the banned flags from guest flags set.
+ for flag in ban_flags_list:
+ if flag in guest_cpuflags_set:
+ guest_cpuflags_set.remove(flag)
+
+ if guest_cpuflags_set.issubset(host_cpuflags_set):
+ logging.info("Guest cpu flags all supported by host")
+ else:
+ invalidflags_set = guest_cpuflags_set - host_cpuflags_set
+ host_cpuflags_str = str(host_cpuflags_set)[4:-1]
+ invalidflags_str = ''
+ for i in invalidflags_set:
+ if host_cpuflags_str.find(i.strip()) == -1:
+ invalidflags_str = invalidflags_str + i + ','
+
+ if invalidflags_str.strip() != '':
+ raise error.TestFail("Unsupported cpu flags by host: %s" % \
+ invalidflags_str[0:-1])
+
+ # check the extra cpuflags in guest.
+ extra_flags_set = set(params.get("extra_flags").split())
+ if extra_flags_set.issubset(guest_cpuflags_set):
+ logging.info("All extra flags are found in guest.")
+ else:
+ invalidflags_set = extra_flags_set - guest_cpuflags_set
+ invalidflags_str = ''
+ for i in invalidflags_set:
+ invalidflags_str = invalidflags_str + i + ','
+ raise error.TestFail("Unsupported extra flags by guest: %s" % \
+ invalidflags_str[0:-1])
+
+ session.close()
+
diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
index 040d0c3..f7dcbb6 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -300,6 +300,13 @@ variants:
shutdown_method = shell
kill_vm = yes
kill_vm_gracefully = no
+
+ - cpuflags:
+ type = cpuflags
+ getcpuflags = grep 'flags' /proc/cpuinfo
+ ban_flags = "up sep hypervisor sep_good"
+ extra_flags = ""
+ strict_check = yes
# Do not define test variants below shutdown
@@ -1001,7 +1008,7 @@ variants:
md5sum = 9fae22f2666369968a76ef59e9a81ced
-linux_s3:
+linux_s3|cpuflags:
only Linux
--
1.5.5.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM test: Add a subtest cpuflags
2010-03-04 7:20 [PATCH] KVM test: Add a subtest cpuflags sshang
@ 2011-07-29 5:27 ` Amos Kong
0 siblings, 0 replies; 2+ messages in thread
From: Amos Kong @ 2011-07-29 5:27 UTC (permalink / raw)
To: sshang, lmr, autotest, kvm
On Thu, Mar 4, 2010 at 3:20 PM, sshang <sshang@redhat.com> wrote:
> This test mainly tests whether all guest cpu flags are supported by host machine.
>
> Signed-off-by: sshang <sshang@redhat.com>
Hi Lucas,
It seems that this patch[1] was lost by us. Have confirmed with shuang,
this subtest needs to be refactored. So let's wait the new version!
[1] https://patchwork.kernel.org/patch/83543/
> ---
> client/tests/kvm/tests/cpuflags.py | 80 ++++++++++++++++++++++++++++++++
> client/tests/kvm/tests_base.cfg.sample | 9 +++-
> 2 files changed, 88 insertions(+), 1 deletions(-)
> create mode 100644 client/tests/kvm/tests/cpuflags.py
>
> diff --git a/client/tests/kvm/tests/cpuflags.py b/client/tests/kvm/tests/cpuflags.py
> new file mode 100644
> index 0000000..5f51d65
> --- /dev/null
> +++ b/client/tests/kvm/tests/cpuflags.py
> @@ -0,0 +1,80 @@
> +import logging,os,commands
> +from autotest_lib.client.common_lib import error
> +import kvm_test_utils
> +
> +def run_cpuflags(test,params,env):
> + """
> + Check guest cpu extension flags supported by host
> + 1) Log into guest
> + 2) Get guest cpu information and host cpu information
> + 3) Compare with each other make sure host cpu extension flags
> + bits contain guest
> +
> + @param test: kvm test object
> + @param params: Dictionary with the test parameters
> + @param env: Dictionary with test environment.
> + """
> + vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
> + session = kvm_test_utils.wait_for_login(vm,
> + timeout=int(params.get("login_timeout", 360)))
> +
> + get_cpuflags_cmd = params.get("getcpuflags")
> + s, o = session.get_command_status_output(get_cpuflags_cmd)
> + if s != 0:
> + raise error.TestFail, "Could not read guest cpu flags"
> + guest_cpuflags_list = o.splitlines()[0].split(':')[1].split()
> + host_cpuflags_list = commands.getoutput(get_cpuflags_cmd).\
> + splitlines()[0].split(':')[1].split()
> +
> + logging.debug("Host flags %s" % host_cpuflags_list)
> + logging.debug("Guest flags %s" % guest_cpuflags_list)
> +
> + # There are some special flags, for example 'hypervisor', 'sep',
> + # present in guests but not in the hosts, exclude these flags from
> + # comparison.
> + ban_flags_list = params.get("ban_flags").split()
> +
> + guest_cpuflags_set = set(guest_cpuflags_list)
> + host_cpuflags_set = set(host_cpuflags_list)
> +
> + # If the excluded flags provided by the config file that exist in the
> + # host, remove them from the ban_flags_list, because we require kvm
> + # virtualize/simulate the host.
> + if params.get("strict_check") == "yes":
> + for flag in ban_flags_list:
> + if flag in host_cpuflags_list:
> + ban_flags_list.remove(flag)
> +
> + # exclude the banned flags from guest flags set.
> + for flag in ban_flags_list:
> + if flag in guest_cpuflags_set:
> + guest_cpuflags_set.remove(flag)
> +
> + if guest_cpuflags_set.issubset(host_cpuflags_set):
> + logging.info("Guest cpu flags all supported by host")
> + else:
> + invalidflags_set = guest_cpuflags_set - host_cpuflags_set
> + host_cpuflags_str = str(host_cpuflags_set)[4:-1]
> + invalidflags_str = ''
> + for i in invalidflags_set:
> + if host_cpuflags_str.find(i.strip()) == -1:
> + invalidflags_str = invalidflags_str + i + ','
> +
> + if invalidflags_str.strip() != '':
> + raise error.TestFail("Unsupported cpu flags by host: %s" % \
> + invalidflags_str[0:-1])
> +
> + # check the extra cpuflags in guest.
> + extra_flags_set = set(params.get("extra_flags").split())
> + if extra_flags_set.issubset(guest_cpuflags_set):
> + logging.info("All extra flags are found in guest.")
> + else:
> + invalidflags_set = extra_flags_set - guest_cpuflags_set
> + invalidflags_str = ''
> + for i in invalidflags_set:
> + invalidflags_str = invalidflags_str + i + ','
> + raise error.TestFail("Unsupported extra flags by guest: %s" % \
> + invalidflags_str[0:-1])
> +
> + session.close()
> +
> diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
> index 040d0c3..f7dcbb6 100644
> --- a/client/tests/kvm/tests_base.cfg.sample
> +++ b/client/tests/kvm/tests_base.cfg.sample
> @@ -300,6 +300,13 @@ variants:
> shutdown_method = shell
> kill_vm = yes
> kill_vm_gracefully = no
> +
> + - cpuflags:
> + type = cpuflags
> + getcpuflags = grep 'flags' /proc/cpuinfo
> + ban_flags = "up sep hypervisor sep_good"
> + extra_flags = ""
> + strict_check = yes
> # Do not define test variants below shutdown
>
>
> @@ -1001,7 +1008,7 @@ variants:
> md5sum = 9fae22f2666369968a76ef59e9a81ced
>
>
> -linux_s3:
> +linux_s3|cpuflags:
> only Linux
>
>
> --
> 1.5.5.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-07-29 5:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-04 7:20 [PATCH] KVM test: Add a subtest cpuflags sshang
2011-07-29 5:27 ` Amos Kong
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.