[LTP] [PATCH 1/1] kirk: Update to v3.2

Andrea Cervesato andrea.cervesato@suse.com
Thu Jan 15 11:13:40 CET 2026


>
> After playing with the ltp.py for a while and assisted by GPT5,
> I drafted a simple patch like below, it works from my test, can
> Do you think it's worth opening a PR to Kirk?

Thanks for checking, see considerations below.

>
> --- a/libkirk/ltp.py
> +++ b/libkirk/ltp.py
> @@ -50,7 +50,7 @@ class LTPFramework(Framework):
>          self,
>          max_runtime: float = 0.0,
>          timeout: float = 30.0,
> -        env: dict = {},
> +        env: Optional[dict] = None,

No need for this, if default it's {} already. That None adds one more
layer of complexity, because then we need to make sure env is not None.

>      ) -> None:
>          """
>          :param max_runtime: filter out all tests above this time value
> @@ -63,7 +63,8 @@ class LTPFramework(Framework):
>          self._logger = logging.getLogger("libkirk.ltp")
>          self._cmd_matcher = re.compile(r'(?:"[^"]*"|\'[^\']*\'|\S+)')
>          self._max_runtime = max_runtime
> -        self._root = os.environ.get("LTPROOT", "/opt/ltp")
> +        env = env or {}

See above.

> +        self._root = env.get("LTPROOT") or os.environ.get("LTPROOT")
> or "/opt/ltp"

This makes sense, but that "or /opt/ltp" is not needed. See below.

>          self._tc_folder = os.path.join(self._root, "testcases", "bin")
>
>          self._env = {
> @@ -79,8 +80,7 @@ class LTPFramework(Framework):
>              if timeout:
>                  self._env["LTP_TIMEOUT_MUL"] = str((timeout * 0.9) / 300.0)
>
> -        if env:
> -            self._env.update(env)
> +        self._env.update(env)
>
>      async def _read_path(self, channel: ComChannel) -> Dict[str, str]:
>          """

diff --git a/libkirk/ltp.py b/libkirk/ltp.py
index 2c0f6d2..153bc7b 100644
--- a/libkirk/ltp.py
+++ b/libkirk/ltp.py
@@ -63,7 +63,7 @@ class LTPFramework(Framework):
         self._logger = logging.getLogger("libkirk.ltp")
         self._cmd_matcher = re.compile(r'(?:"[^"]*"|\'[^\']*\'|\S+)')
         self._max_runtime = max_runtime
-        self._root = os.environ.get("LTPROOT", "/opt/ltp")
+        self._root = env.get("LTPROOT") or os.environ.get("LTPROOT", "/opt/ltp")
         self._tc_folder = os.path.join(self._root, "testcases", "bin")
 
         self._env = {
@@ -94,8 +94,7 @@ class LTPFramework(Framework):
             if not ret or ret["returncode"] != 0:
                 raise FrameworkError("Can't read PATH variable")
 
-            tcases = os.path.join(self._root, "testcases", "bin")
-            env["PATH"] = ret["stdout"].strip() + f":{tcases}"
+            env["PATH"] = ret["stdout"].strip() + f":{self._tc_folder}"
 
         self._logger.debug("PATH=%s", env["PATH"])
 

-- 
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com



More information about the ltp mailing list