fm-weck 1.5.2__py3-none-any.whl → 1.5.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
fm_weck/__init__.py CHANGED
@@ -8,4 +8,4 @@
8
8
  from .config import Config # noqa: F401
9
9
  from .image_mgr import ImageMgr # noqa: F401
10
10
 
11
- __version__ = "1.5.2"
11
+ __version__ = "1.5.3"
fm_weck/cli.py CHANGED
@@ -581,6 +581,9 @@ def main_runexec(args: argparse.Namespace):
581
581
  command=args.argument_list,
582
582
  )
583
583
 
584
+ if result is None:
585
+ return 1 # Indicate failure due to runexec setup issues
586
+
584
587
  return result.exit_code
585
588
 
586
589
 
@@ -757,7 +760,7 @@ def _do_smoke_test_mode(fm_data, shelve_space, tool, gitlab_ci_mode) -> int:
757
760
  "Smoke test failed (exit code %d).\n"
758
761
  "- Tool: %s\n"
759
762
  "- Tool cache dir (host): %s\n"
760
- "- Script name: smoketest.sh or smoke_test.sh\n"
763
+ "- Script name: smoketest.sh\n"
761
764
  "Last 50 lines of output:\n%s",
762
765
  result.exit_code,
763
766
  tool.stem,
@@ -824,8 +827,8 @@ def main_smoke_test(args: argparse.Namespace):
824
827
  except NoSmokeTestFileError as e:
825
828
  print(
826
829
  f"{e}\n"
827
- "Expected a smoke test script named 'smoketest.sh' or 'smoke_test.sh' in the tool directory.\n"
828
- "Action: Add a minimal script 'smoke_test.sh' to the root of the tool directory that exercises the tool.\n"
830
+ "Expected a smoke test script named 'smoketest.sh' in the tool directory.\n"
831
+ "Action: Add a minimal script 'smoketest.sh' to the root of the tool directory that exercises the tool.\n"
829
832
  "The top level contents of the tool directory were:\n"
830
833
  f"{os.linesep.join([str(p.name) for p in shelve_space.iterdir()])}",
831
834
  )
fm_weck/config.py CHANGED
@@ -14,8 +14,6 @@ from functools import cache
14
14
  from pathlib import Path
15
15
  from typing import TYPE_CHECKING, Any, Callable, Iterable, Optional, Tuple, TypeVar
16
16
 
17
- from werkzeug.utils import secure_filename
18
-
19
17
  try:
20
18
  from fm_tools.fmtool import FmTool
21
19
  from fm_tools.fmtoolversion import FmToolVersion
@@ -37,7 +35,7 @@ except ImportError:
37
35
  raise ImportError("fm_tools is not imported.")
38
36
 
39
37
 
40
- from fm_weck.resources import RUN_WITH_OVERLAY, RUNEXEC_SCRIPT
38
+ from fm_weck.resources import RUN_WITH_OVERLAY
41
39
 
42
40
  from .file_util import copy_ensuring_unix_line_endings
43
41
 
@@ -170,6 +168,8 @@ class Config(object):
170
168
  return self.cache_location / ".checksums.dbm"
171
169
 
172
170
  def get_shelve_space_for(self, fm_data: FmToolVersion) -> Path:
171
+ from werkzeug.utils import secure_filename
172
+
173
173
  shelve = self.cache_location
174
174
  # Remove leading http:// or https:// from the raw archive location
175
175
  raw_location = fm_data.get_archive_location().raw
@@ -195,9 +195,6 @@ class Config(object):
195
195
  def _system_is_not_posix():
196
196
  return not (sys.platform.startswith("linux") or sys.platform == "darwin")
197
197
 
198
- def make_runexec_script_available(self) -> Path | None:
199
- return self.make_script_available(RUNEXEC_SCRIPT)
200
-
201
198
  def make_script_available(self, target_name: str = RUN_WITH_OVERLAY) -> Path | None:
202
199
  script_dir = self.cache_location / ".scripts"
203
200
  target = script_dir / target_name
@@ -9,8 +9,6 @@ import importlib.resources as pkg_resources
9
9
  from functools import cache
10
10
  from pathlib import Path
11
11
 
12
- from . import fm_tools, properties
13
-
14
12
  # During the build of the wheel file, the fm-tools/data directory is copied
