From 695e99329f7cb88d8819c2afa9633afcf8901d50 Mon Sep 17 00:00:00 2001 From: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> Date: Tue, 13 Dec 2022 16:40:06 -0500 Subject: [PATCH] [NFC] Minor SysSan improvements (#9149) --- infra/experimental/SystemSan/Makefile | 4 ++-- infra/experimental/SystemSan/target_dns.cpp | 2 +- infra/presubmit.py | 19 ++++++++++++++++--- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/infra/experimental/SystemSan/Makefile b/infra/experimental/SystemSan/Makefile index 7ca34f1dc..04db9976e 100644 --- a/infra/experimental/SystemSan/Makefile +++ b/infra/experimental/SystemSan/Makefile @@ -1,8 +1,8 @@ .POSIX: CXX = clang++ -CFLAGS = -std=c++17 -Wall -Wextra -O3 -g3 +CFLAGS = -std=c++17 -Wall -Wextra -O3 -g3 -Werror -all: clean SystemSan target target_file target_dns +all: SystemSan target target_file target_dns SystemSan: SystemSan.cpp inspect_dns.cpp inspect_utils.cpp $(CXX) $(CFLAGS) -lpthread -o $@ $^ diff --git a/infra/experimental/SystemSan/target_dns.cpp b/infra/experimental/SystemSan/target_dns.cpp index 22dbc66f7..7d7ef1cee 100644 --- a/infra/experimental/SystemSan/target_dns.cpp +++ b/infra/experimental/SystemSan/target_dns.cpp @@ -30,7 +30,7 @@ extern "C" int LLVMFuzzerTestOneInput(char* data, size_t size) { struct addrinfo *result = NULL; - int s = getaddrinfo(str.c_str(), NULL, NULL, &result); + getaddrinfo(str.c_str(), NULL, NULL, &result); if (result) { freeaddrinfo(result); } diff --git a/infra/presubmit.py b/infra/presubmit.py index 137463a32..82a985cd3 100755 --- a/infra/presubmit.py +++ b/infra/presubmit.py @@ -402,6 +402,14 @@ def run_tests(_=None, parallel=False, build_tests=True, nonbuild_tests=True): return nonbuild_success and build_success +def run_systemsan_tests(_=None): + """Runs SystemSan unit tests.""" + command = ['make', 'test'] + return subprocess.run(command, + cwd='infra/experimental/SystemSan', + check=False).returncode == 0 + + def get_all_files(): """Returns a list of absolute paths of files in this repo.""" get_all_files_command = ['git', 'ls-files'] @@ -413,9 +421,10 @@ def main(): """Check changes on a branch for common issues before submitting.""" # Get program arguments. parser = argparse.ArgumentParser(description='Presubmit script for oss-fuzz.') - parser.add_argument('command', - choices=['format', 'lint', 'license', 'infra-tests'], - nargs='?') + parser.add_argument( + 'command', + choices=['format', 'lint', 'license', 'infra-tests', 'systemsan-tests'], + nargs='?') parser.add_argument('-a', '--all-files', action='store_true', @@ -466,6 +475,10 @@ def main(): nonbuild_tests=(not args.skip_nonbuild_tests)) return bool_to_returncode(success) + if args.command == 'systemsan-tests': + success = run_systemsan_tests(relevant_files) + return bool_to_returncode(success) + # Do all the checks (but no tests). success = do_checks(relevant_files)