drgn/tests/test_platform.py
Omar Sandoval d60c6a1d68 libdrgn: add register information to platform
In order to retrieve registers from stack traces, we need to know what
registers are defined for a platform. This adds a small DSL for defining
registers for an architecture. The DSL is parsed by an awk script that
generates the necessary tables, lookup functions, and enum definitions.
2019-10-18 14:33:02 -07:00

17 lines
505 B
Python

import unittest
from drgn import Architecture, Platform, PlatformFlags
class TestPlatform(unittest.TestCase):
def test_default_flags(self):
Platform(Architecture.X86_64)
self.assertRaises(ValueError, Platform, Architecture.UNKNOWN)
def test_registers(self):
self.assertIn(
'rax',
(reg.name for reg in Platform(Architecture.X86_64).registers))
self.assertEqual(
Platform(Architecture.UNKNOWN, PlatformFlags(0)).registers, ())