From 2f37633b923e0294acd894454a95d2a9ee1d36a9 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 23 Dec 2023 10:41:55 -0500 Subject: [PATCH] Fix pkg-test tests and run from CI --- .github/workflows/main.yml | 1 + README-maintainer.md | 16 ---------------- build-scripts/pkg-test | 16 ++++++++++++++++ pkg-test/README.md | 13 ++++++++----- pkg-test/test-cli | 2 +- pkg-test/test-cmake | 2 +- pkg-test/test-pkg-config | 2 +- 7 files changed, 28 insertions(+), 24 deletions(-) create mode 100755 build-scripts/pkg-test diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b86f3a28..869543d3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -132,6 +132,7 @@ jobs: matrix: script: - build-fuzzer + - pkg-test - build-linux32 - test-alt-zlib - test-unsigned-char diff --git a/README-maintainer.md b/README-maintainer.md index 4c8bd6e6..1230249e 100644 --- a/README-maintainer.md +++ b/README-maintainer.md @@ -532,22 +532,6 @@ When done, the following should happen: * /tmp/check-abi/new contains new sizes and library * run check_abi manually to compare -* Run package tests: - - (Note: can't use DESTDIR because pkg-config won't know about it.) - -``` -\rm -rf /tmp/inst build.tmp -cmake -S . -B build.tmp \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/tmp/inst -cmake --build build.tmp -j$(nproc) -cmake --install build.tmp -env PKG_CONFIG_PATH=/tmp/inst/lib/pkgconfig \ - LD_LIBRARY_PATH=/tmp/inst/lib \ - CMAKE_PREFIX_PATH=/tmp/inst \ - ./pkg-test/run-all -``` - ## CREATING A RELEASE * Push to main. This will create an artifact called distribution diff --git a/build-scripts/pkg-test b/build-scripts/pkg-test new file mode 100755 index 00000000..9c8f94aa --- /dev/null +++ b/build-scripts/pkg-test @@ -0,0 +1,16 @@ +#!/bin/bash +set -e +sudo apt-get update +sudo apt-get -y install \ + build-essential cmake \ + zlib1g-dev libjpeg-dev libgnutls28-dev libssl-dev + +cmake -S . -B build \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/tmp/inst +cmake --build build -j$(nproc) +cmake --install build +env PKG_CONFIG_PATH=/tmp/inst/lib/pkgconfig \ + LD_LIBRARY_PATH=/tmp/inst/lib \ + CMAKE_PREFIX_PATH=/tmp/inst \ + PATH=/tmp/inst/bin:$PATH \ + ./pkg-test/run-all diff --git a/pkg-test/README.md b/pkg-test/README.md index 95f7ecb8..6426388a 100644 --- a/pkg-test/README.md +++ b/pkg-test/README.md @@ -2,13 +2,16 @@ The files in this directory are called by autopkgtest in the debian package but can be used by any packager to verify installed packages. Each test-* script should be run from the top of the source tree and takes an empty directory as its single argument. The test passes if the script exits with a zero exit status. Note that these tests write to stderr because they use set -x in the shell. -On a GNU/Linux system, you can run `./pkg-test/run-all` from the top-level directory to run all the tests. For example: +On a GNU/Linux system, you can run `./pkg-test/run-all` from the top-level directory to run all the tests. Note that you have to specify an altrenative install prefix rather than using DESTDIR since, otherwise, pkg-config won't find the packages. For example: ``` -cmake -S . -B build +cmake -S . -B build \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/tmp/inst cmake --build build -j$(nproc) -DESTDIR=/tmp/inst cmake --install build -env PKG_CONFIG_PATH=/tmp/inst/usr/local/lib/pkgconfig \ - CMAKE_PREFIX_PATH=/tmp/inst/usr/local \ +cmake --install build +env PKG_CONFIG_PATH=/tmp/inst/lib/pkgconfig \ + LD_LIBRARY_PATH=/tmp/inst/lib \ + CMAKE_PREFIX_PATH=/tmp/inst \ + PATH=/tmp/inst/bin:$PATH \ ./pkg-test/run-all ``` diff --git a/pkg-test/test-cli b/pkg-test/test-cli index f69e546a..a88f8fb3 100755 --- a/pkg-test/test-cli +++ b/pkg-test/test-cli @@ -11,7 +11,7 @@ if [ ! -d "$TMP" ]; then exit 2 fi -WANTED_VERSION=$(awk -F'"' '/#define QPDF_VERSION / {print $2}' include/qpdf/DLL.h) +WANTED_VERSION=$(awk -F'"' '/# *define QPDF_VERSION / {print $2}' include/qpdf/DLL.h | tail -n 1) qpdf --version | grep -F $WANTED_VERSION qpdf --help diff --git a/pkg-test/test-cmake b/pkg-test/test-cmake index 868ce363..580da370 100755 --- a/pkg-test/test-cmake +++ b/pkg-test/test-cmake @@ -13,7 +13,7 @@ if [ ! -d "$TMP" ]; then exit 2 fi -WANTED_VERSION=$(awk -F'"' '/#define QPDF_VERSION / {print $2}' include/qpdf/DLL.h) +WANTED_VERSION=$(awk -F'"' '/# *define QPDF_VERSION / {print $2}' include/qpdf/DLL.h | tail -n 1) cp pkg-test/qpdf-version.cc pkg-test/CMakeLists.txt $TMP cd $TMP diff --git a/pkg-test/test-pkg-config b/pkg-test/test-pkg-config index 4c46a59c..cbc0d133 100755 --- a/pkg-test/test-pkg-config +++ b/pkg-test/test-pkg-config @@ -12,7 +12,7 @@ if [ ! -d "$TMP" ]; then exit 2 fi -WANTED_VERSION=$(awk -F'"' '/#define QPDF_VERSION / {print $2}' include/qpdf/DLL.h) +WANTED_VERSION=$(awk -F'"' '/# *define QPDF_VERSION / {print $2}' include/qpdf/DLL.h | tail -n 1) cp pkg-test/qpdf-version.cc $TMP cd $TMP