15
13
  # to the wheel file under fm_weck/resources/fm_tools
16
14
 
@@ -20,7 +18,8 @@ RUNEXEC_SCRIPT = "runexec"
20
18
 
21
19
 
22
20
  def iter_fm_data():
23
- for entry in pkg_resources.files(fm_tools).iterdir():
21
+ root = pkg_resources.files(__package__) / "fm_tools"
22
+ for entry in root.iterdir():
24
23
  if entry.name.endswith((".yml", ".yaml")):
25
24
  with pkg_resources.as_file(entry) as path:
26
25
  fm_data_path = Path(path)
@@ -29,7 +28,8 @@ def iter_fm_data():
29
28
 
30
29
 
31
30
  def iter_properties():
32
- for entry in pkg_resources.files(properties).iterdir():
31
+ root = pkg_resources.files(__package__) / "properties"
32
+ for entry in root.iterdir():
33
33
  with pkg_resources.as_file(entry) as path:
34
34
  prop_path = Path(path)
35
35
  if prop_path.is_file():
fm_weck/run_result.py CHANGED
@@ -6,12 +6,11 @@
6
6
  # SPDX-License-Identifier: Apache-2.0
7
7
 
8
8
  from dataclasses import dataclass
9
- from functools import singledispatchmethod
9
+ from typing import TYPE_CHECKING
10
10
 
11
- from benchexec.tools.template import BaseTool2
12
- from benchexec.util import ProcessExitCode
13
- from fm_tools.fmtoolversion import FmToolVersion
14
- from fm_tools.run import get_tool_info
11
+ if TYPE_CHECKING:
12
+ from benchexec.tools.template import BaseTool2
13
+ from fm_tools.fmtoolversion import FmToolVersion
15
14
 
16
15
 
17
16
  @dataclass(frozen=True)
@@ -21,6 +20,9 @@ class RunResult:
21
20
  raw_output: str
22
21
 
23
22
  def as_benchexec_run(self):
23
+ from benchexec.tools.template import BaseTool2
24
+ from benchexec.util import ProcessExitCode
25
+
24
26
  return BaseTool2.Run(
25
27
  cmdline=self.command,
26
28
  exit_code=ProcessExitCode.create(value=self.exit_code),
@@ -28,11 +30,13 @@ class RunResult:
28
30
  termination_reason=False, # TODO: We do not know about this
29
31
  )
30
32
 
31
- @singledispatchmethod
32
- def determine_result(self, tool: BaseTool2) -> str:
33
- return tool.determine_result(self.as_benchexec_run())
33
+ def determine_result(self, tool: "BaseTool2 | FmToolVersion") -> str:
34
+ from benchexec.tools.template import BaseTool2
35
+
36
+ if isinstance(tool, BaseTool2):
37
+ return tool.determine_result(self.as_benchexec_run())
38
+
39
+ from fm_tools.run import get_tool_info
34
40
 
35
- @determine_result.register
36
- def _(self, tool: FmToolVersion) -> str:
37
41
  tool_ = get_tool_info(tool)
38
- return self.determine_result(tool_)
42
+ return tool_.determine_result(self.as_benchexec_run())
fm_weck/runexec_mode.py CHANGED
@@ -7,11 +7,13 @@
7
7
 
8
8
  import importlib.resources as pkg_resources
9
9
  import logging
10
+ import os
10
11
  import shutil
11
12
  from pathlib import Path
13
+ from tempfile import NamedTemporaryFile
12
14
  from typing import TYPE_CHECKING, Optional
13
15
 
14
- from fm_weck.resources import BENCHEXEC_WHL
16
+ from fm_weck.resources import BENCHEXEC_WHL, RUNEXEC_SCRIPT
15
17
  from fm_weck.runexec_util import mountable_absolute_paths_of_command
16
18
 
17
19
  from .config import Config
@@ -20,16 +22,38 @@ from .engine import CACHE_MOUNT_LOCATION, Engine
20
22
  logger = logging.getLogger(__name__)
21
23
 
22
24
  if TYPE_CHECKING:
25
+ from tempfile import _TemporaryFileWrapper
26
+
23
27
  from fm_weck.run_result import RunResult
24
28
 
25
29
 
