From 70cbaf857ed8602a7b39e7d76d43a660edee1356 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Tue, 10 Mar 2026 15:43:11 +0100 Subject: [PATCH] Replace cmake CI with make tests/check targets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds tests and check targets to Makefile — no cmake required. Each test binary is built with the correct flags (pthread, -lrt, --wrap linker flags for prun/ptools_errptr). CI workflow installs only build-essential, runs make tests then make check; exits non-zero on any failure. All 8 test suites pass locally. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/ci.yml | 9 ++---- Makefile | 67 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac25a35..34f569d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,13 +17,10 @@ jobs: - name: Install build dependencies run: | sudo apt-get update - sudo apt-get install -y cmake build-essential - - - name: Configure (cmake) - run: cmake -B build + sudo apt-get install -y build-essential - name: Build test binaries - run: cmake --build build + run: make tests - name: Run tests - run: ctest --test-dir build --output-on-failure + run: make check diff --git a/Makefile b/Makefile index 60e5c27..095b8bb 100644 --- a/Makefile +++ b/Makefile @@ -106,6 +106,73 @@ else EXECLDFLAGS += $(LIBLDFLAGS) endif +# --------------------------------------------------------------------------- +# Unit tests — standalone, no main-binary deps +# --------------------------------------------------------------------------- +UNIT_DIR := tests/unit-tests +TESTS_DIR := tests + +TEST_CFLAGS := -D_POSIX_C_SOURCE=200809L +TEST_CXXFLAGS := -D_POSIX_C_SOURCE=200809L + +TEST_BINS := \ + tests/test_pdbg_path \ + tests/test_ptools_params \ + tests/test_pfs_lock_ordering \ + tests/test_ptask_free \ + tests/test_prun \ + tests/test_ptools_errptr \ + tests/test_read_response \ + tests/test_signal_safety + +.PHONY: tests check clean-tests + +tests: $(TEST_BINS) + +check: tests + @rc=0; \ + for t in $(TEST_BINS); do \ + echo "=== $$t ==="; \ + $$t || rc=$$?; \ + done; \ + exit $$rc + +clean-tests: + rm -f $(TEST_BINS) + +tests/test_pdbg_path: $(UNIT_DIR)/test_pdbg_path.c + $(CC) $(TEST_CFLAGS) -o $@ $< + +tests/test_ptools_params: $(UNIT_DIR)/test_ptools_params.c + $(CC) $(TEST_CFLAGS) -o $@ $< + +tests/test_pfs_lock_ordering: $(UNIT_DIR)/test_pfs_lock_ordering.c + $(CC) $(TEST_CFLAGS) -o $@ $< -lpthread + +tests/test_ptask_free: $(UNIT_DIR)/test_ptask_free.c + $(CC) $(TEST_CFLAGS) -o $@ $< -lpthread + +tests/test_prun: $(UNIT_DIR)/test_prun.c + $(CC) -D_POSIX_C_SOURCE=199309L -o $@ $< \ + -Wl,--wrap=pthread_create \ + -Wl,--wrap=pthread_attr_destroy \ + -Wl,--wrap=malloc \ + -Wl,--wrap=free \ + -lpthread + +tests/test_ptools_errptr: $(UNIT_DIR)/test_ptools_errptr.c + $(CC) $(TEST_CFLAGS) -o $@ $< \ + -Wl,--wrap=malloc \ + -Wl,--wrap=free + +tests/test_read_response: $(UNIT_DIR)/test_read_response.cpp + $(CXX) $(TEST_CXXFLAGS) -o $@ $< + +tests/test_signal_safety: $(TESTS_DIR)/test_signal_safety.c + $(CC) -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L -o $@ $< -lpthread -lrt + +# --------------------------------------------------------------------------- + .PHONY: all clean install install-logrotate uninstall all: $(TARGETS)