28 lines
1.0 KiB
Python
28 lines
1.0 KiB
Python
from pathlib import Path
|
|
import sys
|
|
import unittest
|
|
|
|
ROOT=Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0,str(ROOT/'tools/binary'))
|
|
from collision_response import collect, header, TARGETS
|
|
|
|
|
|
class CollisionResponseTests(unittest.TestCase):
|
|
def test_original_callgraph_bodies_and_constants(self):
|
|
report=collect(ROOT.parent/'Original')
|
|
self.assertEqual(len(report['bodies']),6)
|
|
self.assertAlmostEqual(report['constants']['0x48d974'],.7)
|
|
self.assertAlmostEqual(report['constants']['0x4a3148'],-.7)
|
|
self.assertEqual(report['constants']['0x49b1f8'],-1)
|
|
|
|
def test_probe_relocations_are_bounded_explicit_operands(self):
|
|
report=collect(ROOT.parent/'Original')
|
|
locations=[p['va'] for p in report['probe_operands']]
|
|
self.assertEqual(len(locations),len(set(locations)))
|
|
self.assertGreater(len(locations),40)
|
|
self.assertTrue(all(p['target'] in TARGETS for p in report['probe_operands']))
|
|
self.assertIn('{0x47c0c0, 0x48d104}',header(report))
|
|
|
|
|
|
if __name__=='__main__': unittest.main()
|