30
+ def _setup_script_in_cache(target: "_TemporaryFileWrapper[bytes]") -> Path:
31
+ # When running multiple instances in parallel it can happen, that two processes interfere
32
+ # when copying the script causing a "Text file is busy" error.
33
+ # Using a temp file avoids this problem.
34
+ # The cleaner solution would be to use a direct bind mount from the package resource, but this does not
35
+ # work on the benchcloud right now.
36
+
37
+ with pkg_resources.path("fm_weck.resources", RUNEXEC_SCRIPT) as source_path:
38
+ shutil.copy(source_path, target.name)
39
+
40
+ target_path = Path(target.name)
41
+ mode = target_path.stat().st_mode
42
+ # make the temp file executable
43
+ target_path.chmod(mode | os.X_OK)
44
+ target.flush()
45
+ target.close()
46
+
47
+ return target_path
48
+
49
+
26
50
  def run_runexec(
27
51
  benchexec_package: Optional[Path],
28
52
  use_image: Optional[str],
29
53
  configuration: Config,
30
54
  extra_container_args: list[list[str]],
31
55
  command: list[str],
32
- ) -> "RunResult":
56
+ ) -> "RunResult| None":
33
57
  if use_image is not None:
34
58
  configuration.set_default_image(use_image)
35
59
 
