diff --git a/.gitignore b/.gitignore index 1c13cb9..e066fb5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ -.deps *.o *.so -/results -.log -Dockerfile +/.deps/ /log/ +/results/ +/tmp_check/ diff --git a/.travis.yml b/.travis.yml index aa9e796..b4296bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,32 +1,20 @@ -os: - - linux - -sudo: required dist: jammy - language: c - -services: - - docker - -install: - - sed -e 's/${CHECK_CODE}/'${CHECK_CODE}/g -e 's/${PG_VERSION}/'${PG_VERSION}/g Dockerfile.tmpl > Dockerfile - - docker-compose build - -script: - - docker-compose run tests - env: - - PG_VERSION=11 CHECK_CODE=clang - - PG_VERSION=11 CHECK_CODE=cppcheck - - PG_VERSION=11 CHECK_CODE=false - - PG_VERSION=12 CHECK_CODE=clang - - PG_VERSION=12 CHECK_CODE=false - - PG_VERSION=13 CHECK_CODE=clang - - PG_VERSION=13 CHECK_CODE=false - - PG_VERSION=14 CHECK_CODE=clang - - PG_VERSION=14 CHECK_CODE=false - - PG_VERSION=15 CHECK_CODE=clang - - PG_VERSION=15 CHECK_CODE=false - - PG_VERSION=16 CHECK_CODE=clang - - PG_VERSION=16 CHECK_CODE=false +- PG_MAJOR=16 +- PG_MAJOR=15 +- PG_MAJOR=14 +- PG_MAJOR=13 +- PG_MAJOR=12 +- PG_MAJOR=11 +before_script: +- curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - +- echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee -a /etc/apt/sources.list +- sudo apt-get update +- sudo systemctl stop postgresql +- sudo apt-get install -y --no-install-recommends postgresql-${PG_MAJOR} postgresql-server-dev-${PG_MAJOR} +- sudo systemctl stop postgresql +script: ./run-tests.sh +after_script: +- cat regression.diffs +- cat logfile diff --git a/Dockerfile.tmpl b/Dockerfile.tmpl deleted file mode 100644 index eaf70c8..0000000 --- a/Dockerfile.tmpl +++ /dev/null @@ -1,34 +0,0 @@ -FROM postgres:${PG_VERSION}-alpine - -ENV LANG=C.UTF-8 PGDATA=/pg/data - -RUN if [ "${CHECK_CODE}" = "clang" ] ; then \ - # echo 'http://dl-3.alpinelinux.org/alpine/edge/main' > /etc/apk/repositories; \ - # Use alpine/v3.6/main instead of alpine/edge/main to fix version of clang to '8.*.*' - apk --no-cache add clang-analyzer make musl-dev gcc --repository http://dl-cdn.alpinelinux.org/alpine/v3.6/main; \ - fi - -RUN if [ "${CHECK_CODE}" = "cppcheck" ] ; then \ - apk --no-cache add cppcheck --repository http://dl-cdn.alpinelinux.org/alpine/v3.6/community; \ - fi - -RUN if [ "${CHECK_CODE}" = "false" ] ; then \ - # echo 'http://dl-3.alpinelinux.org/alpine/edge/main' > /etc/apk/repositories; \ - # Use alpine/v3.6/main instead of alpine/edge/main to fix version of clang to '8.*.*' - # Install clang as well, since LLVM is enabled in PG_VERSION >= 11 by default - apk --no-cache add curl python3 gcc make musl-dev llvm clang clang-dev \ - --repository http://dl-cdn.alpinelinux.org/alpine/v3.6/community \ - --repository http://dl-cdn.alpinelinux.org/alpine/v3.6/main; \ - fi - -RUN mkdir -p ${PGDATA} && \ - mkdir /pg/src && \ - chown postgres:postgres ${PGDATA} && \ - chmod -R a+rwx /usr/local/lib/postgresql && \ - chmod a+rwx /usr/local/share/postgresql/extension - -ADD . /pg/src -WORKDIR /pg/src -RUN chmod -R go+rwX /pg/src -USER postgres -ENTRYPOINT PGDATA=${PGDATA} CHECK_CODE=${CHECK_CODE} bash run_tests.sh diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 471ab77..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,2 +0,0 @@ -tests: - build: . diff --git a/run-tests.sh b/run-tests.sh new file mode 100755 index 0000000..f3f1bba --- /dev/null +++ b/run-tests.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -ev + +PATH=/usr/lib/postgresql/$PG_MAJOR/bin:$PATH +export PGDATA=/var/lib/postgresql/$PG_MAJOR/test +export COPT=-Werror +export USE_PGXS=1 + +sudo chmod 1777 /var/lib/postgresql/$PG_MAJOR +sudo chmod 1777 /var/run/postgresql + +make clean +make + +sudo -E env PATH=$PATH make install + +initdb +echo "shared_preload_libraries = pg_wait_sampling" >> $PGDATA/postgresql.conf + +pg_ctl -l logfile start +make installcheck +pg_ctl stop diff --git a/run_tests.sh b/run_tests.sh deleted file mode 100755 index 3bdeb32..0000000 --- a/run_tests.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash - -# This is a main testing script for: -# * regression tests -# * testgres-based tests -# * cmocka-based tests -# Copyright (c) 2017, Postgres Professional - -set -eux - -echo CHECK_CODE=$CHECK_CODE - -status=0 - -# perform code analysis if necessary -if [ "$CHECK_CODE" = "clang" ]; then - scan-build --status-bugs make USE_PGXS=1 || status=$? - exit $status - -elif [ "$CHECK_CODE" = "cppcheck" ]; then - cppcheck \ - --template "{file} ({line}): {severity} ({id}): {message}" \ - --enable=warning,portability,performance \ - --suppress=redundantAssignment \ - --suppress=uselessAssignmentPtrArg \ - --suppress=literalWithCharPtrCompare \ - --suppress=incorrectStringBooleanError \ - --std=c89 *.c *.h 2> cppcheck.log - - if [ -s cppcheck.log ]; then - cat cppcheck.log - status=1 # error - fi - - exit $status -fi - -# don't forget to "make clean" -make USE_PGXS=1 clean - -# initialize database -initdb - -# build extension -make USE_PGXS=1 install - -# check build -status=$? -if [ $status -ne 0 ]; then exit $status; fi - -# add pg_wait_sampling to shared_preload_libraries and restart cluster 'test' -echo "shared_preload_libraries = 'pg_wait_sampling'" >> $PGDATA/postgresql.conf -echo "port = 55435" >> $PGDATA/postgresql.conf -pg_ctl start -l /tmp/postgres.log -w - -# check startup -status=$? -if [ $status -ne 0 ]; then cat /tmp/postgres.log; fi - -# run regression tests -export PG_REGRESS_DIFF_OPTS="-w -U3" # for alpine's diff (BusyBox) -PGPORT=55435 make USE_PGXS=1 installcheck || status=$? - -# show diff if it exists -if test -f regression.diffs; then cat regression.diffs; fi - -exit $status