Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cpu_topology_test: Add test case to test cpu topology
Signed-off-by: Qianqian Zhu <qizhu@redhat.com>
- Loading branch information
1 parent
b9f1a51
commit 685688b
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
- cpu_topology_test: | ||
no smp2 | ||
only Linux | ||
type = cpu_topology_test | ||
start_vm = no | ||
Linux: | ||
check_siblings_cmd = 'cat /proc/cpuinfo |grep siblings |uniq |cut -d ":" -f 2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import random | ||
|
||
from virttest import error_context | ||
from virttest import env_process | ||
|
||
from provider.cpu_utils import check_guest_cpu_topology | ||
|
||
|
||
@error_context.context_aware | ||
def run(test, params, env): | ||
""" | ||
:param test: QEMU test object. | ||
:param params: Dictionary with test parameters. | ||
:param env: Dictionary with the test environment. | ||
""" | ||
|
||
def check(p_name, exp, check_cmd): | ||
""" | ||
Check the cpu property inside guest | ||
:param p_name: Property name | ||
:param exp: The expect value | ||
:param check_cmd: The param to get check command | ||
""" | ||
res = session.cmd_output(params[check_cmd]).strip() | ||
if int(res) != int(exp): | ||
test.fail('The vcpu %s number inside guest is %s,' | ||
' while it is set to %s' % (p_name, res, exp)) | ||
|
||
os_type = params['os_type'] | ||
params['vcpu_cores'] = vcpu_cores = random.randint(1, 10) | ||
vcpu_threads_list = [1, 2] | ||
if params['machine_type'] == 'pseries': | ||
vcpu_threads_list = [1, 2, 4, 8] | ||
vcpu_sockets = random.randint(1, 10) | ||
params['vcpu_sockets'] = 2 if (os_type == 'Windows' and | ||
vcpu_sockets > 2) else vcpu_sockets | ||
vm_name = params['main_vm'] | ||
for vcpu_threads in vcpu_threads_list: | ||
params['vcpu_threads'] = vcpu_threads | ||
params['smp'] = params['vcpu_maxcpus'] = (vcpu_cores * | ||
vcpu_threads * vcpu_sockets) | ||
params['start_vm'] = 'yes' | ||
env_process.preprocess_vm(test, params, env, vm_name) | ||
vm = env.get_vm(vm_name) | ||
session = vm.wait_for_login() | ||
check_guest_cpu_topology(session, os_type, vm.cpuinfo) | ||
if params.get('check_siblings_cmd'): | ||
check('sibling', vcpu_threads * vcpu_cores, 'check_siblings_cmd') | ||
vm.destroy() |