kunit: tool: stop using a shell to run kernel under QEMU
[linux-2.6-microblaze.git] / tools / testing / kunit / kunit_kernel.py
index 483f78e..1b9c492 100644 (file)
@@ -11,6 +11,7 @@ import importlib.util
 import logging
 import subprocess
 import os
+import shlex
 import shutil
 import signal
 import threading
@@ -118,16 +119,17 @@ class LinuxSourceTreeOperationsQemu(LinuxSourceTreeOperations):
                                '-nodefaults',
                                '-m', '1024',
                                '-kernel', kernel_path,
-                               '-append', '\'' + ' '.join(params + [self._kernel_command_line]) + '\'',
+                               '-append', ' '.join(params + [self._kernel_command_line]),
                                '-no-reboot',
                                '-nographic',
-                               '-serial stdio'] + self._extra_qemu_params
-               print('Running tests with:\n$', ' '.join(qemu_command))
-               return subprocess.Popen(' '.join(qemu_command),
-                                          stdin=subprocess.PIPE,
-                                          stdout=subprocess.PIPE,
-                                          stderr=subprocess.STDOUT,
-                                          text=True, shell=True, errors='backslashreplace')
+                               '-serial', 'stdio'] + self._extra_qemu_params
+               # Note: shlex.join() does what we want, but requires python 3.8+.
+               print('Running tests with:\n$', ' '.join(shlex.quote(arg) for arg in qemu_command))
+               return subprocess.Popen(qemu_command,
+                                       stdin=subprocess.PIPE,
+                                       stdout=subprocess.PIPE,
+                                       stderr=subprocess.STDOUT,
+                                       text=True, errors='backslashreplace')
 
 class LinuxSourceTreeOperationsUml(LinuxSourceTreeOperations):
        """An abstraction over command line operations performed on a source tree."""