diff options
| author | Peter LaFosse <peter@vector35.com> | 2018-11-08 09:58:36 -0500 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2018-11-13 11:07:27 -0500 |
| commit | d8ff0a6324fe92ccafe296298409c50cc4b526fa (patch) | |
| tree | c5bf8cdf43902d3122a6747d5c42d9197afc0808 /suite | |
| parent | 9df7c7c621c82e6caa7a09c4273e4feba86277f2 (diff) | |
Add expression parsing APIs
Add text-based and constant-based searching
Diffstat (limited to 'suite')
| -rw-r--r-- | suite/testcommon.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/suite/testcommon.py b/suite/testcommon.py index ae5ed863..fe7b69d5 100644 --- a/suite/testcommon.py +++ b/suite/testcommon.py @@ -377,7 +377,7 @@ class BinaryViewTestBuilder(Builder): class TestBuilder(Builder): - """ The TestBuilder is for tests that need to be checked againsttest_BinaryView + """ The TestBuilder is for tests that need to be checked against a stored oracle data that isn't from a binary. These test are generated on your local machine then run again on the build machine to verify correctness. @@ -791,6 +791,27 @@ class VerifyBuilder(Builder): def get_comments(self, bv): return bv.functions[0].comments + def test_expression_parse(self): + file_name = self.unpackage_file("helloworld") + try: + bv = binja.BinaryViewType.get_view_of_file(file_name) + assert bv.parse_expression("1 + 1") == 2 + assert bv.parse_expression("-1 + 1") == 0 + assert bv.parse_expression("1 - 1") == 0 + assert bv.parse_expression("1 + -1") == 0 + assert bv.parse_expression("[0x8000]") == 0x464c457f + assert bv.parse_expression("[0x8000]b") == 0 + assert bv.parse_expression("[0x8000].b") == 0x7f + assert bv.parse_expression("[0x8000].w") == 0x457f + assert bv.parse_expression("[0x8000].d") == 0x464c457f + assert bv.parse_expression("[0x8000].q") == 0x10101464c457f + assert bv.parse_expression("$here + 1", 12345) == 12345 + 1 + assert bv.parse_expression("_start") == 0x830c + assert bv.parse_expression("_start + 4") == 0x8310 + return True + finally: + self.delete_package("helloworld") + def test_verify_BNDB_round_trip(self): """Binary Ninja Database output doesn't match its input""" # This will test Binja's ability to save and restore databases |
