|
2 | 2 |
|
3 | 3 |
|
4 | 4 | from collections import defaultdict |
| 5 | +from enum import Enum |
5 | 6 | from importlib.machinery import ModuleSpec |
6 | 7 | from importlib.util import find_spec |
7 | 8 | import logging |
@@ -231,6 +232,49 @@ def on_after_set_output_dir(cls, value: Path | None) -> Path | None: |
231 | 232 | return value |
232 | 233 |
|
233 | 234 |
|
| 235 | +class _CommandOracleOutputTypes(Enum): |
| 236 | + PYTEST = "PYTEST" |
| 237 | + |
| 238 | + |
| 239 | +class CommandOracleConfig(BaseModel): |
| 240 | + """Configures the command-based verifier.""" |
| 241 | + |
| 242 | + cmd: str = Field( |
| 243 | + default="", |
| 244 | + description=( |
| 245 | + "The command to run to verify the files. The following" |
| 246 | + "variables are supported:\n" |
| 247 | + "1. {files} - Represents the source files." |
| 248 | + "2. {includes} - Represents the include directories." |
| 249 | + ), |
| 250 | + ) |
| 251 | + |
| 252 | + exit_success: int = Field( |
| 253 | + default=0, |
| 254 | + description=("The exit code expected when the command runs successfully."), |
| 255 | + ) |
| 256 | + |
| 257 | + parser: _CommandOracleOutputTypes | None = Field( |
| 258 | + default=None, |
| 259 | + description=( |
| 260 | + "The type of verifier output to expect. Current options: " |
| 261 | + f"{", ".join(t.value for t in _CommandOracleOutputTypes)}" |
| 262 | + ), |
| 263 | + ) |
| 264 | + |
| 265 | + @field_validator("parser", mode="before") |
| 266 | + @classmethod |
| 267 | + def on_set_parser(cls, value: str | None) -> _CommandOracleOutputTypes | None: |
| 268 | + if not value: |
| 269 | + return None |
| 270 | + |
| 271 | + value_upper: str = value.upper() |
| 272 | + if value_upper in _CommandOracleOutputTypes: |
| 273 | + return _CommandOracleOutputTypes(value_upper) |
| 274 | + |
| 275 | + raise ValueError(f"Invalid parser set: {value}") |
| 276 | + |
| 277 | + |
234 | 278 | class ESBMCConfig(BaseModel): |
235 | 279 | """ESBMC-specific configuration. |
236 | 280 |
|
@@ -287,6 +331,11 @@ class VerifierConfig(BaseModel): |
287 | 331 | "This is not supported by all verifiers.", |
288 | 332 | ) |
289 | 333 |
|
| 334 | + command_oracle: CommandOracleConfig = Field( |
| 335 | + default_factory=CommandOracleConfig, |
| 336 | + description='Command oracle "command-oracle" specific configuration.', |
| 337 | + ) |
| 338 | + |
290 | 339 | esbmc: ESBMCConfig = Field( |
291 | 340 | default_factory=ESBMCConfig, |
292 | 341 | description="ESBMC-specific configuration.", |
|
0 commit comments