24.01.2021 00:04, Vladimir Sementsov-Ogievskiy wrote:
Add TestEnv class, which will handle test environment in a new python
iotests running framework.
Don't add compat=1.1 for qcow2 IMGOPTS, as v3 is default anyway.
Signed-off-by: Vladimir Sementsov-Ogievskiy<[email protected]>
---
tests/qemu-iotests/testenv.py | 278 ++++++++++++++++++++++++++++++++++
1 file changed, 278 insertions(+)
create mode 100644 tests/qemu-iotests/testenv.py
diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py
new file mode 100644
index 0000000000..348af593e9
[..]
+ def init_binaries(self):
+ """Init binary path variables:
+ PYTHON (for bash tests)
+ QEMU_PROG, QEMU_IMG_PROG, QEMU_IO_PROG, QEMU_NBD_PROG, QSD_PROG
+ SOCKET_SCM_HELPER
+ """
+ self.python = sys.executable
+
+ def root(*names):
+ return os.path.join(self.build_root, *names)
+
+ arch = os.uname().machine
+ if 'ppc64' in arch:
+ arch = 'ppc64'
+
+ self.qemu_prog = os.getenv('QEMU_PROG', root(f'qemu-system-{arch}'))
+ if not os.path.exists(self.qemu_prog):
+ pattern = root('qemu-system-*')
+ progs = glob.glob(pattern)
+ if not progs:
+ sys.exit(f"Not found any Qemu binary by pattern '{pattern}'")
+ if len(progs) > 1:
+ progs_list = ', '.join(progs)
+ sys.exit(f"Several non '{arch}' qemu binaries found: "
+ f"{progs_list}, please set QEMU_PROG environment "
+ "variable")
+ self.qemu_prog = progs[0]
squash-in:
diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py
index 348af593e9..1633510caf 100644
--- a/tests/qemu-iotests/testenv.py
+++ b/tests/qemu-iotests/testenv.py
@@ -129,14 +129,14 @@ class TestEnv(AbstractContextManager['TestEnv']):
if not os.path.exists(self.qemu_prog):
pattern = root('qemu-system-*')
progs = glob.glob(pattern)
- if not progs:
- sys.exit(f"Not found any Qemu binary by pattern '{pattern}'")
- if len(progs) > 1:
- progs_list = ', '.join(progs)
- sys.exit(f"Several non '{arch}' qemu binaries found: "
- f"{progs_list}, please set QEMU_PROG environment "
- "variable")
- self.qemu_prog = progs[0]
+ found = False
+ for p in progs:
+ if os.access(p, os.X_OK):
+ self.qemu_prog = p
+ found = True
+ if not found:
+ sys.exit("Not found any Qemu executable binary by pattern "
+ f"'{pattern}'")
--
Best regards,
Vladimir