diff --git a/Makefile.am b/Makefile.am index f4d5c3af2..e22383209 100644 --- a/Makefile.am +++ b/Makefile.am @@ -92,8 +92,7 @@ lib_LTLIBRARIES = libcupsfilters.la check_SCRIPTS = \ cupsfilters/testfilters.sh \ - cupsfilters/test-pclm-overflow.sh \ - cupsfilters/test-pdftoraster-copy-height.sh + cupsfilters/test-pclm-overflow.sh check_PROGRAMS = \ testcmyk \ @@ -106,7 +105,8 @@ check_PROGRAMS = \ test-analyze \ test-pdf \ test-ps \ - testfilters + testfilters \ + test-pdftoraster-copy-height TESTS = \ testdither \ @@ -115,9 +115,9 @@ TESTS = \ test-analyze \ test-pdf \ test-ps \ + test-pdftoraster-copy-height \ cupsfilters/testfilters.sh \ - cupsfilters/test-pclm-overflow.sh \ - cupsfilters/test-pdftoraster-copy-height.sh + cupsfilters/test-pclm-overflow.sh # testcmyk # fails as it opens some image.ppm which is nowerhe to be found. # testimage # requires also some ppm file as argument @@ -323,6 +323,9 @@ test_ps_SOURCES = cupsfilters/fontembed/test-ps.c test_ps_LDADD = libcupsfilters.la $(CUPS_LIBS) test_ps_CFLAGS = $(CUPS_CFLAGS) +test_pdftoraster_copy_height_SOURCES = \ + cupsfilters/test-pdftoraster-copy-height.c + testfilters_SOURCES = \ cupsfilters/testfilters.c \ $(pkgfiltersinclude_DATA) diff --git a/configure.ac b/configure.ac index 7ef2a37ab..b4103f071 100644 --- a/configure.ac +++ b/configure.ac @@ -79,7 +79,14 @@ AS_IF([$PKGCONFIG --exists cups3], [ AC_SUBST(CUPS_CFLAGS) AC_SUBST(CUPS_LIBS) - CUPS_DATADIR="$($PKGCONFIG --variable=prefix cups3)/share/cups" + # Prefer the datadir cups3.pc exports directly. Reconstructing it from + # --variable=prefix is wrong when CUPS was built with an architecture- + # specific prefix (e.g. /usr/x86_64-pc-linux-gnu): the data lives in the + # arch-independent /usr/share/cups, which the .pc records in cups_datadir. + # Fall back to the prefix-relative path for a .pc without it. (#201) + CUPS_DATADIR="$($PKGCONFIG --variable=cups_datadir cups3)" + AS_IF([test "x$CUPS_DATADIR" = x], + [CUPS_DATADIR="$($PKGCONFIG --variable=prefix cups3)/share/cups"]) AC_DEFINE_UNQUOTED(CUPS_DATADIR, "$CUPS_DATADIR", [CUPS datadir]) AC_SUBST(CUPS_DATADIR) @@ -128,7 +135,14 @@ AS_IF([$PKGCONFIG --exists cups3], [ cups_prefix="$($PKGCONFIG --variable=prefix cups)" AS_IF([test "x$cups_prefix" = x], [cups_prefix=/usr]) - CUPS_DATADIR="$cups_prefix/share/cups" + # Prefer the datadir cups.pc exports directly. Reconstructing it from + # --variable=prefix is wrong when CUPS was built with an architecture- + # specific prefix (e.g. /usr/x86_64-pc-linux-gnu): the data lives in the + # arch-independent /usr/share/cups, which the .pc records in cups_datadir. + # Fall back to the prefix-relative path for a .pc without it. (#201) + CUPS_DATADIR="$($PKGCONFIG --variable=cups_datadir cups)" + AS_IF([test "x$CUPS_DATADIR" = x], + [CUPS_DATADIR="$cups_prefix/share/cups"]) AC_DEFINE_UNQUOTED(CUPS_DATADIR, "$CUPS_DATADIR", [CUPS datadir]) AC_SUBST(CUPS_DATADIR) diff --git a/cupsfilters/test-pclm-overflow.sh b/cupsfilters/test-pclm-overflow.sh index 92695109b..c7c003e46 100755 --- a/cupsfilters/test-pclm-overflow.sh +++ b/cupsfilters/test-pclm-overflow.sh @@ -7,6 +7,17 @@ LIBTOOL="${BUILD_ROOT}/libtool" CC="${CC:-cc}" SAN_FLAGS="${SAN_FLAGS:--fsanitize=address -fno-omit-frame-pointer}" +# AddressSanitizer is what makes this test meaningful. When libasan is not +# installed the compiler still accepts -fsanitize=address but the link fails +# (missing libasan_preinit.o / -lasan) -- that is an environment gap, not a +# libcupsfilters bug. Skip (Automake exit 77) instead of failing; a real +# failure is reported only when ASan IS available and the sanitizer fires. +if ! printf 'int main(void){return 0;}\n' \ + | "${CC}" ${SAN_FLAGS} -x c - -o /dev/null >/dev/null 2>&1; then + echo "AddressSanitizer not available (cannot link ${SAN_FLAGS}); skipping." >&2 + exit 77 +fi + if [[ ! -x "${LIBTOOL}" ]]; then echo "libtool helper not found at ${LIBTOOL}" >&2 exit 99 diff --git a/cupsfilters/test-pdftoraster-copy-height.sh b/cupsfilters/test-pdftoraster-copy-height.sh deleted file mode 100755 index 3455ef16f..000000000 --- a/cupsfilters/test-pdftoraster-copy-height.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -# -# Test that pdftoraster copy_height fix works correctly. -# This reproduces the off-by-one logic without needing ASan. -set -euo pipefail - -SRC="$(dirname "$0")/test-pdftoraster-copy-height.c" -BIN="/tmp/test-pdftoraster-copy-height" - -# Compile if needed -if [ ! -x "$BIN" ] || [ "$SRC" -nt "$BIN" ]; then - "${CC:-cc}" -std=c11 -O0 -g -Wall -Wextra \ - "$SRC" -o "$BIN" -fi - -exec "$BIN"