From 4c430bcebcb2a708fb4bf8a66e75939f8b3530bd Mon Sep 17 00:00:00 2001 From: DepressedTWM Date: Fri, 31 Jul 2026 20:38:42 +0400 Subject: [PATCH] CMake changes and simple testing system --- CMakeLists.txt | 9 +++++++-- tests.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 tests.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 4852edd..17223fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -324,12 +324,17 @@ else() endif() if(SANITIZERS) - set(SANITIZERS "address,undefined,leak,shift,shift-base,shift-exponent,integer-divide-by-zero,unreachable,vla-bound,null,signed-integer-overflow,bounds,bounds-strict,alignment,object-size,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr,pointer-overflow,builtin,pointer-subtract,pointer-compare") + set(SANITIZERS "undefined,leak,shift,shift-base,shift-exponent,integer-divide-by-zero,unreachable,vla-bound,null,signed-integer-overflow,bounds,bounds-strict,alignment,object-size,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr,pointer-overflow,builtin,pointer-subtract,pointer-compare") add_compile_options(-fsanitize=${SANITIZERS}) add_link_options(-fsanitize=${SANITIZERS}) endif() if(DEBUG) - add_compile_options(-g3 -fno-omit-frame-pointer) + add_compile_options( + -g3 + -fno-omit-frame-pointer + -Og + -Wall + -Wextra) else() add_compile_options( -O2 diff --git a/tests.sh b/tests.sh new file mode 100644 index 0000000..12125da --- /dev/null +++ b/tests.sh @@ -0,0 +1,33 @@ +#!/bin/bash +set -euo pipefail +FASTERER_PATH="$1" + +check_file() { + local f="$1" + + case "$f" in + *.c|*.cc|*.cpp|*.cxx) + cppcheck --check-level=exhaustive --disable=missingInclude --enable=all --force -q -I . "$f" \ + || echo "cppcheck is not installed or reported issues for: $f" + + gcc -fanalyzer -Wall -Wextra -Wpedantic -std=c11 -c "$f" -o /dev/null 2>/dev/null \ + || echo "gcc is not installed or analyzer reported issues for: $f" + + cbmc "$f" \ + || echo "cbmc is not installed or reported issues for: $f" + ;; + *.h|*.hh|*.hpp|*.hxx) + cppcheck --check-level=exhaustive --enable=all --disable=missingInclude -q "$f" \ + || echo "cppcheck is not installed or reported issues for header: $f" + ;; + esac +} +export -f check_file + +find . -type f \( \ + -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.cxx' \ + -o -name '*.h' -o -name '*.hh' -o -name '*.hpp' -o -name '*.hxx' \ +\) -print0 \ +| xargs -0 -n 1 bash -c 'check_file "$1"' _ + +find . | grep .rb | $FASTERER_PATH