@@ -38,7 +62,7 @@ def run_runexec(
38
62
  engine.add_mounting_capabilities = False
39
63
 
40
64
  if benchexec_package is not None:
41
- engine.mount(benchexec_package.parent.absolute(), "/home/__fm_weck_benchexec")
65
+ engine.mount(str(benchexec_package.parent.absolute()), "/home/__fm_weck_benchexec")
42
66
  engine.env["PYTHONPATH"] = f"/home/__fm_weck_benchexec/{benchexec_package.name}"
43
67
  else:
44
68
  # Default to the bundled benchexec package
@@ -52,13 +76,19 @@ def run_runexec(
52
76
  return None
53
77
 
54
78
  for path in mountable_absolute_paths_of_command(Path.cwd().absolute(), command):
55
- engine.mount(path, str(path) + ":ro")
79
+ engine.mount(str(path), str(path) + ":ro")
56
80
 
57
81
  for arg in extra_container_args:
58
82
  engine.add_container_long_opt(arg)
59
83
 
60
- configuration.make_runexec_script_available()
61
-
62
84
  engine.handle_io = False
63
85
 
64
- return engine.run(f"{CACHE_MOUNT_LOCATION}/.scripts/runexec", *command)
86
+ with (
87
+ NamedTemporaryFile(
88
+ prefix="runexec_", dir=str(configuration.cache_location / ".scripts"), delete=True, delete_on_close=False
89
+ ) as tmp_file,
90
+ ):
91
+ script_path = _setup_script_in_cache(tmp_file)
92
+
93
+ rel_path = script_path.relative_to(configuration.cache_location)
94
+ return engine.run(f"{CACHE_MOUNT_LOCATION}/{rel_path}", *command)
@@ -48,7 +48,7 @@ class SmokeTestFileIsNotExecutableError(SmokeTestError):
48
48
 
49
49
 
50
50
  def locate_and_check_smoke_test_file(shelve_space: Path) -> str:
51
- """Check if the smoke test file exists and is not empty.
51
+ """Check if the smoke test file exists, is executable, and is not empty.
52
52
 
53
53
  Args:
54
54
  shelve_space: Path to the shelve space directory.
@@ -59,15 +59,11 @@ def locate_and_check_smoke_test_file(shelve_space: Path) -> str:
59
59
  Raises:
60
60
  NoSmokeTestFileError: If the smoke test file does not exist.
61
61
  SmokeTestFileIsEmptyError: If the smoke test file is empty.
62
+ SmokeTestFileIsNotExecutableError: If the smoke test file is not executable.
62
63
  """
63
- if not (shelve_space / "smoketest.sh").exists() and not (shelve_space / "smoke_test.sh").exists():
64
- raise NoSmokeTestFileError(f"Smoke test file not found in: {shelve_space}")
65
-
66
- if (shelve_space / "smoketest.sh").exists():
67
- file_path = shelve_space / "smoketest.sh"
68
- else:
69
- # Since we checked for existence above, this must exist
70
- file_path = shelve_space / "smoke_test.sh"
64
+ file_path = shelve_space / "smoketest.sh"
65
+ if not file_path.exists():
66
+ raise NoSmokeTestFileError(f"Smoke test file 'smoketest.sh' not found in: {shelve_space}")
71
67
 
72
68
  if not file_path.stat().st_mode & os.X_OK:
73
69
  raise SmokeTestFileIsNotExecutableError(file_path.relative_to(shelve_space))
@@ -100,7 +96,7 @@ def run_smoke_test_gitlab_ci(fm_data: FmToolVersion, tool_dir: Path):
100
96
 
101
97
  Args:
102
98
  fm_data: The FmToolVersion object containing tool information
103
- tool_dir: The directory containing the tool's smoke_test.sh script
99
+ tool_dir: The directory containing the tool's smoketest.sh script
104
100
  """
105
101
  # Get required packages from fm_data
106
102
  required_packages = fm_data.get_images().required_packages
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fm-weck
3
- Version: 1.5.2
3
+ Version: 1.5.3
4
4
  Author-email: Henrik Wachowitz <henrik.wachowitz@ifi.lmu.de>
5
5
  Maintainer-email: Henrik Wachowitz <henrik.wachowitz@ifi.lmu.de>
6
6
  Classifier: Development Status :: 4 - Beta
@@ -1,18 +1,18 @@
1
- fm_weck/__init__.py,sha256=P8xygPjF_sqOcyrYtuILR2BsTY8VZAPkvhl0WRrgKSc,351
1
+ fm_weck/__init__.py,sha256=XKFqL4QIrZPlt9h9GadbHOpCIMJiY650ZjDdLbYQWa8,351
2
2
  fm_weck/__main__.py,sha256=IfNDAqM6MK6P7KsQoW3wOHPOscB8evdVlS9C7R4wd_0,391
3
3
  fm_weck/cache_mgr.py,sha256=3-OQFmCeswazXmX08ND4oEHFOR07ZDCwWzjmFTDkOSE,1373
4
4
  fm_weck/capture.py,sha256=iogn3JvCZEjD0SQL8Xa3TzmZAWifd9ZIP81c3JIsdUQ,982
5
- fm_weck/cli.py,sha256=wDRzNUvocQmBKicP7aeJPWLmiIlHd_nnH87vEowMNk4,29097
6
- fm_weck/config.py,sha256=DHIdGA4OhVAHAPJyB--G19EwGshAirmb6PGwoJQtZaE,8136
5
+ fm_weck/cli.py,sha256=sY9MYVqma0b7abXyqoLZ2rh0JkP6y72WUayble_cPVY,29149
6
+ fm_weck/config.py,sha256=N7PgJRHXrhwNbfussz7NTGGMAVaFy9YiUbYFIXlRzVE,8009
7
7
  fm_weck/engine.py,sha256=P48zCTeMHI3imE0ho5AxhDNTRY3mX0Nzd0gBzjqRCX4,21729
8
8
  fm_weck/exceptions.py,sha256=AfqTt6gxZPUQ0rKqwgdGTyfIjWmU3xBFIJxQnMLbLGo,2465
9
9
  fm_weck/file_util.py,sha256=FG_uBuNWGWbSivBv0dYzwugMkGfdS_iFY-hG6GLDD54,799
10
10
  fm_weck/image_mgr.py,sha256=lkn1nWuwKtMhtVf_PFZOOJftY5uyE0EydY2f-sefHGE,1943
11
- fm_weck/run_result.py,sha256=srg3w2MvC-2YqgpRtqrat2DoxhErtlc5FQO3uaFaGTI,1253
12
- fm_weck/runexec_mode.py,sha256=UamxVvYm0XErPjR2sRJaLMX8uHBzRcgCTWbQIZjdju0,2195
11
+ fm_weck/run_result.py,sha256=58SIkYpdZY3l5A7UKk4Uz2V8W57uo_nfKQPZD3V4-Iw,1377
12
+ fm_weck/runexec_mode.py,sha256=ws1FwQxLFumh8iklFXeFRMgWXRLSWNX2eUlh-QcMqo8,3359
13
13
  fm_weck/runexec_util.py,sha256=YBvVIPpmEousZVxbZ5NS8jzpKPLyws31kIFE2z3Ki2E,1370
14
14
  fm_weck/serve.py,sha256=RUz_3v15By_CvcBJlNBw-mKuDubAiIha5EfayFBnqps,10728
15
- fm_weck/smoke_test_mode.py,sha256=5n2LdYyTxATFl-yaDVfkie-IiNACL3Hs2c_CARqMvek,4196
15
+ fm_weck/smoke_test_mode.py,sha256=FAUftedyDl_-xxsU74CcX4RxYH_cPR0zsNkIZwkk2Os,4060
16
16
  fm_weck/tmp_file.py,sha256=oJiE8VGTPxhl-bXdtbM8eNqQ4e9ECPG1jDmiboVDo_k,1956
17
17
  fm_weck/version_listing.py,sha256=caaoC3n9R-Ao2sEQ_ngOVO3bnKr7cNVeH6EiA8jO5Sc,864
18
18
  fm_weck/grpc_service/__init__.py,sha256=TvQSR0pVeh4MMMT40VfzJFyZTHpAOI7C808vjJpWiOs,390
@@ -30,7 +30,7 @@ fm_weck/grpc_service/proto/generate_protocol_files.sh,sha256=F9dd95qKejtB7B3P-x9
30
30
  fm_weck/resources/BenchExec-3.27-py3-none-any.whl,sha256=g-db8LM8HfqLhbnl7n5lvUbMnF2tZ4MHAVOxTGxqO8w,732849
31
31
  fm_weck/resources/BenchExec-3.27-py3-none-any.whl.license,sha256=Nq2Mwgn_pyr6ZZrTT095QPtFP3hr15ZeIRIaY0B7eC8,201
32
32
  fm_weck/resources/Containerfile,sha256=HpPkrzJe1IKsmLOfbe5LbT-suaV6eJn1fT4csSvEkOk,390
33
- fm_weck/resources/__init__.py,sha256=Gd3SNYBUUgDCJFMVwaaPynmugTUKoWamBXRhbasRKJE,1522
33
+ fm_weck/resources/__init__.py,sha256=c3WqvUoTCFCM1SVxYEDQs4FqFxcNRiJkpeN5g-OA5VU,1550
34
34
  fm_weck/resources/c_program_example.c,sha256=WOTAn4XyQL8TlplI6M8FbKiUxiwnvHUy2o6n0hLIe6o,21862
35
35
  fm_weck/resources/run_with_overlay.sh,sha256=v1gV_6kMQ0v9BQ3chgDqI1MAOLHbPWeeTC52aCqVpEM,1162
36
36
  fm_weck/resources/runexec,sha256=ogIBO38HLu9C9kDTTANBgAqVnH-UIF1bSJ9d3DSjyF4,462
@@ -165,7 +165,7 @@ fm_weck/resources/fm_tools/wit4java.yml,sha256=ylfze2XbV4zKkVUH57Veqn7G49gW0Byxd
165
165
  fm_weck/resources/fm_tools/witch.yml,sha256=wwe6lrI2sxGKVZbLeipa38rPhB2pcSUFi9uVngtXGUQ,1795
166
166
  fm_weck/resources/fm_tools/witnesslint.yml,sha256=EvMBcm5fx6lgSLRmHSKXSxXIJKZ-BrxLwTXI4GQ6FMs,6812
167
167
  fm_weck/resources/fm_tools/witnessmap.yml,sha256=FyZtEloxpWBBjLn9kyqoen2kPjOkH2r4fxAj5gfV8Bg,1692
168
- fm_weck-1.5.2.dist-info/METADATA,sha256=1a0oYolO5XlQSwC0tT2qWCdzzroGb-PdS6YQbFEZUME,3339
169
- fm_weck-1.5.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
170
- fm_weck-1.5.2.dist-info/entry_points.txt,sha256=toWpKCSY1u593MPnI_xW5gnwlnkerP4AvmPQ1s2nPgY,50
171
- fm_weck-1.5.2.dist-info/RECORD,,
168
+ fm_weck-1.5.3.dist-info/METADATA,sha256=m_4VrPdPCvQesR-70_0l0y_wSZf1fROQ01QOoZFpUKo,3339
169
+ fm_weck-1.5.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
170
+ fm_weck-1.5.3.dist-info/entry_points.txt,sha256=toWpKCSY1u593MPnI_xW5gnwlnkerP4AvmPQ1s2nPgY,50
171
+ fm_weck-1.5.3.dist-info/RECORD,,