18 lines
1.5 KiB
Python
18 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
from __future__ import annotations
|
|
import argparse,json,unittest
|
|
from pathlib import Path
|
|
P=argparse.ArgumentParser();P.add_argument("--root",type=Path,required=True);R=P.parse_args().root
|
|
class Tests(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):cls.m=json.loads((R/"manifests/retroarch/phase-1.0dm-bounded-snapshot-observer.json").read_text())
|
|
def test_wx_closed(self):self.assertEqual(self.m["static_elf"]["load_segment_flags"],["RE","RW","RW"]);self.assertFalse(self.m["static_elf"]["writable_executable_segment_present"])
|
|
def test_read_only_bounded(self):
|
|
c=self.m["target_contract"];self.assertEqual(c["open_flags"],["O_RDONLY","O_CLOEXEC","O_NOFOLLOW"]);self.assertEqual((c["maximum_snapshot_bytes"],c["total_alarm_seconds"]),(67108864,20));self.assertFalse(c["socket_creation"] or c["connect"] or c["listener"] or c["filesystem_write"] or c["retry"])
|
|
def test_reproducible_inactive_artifact(self):
|
|
a=self.m["artifact"];self.assertTrue(a["two_consecutive_build_hashes_equal"]);self.assertFalse(a["execution_eligible"] or a["transfer_eligible"] or a["installation_eligible"])
|
|
def test_gates_open(self):self.assertFalse(any(self.m["remaining_gates"].values()))
|
|
def test_next(self):self.assertFalse(self.m["decision"]["device_action_allowed"]);self.assertEqual(self.m["decision"]["next_step"],"INACTIVE_ONE_SHOT_STREAM_RECEIVER_AND_ACTIVATION_GATE")
|
|
if __name__=="__main__":unittest.main(argv=[__file__])
|