Model terminal interaction authority and bounded verification
This commit is contained in:
parent
690738d846
commit
6d3a2cfe16
1 changed files with 785 additions and 14 deletions
|
|
@ -703,18 +703,89 @@ class VerificationTests(unittest.TestCase):
|
|||
|
||||
def test_model_paths_are_current_and_complete(self) -> None:
|
||||
self.assertEqual(
|
||||
{module.name for module, _ in VERIFY.MODEL_CONFIGURATIONS},
|
||||
{
|
||||
"IgnoredWorkspaceHardlinkRouting.tla",
|
||||
"IgnoredWorkspaceRouting.tla",
|
||||
"Lazaret.tla",
|
||||
"PreparedLower.tla",
|
||||
(module.name, config.name)
|
||||
for module, config in VERIFY.MODEL_CONFIGURATIONS
|
||||
},
|
||||
{
|
||||
(
|
||||
"IgnoredWorkspaceHardlinkRouting.tla",
|
||||
"IgnoredWorkspaceHardlinkRouting.cfg",
|
||||
),
|
||||
("IgnoredWorkspaceRouting.tla", "IgnoredWorkspaceRouting.cfg"),
|
||||
("Lazaret.tla", "Lazaret.cfg"),
|
||||
("Lazaret.tla", "LazaretTerminalLocalControl.cfg"),
|
||||
("Lazaret.tla", "LazaretTerminalPeerIsolation.cfg"),
|
||||
("Lazaret.tla", "LazaretTerminalSafety.cfg"),
|
||||
("PreparedLower.tla", "PreparedLower.cfg"),
|
||||
},
|
||||
)
|
||||
for module, config in VERIFY.MODEL_CONFIGURATIONS:
|
||||
self.assertTrue(module.is_file())
|
||||
self.assertTrue(config.is_file())
|
||||
|
||||
def test_model_metadata_directories_are_unique_per_configuration(self) -> None:
|
||||
commands = []
|
||||
manager = mock.MagicMock()
|
||||
manager.__enter__.return_value = "/verification"
|
||||
manager.__exit__.return_value = False
|
||||
with (
|
||||
mock.patch.object(VERIFY.shutil, "which", return_value="/usr/bin/tlc"),
|
||||
mock.patch.object(VERIFY, "temporary_directory", return_value=manager),
|
||||
mock.patch.object(
|
||||
VERIFY,
|
||||
"run",
|
||||
side_effect=lambda command, cwd: commands.append(command),
|
||||
),
|
||||
):
|
||||
VERIFY.run_models()
|
||||
|
||||
self.assertEqual(
|
||||
[
|
||||
(
|
||||
Path(command[-1]).name,
|
||||
Path(command[command.index("-config") + 1]).name,
|
||||
)
|
||||
for command in commands
|
||||
],
|
||||
[
|
||||
(module.name, config.name)
|
||||
for module, config in VERIFY.MODEL_CONFIGURATIONS
|
||||
],
|
||||
)
|
||||
metadata = [command[command.index("-metadir") + 1] for command in commands]
|
||||
self.assertEqual(len(metadata), len(set(metadata)))
|
||||
self.assertEqual(
|
||||
[Path(path).name for path in metadata],
|
||||
[
|
||||
f"{module.stem}-{config.stem}"
|
||||
for module, config in VERIFY.MODEL_CONFIGURATIONS
|
||||
],
|
||||
)
|
||||
|
||||
def test_lazaret_terminal_configs_retain_common_constants(self) -> None:
|
||||
configs = [
|
||||
ROOT / "docs/protocol/Lazaret.cfg",
|
||||
ROOT / "docs/protocol/LazaretTerminalSafety.cfg",
|
||||
ROOT / "docs/protocol/LazaretTerminalPeerIsolation.cfg",
|
||||
ROOT / "docs/protocol/LazaretTerminalLocalControl.cfg",
|
||||
]
|
||||
prefixes = {
|
||||
config.read_text().partition(" TerminalEventPlan <-")[0]
|
||||
for config in configs
|
||||
}
|
||||
self.assertEqual(len(prefixes), 1)
|
||||
|
||||
def test_lazaret_full_event_safety_retains_canonical_invariants(self) -> None:
|
||||
def invariants(config: Path) -> tuple[str, ...]:
|
||||
body = config.read_text().split("INVARIANTS\n", 1)[1]
|
||||
return tuple(body.split("\n\n", 1)[0].split())
|
||||
|
||||
self.assertEqual(
|
||||
invariants(ROOT / "docs/protocol/LazaretTerminalSafety.cfg"),
|
||||
invariants(ROOT / "docs/protocol/Lazaret.cfg"),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Reference in a new issue