Openembedded Devel Discussions
 help / color / mirror / Atom feed
* [meta-oe][PATCH v2 0/3] ptest for PGXS extensions
@ 2026-12-02  1:25 Babanpreet Singh
  2026-12-02  1:25 ` [meta-oe][PATCH v2 1/3] postgresql: package pg_regress in postgresql-regress Babanpreet Singh
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Babanpreet Singh @ 2026-12-02  1:25 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Khem Raj, Babanpreet Singh

Run the regression tests of PGXS extensions as ptest, starting with
pg-cron. pg_regress gets its own package for this.

v2 follows Khem's review; per-patch notes are below the ---.

Babanpreet Singh (3):
  postgresql: package pg_regress in postgresql-regress
  ptest-pgxs.bbclass: add class for PGXS extension tests
  pg-cron: add ptest support

 meta-oe/classes/ptest-pgxs.bbclass            | 108 ++++++++++++++++++
 .../include/ptest-packagelists-meta-oe.inc    |   1 +
 meta-oe/recipes-dbs/pg-cron/pg-cron_1.6.8.bb  |   4 +-
 meta-oe/recipes-dbs/postgresql/postgresql.inc |   5 +-
 4 files changed, 116 insertions(+), 2 deletions(-)
 create mode 100644 meta-oe/classes/ptest-pgxs.bbclass

-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [meta-oe][PATCH v2 1/3] postgresql: package pg_regress in postgresql-regress
  2026-12-02  1:25 [meta-oe][PATCH v2 0/3] ptest for PGXS extensions Babanpreet Singh
@ 2026-12-02  1:25 ` Babanpreet Singh
  2026-12-02  1:25 ` [meta-oe][PATCH v2 2/3] ptest-pgxs.bbclass: add class for PGXS extension tests Babanpreet Singh
  2026-12-02  1:25 ` [meta-oe][PATCH v2 3/3] pg-cron: add ptest support Babanpreet Singh
  2 siblings, 0 replies; 4+ messages in thread
From: Babanpreet Singh @ 2026-12-02  1:25 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Khem Raj, Babanpreet Singh

Extension ptests need pg_regress without postgresql-server-dev, which
now recommends the new package so installcheck keeps working.

AI-Generated: Uses Claude (claude-opus-5-5)
Signed-off-by: Babanpreet Singh <bbnpreetsingh@gmail.com>
---
v2: postgresql-server-dev recommends postgresql-regress

 meta-oe/recipes-dbs/postgresql/postgresql.inc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/meta-oe/recipes-dbs/postgresql/postgresql.inc b/meta-oe/recipes-dbs/postgresql/postgresql.inc
index 00545ec74e..8d9ca10955 100644
--- a/meta-oe/recipes-dbs/postgresql/postgresql.inc
+++ b/meta-oe/recipes-dbs/postgresql/postgresql.inc
@@ -359,7 +359,7 @@ postgresql_fix_sources () {
 }
 PACKAGESPLITFUNCS =+ "postgresql_fix_sources"
 
-PACKAGES =+ "${PN}-client ${PN}-client-doc ${PN}-server-dev ${PN}-timezone \
+PACKAGES =+ "${PN}-client ${PN}-client-doc ${PN}-regress ${PN}-server-dev ${PN}-timezone \
     libecpg-compat libecpg-compat-dev \
     libecpg libecpg-dev libecpg-staticdev libecpg-doc \
     libpq libpq-dev libpq-staticdev \
@@ -421,6 +421,9 @@ FILES:${PN}-timezone = "${datadir}/${BPN}/timezone \
     ${datadir}/${BPN}/timezonesets \
 "
 RDEPENDS:${PN} += "${PN}-timezone"
