]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - test/test-functions
test: try to determine QEMU_SMP dynamically
[thirdparty/systemd.git] / test / test-functions
index a936202e4a79baf3682b814fe6ce54b4ba3f0eb9..d8a3502a4ada02d3f33881f517117c7b38a4444b 100644 (file)
@@ -134,7 +134,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