]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Allow more VMs to be started in parallel
authorJouni Malinen <j@w1.fi>
Fri, 27 Dec 2019 18:31:33 +0000 (20:31 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 27 Dec 2019 18:31:33 +0000 (20:31 +0200)
Check the number of CPUs to determine how many VMs can be started in
parallel.

Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/vm/parallel-vm.py

index 07fa3d52eb1d92da3277815f42bcdaf8b59d20f8..47972d0dbac8686f955762c2b52df0e9b14ce57d 100755 (executable)
@@ -10,6 +10,7 @@ from __future__ import print_function
 import curses
 import fcntl
 import logging
+import multiprocessing
 import os
 import selectors
 import subprocess
@@ -213,21 +214,25 @@ def vm_next_step(_vm, scr, test_queue):
 
 def check_vm_start(scr, sel, test_queue):
     running = False
-    updated = False
     for i in range(num_servers):
-        if not vm[i]['proc']:
-            # Either not yet started or already stopped VM
-            if test_queue and vm[i]['cmd'] and num_vm_starting() < 2:
-                scr.move(i + 1, 10)
-                scr.clrtoeol()
-                scr.addstr(i + 1, 10, "starting VM")
-                updated = True
-                start_vm(vm[i], sel)
-            else:
-                continue
+        if vm[i]['proc']:
+            running = True
+            continue
 
-        running = True
-    return running, updated
+        # Either not yet started or already stopped VM
+        max_start = multiprocessing.cpu_count()
+        if max_start > 4:
+            max_start /= 2
+        num_starting = num_vm_starting()
+        if vm[i]['cmd'] and len(test_queue) > num_starting and \
+           num_starting < max_start:
+            scr.move(i + 1, 10)
+            scr.clrtoeol()
+            scr.addstr(i + 1, 10, "starting VM")
+            start_vm(vm[i], sel)
+            return True, True
+
+    return running, False
 
 def vm_terminated(_vm, scr, sel, test_queue):
     updated = False