Squashed 'external/toxcore/c-toxcore/' changes from e29e185c03..f1df709b87
f1df709b87 feat: add ngc events 1b6c907235 refactor: Make event dispatch ordered by receive time. b7f9367f6f test: Upgrade cppcheck, fix some warnings. 766e62bc89 chore: Use `pkg_search_module` directly in cmake. 00ff078f91 cleanup: Use target_link_libraries directly in cmake. c58928cc89 chore: Add `IMPORTED_TARGET` to pkg-config packages. 895a6af122 cleanup: Remove NaCl support. 41dfb1c1c0 fix: unpack enum function names in event impl generator 447666d1a1 chore: Disable targets for cross-compilation. 572924e924 chore: Build a docker image with coverage info in it. 415cb78f5e cleanup: Some portability/warning fixes for Windows builds. 425216d9ec fix: Correct a use-after-free and fix some memory leaks. 4b1cfa3e08 refactor: Change all enum-like `#define` sequences into enums. d3c2704fa9 chore: Fix make_single_file to support core-only. 0ce46b644e refactor: Change the `TCP_PACKET_*` defines into an enum. 22cd38ad50 adopt event impl generation tool to #2392 f31ea1088a add the event impl generation tool 4e603bb613 refactor: Use `enum-from-int` rule from tokstyle. 19d8f180d6 chore: Update github actions `uses`. 6a895be0c7 test: Make esp32 build actually try to instantiate tox. 65d09c9bfb cleanup: Remove test net support. REVERT: e29e185c03 feat: add ngc events git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: f1df709b8792da4c0e946d826b11df77d565064d
This commit is contained in:
@ -39,8 +39,8 @@ _ENV = {
|
||||
}
|
||||
|
||||
|
||||
def run_mallocfail(tmpdir: str, timeout: float, exe: str,
|
||||
iteration: int) -> bool:
|
||||
def run_mallocfail(tmpdir: str, timeout: float, exe: str, iteration: int,
|
||||
keep_going: bool) -> bool:
|
||||
"""Run a program with mallocfail."""
|
||||
print(f"\x1b[1;33mmallocfail '{exe}' run #{iteration}\x1b[0m")
|
||||
hashes = os.path.join(tmpdir, _HASHES)
|
||||
@ -73,7 +73,8 @@ def run_mallocfail(tmpdir: str, timeout: float, exe: str,
|
||||
print(
|
||||
f"\x1b[1;32mProgram '{exe}' failed to handle OOM situation cleanly\x1b[0m"
|
||||
)
|
||||
raise Exception("Aborting test")
|
||||
if not keep_going:
|
||||
raise Exception("Aborting test")
|
||||
|
||||
return True
|
||||
|
||||
@ -95,7 +96,8 @@ def find_prog(name: str) -> Tuple[Optional[str], ...]:
|
||||
return path
|
||||
return None
|
||||
|
||||
return (attempt(f"./unit_{name}_test"), attempt(f"./auto_{name}_test"))
|
||||
return (attempt(f"./unit_{name}_test"),
|
||||
attempt(f"auto_tests/auto_{name}_test"))
|
||||
|
||||
|
||||
def parse_flags(args: List[str]) -> Tuple[Dict[str, str], List[str]]:
|
||||
@ -110,15 +112,19 @@ def parse_flags(args: List[str]) -> Tuple[Dict[str, str], List[str]]:
|
||||
return flags, exes
|
||||
|
||||
|
||||
def loop_mallocfail(tmpdir: str, timeout: float, exe: str) -> None:
|
||||
def loop_mallocfail(tmpdir: str,
|
||||
timeout: float,
|
||||
exe: str,
|
||||
keep_going: bool = False) -> None:
|
||||
i = 1
|
||||
while run_mallocfail(tmpdir, timeout, exe, i):
|
||||
while run_mallocfail(tmpdir, timeout, exe, i, keep_going):
|
||||
i += 1
|
||||
|
||||
|
||||
def isolated_mallocfail(timeout: int, exe: str) -> None:
|
||||
with tempfile.TemporaryDirectory(prefix="mallocfail") as tmpdir:
|
||||
print(f"\x1b[1;33mRunning for {exe} in isolated path {tmpdir}\x1b[0m")
|
||||
os.mkdir(os.path.join(tmpdir, "auto_tests"))
|
||||
shutil.copy(exe, os.path.join(tmpdir, exe))
|
||||
shutil.copy(_HASHES, os.path.join(tmpdir, _HASHES))
|
||||
loop_mallocfail(tmpdir, timeout, exe)
|
||||
@ -149,7 +155,7 @@ def main(args: List[str]) -> None:
|
||||
# such as llvm_gcov_init fail.
|
||||
if os.path.exists(_PRIMER):
|
||||
print(f"\x1b[1;33mPriming hashes with unit_util_test\x1b[0m")
|
||||
loop_mallocfail(".", timeout, _PRIMER)
|
||||
loop_mallocfail(".", timeout, _PRIMER, keep_going=True)
|
||||
|
||||
print(f"\x1b[1;33m--------------------------------\x1b[0m")
|
||||
print(f"\x1b[1;33mStarting mallocfail for {len(exes)} programs:\x1b[0m")
|
||||
|
Reference in New Issue
Block a user