8f77395b58
Add unit tests for previously untested modules (protocol, data, metadata, file, glob), robustness tests for deserialization of malformed inputs, thread safety stress tests, property-based roundtrip tests, and 6 fuzz targets. Update CI with CTest integration, coverage reporting, and valgrind memory checking. New test files: - test_data.c: Data type lifecycle (5 tests) - test_protocol.c: Protocol I/O roundtrips and error paths (9 tests) - test_metadata.c: Metadata serialization roundtrips (6 tests) - test_file.c: File operations and send/receive (12 tests) - test_glob.c: Glob pattern matching (10 tests) - test_robustness.c: Malformed input handling for chunk/delta/protocol (11 tests) - test_stress.c: MPMC queue stress, backpressure, rapid create/destroy (3 tests) - test_property.c: Compress, delta, chunk, glob roundtrip properties (4 tests) - tests/fuzz/: 6 libFuzzer targets for deserialization functions Extended existing tests: - test_config.c: config_send/config_receive roundtrip via fork+pipe - test_shared_utils.c: mkdir_r, glob_match, delete_extras Infrastructure: - CTest integration in CMakeLists.txt - Coverage support (-DENABLE_COVERAGE=ON) - Fuzz target support (-DENABLE_FUZZ=ON) - CI: coverage, valgrind, address sanitizer jobs - Fixed MPMC stress test race condition (cnd_signal -> cnd_broadcast)
142 lines
4.1 KiB
YAML
142 lines
4.1 KiB
YAML
name: CI
|
|
|
|
on: [push, pull_request]
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
container: gitea.tap-tap.win/taptap/fastsync-ci:v9
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: clang-format check
|
|
run: find src/ tests/ -name '*.c' -o -name '*.h' | xargs clang-format --dry-run --Werror
|
|
|
|
- name: cppcheck
|
|
run: cppcheck --enable=warning,style,performance,portability --suppress=missingIncludeSystem --error-exitcode=1 --inline-suppr src/ tests/
|
|
|
|
build-and-test:
|
|
runs-on: ubuntu-latest
|
|
container: gitea.tap-tap.win/taptap/fastsync-ci:v9
|
|
needs: lint
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Configure
|
|
run: cmake -B build -S . -DSTRICT_WARNINGS=ON
|
|
|
|
- name: Build
|
|
run: cmake --build build -j$(nproc)
|
|
|
|
- name: Unit Tests
|
|
run: ctest --test-dir build --output-on-failure -j$(nproc)
|
|
|
|
- name: Integration Tests
|
|
run: python3 -m pytest tests/integration/ -v --tb=short
|
|
|
|
sanitizers:
|
|
runs-on: ubuntu-latest
|
|
container: gitea.tap-tap.win/taptap/fastsync-ci:v9
|
|
needs: lint
|
|
strategy:
|
|
matrix:
|
|
sanitizer: [address, undefined]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Configure
|
|
run: cmake -B build-${{ matrix.sanitizer }} -S . -DSANITIZER=${{ matrix.sanitizer }}
|
|
|
|
- name: Build
|
|
run: cmake --build build-${{ matrix.sanitizer }} -j$(nproc)
|
|
|
|
- name: Symlink for integration tests
|
|
run: ln -sf build-${{ matrix.sanitizer }} build
|
|
|
|
- name: Unit Tests
|
|
run: ctest --test-dir build-${{ matrix.sanitizer }} --output-on-failure
|
|
|
|
- name: Integration Tests
|
|
run: LSAN_OPTIONS=suppressions=.lsan-suppressions.txt python3 -m pytest tests/ -v --tb=short
|
|
|
|
clang-tidy:
|
|
runs-on: ubuntu-latest
|
|
container: gitea.tap-tap.win/taptap/fastsync-ci:v9
|
|
needs: lint
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Configure (generate compile_commands.json)
|
|
run: cmake -B build -S .
|
|
|
|
- name: Run clang-tidy (informational, non-blocking)
|
|
run: |
|
|
find src/ -name '*.c' | xargs clang-tidy -p build \
|
|
--checks='-*,bugprone-*,clang-analyzer-*,misc-*,-misc-no-recursion' \
|
|
2>&1 | tee clang-tidy-output.txt
|
|
if grep -q -E " error:| warning:" clang-tidy-output.txt; then
|
|
echo "::warning::clang-tidy found issues — review the output above"
|
|
else
|
|
echo "clang-tidy: no issues found"
|
|
fi
|
|
|
|
fuzz-build:
|
|
runs-on: ubuntu-latest
|
|
container: gitea.tap-tap.win/taptap/fastsync-ci:v9
|
|
needs: lint
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Configure (clang + fuzz)
|
|
run: CC=clang CXX=clang++ cmake -B build-fuzz -S . -DENABLE_FUZZ=ON
|
|
|
|
- name: Build fuzz targets
|
|
run: cmake --build build-fuzz -j$(nproc)
|
|
|
|
coverage:
|
|
runs-on: ubuntu-latest
|
|
container: gitea.tap-tap.win/taptap/fastsync-ci:v9
|
|
needs: lint
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Configure
|
|
run: cmake -B build -S . -DENABLE_COVERAGE=ON
|
|
|
|
- name: Build
|
|
run: cmake --build build -j$(nproc)
|
|
|
|
- name: Unit Tests
|
|
run: ctest --test-dir build --output-on-failure
|
|
|
|
- name: Coverage Report
|
|
run: |
|
|
lcov --capture --directory build --output-file coverage.info --branch-coverage
|
|
lcov --remove coverage.info '/usr/*' '*/tests/*' '*/_deps/*' --output-file coverage.info --branch-coverage --ignore-errors unused
|
|
lcov --list coverage.info
|
|
|
|
valgrind:
|
|
runs-on: ubuntu-latest
|
|
container: gitea.tap-tap.win/taptap/fastsync-ci:v9
|
|
needs: lint
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Configure
|
|
run: cmake -B build -S . -DSTRICT_WARNINGS=ON
|
|
|
|
- name: Build
|
|
run: cmake --build build -j$(nproc)
|
|
|
|
- name: Valgrind Memcheck
|
|
run: valgrind --leak-check=full --show-leak-kinds=definite --error-exitcode=1 ./build/tests
|
|
env:
|
|
FASTSYNC_UNDER_VALGRIND: "1"
|