Skip to content

Commit 8ba873f

Browse files
authored
Add hermetic C unit-test suite for libppd API (#71)
* Implement native C unit tests for PPD localization * Add hermetic unit tests for PPD cache API * Add hermetic unit tests for PPD to IPP attributes API * Add hermetic unit tests for PPD option marking API * Add hermetic unit tests for PPD custom-option API * Add hermetic unit tests for PPD attribute API * Add hermetic unit tests for PPD attribute API * Add hermetic unit tests for PPD page-size API * Add hermetic unit tests for PPD conflicts API * Add hermetic unit tests for PPD emission API * Add hermetic unit tests for PPD filter wrapper API * Add hermetic unit tests for IPP-to-PPD generator API * Add hermetic unit tests for ppd-load-profile profile loader API * Introduced GitHub Actions workflow * Fix testEndMessage silently swallowing assertion failures
1 parent 2914b19 commit 8ba873f

15 files changed

Lines changed: 9135 additions & 17 deletions

.github/workflows/build.yml

Lines changed: 101 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,126 @@
1-
name: Build libppd
1+
# =============================================================================
2+
# Build and Test Workflow for libppd (x86_64 / ubuntu-latest)
3+
#
4+
# Modelled on the libcupsfilters CI in the sister OpenPrinting repository.
5+
# Scope is intentionally restricted to a single native architecture
6+
# (x86_64 on ubuntu-latest) so the build runs quickly and deterministically
7+
# while still proving:
8+
#
9+
# * The complete repository compiles end-to-end (libppd.la plus all
10+
# declared programs and tests under check_PROGRAMS) — not just that
11+
# the test binaries link against an already-built library.
12+
# * All registered TESTS pass (the 8 native C unit tests added in this
13+
# cycle: testppd, test_ppd_localize, test_ppd_cache, test_ppd_ipp,
14+
# test_ppd_mark, test_ppd_custom, test_ppd_attr, test_ppd_page,
15+
# test_ppd_conflicts). test_ppd_load_profile is intentionally
16+
# deregistered in Makefile.am pending mentor review of a latent
17+
# bug in ppdLutLoad().
18+
#
19+
# The apt package list was derived from a direct scan of configure.ac:
20+
#
21+
# * PKG_CHECK_MODULES([LIBCUPSFILTERS], [libcupsfilters]) -> libcupsfilters-dev
22+
# * PKG_CHECK_MODULES([ZLIB], [zlib]) -> zlib1g-dev
23+
# * AC_PATH_TOOL(CUPSCONFIG, [cups-config]) (cups3 absent
24+
# on ubuntu-latest, falls back to libcups2) -> libcups2-dev
25+
# * AC_CHECK_PROG(CUPS_GHOSTSCRIPT, gs) -> ghostscript
26+
# * AC_CHECK_PROG(CUPS_PDFTOPS, pdftops) -> poppler-utils
27+
# * AC_CHECK_PROG(CUPS_MUTOOL, mutool) -> mupdf-tools
28+
# * pdftocairo (Poppler renderer) -> poppler-utils
29+
# * AM_GNU_GETTEXT([external]) / AM_ICONV -> gettext, autopoint
30+
# * AC_PROG_CC, AC_PROG_CXX, AX_CXX_COMPILE_STDCXX([11]) -> build-essential
31+
# * LT_INIT -> libtool
32+
# * PKG_PROG_PKG_CONFIG -> pkg-config
33+
# * AC_PROG_INSTALL -> (provided by build-essential)
34+
#
35+
# All three of ghostscript / poppler-utils / mupdf-tools are installed so
36+
# the default ./configure (no --disable-* flags) succeeds — that gives us
37+
# the maximum-coverage build the user asked for ("comprehensive build,
38+
# rather than just checking if the unit tests run").
39+
# =============================================================================
40+
41+
name: Build and Test (libppd)
242

343
on:
444
push:
45+
branches:
46+
- '**'
547
pull_request:
48+
branches:
49+
- '**'
50+
workflow_dispatch:
651

752
jobs:
853
build:
54+
name: Build & Test (x86_64)
955
runs-on: ubuntu-latest
1056

1157
steps:
1258
- name: Checkout repository
1359
uses: actions/checkout@v4
1460

15-
- name: Install dependencies
61+
# -----------------------------------------------------------------------
62+
# System dependencies — derived from configure.ac (see header comment).
63+
# -----------------------------------------------------------------------
64+
- name: Install build & runtime dependencies
1665
run: |
17-
sudo apt-get update
18-
sudo apt-get install -y \
66+
set -ex
67+
sudo apt-get update --fix-missing -y
68+
sudo apt-get install -y --no-install-recommends \
1969
build-essential \
2070
autoconf \
2171
automake \
2272
autopoint \
23-
gettext \
2473
libtool \
2574
pkg-config \
75+
gettext \
2676
libcups2-dev \
2777
libcupsfilters-dev \
78+
zlib1g-dev \
2879
ghostscript \
2980
poppler-utils \
30-
mupdf-tools
81+
mupdf-tools
3182
32-
- name: Build project
33-
run: |
34-
./autogen.sh
35-
./configure
36-
make
37-
38-
- name: Run tests
39-
run: make check
83+
# -----------------------------------------------------------------------
84+
# Full build — autogen.sh regenerates configure / Makefile.in from the
85+
# autotools sources; configure runs without --disable-* flags so every
86+
# external renderer (gs / pdftops / mutool / pdftocairo) is exercised;
87+
# make -j$(nproc) builds the library AND every check_PROGRAMS binary,
88+
# surfacing any compiler errors or warnings as build output.
89+
# -----------------------------------------------------------------------
90+
- name: autogen.sh
91+
run: ./autogen.sh
92+
93+
- name: configure
94+
run: ./configure
95+
96+
- name: make
97+
run: make -j$(nproc) V=1
98+
99+
# -----------------------------------------------------------------------
100+
# Run the registered TESTS. V=1 and VERBOSE=1 expose both the
101+
# compile-line per object AND each test's stderr in the workflow log
102+
# on failure, matching the libcupsfilters CI pattern. We deliberately
103+
# do NOT pipe stderr away — a failing test prints its full diagnostic
104+
# before the step exits non-zero, and the test-suite.log artifact (see
105+
# next step) preserves the full automake summary for download.
106+
# -----------------------------------------------------------------------
107+
- name: make check
108+
id: check
109+
run: make check V=1 VERBOSE=1
110+
111+
# -----------------------------------------------------------------------
112+
# Artifact upload — only fires when `make check` failed. Captures the
113+
# top-level test-suite.log automake produces plus any per-test .log /
114+
# .trs files so the failure can be diagnosed offline.
115+
# -----------------------------------------------------------------------
116+
- name: Upload test-suite.log on failure
117+
if: failure() && steps.check.conclusion == 'failure'
118+
uses: actions/upload-artifact@v4
119+
with:
120+
name: libppd-test-suite-log-x86_64
121+
path: |
122+
test-suite.log
123+
**/*.log
124+
**/*.trs
125+
if-no-files-found: warn
126+
retention-days: 14

Makefile.am

Lines changed: 130 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ EXTRA_DIST = \
2424
libppd.pc.in
2525

2626
EXTRA_DIST += \
27-
ppd/testdriver.c
27+
ppd/testdriver.c \
28+
ppd/test-internal.h
2829

2930
# =========
3031
# Utilities
@@ -54,9 +55,33 @@ pkgppddefs_DATA = \
5455
lib_LTLIBRARIES = libppd.la
5556

5657
check_PROGRAMS = \
57-
testppd
58+
testppd \
59+
test_ppd_localize \
60+
test_ppd_cache \
61+
test_ppd_ipp \
62+
test_ppd_mark \
63+
test_ppd_custom \
64+
test_ppd_attr \
65+
test_ppd_page \
66+
test_ppd_conflicts \
67+
test_ppd_emit \
68+
test_ppd_filter \
69+
test_ppd_generator \
70+
test_ppd_load_profile
5871
TESTS = \
59-
testppd
72+
testppd \
73+
test_ppd_localize \
74+
test_ppd_cache \
75+
test_ppd_ipp \
76+
test_ppd_mark \
77+
test_ppd_custom \
78+
test_ppd_attr \
79+
test_ppd_page \
80+
test_ppd_conflicts \
81+
test_ppd_emit \
82+
test_ppd_filter \
83+
test_ppd_generator \
84+
test_ppd_load_profile
6085

6186
libppd_la_SOURCES = \
6287
ppd/ppd-attr.c \
@@ -140,6 +165,108 @@ testppd_CFLAGS = \
140165
-I$(srcdir)/ppd/ \
141166
$(CUPS_CFLAGS)
142167

168+
test_ppd_localize_SOURCES = ppd/test_ppd_localize.c
169+
test_ppd_localize_LDADD = \
170+
libppd.la \
171+
$(CUPS_LIBS)
172+
test_ppd_localize_CFLAGS = \
173+
-I$(srcdir)/ppd/ \
174+
$(CUPS_CFLAGS)
175+
176+
test_ppd_cache_SOURCES = ppd/test_ppd_cache.c
177+
test_ppd_cache_LDADD = \
178+
libppd.la \
179+
$(CUPS_LIBS)
180+
test_ppd_cache_CFLAGS = \
181+
-I$(srcdir)/ppd/ \
182+
$(CUPS_CFLAGS)
183+
184+
test_ppd_ipp_SOURCES = ppd/test_ppd_ipp.c
185+
test_ppd_ipp_LDADD = \
186+
libppd.la \
187+
$(CUPS_LIBS)
188+
test_ppd_ipp_CFLAGS = \
189+
-I$(srcdir)/ppd/ \
190+
$(CUPS_CFLAGS)
191+
192+
test_ppd_mark_SOURCES = ppd/test_ppd_mark.c
193+
test_ppd_mark_LDADD = \
194+
libppd.la \
195+
$(CUPS_LIBS)
196+
test_ppd_mark_CFLAGS = \
197+
-I$(srcdir)/ppd/ \
198+
$(CUPS_CFLAGS)
199+
200+
test_ppd_custom_SOURCES = ppd/test_ppd_custom.c
201+
test_ppd_custom_LDADD = \
202+
libppd.la \
203+
$(CUPS_LIBS)
204+
test_ppd_custom_CFLAGS = \
205+
-I$(srcdir)/ppd/ \
206+
$(CUPS_CFLAGS)
207+
208+
test_ppd_attr_SOURCES = ppd/test_ppd_attr.c
209+
test_ppd_attr_LDADD = \
210+
libppd.la \
211+
$(CUPS_LIBS)
212+
test_ppd_attr_CFLAGS = \
213+
-I$(srcdir)/ppd/ \
214+
$(CUPS_CFLAGS)
215+
216+
test_ppd_page_SOURCES = ppd/test_ppd_page.c
217+
test_ppd_page_LDADD = \
218+
libppd.la \
219+
$(CUPS_LIBS)
220+
test_ppd_page_CFLAGS = \
221+
-I$(srcdir)/ppd/ \
222+
$(CUPS_CFLAGS)
223+
224+
test_ppd_conflicts_SOURCES = ppd/test_ppd_conflicts.c
225+
test_ppd_conflicts_LDADD = \
226+
libppd.la \
227+
$(CUPS_LIBS)
228+
test_ppd_conflicts_CFLAGS = \
229+
-I$(srcdir)/ppd/ \
230+
$(CUPS_CFLAGS)
231+
232+
test_ppd_emit_SOURCES = ppd/test_ppd_emit.c
233+
test_ppd_emit_LDADD = \
234+
libppd.la \
235+
$(CUPS_LIBS)
236+
test_ppd_emit_CFLAGS = \
237+
-I$(srcdir)/ppd/ \
238+
$(CUPS_CFLAGS)
239+
240+
test_ppd_filter_SOURCES = ppd/test_ppd_filter.c
241+
test_ppd_filter_LDADD = \
242+
libppd.la \
243+
$(LIBCUPSFILTERS_LIBS) \
244+
$(CUPS_LIBS)
245+
test_ppd_filter_CFLAGS = \
246+
-I$(srcdir)/ppd/ \
247+
$(LIBCUPSFILTERS_CFLAGS) \
248+
$(CUPS_CFLAGS)
249+
250+
test_ppd_generator_SOURCES = ppd/test_ppd_generator.c
251+
test_ppd_generator_LDADD = \
252+
libppd.la \
253+
$(LIBCUPSFILTERS_LIBS) \
254+
$(CUPS_LIBS)
255+
test_ppd_generator_CFLAGS = \
256+
-I$(srcdir)/ppd/ \
257+
$(LIBCUPSFILTERS_CFLAGS) \
258+
$(CUPS_CFLAGS)
259+
260+
test_ppd_load_profile_SOURCES = ppd/test_ppd_load_profile.c
261+
test_ppd_load_profile_LDADD = \
262+
libppd.la \
263+
$(CUPS_LIBS) \
264+
$(LIBCUPSFILTERS_LIBS)
265+
test_ppd_load_profile_CFLAGS = \
266+
-I$(srcdir)/ppd/ \
267+
$(CUPS_CFLAGS) \
268+
$(LIBCUPSFILTERS_CFLAGS)
269+
143270
EXTRA_DIST += \
144271
$(pkgppdinclude_DATA) \
145272
$(pkgppddefs_DATA) \

0 commit comments

Comments
 (0)