Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
run_tests: Probe for max-smp
KVM can be configured to only support a few vcpus. ARM and AArch64
currently have a default config of only 4. While it's nice to be
able to write tests that use the maximum recommended, nr-host-cpus,
we can't assume that nr-host-cpus == kvm-max-vcpus. This patch allows
one to put $MAX_SMP in the smp = <num> line of a unittests.cfg file.
That variable will then expand to the number of host cpus, or to the
maximum vcpus allowed by KVM.

[Inspired by a patch from Alex Bennée solving the same issue.]

Signed-off-by: Andrew Jones <drjones@redhat.com>
  • Loading branch information
Andrew Jones committed Aug 2, 2015
1 parent 7ab5971 commit 336d873
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arm/unittests.cfg
Expand Up @@ -2,6 +2,7 @@
# [unittest_name]
# file = foo.flat # Name of the flat file to be used
# smp = 2 # Number of processors the VM will use during this test
# # Use $MAX_SMP to use the maximum the host supports.
# extra_params = -append <params...> # Additional parameters used
# arch = arm/arm64 # Only if test case is specific to one
# groups = group1 group2 # Used to identify test cases with run_tests -g ...
Expand Down Expand Up @@ -32,6 +33,6 @@ groups = selftest
# Test SMP support
[selftest-smp]
file = selftest.flat
smp = `getconf _NPROCESSORS_CONF`
smp = $MAX_SMP
extra_params = -append 'smp'
groups = selftest
9 changes: 9 additions & 0 deletions run_tests.sh
Expand Up @@ -97,4 +97,13 @@ while getopts "g:hv" opt; do
esac
done

#
# Probe for MAX_SMP
#
MAX_SMP=$(getconf _NPROCESSORS_CONF)
while ./$TEST_DIR-run _NO_FILE_4Uhere_ -smp $MAX_SMP \
|& grep -q 'exceeds max cpus'; do
((--MAX_SMP))
done

for_each_unittest $config run
7 changes: 7 additions & 0 deletions scripts/mkstandalone.sh
Expand Up @@ -94,6 +94,13 @@ qemu="$qemu"
if [ "\$QEMU" ]; then
qemu="\$QEMU"
fi
cmdline="\`echo '$cmdline' | sed s%$kernel%_NO_FILE_4Uhere_%\`"
MAX_SMP=\`getconf _NPROCESSORS_CONF\`
while \$qemu \$cmdline -smp \$MAX_SMP 2>&1 | grep 'exceeds max cpus' > /dev/null; do
MAX_SMP=\`expr \$MAX_SMP - 1\`
done
cmdline="\`echo '$cmdline' | sed s%$kernel%\$bin%\`"
echo \$qemu $cmdline -smp $smp $opts
\$qemu \$cmdline -smp $smp $opts
Expand Down
1 change: 1 addition & 0 deletions x86/unittests.cfg
Expand Up @@ -2,6 +2,7 @@
# [unittest_name]
# file = foo.flat # Name of the flat file to be used
# smp = 2 # Number of processors the VM will use during this test
# # Use $MAX_SMP to use the maximum the host supports.
# extra_params = -cpu qemu64,+x2apic # Additional parameters used
# arch = i386/x86_64 # Only if the test case works only on one of them
# groups = group1 group2 # Used to identify test cases with run_tests -g ...
Expand Down

0 comments on commit 336d873

Please sign in to comment.