Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions cle/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def __setitem__(self, k, v):
def __contains__(self, k):
raise NotImplementedError

def __iter__(self):
raise NotImplementedError

def load(self, addr, n):
raise NotImplementedError

Expand Down
30 changes: 30 additions & 0 deletions tests/test_clemory_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from __future__ import annotations

import os

import cle

test_location = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", "binaries", "tests")


def test_clemory_views_refuse_iteration():
loader = cle.Loader(os.path.join(test_location, "x86_64", "fauxware"), auto_load_libs=False)
memory = loader.memory
start = memory.min_addr

for view in (
cle.ClemoryView(memory, start, start + 0x100),
cle.ClemoryTranslator(memory, lambda addr: addr + start),
cle.ClemoryReadOnlyView(loader.main_object.arch, memory),
):
try:
iter(view)
except NotImplementedError:
continue
raise AssertionError(f"{type(view).__name__} still falls back to the sequence protocol")

assert len(list(memory)) == sum(len(backer) for _, backer in memory.backers())


if __name__ == "__main__":
test_clemory_views_refuse_iteration()
Loading