Skip to content

Commit 70cbaf8

Browse files
Levi Neelyclaude
andcommitted
Replace cmake CI with make tests/check targets
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 <noreply@anthropic.com>
1 parent 3c1b5a7 commit 70cbaf8

2 files changed

Lines changed: 70 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@ jobs:
1717
- name: Install build dependencies
1818
run: |
1919
sudo apt-get update
20-
sudo apt-get install -y cmake build-essential
21-
22-
- name: Configure (cmake)
23-
run: cmake -B build
20+
sudo apt-get install -y build-essential
2421
2522
- name: Build test binaries
26-
run: cmake --build build
23+
run: make tests
2724

2825
- name: Run tests
29-
run: ctest --test-dir build --output-on-failure
26+
run: make check

Makefile

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,73 @@ else
106106
EXECLDFLAGS += $(LIBLDFLAGS)
107107
endif
108108

109+
# ---------------------------------------------------------------------------
110+
# Unit tests — standalone, no main-binary deps
111+
# ---------------------------------------------------------------------------
112+
UNIT_DIR := tests/unit-tests
113+
TESTS_DIR := tests
114+
115+
TEST_CFLAGS := -D_POSIX_C_SOURCE=200809L
116+
TEST_CXXFLAGS := -D_POSIX_C_SOURCE=200809L
117+
118+
TEST_BINS := \
119+
tests/test_pdbg_path \
120+
tests/test_ptools_params \
121+
tests/test_pfs_lock_ordering \
122+
tests/test_ptask_free \
123+
tests/test_prun \
124+
tests/test_ptools_errptr \
125+
tests/test_read_response \
126+
tests/test_signal_safety
127+
128+
.PHONY: tests check clean-tests
129+
130+
tests: $(TEST_BINS)
131+
132+
check: tests
133+
@rc=0; \
134+
for t in $(TEST_BINS); do \
135+
echo "=== $$t ==="; \
136+
$$t || rc=$$?; \
137+
done; \
138+
exit $$rc
139+
140+
clean-tests:
141+
rm -f $(TEST_BINS)
142+
143+
tests/test_pdbg_path: $(UNIT_DIR)/test_pdbg_path.c
144+
$(CC) $(TEST_CFLAGS) -o $@ $<
145+
146+
tests/test_ptools_params: $(UNIT_DIR)/test_ptools_params.c
147+
$(CC) $(TEST_CFLAGS) -o $@ $<
148+
149+
tests/test_pfs_lock_ordering: $(UNIT_DIR)/test_pfs_lock_ordering.c
150+
$(CC) $(TEST_CFLAGS) -o $@ $< -lpthread
151+
152+
tests/test_ptask_free: $(UNIT_DIR)/test_ptask_free.c
153+
$(CC) $(TEST_CFLAGS) -o $@ $< -lpthread
154+
155+
tests/test_prun: $(UNIT_DIR)/test_prun.c
156+
$(CC) -D_POSIX_C_SOURCE=199309L -o $@ $< \
157+
-Wl,--wrap=pthread_create \
158+
-Wl,--wrap=pthread_attr_destroy \
159+
-Wl,--wrap=malloc \
160+
-Wl,--wrap=free \
161+
-lpthread
162+
163+
tests/test_ptools_errptr: $(UNIT_DIR)/test_ptools_errptr.c
164+
$(CC) $(TEST_CFLAGS) -o $@ $< \
165+
-Wl,--wrap=malloc \
166+
-Wl,--wrap=free
167+
168+
tests/test_read_response: $(UNIT_DIR)/test_read_response.cpp
169+
$(CXX) $(TEST_CXXFLAGS) -o $@ $<
170+
171+
tests/test_signal_safety: $(TESTS_DIR)/test_signal_safety.c
172+
$(CC) -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L -o $@ $< -lpthread -lrt
173+
174+
# ---------------------------------------------------------------------------
175+
109176
.PHONY: all clean install install-logrotate uninstall
110177

111178
all: $(TARGETS)

0 commit comments

Comments
 (0)