From 6586659716d960fdab1ec0977a84645b9d06fc36 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Fri, 25 Sep 2020 21:36:19 +0200 Subject: Testsuite: automatically determine number of CPUs used --- scripts/check-qemu-install | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/check-qemu-install b/scripts/check-qemu-install index 3f68648b..77b65c9e 100755 --- a/scripts/check-qemu-install +++ b/scripts/check-qemu-install @@ -42,6 +42,7 @@ import random import traceback import logging import re + from io import BytesIO, StringIO from datetime import datetime @@ -97,6 +98,13 @@ class StreamToLogger(object): def flush(self): pass +def get_half_cpus(): + """ return 1/2 of the numbers of available CPUs """ + cpu = os.cpu_count() + if cpu > 1: + cpu /= 2 + return int(cpu) + def get_qemu_cmd(name, enable_kvm, disk_img, iso_img=None): kvm = "" cpu = "-cpu host" @@ -108,9 +116,12 @@ def get_qemu_cmd(name, enable_kvm, disk_img, iso_img=None): if iso_img: cdrom = "-boot d -cdrom {}".format(iso_img) + # test using half of the available CPUs on the system + cpucount = get_half_cpus() + cmd = f'qemu-system-x86_64 \ -name "{name}" \ - -smp 2 \ + -smp {cpucount} \ -m 2G \ -nic user,model=virtio,mac=52:54:99:12:34:56 \ -nic user,model=virtio,mac=52:54:99:12:34:57 \ -- cgit v1.2.3