Skip to content

Commit 206880e

Browse files
Implement fuzzing for Boolean and integer parameters (#765)
* Move implementation of call config generation into `kmir.kast` * Add method `make_call_config` to `KMIR` with parameter `mode` to select between concrete, symbolic, and a newly added random mode * Implement random argument generation for parameters of Boolean and integer types * Many small refactorings in call config generation --------- Co-authored-by: Jost Berthold <jost.berthold@gmail.com>
1 parent 64f12f0 commit 206880e

26 files changed

Lines changed: 1728 additions & 83 deletions

kmir/src/kmir/cargo.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from .smir import SMIRInfo
1616

1717
if TYPE_CHECKING:
18+
from collections.abc import Iterable
1819
from typing import Any, Final
1920

2021
_LOGGER: Final = logging.getLogger(__name__)
@@ -167,10 +168,20 @@ def default_target(self) -> str:
167168
return bin_targets[0]
168169

169170

170-
def cargo_get_smir_json(rs_file: Path, save_smir: bool = False) -> dict[str, Any]:
171-
command = [str(stable_mir_json()), '-Zno-codegen', str(rs_file.resolve())]
172-
smir_json_result = Path.cwd() / rs_file.with_suffix('.smir.json').name
173-
run_process_2(command)
171+
def cargo_get_smir_json(
172+
rs_file: Path,
173+
*,
174+
flags: Iterable[str] | None = None,
175+
cwd: Path | None = None,
176+
save_smir: bool = False,
177+
) -> dict[str, Any]:
178+
command = [str(stable_mir_json()), '-Zno-codegen']
179+
command += flags or []
180+
command.append(str(rs_file.resolve()))
181+
182+
cwd = cwd or Path.cwd()
183+
smir_json_result = cwd / rs_file.with_suffix('.smir.json').name
184+
run_process_2(command, cwd=cwd)
174185
json_smir = json.loads(smir_json_result.read_text())
175186
_LOGGER.info(f'Loaded: {smir_json_result}')
176187
if save_smir:

0 commit comments

Comments
 (0)