diff options
| author | Donald Sharp <donaldsharp72@gmail.com> | 2022-11-03 08:54:09 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-03 08:54:09 -0400 |
| commit | d7cde18c63c4eef83e12f562aa025cf1dbeaee05 (patch) | |
| tree | 591e68540bb026cfe9f212a69c150bfcfa8bbf36 /python/test_xrelfo.py | |
| parent | 70f29b9f7bf157cd439518cba0ecd52efcf22429 (diff) | |
| parent | 6c7bc49428b594e0747af9813b4c510bd2817f4e (diff) | |
Merge pull request #12196 from opensourcerouting/xref-vtysh
*: rewrite `extract.pl` using `xref` infra
Diffstat (limited to 'python/test_xrelfo.py')
| -rw-r--r-- | python/test_xrelfo.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/python/test_xrelfo.py b/python/test_xrelfo.py index 3ae24ea7b3..3379959dc1 100644 --- a/python/test_xrelfo.py +++ b/python/test_xrelfo.py @@ -22,20 +22,21 @@ import pytest from pprint import pprint root = os.path.dirname(os.path.dirname(__file__)) -sys.path.append(os.path.join(root, 'python')) +sys.path.append(os.path.join(root, "python")) import xrelfo from clippy import elf, uidhash + def test_uidhash(): - assert uidhash.uidhash("lib/test_xref.c", "logging call", 3, 0) \ - == 'H7KJB-67TBH' + assert uidhash.uidhash("lib/test_xref.c", "logging call", 3, 0) == "H7KJB-67TBH" + def test_xrelfo_other(): for data in [ - elf.ELFNull(), - elf.ELFUnresolved('somesym', 0), - ]: + elf.ELFNull(), + elf.ELFUnresolved("somesym", 0), + ]: dissect = xrelfo.XrefPtr(data) print(repr(dissect)) @@ -43,9 +44,10 @@ def test_xrelfo_other(): with pytest.raises(AttributeError): dissect.xref + def test_xrelfo_obj(): xrelfo_ = xrelfo.Xrelfo() - edf = xrelfo_.load_elf(os.path.join(root, 'lib/.libs/zclient.o'), 'zclient.lo') + edf = xrelfo_.load_elf(os.path.join(root, "lib/.libs/zclient.o"), "zclient.lo") xrefs = xrelfo_._xrefs with pytest.raises(elf.ELFAccessError): @@ -54,12 +56,13 @@ def test_xrelfo_obj(): pprint(xrefs[0]) pprint(xrefs[0]._data) + def test_xrelfo_bin(): xrelfo_ = xrelfo.Xrelfo() - edf = xrelfo_.load_elf(os.path.join(root, 'lib/.libs/libfrr.so'), 'libfrr.la') + edf = xrelfo_.load_elf(os.path.join(root, "lib/.libs/libfrr.so"), "libfrr.la") xrefs = xrelfo_._xrefs - assert edf[0:4] == b'\x7fELF' + assert edf[0:4] == b"\x7fELF" pprint(xrefs[0]) pprint(xrefs[0]._data) |
