summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-dbs/postgresql/files
diff options
context:
space:
mode:
authorGuocai He <guocai.he.cn@windriver.com>2026-03-24 18:50:21 +0800
committerKhem Raj <khem.raj@oss.qualcomm.com>2026-03-24 09:13:49 -0700
commit4fe575d155a02e8d286d1caaa14286d23ea74a84 (patch)
tree43768c1f0d25fb55a9559afe36eb464938e4d894 /meta-oe/recipes-dbs/postgresql/files
parentc4c6915cba39bf510d53ceb11778314665b510f6 (diff)
downloadmeta-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-ptest65
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
10set -e
11
12PGDATA=/tmp/ptest_pgdata
13PTEST_PATH=$(dirname "$(readlink -f "$0")")
14TESTDIR="${PTEST_PATH}/test"
15PGBIN=$(pg_config --bindir)
16PKGLIBDIR=$(pg_config --pkglibdir)
17
18cleanup() {
19 su - postgres -c "pg_ctl -D ${PGDATA} stop -m immediate" 2>/dev/null || true
20 rm -rf "${PGDATA}"
21}
22trap cleanup EXIT
23
24# Initialize the database cluster
25rm -rf "${PGDATA}"
26su - postgres -c "${PGBIN}/initdb -D ${PGDATA} --no-locale" || exit 1
27
28# Start the server
29su - 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/).
33chown -R postgres:postgres "${TESTDIR}"
34
35# Prepare the tablespace test directory
36mkdir -p "${TESTDIR}/testtablespace"
37chmod 0700 "${TESTDIR}/testtablespace"
38chown postgres:postgres "${TESTDIR}/testtablespace"
39
40# Disable set -e before the pipe so we can capture PIPESTATUS
41set +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.
47su - 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'
57RESULT=${PIPESTATUS[0]}
58
59if [ "${RESULT}" = "0" ]; then
60 echo "PASS: all tests passed"
61else
62 echo "FAIL: some tests failed"
63fi
64
65exit ${RESULT}