[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v9 3/6] iotests: add testenv.py
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
Re: [PATCH v9 3/6] iotests: add testenv.py |
Date: |
Tue, 26 Jan 2021 13:10:54 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 |
25.01.2021 21:50, 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<vsementsov@virtuozzo.com>
squash-in to fix mypy complains, and try use ContextManager for CI:
diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py
index ca9cab531b..8b80425670 100644
--- a/tests/qemu-iotests/testenv.py
+++ b/tests/qemu-iotests/testenv.py
@@ -25,8 +25,7 @@ import collections
import random
import subprocess
import glob
-from contextlib import AbstractContextManager
-from typing import Dict, Any, Optional
+from typing import Dict, Any, Optional, ContextManager
def isxfile(path: str) -> bool:
@@ -50,7 +49,7 @@ def get_default_machine(qemu_prog: str) -> str:
return default_machine
-class TestEnv(AbstractContextManager['TestEnv']):
+class TestEnv(ContextManager['TestEnv']):
"""
Manage system environment for running tests
@@ -81,7 +80,7 @@ class TestEnv(AbstractContextManager['TestEnv']):
return env
- def init_directories(self):
+ def init_directories(self) -> None:
"""Init directory variables:
PYTHONPATH
TEST_DIR
@@ -100,11 +99,11 @@ class TestEnv(AbstractContextManager['TestEnv']):
os.path.join(os.getcwd(), 'scratch'))
Path(self.test_dir).mkdir(parents=True, exist_ok=True)
- self.sock_dir = os.getenv('SOCK_DIR')
- self.tmp_sock_dir = False
- if self.sock_dir:
+ try:
+ self.sock_dir = os.environ['SOCK_DIR']
+ self.tmp_sock_dir = False
Path(self.test_dir).mkdir(parents=True, exist_ok=True)
- else:
+ except KeyError:
self.sock_dir = tempfile.mkdtemp()
self.tmp_sock_dir = True
@@ -114,7 +113,7 @@ class TestEnv(AbstractContextManager['TestEnv']):
self.output_dir = os.getcwd() # OUTPUT_DIR
- def init_binaries(self):
+ def init_binaries(self) -> None:
"""Init binary path variables:
PYTHON (for bash tests)
QEMU_PROG, QEMU_IMG_PROG, QEMU_IO_PROG, QEMU_NBD_PROG, QSD_PROG
@@ -122,7 +121,7 @@ class TestEnv(AbstractContextManager['TestEnv']):
"""
self.python = sys.executable
- def root(*names):
+ def root(*names: str) -> str:
return os.path.join(self.build_root, *names)
arch = os.uname().machine
--
Best regards,
Vladimir
- [PATCH v9 0/6] Rework iotests/check, Vladimir Sementsov-Ogievskiy, 2021/01/25
- [PATCH v9 3/6] iotests: add testenv.py, Vladimir Sementsov-Ogievskiy, 2021/01/25
- Re: [PATCH v9 3/6] iotests: add testenv.py,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v9 2/6] iotests: add findtests.py, Vladimir Sementsov-Ogievskiy, 2021/01/25
- [PATCH v9 4/6] iotests: add testrunner.py, Vladimir Sementsov-Ogievskiy, 2021/01/25
- [PATCH v9 5/6] iotests: rewrite check into python, Vladimir Sementsov-Ogievskiy, 2021/01/25
- [PATCH v9 6/6] iotests: rename and move 169 and 199 tests, Vladimir Sementsov-Ogievskiy, 2021/01/25
- [PATCH v9 1/6] iotests: 146: drop extra whitespaces from .out file, Vladimir Sementsov-Ogievskiy, 2021/01/25
- Re: [PATCH v9 0/6] Rework iotests/check, Kevin Wolf, 2021/01/26