+FILES:${PN}-regress = "${libdir}/${BPN}/pgxs/src/test/regress/pg_regress"
+RDEPENDS:${PN}-regress += "${PN}-client"
+RRECOMMENDS:${PN}-server-dev += "${PN}-regress"
 FILES:${PN}-server-dev = "${includedir}/${BPN}/server \
                           ${libdir}/${BPN}/pgxs \
 "
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [meta-oe][PATCH v2 2/3] ptest-pgxs.bbclass: add class for PGXS extension tests
  2026-12-02  1:25 [meta-oe][PATCH v2 0/3] ptest for PGXS extensions Babanpreet Singh
  2026-12-02  1:25 ` [meta-oe][PATCH v2 1/3] postgresql: package pg_regress in postgresql-regress Babanpreet Singh
@ 2026-12-02  1:25 ` Babanpreet Singh
  2026-12-02  1:25 ` [meta-oe][PATCH v2 3/3] pg-cron: add ptest support Babanpreet Singh
  2 siblings, 0 replies; 4+ messages in thread
From: Babanpreet Singh @ 2026-12-02  1:25 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Khem Raj, Babanpreet Singh

Run a PGXS extension's own pg_regress tests as its ptest, with the
tests and options taken from the extension's Makefile.

AI-Generated: Uses Claude (claude-opus-5-5)
Signed-off-by: Babanpreet Singh <bbnpreetsingh@gmail.com>
---
v2:
- write the scratch makefile to ${T}
- install a --schedule file under its basename and pass that name to
  pg_regress, so a schedule in a subdirectory is found
- document the fixed database and PTEST_PGXS_CONF in the class header,
  and the whitespace split of REGRESS_OPTS
- pg_regress path kept as ${libdir}/postgresql: in this class ${BPN}
  is the extension's name, not postgresql

 meta-oe/classes/ptest-pgxs.bbclass | 108 +++++++++++++++++++++++++++++
 1 file changed, 108 insertions(+)
 create mode 100644 meta-oe/classes/ptest-pgxs.bbclass

diff --git a/meta-oe/classes/ptest-pgxs.bbclass b/meta-oe/classes/ptest-pgxs.bbclass
new file mode 100644
index 0000000000..8e1eda3602
--- /dev/null
+++ b/meta-oe/classes/ptest-pgxs.bbclass
@@ -0,0 +1,108 @@
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+# Class for running the pg_regress tests of PostgreSQL extensions built
+# with PGXS as ptest
+#
+# The tests run against a temporary server, always in the database
+# contrib_regression: --temp-instance, --temp-config and --dbname in the
+# extension's REGRESS_OPTS are replaced. An extension whose expected
+# output names its own database, or needs other server settings, sets
+# them in PTEST_PGXS_CONF (pg-cron sets cron.database_name this way).
+
+inherit pgxs ptest
+
+PTEST_PGXS_CONF ?= ""
+PTEST_PGXS_CONF[doc] = "Extra postgresql.conf lines for the test server, separated by \\n."
+
+do_install_ptest() {
+	cat > ${T}/ptest-pgxs.mk << 'EOF'
+ptest-pgxs-vars:
+	@echo "REGRESS=$(REGRESS)"
+	@echo "REGRESS_OPTS=$(REGRESS_OPTS)"
+EOF
+	vars=$(oe_runmake -s -C ${B} -f Makefile -f ${T}/ptest-pgxs.mk ptest-pgxs-vars)
+	regress=$(echo "$vars" | sed -n 's/^REGRESS=//p')
+	conf=""
+	opts=""
+	inputdir=.
+	schedules=""
+	# REGRESS_OPTS is split on whitespace, so an option whose value
+	# contains spaces or quotes is not supported
+	for o in $(echo "$vars" | sed -n 's/^REGRESS_OPTS=//p'); do
+		case "$o" in
+		--temp-config=*) conf=$(basename "${o#--temp-config=}") ;;
+		--temp-instance=*|--dbname=*) ;;
+		--inputdir=*) inputdir="${o#--inputdir=}"; opts="$opts $o" ;;
+		--schedule=*)
+			schedules="$schedules ${o#--schedule=}"
+			opts="$opts --schedule=$(basename "${o#--schedule=}")"
+			;;
+		*) opts="$opts $o" ;;
+		esac
+	done
+
+	install -d ${D}${PTEST_PATH}/tests/$inputdir
+	for d in sql expected input output data; do
+		if [ -d ${S}/$inputdir/$d ]; then
+			cp -r ${S}/$inputdir/$d ${D}${PTEST_PATH}/tests/$inputdir/
+		fi
+	done
+	for s in $schedules; do
+		install -m 0644 ${S}/$s ${D}${PTEST_PATH}/tests/
+	done
+
+	: > ${D}${PTEST_PATH}/tests/ptest.conf
+	if [ -n "$conf" ] && [ -f ${S}/$conf ]; then
+		cat ${S}/$conf >> ${D}${PTEST_PATH}/tests/ptest.conf
+	fi
+	if [ -n "${PTEST_PGXS_CONF}" ]; then
+		printf '%b\n' "${PTEST_PGXS_CONF}" >> ${D}${PTEST_PATH}/tests/ptest.conf
+	fi
+
+	printf 'REGRESS="%s"\nREGRESS_OPTS="%s"\nPGBIN="%s"\nPG_REGRESS="%s"\n' \
+		"$regress" "$opts" "${bindir}" \
+		"${libdir}/postgresql/pgxs/src/test/regress/pg_regress" \
+		> ${D}${PTEST_PATH}/ptest-pgxs.vars
+
+	if [ ! -f "${UNPACKDIR}/run-ptest" ]; then
+		cat > ${D}${PTEST_PATH}/run-ptest << 'EOF'
+#!/bin/sh
+
+PTEST_PATH=$(dirname "$(readlink -f "$0")")
+. "$PTEST_PATH/ptest-pgxs.vars"
+NAME=$(basename "$(dirname "$PTEST_PATH")")
+
+WORK=$(mktemp -d /tmp/ptest-pgxs.XXXXXX)
+cp -r "$PTEST_PATH/tests/." "$WORK/"
+chown -R postgres:postgres "$WORK"
+
+LOG="$WORK/pg_regress.log"
+{ su postgres -c "cd $WORK && $PG_REGRESS \
+      --temp-instance=$WORK/tmp_check --temp-config=$WORK/ptest.conf \
+      --bindir=$PGBIN --dbname=contrib_regression \
+      $REGRESS_OPTS $REGRESS" 2>&1; echo $? > "$WORK/rc"; } |
+    tee "$LOG" |
+    sed -n -e 's/^ok [0-9]* *[-+] *\([^ ]*\).*/PASS: \1/p' \
+           -e 's/^not ok [0-9]* *[-+] *\([^ ]*\).*/FAIL: \1/p'
+RC=$(cat "$WORK/rc" 2>/dev/null || echo 2)
+
+if [ "$RC" -ne 0 ]; then
+    if [ "$RC" -ne 1 ] || ! grep -q '^\(not \)\{0,1\}ok [0-9]' "$LOG"; then
+        echo "FAIL: $NAME"
+        cat "$LOG"
+        echo
+    fi
+    [ -f "$WORK/regression.diffs" ] && cat "$WORK/regression.diffs"
+fi
+rm -rf "$WORK"
+[ "$RC" -eq 0 ]
+EOF
+		chmod 0755 ${D}${PTEST_PATH}/run-ptest
+	fi
+}
+
+RDEPENDS:${PN}-ptest += "postgresql postgresql-client postgresql-regress"
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [meta-oe][PATCH v2 3/3] pg-cron: add ptest support
  2026-12-02  1:25 [meta-oe][PATCH v2 0/3] ptest for PGXS extensions Babanpreet Singh
  2026-12-02  1:25 ` [meta-oe][PATCH v2 1/3] postgresql: package pg_regress in postgresql-regress Babanpreet Singh
  2026-12-02  1:25 ` [meta-oe][PATCH v2 2/3] ptest-pgxs.bbclass: add class for PGXS extension tests Babanpreet Singh
@ 2026-12-02  1:25 ` Babanpreet Singh
  2 siblings, 0 replies; 4+ messages in thread
