Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test_prog_always_return_42 from erroring in pytest #59

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions tests/test_ebpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@
TEST_PROGRAMS_BASE = Path(__file__).parent.parent / "test_programs" / "ebpf"


def test_prog_always_returns_42(filename: str) -> None:
proj = angr.Project(TEST_PROGRAMS_BASE / filename)
assert isinstance(proj.arch, ArchExtendedBPF)

state = proj.factory.entry_state()
simgr = proj.factory.simgr(state)
simgr.run()
class TestEbpf(unittest.TestCase):
@staticmethod
def _test_prog_always_returns_42(filename: str) -> None:
proj = angr.Project(TEST_PROGRAMS_BASE / filename)
assert isinstance(proj.arch, ArchExtendedBPF)

assert len(simgr.deadended) == 1
assert state.solver.eval_exact(simgr.deadended[0].regs.R0, 1) == [42]
state = proj.factory.entry_state()
simgr = proj.factory.simgr(state)
simgr.run()

assert len(simgr.deadended) == 1
assert state.solver.eval_exact(simgr.deadended[0].regs.R0, 1) == [42]

class TestEbpf(unittest.TestCase):
# pylint:disable=missing-class-docstring,no-self-use
def test_trivial_return(self):
test_prog_always_returns_42("return_42.o")
self._test_prog_always_returns_42("return_42.o")

def test_branched_return(self):
test_prog_always_returns_42("return_if.o")
self._test_prog_always_returns_42("return_if.o")

def test_get_ns(self):
test_prog_always_returns_42("get_ns.o")
self._test_prog_always_returns_42("get_ns.o")

def test_ebpf_lift(self):
proj = angr.Project(TEST_PROGRAMS_BASE / "return_42.o")
Expand Down
Loading