diff options
| author | Guocai He <guocai.he.cn@windriver.com> | 2026-03-24 18:50:21 +0800 |
|---|---|---|
| committer | Khem Raj <khem.raj@oss.qualcomm.com> | 2026-03-24 09:13:49 -0700 |
| commit | 4fe575d155a02e8d286d1caaa14286d23ea74a84 (patch) | |
| tree | 43768c1f0d25fb55a9559afe36eb464938e4d894 /meta-oe/recipes-dbs/postgresql/files | |
| parent | c4c6915cba39bf510d53ceb11778314665b510f6 (diff) | |
| download | meta-openembedded-4fe575d155a02e8d286d1caaa14286d23ea74a84.tar.gz | |
postgresql: add ptest support
Add ptest infrastructure to run the PostgreSQL standard regression test
suite (pg_regress) on the target system.
Test logs:
root@qemux86-64:~# ptest-runner postgresql
START: ptest-runner
2026-03-24T02:42
BEGIN: /usr/lib64/postgresql/ptest
.....
**if all pass **
PASS: - event_trigger_login 1901 ms
PASS: - fast_default 9459 ms
PASS: - tablespace 16542 ms
PASS: all tests passed
**if have fail**
FAIL: create_type 1763 ms
PASS: create_schema 2123 ms
PASS: - tablespace 23226 ms
FAIL: some tests failed
waiting for server to shut down.... done
server stopped
DURATION: 853
END: /usr/lib64/postgresql/ptest
2026-03-24T02:56
STOP: ptest-runner
TOTAL: 1 FAIL: 0
Signed-off-by: Guocai He <guocai.he.cn@windriver.com>
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
Diffstat (limited to 'meta-oe/recipes-dbs/postgresql/files')
| -rw-r--r-- | meta-oe/recipes-dbs/postgresql/files/run-ptest | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/meta-oe/recipes-dbs/postgresql/files/run-ptest b/meta-oe/recipes-dbs/postgresql/files/run-ptest new file mode 100644 index 0000000000..4cb8e5c7e1 --- /dev/null +++ b/meta-oe/recipes-dbs/postgresql/files/run-ptest | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # | ||
| 3 | # PostgreSQL regression test runner for ptest | ||
| 4 | # | ||
| 5 | # This script initializes a temporary PostgreSQL database cluster, | ||
| 6 | # starts a server instance, and executes the standard regression test | ||
| 7 | # suite via pg_regress against the installed PostgreSQL binaries. | ||
| 8 | # | ||
| 9 | |||
| 10 | set -e | ||
| 11 | |||
| 12 | PGDATA=/tmp/ptest_pgdata | ||
| 13 | PTEST_PATH=$(dirname "$(readlink -f "$0")") | ||
| 14 | TESTDIR="${PTEST_PATH}/test" | ||
| 15 | PGBIN=$(pg_config --bindir) | ||
| 16 | PKGLIBDIR=$(pg_config --pkglibdir) | ||
| 17 | |||
| 18 | cleanup() { | ||
| 19 | su - postgres -c "pg_ctl -D ${PGDATA} stop -m immediate" 2>/dev/null || true | ||
| 20 | rm -rf "${PGDATA}" | ||
| 21 | } | ||
| 22 | trap cleanup EXIT | ||
| 23 | |||
| 24 | # Initialize the database cluster | ||
| 25 | rm -rf "${PGDATA}" | ||
| 26 | su - postgres -c "${PGBIN}/initdb -D ${PGDATA} --no-locale" || exit 1 | ||
| 27 | |||
| 28 | # Start the server | ||
| 29 | su - postgres -c "pg_ctl -D ${PGDATA} -l ${PGDATA}/logfile start -w -t 120" || exit 1 | ||
| 30 | |||
| 31 | # Ensure the test directory is writable by the postgres user for | ||
| 32 | # regression output files (regression.out, regression.diffs, results/). | ||
| 33 | chown -R postgres:postgres "${TESTDIR}" | ||
| 34 | |||
| 35 | # Prepare the tablespace test directory | ||
| 36 | mkdir -p "${TESTDIR}/testtablespace" | ||
| 37 | chmod 0700 "${TESTDIR}/testtablespace" | ||
| 38 | chown postgres:postgres "${TESTDIR}/testtablespace" | ||
| 39 | |||
| 40 | # Disable set -e before the pipe so we can capture PIPESTATUS | ||
| 41 | set +e | ||
| 42 | |||
| 43 | # Run the regression tests. | ||
| 44 | # --dlpath points to the standard PostgreSQL package library directory | ||
| 45 | # where regress.so and contrib modules (autoinc.so, refint.so, etc.) | ||
| 46 | # are installed, so that CREATE FUNCTION ... AS tests can locate them. | ||
| 47 | su - postgres -c "cd ${TESTDIR} && \ | ||
| 48 | ${TESTDIR}/pg_regress \ | ||
| 49 | --inputdir=. \ | ||
| 50 | --bindir=${PGBIN} \ | ||
| 51 | --dlpath=${PKGLIBDIR} \ | ||
| 52 | --max-concurrent-tests=20 \ | ||
| 53 | --schedule=parallel_schedule" 2>&1 | \ | ||
| 54 | stdbuf -oL sed -n \ | ||
| 55 | -e 's/^ok [0-9]\+\s\+[+* ]\?\s*/PASS: /p' \ | ||
| 56 | -e 's/^not ok [0-9]\+\s\+[+* ]\?\s*/FAIL: /p' | ||
| 57 | RESULT=${PIPESTATUS[0]} | ||
| 58 | |||
| 59 | if [ "${RESULT}" = "0" ]; then | ||
| 60 | echo "PASS: all tests passed" | ||
| 61 | else | ||
| 62 | echo "FAIL: some tests failed" | ||
| 63 | fi | ||
| 64 | |||
| 65 | exit ${RESULT} | ||
