From 19d9941367f68d6effb516fbb1444877fea9a9ce Mon Sep 17 00:00:00 2001 From: David Steele Date: Thu, 21 Jul 2022 20:10:51 -0400 Subject: [PATCH] More C test harness improvements and CI. Build pgbackrest binary and auto-generated code automatically. Remove --module option and allow modules to run by parameter. This is less verbose and multiple modules can be run at a time. Allow filtering of modules. Multiple tests can be passed as parameters and if the module ends in / it will be used as a prefix filter. For example, common/ will run all the common modules. If a test errors the remaining tests will still run but the test process will eventually exit with an error. CI tests are included but unit tests remain on the development branch. With these changes all unit tests run except those that specify the define (e.g. common/assert-off) or containerReq (e.g. protocol/protocol) keywords. Building the C test harness has been simplified: meson -Dwerror=true -Dfatal-errors=true -Dbuildtype=debug test/build/none pgbackrest ninja -C test/build/none test/src/test-pgbackrest To run all modules: test/build/none/test/src/test-pgbackrest test Just the common/error module: test/build/none/test/src/test-pgbackrest test common/error All info modules: test/build/none/test/src/test-pgbackrest test info/ --- .github/workflows/test.yml | 28 ++++ test/src/build/config/config.yaml | 15 +- test/src/build/help/help.xml | 22 +-- test/src/command/help/meson.build | 2 +- test/src/command/test/build.c | 17 +-- test/src/command/test/build.h | 10 +- test/src/command/test/test.c | 232 +++++++++++++++++++++++++----- test/src/command/test/test.h | 6 +- test/src/main.c | 7 +- 9 files changed, 262 insertions(+), 77 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 69eb5857c..5414f3787 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -61,6 +61,34 @@ jobs: - name: Run Test run: cd ${HOME?} && ${GITHUB_WORKSPACE?}/pgbackrest/test/ci.pl ${{matrix.param}} --param=build-max=2 + # C test harness. Run inside a container so tests that require socket binding work correctly. + testc: + runs-on: ubuntu-22.04 + container: + image: ubuntu:22.04 + + steps: + - name: Checkout Code + uses: actions/checkout@v2 + with: + path: pgbackrest + + - name: Install + run: | + apt-get update + DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_FRONTEND=noninteractive apt-get install -y sudo zlib1g-dev libssl-dev libxml2-dev libpq-dev libyaml-dev pkg-config gcc ccache meson liblz4-dev liblz4-tool zstd libzstd-dev bzip2 libbz2-dev tzdata + adduser --disabled-password --gecos \"\" runner + + - name: Build + run: | + sudo -u runner cp -rp ${GITHUB_WORKSPACE?}/pgbackrest /home/runner + sudo -u runner meson -Dwerror=true -Dfatal-errors=true -Dbuildtype=debug /home/runner/test/build/none /home/runner/pgbackrest + sudo -u runner ninja -C /home/runner/test/build/none test/src/test-pgbackrest + + - name: Test + run: | + sudo -u runner /home/runner/test/build/none/test/src/test-pgbackrest --repo-path=/home/runner/pgbackrest --test-path=/home/runner/test --no-repo-copy test + # Basic tests on other architectures using emulation. The emulation is so slow that running all the unit tests would be too # expensive, but this at least shows that the build works and some of the more complex tests run. In particular, it is good to # test on one big-endian architecture to be sure that checksums are correct. diff --git a/test/src/build/config/config.yaml b/test/src/build/config/config.yaml index 574c6fab6..1f35bef43 100644 --- a/test/src/build/config/config.yaml +++ b/test/src/build/config/config.yaml @@ -10,7 +10,8 @@ command: log-level-default: DEBUG parameter-allowed: true - test: {} + test: + parameter-allowed: true noop: internal: true @@ -44,16 +45,18 @@ option: - 512KiB - 1MiB - module: - type: string - command: - test: {} - neutral-umask: type: boolean internal: true default: true + repo-copy: + type: boolean + default: true + negate: true + command: + test: {} + repo-path: type: string default: pgbackrest diff --git a/test/src/build/help/help.xml b/test/src/build/help/help.xml index 0c75423fe..8c216df0e 100644 --- a/test/src/build/help/help.xml +++ b/test/src/build/help/help.xml @@ -77,16 +77,6 @@ n - - + +