From 22f969652287f5e5206f26a8f0b6280495c05bdd Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Mon, 23 Jun 2025 03:22:30 -0500 Subject: [PATCH] Fix/hcqfuzz harnesss bug (#10923) * update command so extra module is found * fix empty range in randrange errors * lint --- extra/hcqfuzz/readme | 4 ++-- test/external/external_fuzz_ampt.py | 3 ++- test/external/external_fuzz_tlsf.py | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/extra/hcqfuzz/readme b/extra/hcqfuzz/readme index d3176f453d..df1668b068 100644 --- a/extra/hcqfuzz/readme +++ b/extra/hcqfuzz/readme @@ -4,9 +4,9 @@ To add a new test, define a `TestSpec`-based class in a file in the `tests/` fol You can choose which tests to load from which file: ```bash -RUN_FILES="hcq,allocator" python3 extra/hcqfuzz/fuzzer.py +PYTHONPATH=. RUN_FILES="hcq,allocator" python3 extra/hcqfuzz/fuzzer.py ``` Or skip tests from any file: ```bash -SKIP_FILES="allocator" python3 extra/hcqfuzz/fuzzer.py +PYTHONPATH=. SKIP_FILES="allocator" python3 extra/hcqfuzz/fuzzer.py ``` diff --git a/test/external/external_fuzz_ampt.py b/test/external/external_fuzz_ampt.py index e605f14895..d359599375 100644 --- a/test/external/external_fuzz_ampt.py +++ b/test/external/external_fuzz_ampt.py @@ -1,4 +1,5 @@ import random +from typing import Optional from tinygrad.helpers import round_up from tinygrad.runtime.support.am.amdev import AMPageTableTraverseContext from test.external.external_test_am import helper_read_entry_components, FakeAM @@ -59,7 +60,7 @@ class AMPTFuzzer: return True - def random_alloc(self): + def random_alloc(self) -> Optional[int]: if self.total_size - self.alloc_payload < self.min_alloc_size: return None size = random.randint(self.min_alloc_size, min(self.max_alloc_size, self.total_size - self.alloc_payload)) diff --git a/test/external/external_fuzz_tlsf.py b/test/external/external_fuzz_tlsf.py index 66eb85ca90..029c9bee9d 100644 --- a/test/external/external_fuzz_tlsf.py +++ b/test/external/external_fuzz_tlsf.py @@ -30,6 +30,8 @@ class AllocatorFuzzer: return True def random_alloc(self) -> Optional[int]: + if self.total_size - self.alloc_payload < self.min_alloc_size: return None + size = random.randint(self.min_alloc_size, min(self.max_alloc_size, self.total_size - self.alloc_payload)) try: