summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/format/symbol.py43
1 files changed, 37 insertions, 6 deletions
diff --git a/tests/format/symbol.py b/tests/format/symbol.py
index 6c4f573..fed4133 100644
--- a/tests/format/symbol.py
+++ b/tests/format/symbol.py
@@ -17,7 +17,7 @@ class TestBinarySymbols(ChrysalideTestCase):
def testSymbolProperties(self):
"""Validate the basic properties of symbols."""
- saddr = vmpa(0x10, vmpa.VMPA_NO_VIRTUAL)
+ saddr = vmpa(0x10, vmpa.VmpaSpecialValue.NO_VIRTUAL)
srange = mrange(saddr, 0x3)
symbol = BinSymbol(srange, BinSymbol.SymbolType.ENTRY_POINT)
@@ -53,7 +53,7 @@ class TestBinarySymbols(ChrysalideTestCase):
def testSymbolDefaultStatus(self):
"""Validate the default status for symbols."""
- saddr = vmpa(0x10, vmpa.VMPA_NO_VIRTUAL)
+ saddr = vmpa(0x10, vmpa.VmpaSpecialValue.NO_VIRTUAL)
srange = mrange(saddr, 0x3)
symbol = BinSymbol(srange, BinSymbol.SymbolType.ENTRY_POINT)
@@ -62,18 +62,49 @@ class TestBinarySymbols(ChrysalideTestCase):
self.assertEqual(str(symbol.status), 'SymbolStatus.INTERNAL')
+ def testSymbolFlags(self):
+ """Play with symbol flags."""
+
+ saddr = vmpa(0x10, vmpa.VmpaSpecialValue.NO_VIRTUAL)
+ srange = mrange(saddr, 0x3)
+ symbol = BinSymbol(srange, BinSymbol.SymbolType.ENTRY_POINT)
+
+ self.assertEqual(symbol.flags, BinSymbol.SymbolFlag.NONE)
+
+ ret = symbol.set_flag(BinSymbol.SymbolFlag.NONE)
+ self.assertTrue(ret)
+
+ ret = symbol.has_flag(BinSymbol.SymbolFlag.NONE)
+ self.assertFalse(ret)
+
+ ret = symbol.unset_flag(BinSymbol.SymbolFlag.NONE)
+ self.assertFalse(ret)
+
+ ret = symbol.set_flag(BinSymbol.SymbolFlag.PREFIXED_NAME)
+ self.assertTrue(ret)
+
+ ret = symbol.has_flag(BinSymbol.SymbolFlag.PREFIXED_NAME)
+ self.assertTrue(ret)
+
+ ret = symbol.unset_flag(BinSymbol.SymbolFlag.PREFIXED_NAME)
+ self.assertTrue(ret)
+
+ ret = symbol.has_flag(BinSymbol.SymbolFlag.PREFIXED_NAME)
+ self.assertFalse(ret)
+
+
def testSymbolComparison(self):
"""Compare symbols and check the result."""
- saddr = vmpa(0x100, vmpa.VMPA_NO_VIRTUAL)
+ saddr = vmpa(0x100, vmpa.VmpaSpecialValue.NO_VIRTUAL)
srange = mrange(saddr, 0x3)
symbol0 = BinSymbol(srange, BinSymbol.SymbolType.ENTRY_POINT)
- saddr = vmpa(0x10, vmpa.VMPA_NO_VIRTUAL)
+ saddr = vmpa(0x10, vmpa.VmpaSpecialValue.NO_VIRTUAL)
srange = mrange(saddr, 0x3)
symbol1 = BinSymbol(srange, BinSymbol.SymbolType.ENTRY_POINT)
- saddr = vmpa(0x100, vmpa.VMPA_NO_VIRTUAL)
+ saddr = vmpa(0x100, vmpa.VmpaSpecialValue.NO_VIRTUAL)
srange = mrange(saddr, 0x30)
symbol2 = BinSymbol(srange, BinSymbol.SymbolType.ENTRY_POINT)
@@ -93,7 +124,7 @@ class TestBinarySymbols(ChrysalideTestCase):
def _get_label(self):
return 'AAA'
- saddr = vmpa(0x100, vmpa.VMPA_NO_VIRTUAL)
+ saddr = vmpa(0x100, vmpa.VmpaSpecialValue.NO_VIRTUAL)
srange = mrange(saddr, 0x3)
symbol = MySymbol(srange, BinSymbol.SymbolType.ENTRY_POINT)