summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrantisek Sumsal <frantisek@sumsal.cz>2019-03-05 16:08:00 +0100
committerThe Plumber <50238977+systemd-rhel-bot@users.noreply.github.com>2020-05-18 19:35:19 +0200
commitc83025b14c1ec1aead2e6940e023c098ccc8fa9c (patch)
tree0ff646a53d07f2b5c0a5b124531842f54f4b1dd2
parent0b08d53cb68f008610722773ee4e9188b8e67d06 (diff)
downloadsystemd-c83025b14c1ec1aead2e6940e023c098ccc8fa9c.tar.gz
test: try to determine QEMU_SMP dynamically
If the QEMU_SMP value has not been explicitly set, try to determine it from the number of online CPUs using the nproc utility. If this approach fails, fall back to the default value QEMU_SMP=1. This change should significantly help when running integration tests under QEMU on multicore systems. (cherry picked from commit 5bfb2a93a4a36bba0d24199553dcda6e560cbb75) (cherry picked from commit dd166ab28360ceeb821d7b6d04e3c360b9023896) Resolves: #1836979
-rw-r--r--test/test-functions11
1 files changed, 10 insertions, 1 deletions
diff --git a/test/test-functions b/test/test-functions
index 0938e6e826..3f1c327f3c 100644
--- a/test/test-functions
+++ b/test/test-functions
@@ -120,7 +120,16 @@ run_qemu() {
fi
fi
- [ "$QEMU_SMP" ] || QEMU_SMP=1
+ # If QEMU_SMP was not explicitly set, try to determine the value 'dynamically'
+ # i.e. use the number of online CPUs on the host machine. If the nproc utility
+ # is not installed or there's some other error when calling it, fall back
+ # to the original value (QEMU_SMP=1).
+ if ! [ "$QEMU_SMP" ]; then
+ if ! QEMU_SMP=$(nproc); then
+ dwarn "nproc utility is not installed, falling back to QEMU_SMP=1"
+ QEMU_SMP=1
+ fi
+ fi
find_qemu_bin || return 1