Recover Rocketship flight components against original-code probes
This commit is contained in:
1 parent
c6eb1861cd
commit
a274670fe8
23 files changed
+2462
-2
No files matched your search
@@ -0,0 +1,49 @@
|
||||
"""Original source identity/ABI guards and rejected component-capture ingestion."""
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT/'tools/binary'))
|
||||
from rocketship import collect, probe_results
|
||||
|
||||
|
||||
class RocketSourceTests(unittest.TestCase):
|
||||
def test_original_spans_and_pointer_bases(self):
|
||||
report = collect(ROOT.parent/'Original')
|
||||
self.assertEqual(len(report['bodies']), 10)
|
||||
self.assertEqual(len(report['vtables']), 6)
|
||||
self.assertEqual(report['rider_pointer'], 'complete rocket+740 = game interface+680')
|
||||
self.assertEqual(report['radius'], 50)
|
||||
self.assertEqual(report['item'], report['raw_mode'])
|
||||
self.assertTrue(all(int(b['va'], 16)-int(b['file_offset'], 16) == 0x400000
|
||||
for b in report['bodies']))
|
||||
self.assertTrue(any(v['table'] == '0x4cdd30' and v['slot'] == '0x134'
|
||||
and v['target'] == '0x475cd0' for v in report['vtables']))
|
||||
|
||||
def test_changed_executable_is_rejected(self):
|
||||
data = bytearray((ROOT.parent/'Original/Neutron.exe').read_bytes())
|
||||
data[0x1a8dc] ^= 1
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
path = Path(temp)/'Neutron.exe'
|
||||
path.write_bytes(data)
|
||||
with self.assertRaisesRegex(ValueError, 'identity'):
|
||||
collect(Path(temp))
|
||||
|
||||
def test_missing_or_repeated_original_samples_are_rejected(self):
|
||||
report = collect(ROOT.parent/'Original')
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
log = Path(temp)/'wine.log'
|
||||
executable = Path(temp)/'absent.exe'
|
||||
log.write_text('CASE up_air speed=400\n')
|
||||
with self.assertRaisesRegex(ValueError, 'Incomplete'):
|
||||
probe_results(report, log, executable)
|
||||
line = 'CASE up_air speed=400 bank=0 keyboard=0 up=1 down=0 dest=20,0,0\n'
|
||||
log.write_text(line*2+'ROCKET_INPUT_COMPONENT_COMPLETE:\n')
|
||||
with self.assertRaisesRegex(ValueError, 'repeated'):
|
||||
probe_results(report, log, executable)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user