1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
# Deterministic writer/font allocation faults; no services or real user assets.
set -eu
ulimit -c 0
cd "$(dirname "$0")/.."
TMP=$(mktemp -d /tmp/signet-pdfw-alloc.XXXXXX)
trap 'rm -rf "$TMP"' 0
trap 'exit 1' HUP INT TERM
FONT=${SIGNET_TEST_FONT:-/usr/share/fonts/dejavu/DejaVuSans.ttf}
CC=${CC:-cc}
"$CC" -O2 -std=c99 -Ivendor -c vendor/sha256.c -o "$TMP/sha256.o"
for source in pdfw ttf; do
"$CC" -O2 -std=c99 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -Wall -Wextra \
-Isrc -Ivendor -include test/pdfw-alloc.h -c "src/$source.c" \
-o "$TMP/$source.o"
done
"$CC" -O2 -std=c99 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -Wall -Wextra \
-Isrc -Ivendor test/pdfw-alloc.c src/util.c "$TMP/pdfw.o" "$TMP/ttf.o" \
"$TMP/sha256.o" -lpng -lz -lm -o "$TMP/pdfw-alloc"
"$TMP/pdfw-alloc" "$FONT" test/fixtures/seal.png "$TMP/healthy.pdf"
qpdf --check "$TMP/healthy.pdf" >/dev/null
test "$(pdfinfo "$TMP/healthy.pdf" | awk '/^Pages:/ {print $2}')" = 2
printf '%s\n' 'pdfw allocation contract: healthy two-page PDF passed'