From: Babanpreet Singh @ 2026-12-02  1:25 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Khem Raj, Babanpreet Singh

Use ptest-pgxs and point cron.database_name at contrib_regression,
the database the class runs the tests in.

Tested on qemux86-64 with ptest-runner: TOTAL: 1 FAIL: 0

AI-Generated: Uses Claude (claude-opus-5-5)
Signed-off-by: Babanpreet Singh <bbnpreetsingh@gmail.com>
---
v2: say what the patch does in the commit message

 meta-oe/conf/include/ptest-packagelists-meta-oe.inc | 1 +
 meta-oe/recipes-dbs/pg-cron/pg-cron_1.6.8.bb        | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
index 0e2df75d3f..09f78517e3 100644
--- a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
+++ b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
@@ -56,6 +56,7 @@ PTESTS_FAST_META_OE = "\
     openjpeg \
     oprofile \
     pegtl \
+    pg-cron \
     pv \
     sdbus-c++ \
     tomlplusplus \
diff --git a/meta-oe/recipes-dbs/pg-cron/pg-cron_1.6.8.bb b/meta-oe/recipes-dbs/pg-cron/pg-cron_1.6.8.bb
index 9f9a59b398..20b16bda44 100644
--- a/meta-oe/recipes-dbs/pg-cron/pg-cron_1.6.8.bb
+++ b/meta-oe/recipes-dbs/pg-cron/pg-cron_1.6.8.bb
@@ -10,4 +10,6 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=b70f68d78dbcc36c5654d795cee59b0d"
 SRC_URI = "git://github.com/citusdata/pg_cron.git;protocol=https;branch=main;tag=v${PV}"
 SRCREV = "2323864075a50f234235f98e567eb958f923b2b3"
 
-inherit pgxs
+inherit ptest-pgxs
+
+PTEST_PGXS_CONF = "cron.database_name = 'contrib_regression'"
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-02  1:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02  1:25 [meta-oe][PATCH v2 0/3] ptest for PGXS extensions Babanpreet Singh
2026-12-02  1:25 ` [meta-oe][PATCH v2 1/3] postgresql: package pg_regress in postgresql-regress Babanpreet Singh
2026-12-02  1:25 ` [meta-oe][PATCH v2 2/3] ptest-pgxs.bbclass: add class for PGXS extension tests Babanpreet Singh
2026-12-02  1:25 ` [meta-oe][PATCH v2 3/3] pg-cron: add ptest support Babanpreet Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox