Squashed 'external/toxcore/c-toxcore/' changes from 8f0d505f9a..6d634674a9

6d634674a9 cleanup: Remove old type-ordered event getters.
d1d48d1dfc feat: add ngc events
994ffecc6b refactor: Make event dispatch ordered by receive time.
812f931d5f fix: Make sure there's enough space for CONSUME1 in fuzzers.
50f1b30fa9 test: Add fuzz tests to the coverage run.
df76f5cf47 chore: Move from gcov to llvm source-based coverage.
072e3beb3f fix: issues with packet broadcast error reporting
6b6718e4d2 cleanup: Make group packet entry creation less error-prone
5b9c420ce1 refactor: packet broadcast functions now return errors
af4cb31028 refactor: Use `operator==` for equality tests of `Node_format`.
9592d590cf refactor(test): Slightly nicer C++ interface to tox Random.
c66e10fb7a refactor: Minor refactoring of get_close_nodes functions.
ebc9643862 fix: don't pass garbage data buffer to packet send functions
32b68cffca cleanup: Some more test cleanups, removing overly smart code.
0426624dcb refactor: Assign malloc return to a local variable first.
afc38f2458 test: Add more unit tests for `add_to_list`.
05ce5c1ab9 test: Add "infer" CI check to github, remove from circle.
REVERT: 8f0d505f9a feat: add ngc events
REVERT: 9b8216e70c refactor: Make event dispatch ordered by receive time.

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: 6d634674a929edb0ab70689dcbcb195b3547be13
This commit is contained in:
2024-01-12 21:30:48 +01:00
parent 9ace11a0e2
commit 8eb4892b49
126 changed files with 1556 additions and 2484 deletions

View File

@ -27,11 +27,12 @@ from typing import NoReturn
from typing import Optional
from typing import Tuple
_PRIMER = "./unit_util_test"
_PRIMER = "auto_tests/auto_version_test"
_MALLOCFAIL_SO = "/usr/local/lib/mallocfail.so"
_HASHES = "mallocfail_hashes"
_HASHES_PREV = "mallocfail_hashes.prev"
_TIMEOUT = 3.0
_BUILD_DIR = os.getcwd()
_ENV = {
"LD_PRELOAD": _MALLOCFAIL_SO,
@ -45,10 +46,19 @@ def run_mallocfail(tmpdir: str, timeout: float, exe: str, iteration: int,
print(f"\x1b[1;33mmallocfail '{exe}' run #{iteration}\x1b[0m")
hashes = os.path.join(tmpdir, _HASHES)
hashes_prev = os.path.join(tmpdir, _HASHES_PREV)
profraw = os.path.join(_BUILD_DIR, "mallocfail.out", exe, "%p.profraw")
if os.path.exists(hashes):
shutil.copy(hashes, hashes_prev)
try:
proc = subprocess.run([exe], timeout=timeout, env=_ENV, cwd=tmpdir)
proc = subprocess.run(
[exe],
timeout=timeout,
env={
"LLVM_PROFILE_FILE": profraw,
**_ENV,
},
cwd=tmpdir,
)
except subprocess.TimeoutExpired:
print(f"\x1b[1;34mProgram {exe} timed out\x1b[0m")
return True
@ -65,13 +75,16 @@ def run_mallocfail(tmpdir: str, timeout: float, exe: str, iteration: int,
# Process exited cleanly (success or failure).
pass
elif proc.returncode == -6:
# Assertion failed.
# abort(), we allow it.
pass
elif proc.returncode == 7:
# ck_assert failed, also fine for us.
pass
elif proc.returncode == -14:
print(f"\x1b[0;34mProgram '{exe}' timed out\x1b[0m")
else:
print(
f"\x1b[1;32mProgram '{exe}' failed to handle OOM situation cleanly\x1b[0m"
f"\x1b[1;32mProgram '{exe}' failed to handle OOM situation cleanly (code {proc.returncode})\x1b[0m"
)
if not keep_going:
raise Exception("Aborting test")
@ -96,8 +109,8 @@ def find_prog(name: str) -> Tuple[Optional[str], ...]:
return path
return None
return (attempt(f"./unit_{name}_test"),
attempt(f"auto_tests/auto_{name}_test"))
return (attempt(f"auto_tests/auto_{name}_test"),
) # attempt(f"./unit_{name}_test"),
def parse_flags(args: List[str]) -> Tuple[Dict[str, str], List[str]]:
@ -128,6 +141,9 @@ def isolated_mallocfail(timeout: int, exe: str) -> None:
shutil.copy(exe, os.path.join(tmpdir, exe))
shutil.copy(_HASHES, os.path.join(tmpdir, _HASHES))
loop_mallocfail(tmpdir, timeout, exe)
profraw = os.path.join(tmpdir, "default.profraw")
if os.path.exists(profraw):
shutil.copy(profraw, exe + ".mallocfail.profraw")
def main(args: List[str]) -> None:
@ -150,12 +166,12 @@ def main(args: List[str]) -> None:
else:
jobs = 1
# Start by running util_test, which allocates no memory of its own, just
# Start by running version_test, which allocates no memory of its own, just
# to prime the mallocfail hashes so it doesn't make global initialisers
# 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, keep_going=True)
print(f"\x1b[1;33mPriming hashes with {_PRIMER}\x1b[0m")
loop_mallocfail(os.getcwd(), timeout, _PRIMER, keep_going=True)
print(f"\x1b[1;33m--------------------------------\x1b[0m")
print(f"\x1b[1;33mStarting mallocfail for {len(exes)} programs:\x1b[0m")