diff mbox series

[meta-oe] postgresql: add ptest support

Message ID 20260324071621.3104812-1-guocai.he.cn@windriver.com
State New
Headers show
Series [meta-oe] postgresql: add ptest support | expand

Commit Message

He, Guocai March 24, 2026, 7:16 a.m. UTC
From: Guocai He <guocai.he.cn@windriver.com>

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
......
......
All 224 tests passed.
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>
---
 .../include/ptest-packagelists-meta-oe.inc    |  1 +
 .../recipes-dbs/postgresql/files/run-ptest    | 53 +++++++++++++++++++
 meta-oe/recipes-dbs/postgresql/postgresql.inc | 42 ++++++++++++++-
 3 files changed, 95 insertions(+), 1 deletion(-)
 create mode 100644 meta-oe/recipes-dbs/postgresql/files/run-ptest

Comments

Gyorgy Sarvari March 24, 2026, 7:36 a.m. UTC | #1
On 3/24/26 08:16, guocai he via lists.openembedded.org wrote:
> From: Guocai He <guocai.he.cn@windriver.com>
> 
> 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
> ......
> ......


I'd like to ask just one confirmation question about this "....." here

Is the output machine parseable, i.e. do the results have PASS:/FAIL:
prefix, at least as a final summary?
The run-ptest script doesn't seem to do such conversion, so I'm just
curious if the output is usable out of the box.


> All 224 tests passed.
> 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>
> ---
>  .../include/ptest-packagelists-meta-oe.inc    |  1 +
>  .../recipes-dbs/postgresql/files/run-ptest    | 53 +++++++++++++++++++
>  meta-oe/recipes-dbs/postgresql/postgresql.inc | 42 ++++++++++++++-
>  3 files changed, 95 insertions(+), 1 deletion(-)
>  create mode 100644 meta-oe/recipes-dbs/postgresql/files/run-ptest
> 
> diff --git a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
> index 4de602ac1c..0e395db48a 100644
> --- a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
> +++ b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
> @@ -76,6 +76,7 @@ PTESTS_SLOW_META_OE = "\
>      fftw \
>      libusb-compat \
>      mariadb \
> +    postgresql \
>      re2 \
>      rocksdb \
>  "
> 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..004cf2ba87
> --- /dev/null
> +++ b/meta-oe/recipes-dbs/postgresql/files/run-ptest
> @@ -0,0 +1,53 @@
> +#!/bin/sh
> +#
> +# PostgreSQL regression test runner for ptest
> +#
> +# This script initializes a temporary PostgreSQL database cluster,
> +# starts a server instance, and executes the standard regression test
> +# suite via pg_regress against the installed PostgreSQL binaries.
> +#
> +
> +set -e
> +
> +PGDATA=/tmp/ptest_pgdata
> +PTEST_PATH=$(dirname "$(readlink -f "$0")")
> +TESTDIR="${PTEST_PATH}/test"
> +PGBIN=$(pg_config --bindir)
> +PKGLIBDIR=$(pg_config --pkglibdir)
> +
> +cleanup() {
> +    su - postgres -c "pg_ctl -D ${PGDATA} stop -m immediate" 2>/dev/null || true
> +    rm -rf "${PGDATA}"
> +}
> +trap cleanup EXIT
> +
> +# Initialize the database cluster
> +rm -rf "${PGDATA}"
> +su - postgres -c "${PGBIN}/initdb -D ${PGDATA} --no-locale" || exit 1
> +
> +# Start the server
> +su - postgres -c "pg_ctl -D ${PGDATA} -l ${PGDATA}/logfile start -w -t 120" || exit 1
> +
> +# Ensure the test directory is writable by the postgres user for
> +# regression output files (regression.out, regression.diffs, results/).
> +chown -R postgres:postgres "${TESTDIR}"
> +
> +# Prepare the tablespace test directory
> +mkdir -p "${TESTDIR}/testtablespace"
> +chmod 0700 "${TESTDIR}/testtablespace"
> +chown postgres:postgres "${TESTDIR}/testtablespace"
> +
> +# Run the regression tests.
> +# --dlpath points to the standard PostgreSQL package library directory
> +# where regress.so and contrib modules (autoinc.so, refint.so, etc.)
> +# are installed, so that CREATE FUNCTION ... AS tests can locate them.
> +su - postgres -c "cd ${TESTDIR} && \
> +    ${TESTDIR}/pg_regress \
> +        --inputdir=. \
> +        --bindir=${PGBIN} \
> +        --dlpath=${PKGLIBDIR} \
> +        --max-concurrent-tests=20 \
> +        --schedule=parallel_schedule"
> +RESULT=$?
> +
> +exit ${RESULT}
> diff --git a/meta-oe/recipes-dbs/postgresql/postgresql.inc b/meta-oe/recipes-dbs/postgresql/postgresql.inc
> index 040b3d5e34..dfc624f07e 100644
> --- a/meta-oe/recipes-dbs/postgresql/postgresql.inc
> +++ b/meta-oe/recipes-dbs/postgresql/postgresql.inc
> @@ -29,6 +29,7 @@ SRC_URI = "https://ftp.postgresql.org/pub/source/v${PV}/${BP}.tar.bz2 \
>      file://postgresql.pam \
>      file://postgresql-setup \
>      file://postgresql.service \
> +    file://run-ptest \
>  "
>  
>  LEAD_SONAME = "libpq.so"
> @@ -37,7 +38,7 @@ LEAD_SONAME = "libpq.so"
>  export LDFLAGS_SL = "${LDFLAGS}"
>  export LDFLAGS_EX_BE = "-Wl,--export-dynamic"
>  
> -inherit autotools pkgconfig perlnative python3native python3targetconfig useradd update-rc.d systemd gettext perl-version multilib_header
> +inherit autotools pkgconfig perlnative python3native python3targetconfig useradd update-rc.d systemd gettext perl-version multilib_header ptest
>  
>  CFLAGS += "-I${STAGING_INCDIR}/${PYTHON_DIR}"
>  
> @@ -184,6 +185,45 @@ do_compile:append() {
>      done
>  }
>  
> +do_compile_ptest() {
> +    oe_runmake -C src/test/regress all
> +}
> +
> +do_install_ptest() {
> +    mkdir -p ${D}${PTEST_PATH}/test
> +
> +    # Install pg_regress binary
> +    install -m 0755 ${B}/src/test/regress/pg_regress ${D}${PTEST_PATH}/test/
> +
> +    # Install test schedules and resultmap
> +    for f in parallel_schedule serial_schedule resultmap; do
> +        [ -f ${S}/src/test/regress/$f ] && install -m 0644 ${S}/src/test/regress/$f ${D}${PTEST_PATH}/test/
> +    done
> +
> +    # Install SQL, expected, input, output, and data files
> +    for d in sql expected input output data; do
> +        if [ -d ${S}/src/test/regress/$d ]; then
> +            cp -r ${S}/src/test/regress/$d ${D}${PTEST_PATH}/test/
> +        fi
> +    done
> +
> +    # Install the regress test shared library into the standard PostgreSQL
> +    # package library directory (PKGLIBDIR) alongside contrib modules such
> +    # as autoinc.so and refint.so. This allows pg_regress --dlpath to
> +    # resolve all required shared libraries from a single location.
> +    install -d ${D}${libdir}/${BPN}
> +    install -m 0755 ${B}/src/test/regress/regress.so ${D}${libdir}/${BPN}/
> +
> +    # Install run-ptest
> +    install -m 0755 ${UNPACKDIR}/run-ptest ${D}${PTEST_PATH}/
> +
> +    # Set ownership to postgres user for running tests
> +    chown -R postgres:postgres ${D}${PTEST_PATH}
> +}
> +
> +RDEPENDS:${PN}-ptest += "${PN} ${PN}-client ${PN}-contrib perl"


${PN} is part of this RDEPENDS implicitly, no need to add it separately
(granted, it also does no harm by being here)


> +FILES:${PN}-ptest += "${libdir}/${BPN}/regress.so"
> +
>  # server needs to configure user and group
>  usernum = "28"
>  groupnum = "28"
> 
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#125542): https://lists.openembedded.org/g/openembedded-devel/message/125542
> Mute This Topic: https://lists.openembedded.org/mt/118479820/6084445
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [skandigraun@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
He, Guocai March 24, 2026, 7:57 a.m. UTC | #2
On 3/24/26 15:36, Gyorgy Sarvari wrote:
> CAUTION: This email comes from a non Wind River email account!
> Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
> On 3/24/26 08:16, guocai he via lists.openembedded.org wrote:
>> From: Guocai He <guocai.he.cn@windriver.com>
>>
>> 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
>> ......
>> ......
>
> I'd like to ask just one confirmation question about this "....." here
>
> Is the output machine parseable, i.e. do the results have PASS:/FAIL:
> prefix, at least as a final summary?
> The run-ptest script doesn't seem to do such conversion, so I'm just
> curious if the output is usable out of the box.

logs like:

waiting for server to start..... done
server started
# using postmaster on Unix socket, default port
ok 1         - test_setup                              11275 ms
# parallel group (20 tests):  int2 name text char varchar int4 oid txid 
pg_lsn regproc money boolean int8 uuid floa
t4 float8 bit enum rangetypes numeric
ok 2         + boolean                                  4823 ms
ok 3         + char                                     3601 ms
ok 4         + name                                     3347 ms
ok 5         + varchar                                  3695 ms
ok 6         + text                                     3364 ms
ok 7         + int2                                     2609 ms
ok 8         + int4                                     3636 ms
ok 9         + int8                                     5066 ms
ok 10        + oid                                      3590 ms


ok 216       + compression                              9827 ms
ok 217       + memoize                                  9233 ms
ok 218       + stats                                   23898 ms
ok 219       + predicate                                3535 ms
# parallel group (2 tests):  oidjoins event_trigger
ok 220       + oidjoins                                 7394 ms
ok 221       + event_trigger                            9363 ms
ok 222       - event_trigger_login                      2059 ms
ok 223       - fast_default                             8790 ms
ok 224       - tablespace                              19201 ms
1..224
# All 224 tests passed.
waiting for server to shut down.... done
server stopped
DURATION: 890
END: /usr/lib64/postgresql/ptest

>
>
>> All 224 tests passed.
>> 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>
>> ---
>>   .../include/ptest-packagelists-meta-oe.inc    |  1 +
>>   .../recipes-dbs/postgresql/files/run-ptest    | 53 +++++++++++++++++++
>>   meta-oe/recipes-dbs/postgresql/postgresql.inc | 42 ++++++++++++++-
>>   3 files changed, 95 insertions(+), 1 deletion(-)
>>   create mode 100644 meta-oe/recipes-dbs/postgresql/files/run-ptest
>>
>> diff --git a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
>> index 4de602ac1c..0e395db48a 100644
>> --- a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
>> +++ b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
>> @@ -76,6 +76,7 @@ PTESTS_SLOW_META_OE = "\
>>       fftw \
>>       libusb-compat \
>>       mariadb \
>> +    postgresql \
>>       re2 \
>>       rocksdb \
>>   "
>> 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..004cf2ba87
>> --- /dev/null
>> +++ b/meta-oe/recipes-dbs/postgresql/files/run-ptest
>> @@ -0,0 +1,53 @@
>> +#!/bin/sh
>> +#
>> +# PostgreSQL regression test runner for ptest
>> +#
>> +# This script initializes a temporary PostgreSQL database cluster,
>> +# starts a server instance, and executes the standard regression test
>> +# suite via pg_regress against the installed PostgreSQL binaries.
>> +#
>> +
>> +set -e
>> +
>> +PGDATA=/tmp/ptest_pgdata
>> +PTEST_PATH=$(dirname "$(readlink -f "$0")")
>> +TESTDIR="${PTEST_PATH}/test"
>> +PGBIN=$(pg_config --bindir)
>> +PKGLIBDIR=$(pg_config --pkglibdir)
>> +
>> +cleanup() {
>> +    su - postgres -c "pg_ctl -D ${PGDATA} stop -m immediate" 2>/dev/null || true
>> +    rm -rf "${PGDATA}"
>> +}
>> +trap cleanup EXIT
>> +
>> +# Initialize the database cluster
>> +rm -rf "${PGDATA}"
>> +su - postgres -c "${PGBIN}/initdb -D ${PGDATA} --no-locale" || exit 1
>> +
>> +# Start the server
>> +su - postgres -c "pg_ctl -D ${PGDATA} -l ${PGDATA}/logfile start -w -t 120" || exit 1
>> +
>> +# Ensure the test directory is writable by the postgres user for
>> +# regression output files (regression.out, regression.diffs, results/).
>> +chown -R postgres:postgres "${TESTDIR}"
>> +
>> +# Prepare the tablespace test directory
>> +mkdir -p "${TESTDIR}/testtablespace"
>> +chmod 0700 "${TESTDIR}/testtablespace"
>> +chown postgres:postgres "${TESTDIR}/testtablespace"
>> +
>> +# Run the regression tests.
>> +# --dlpath points to the standard PostgreSQL package library directory
>> +# where regress.so and contrib modules (autoinc.so, refint.so, etc.)
>> +# are installed, so that CREATE FUNCTION ... AS tests can locate them.
>> +su - postgres -c "cd ${TESTDIR} && \
>> +    ${TESTDIR}/pg_regress \
>> +        --inputdir=. \
>> +        --bindir=${PGBIN} \
>> +        --dlpath=${PKGLIBDIR} \
>> +        --max-concurrent-tests=20 \
>> +        --schedule=parallel_schedule"
>> +RESULT=$?
>> +
>> +exit ${RESULT}
>> diff --git a/meta-oe/recipes-dbs/postgresql/postgresql.inc b/meta-oe/recipes-dbs/postgresql/postgresql.inc
>> index 040b3d5e34..dfc624f07e 100644
>> --- a/meta-oe/recipes-dbs/postgresql/postgresql.inc
>> +++ b/meta-oe/recipes-dbs/postgresql/postgresql.inc
>> @@ -29,6 +29,7 @@ SRC_URI = "https://ftp.postgresql.org/pub/source/v${PV}/${BP}.tar.bz2 \
>>       file://postgresql.pam \
>>       file://postgresql-setup \
>>       file://postgresql.service \
>> +    file://run-ptest \
>>   "
>>
>>   LEAD_SONAME = "libpq.so"
>> @@ -37,7 +38,7 @@ LEAD_SONAME = "libpq.so"
>>   export LDFLAGS_SL = "${LDFLAGS}"
>>   export LDFLAGS_EX_BE = "-Wl,--export-dynamic"
>>
>> -inherit autotools pkgconfig perlnative python3native python3targetconfig useradd update-rc.d systemd gettext perl-version multilib_header
>> +inherit autotools pkgconfig perlnative python3native python3targetconfig useradd update-rc.d systemd gettext perl-version multilib_header ptest
>>
>>   CFLAGS += "-I${STAGING_INCDIR}/${PYTHON_DIR}"
>>
>> @@ -184,6 +185,45 @@ do_compile:append() {
>>       done
>>   }
>>
>> +do_compile_ptest() {
>> +    oe_runmake -C src/test/regress all
>> +}
>> +
>> +do_install_ptest() {
>> +    mkdir -p ${D}${PTEST_PATH}/test
>> +
>> +    # Install pg_regress binary
>> +    install -m 0755 ${B}/src/test/regress/pg_regress ${D}${PTEST_PATH}/test/
>> +
>> +    # Install test schedules and resultmap
>> +    for f in parallel_schedule serial_schedule resultmap; do
>> +        [ -f ${S}/src/test/regress/$f ] && install -m 0644 ${S}/src/test/regress/$f ${D}${PTEST_PATH}/test/
>> +    done
>> +
>> +    # Install SQL, expected, input, output, and data files
>> +    for d in sql expected input output data; do
>> +        if [ -d ${S}/src/test/regress/$d ]; then
>> +            cp -r ${S}/src/test/regress/$d ${D}${PTEST_PATH}/test/
>> +        fi
>> +    done
>> +
>> +    # Install the regress test shared library into the standard PostgreSQL
>> +    # package library directory (PKGLIBDIR) alongside contrib modules such
>> +    # as autoinc.so and refint.so. This allows pg_regress --dlpath to
>> +    # resolve all required shared libraries from a single location.
>> +    install -d ${D}${libdir}/${BPN}
>> +    install -m 0755 ${B}/src/test/regress/regress.so ${D}${libdir}/${BPN}/
>> +
>> +    # Install run-ptest
>> +    install -m 0755 ${UNPACKDIR}/run-ptest ${D}${PTEST_PATH}/
>> +
>> +    # Set ownership to postgres user for running tests
>> +    chown -R postgres:postgres ${D}${PTEST_PATH}
>> +}
>> +
>> +RDEPENDS:${PN}-ptest += "${PN} ${PN}-client ${PN}-contrib perl"
>
> ${PN} is part of this RDEPENDS implicitly, no need to add it separately
> (granted, it also does no harm by being here)
>
>
>> +FILES:${PN}-ptest += "${libdir}/${BPN}/regress.so"
>> +
>>   # server needs to configure user and group
>>   usernum = "28"
>>   groupnum = "28"
>>
>>
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>> View/Reply Online (#125542): https://lists.openembedded.org/g/openembedded-devel/message/125542
>> Mute This Topic: https://lists.openembedded.org/mt/118479820/6084445
>> Group Owner: openembedded-devel+owner@lists.openembedded.org
>> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [skandigraun@gmail.com]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>
He, Guocai March 24, 2026, 8:05 a.m. UTC | #3
On 3/24/26 15:36, Gyorgy Sarvari wrote:
> CAUTION: This email comes from a non Wind River email account!
> Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
> On 3/24/26 08:16, guocai he via lists.openembedded.org wrote:
>> From: Guocai He <guocai.he.cn@windriver.com>
>>
>> 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
>> ......
>> ......
>
> I'd like to ask just one confirmation question about this "....." here
>
> Is the output machine parseable, i.e. do the results have PASS:/FAIL:
> prefix, at least as a final summary?
> The run-ptest script doesn't seem to do such conversion, so I'm just
> curious if the output is usable out of the box.

if one case fail, the logs like:

.......

not ok 78    + triggers                                38360 ms

......

# 1 of 224 tests failed.

>
>
>> All 224 tests passed.
>> 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>
>> ---
>>   .../include/ptest-packagelists-meta-oe.inc    |  1 +
>>   .../recipes-dbs/postgresql/files/run-ptest    | 53 +++++++++++++++++++
>>   meta-oe/recipes-dbs/postgresql/postgresql.inc | 42 ++++++++++++++-
>>   3 files changed, 95 insertions(+), 1 deletion(-)
>>   create mode 100644 meta-oe/recipes-dbs/postgresql/files/run-ptest
>>
>> diff --git a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
>> index 4de602ac1c..0e395db48a 100644
>> --- a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
>> +++ b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
>> @@ -76,6 +76,7 @@ PTESTS_SLOW_META_OE = "\
>>       fftw \
>>       libusb-compat \
>>       mariadb \
>> +    postgresql \
>>       re2 \
>>       rocksdb \
>>   "
>> 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..004cf2ba87
>> --- /dev/null
>> +++ b/meta-oe/recipes-dbs/postgresql/files/run-ptest
>> @@ -0,0 +1,53 @@
>> +#!/bin/sh
>> +#
>> +# PostgreSQL regression test runner for ptest
>> +#
>> +# This script initializes a temporary PostgreSQL database cluster,
>> +# starts a server instance, and executes the standard regression test
>> +# suite via pg_regress against the installed PostgreSQL binaries.
>> +#
>> +
>> +set -e
>> +
>> +PGDATA=/tmp/ptest_pgdata
>> +PTEST_PATH=$(dirname "$(readlink -f "$0")")
>> +TESTDIR="${PTEST_PATH}/test"
>> +PGBIN=$(pg_config --bindir)
>> +PKGLIBDIR=$(pg_config --pkglibdir)
>> +
>> +cleanup() {
>> +    su - postgres -c "pg_ctl -D ${PGDATA} stop -m immediate" 2>/dev/null || true
>> +    rm -rf "${PGDATA}"
>> +}
>> +trap cleanup EXIT
>> +
>> +# Initialize the database cluster
>> +rm -rf "${PGDATA}"
>> +su - postgres -c "${PGBIN}/initdb -D ${PGDATA} --no-locale" || exit 1
>> +
>> +# Start the server
>> +su - postgres -c "pg_ctl -D ${PGDATA} -l ${PGDATA}/logfile start -w -t 120" || exit 1
>> +
>> +# Ensure the test directory is writable by the postgres user for
>> +# regression output files (regression.out, regression.diffs, results/).
>> +chown -R postgres:postgres "${TESTDIR}"
>> +
>> +# Prepare the tablespace test directory
>> +mkdir -p "${TESTDIR}/testtablespace"
>> +chmod 0700 "${TESTDIR}/testtablespace"
>> +chown postgres:postgres "${TESTDIR}/testtablespace"
>> +
>> +# Run the regression tests.
>> +# --dlpath points to the standard PostgreSQL package library directory
>> +# where regress.so and contrib modules (autoinc.so, refint.so, etc.)
>> +# are installed, so that CREATE FUNCTION ... AS tests can locate them.
>> +su - postgres -c "cd ${TESTDIR} && \
>> +    ${TESTDIR}/pg_regress \
>> +        --inputdir=. \
>> +        --bindir=${PGBIN} \
>> +        --dlpath=${PKGLIBDIR} \
>> +        --max-concurrent-tests=20 \
>> +        --schedule=parallel_schedule"
>> +RESULT=$?
>> +
>> +exit ${RESULT}
>> diff --git a/meta-oe/recipes-dbs/postgresql/postgresql.inc b/meta-oe/recipes-dbs/postgresql/postgresql.inc
>> index 040b3d5e34..dfc624f07e 100644
>> --- a/meta-oe/recipes-dbs/postgresql/postgresql.inc
>> +++ b/meta-oe/recipes-dbs/postgresql/postgresql.inc
>> @@ -29,6 +29,7 @@ SRC_URI = "https://ftp.postgresql.org/pub/source/v${PV}/${BP}.tar.bz2 \
>>       file://postgresql.pam \
>>       file://postgresql-setup \
>>       file://postgresql.service \
>> +    file://run-ptest \
>>   "
>>
>>   LEAD_SONAME = "libpq.so"
>> @@ -37,7 +38,7 @@ LEAD_SONAME = "libpq.so"
>>   export LDFLAGS_SL = "${LDFLAGS}"
>>   export LDFLAGS_EX_BE = "-Wl,--export-dynamic"
>>
>> -inherit autotools pkgconfig perlnative python3native python3targetconfig useradd update-rc.d systemd gettext perl-version multilib_header
>> +inherit autotools pkgconfig perlnative python3native python3targetconfig useradd update-rc.d systemd gettext perl-version multilib_header ptest
>>
>>   CFLAGS += "-I${STAGING_INCDIR}/${PYTHON_DIR}"
>>
>> @@ -184,6 +185,45 @@ do_compile:append() {
>>       done
>>   }
>>
>> +do_compile_ptest() {
>> +    oe_runmake -C src/test/regress all
>> +}
>> +
>> +do_install_ptest() {
>> +    mkdir -p ${D}${PTEST_PATH}/test
>> +
>> +    # Install pg_regress binary
>> +    install -m 0755 ${B}/src/test/regress/pg_regress ${D}${PTEST_PATH}/test/
>> +
>> +    # Install test schedules and resultmap
>> +    for f in parallel_schedule serial_schedule resultmap; do
>> +        [ -f ${S}/src/test/regress/$f ] && install -m 0644 ${S}/src/test/regress/$f ${D}${PTEST_PATH}/test/
>> +    done
>> +
>> +    # Install SQL, expected, input, output, and data files
>> +    for d in sql expected input output data; do
>> +        if [ -d ${S}/src/test/regress/$d ]; then
>> +            cp -r ${S}/src/test/regress/$d ${D}${PTEST_PATH}/test/
>> +        fi
>> +    done
>> +
>> +    # Install the regress test shared library into the standard PostgreSQL
>> +    # package library directory (PKGLIBDIR) alongside contrib modules such
>> +    # as autoinc.so and refint.so. This allows pg_regress --dlpath to
>> +    # resolve all required shared libraries from a single location.
>> +    install -d ${D}${libdir}/${BPN}
>> +    install -m 0755 ${B}/src/test/regress/regress.so ${D}${libdir}/${BPN}/
>> +
>> +    # Install run-ptest
>> +    install -m 0755 ${UNPACKDIR}/run-ptest ${D}${PTEST_PATH}/
>> +
>> +    # Set ownership to postgres user for running tests
>> +    chown -R postgres:postgres ${D}${PTEST_PATH}
>> +}
>> +
>> +RDEPENDS:${PN}-ptest += "${PN} ${PN}-client ${PN}-contrib perl"
>
> ${PN} is part of this RDEPENDS implicitly, no need to add it separately
> (granted, it also does no harm by being here)
>
>
>> +FILES:${PN}-ptest += "${libdir}/${BPN}/regress.so"
>> +
>>   # server needs to configure user and group
>>   usernum = "28"
>>   groupnum = "28"
>>
>>
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>> View/Reply Online (#125542): https://lists.openembedded.org/g/openembedded-devel/message/125542
>> Mute This Topic: https://lists.openembedded.org/mt/118479820/6084445
>> Group Owner: openembedded-devel+owner@lists.openembedded.org
>> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [skandigraun@gmail.com]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>
Gyorgy Sarvari March 24, 2026, 8:16 a.m. UTC | #4
On 3/24/26 09:05, guocai he via lists.openembedded.org wrote:
> 
> On 3/24/26 15:36, Gyorgy Sarvari wrote:
>> CAUTION: This email comes from a non Wind River email account!
>> Do not click links or open attachments unless you recognize the sender and know the content is safe.
>>
>> On 3/24/26 08:16, guocai he via lists.openembedded.org wrote:
>>> From: Guocai He <guocai.he.cn@windriver.com>
>>>
>>> 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
>>> ......
>>> ......
>>
>> I'd like to ask just one confirmation question about this "....." here
>>
>> Is the output machine parseable, i.e. do the results have PASS:/FAIL:
>> prefix, at least as a final summary?
>> The run-ptest script doesn't seem to do such conversion, so I'm just
>> curious if the output is usable out of the box.
> 
> if one case fail, the logs like:
> 
> .......
> 
> not ok 78    + triggers                                38360 ms
> 
> ......
> 
> # 1 of 224 tests failed.
> 

Thanks. The problem with this is that it will always show up as a
failure on the autobuilder, because it can't parse any results - the
logparser looks explicitly for PASS: and FAIL: patterns at the start of
the output to detect passing/failing tests.

Most frequently this is done by sed commands in the run-ptest script,
converting the test output to something ptest-compatible. But at the
least, could you please add a summary to the end of the run-ptest
script, something like

if [ "${RESULT}" == "0" ]; then
  echo PASS: all tests passed
else
  echo FAIL: some tests failed
fi

This would allow automatic evaluation of the results.

>>
>>
>>> All 224 tests passed.
>>> 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>
>>> ---
>>>   .../include/ptest-packagelists-meta-oe.inc    |  1 +
>>>   .../recipes-dbs/postgresql/files/run-ptest    | 53 +++++++++++++++++++
>>>   meta-oe/recipes-dbs/postgresql/postgresql.inc | 42 ++++++++++++++-
>>>   3 files changed, 95 insertions(+), 1 deletion(-)
>>>   create mode 100644 meta-oe/recipes-dbs/postgresql/files/run-ptest
>>>
>>> diff --git a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
>>> index 4de602ac1c..0e395db48a 100644
>>> --- a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
>>> +++ b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
>>> @@ -76,6 +76,7 @@ PTESTS_SLOW_META_OE = "\
>>>       fftw \
>>>       libusb-compat \
>>>       mariadb \
>>> +    postgresql \
>>>       re2 \
>>>       rocksdb \
>>>   "
>>> 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..004cf2ba87
>>> --- /dev/null
>>> +++ b/meta-oe/recipes-dbs/postgresql/files/run-ptest
>>> @@ -0,0 +1,53 @@
>>> +#!/bin/sh
>>> +#
>>> +# PostgreSQL regression test runner for ptest
>>> +#
>>> +# This script initializes a temporary PostgreSQL database cluster,
>>> +# starts a server instance, and executes the standard regression test
>>> +# suite via pg_regress against the installed PostgreSQL binaries.
>>> +#
>>> +
>>> +set -e
>>> +
>>> +PGDATA=/tmp/ptest_pgdata
>>> +PTEST_PATH=$(dirname "$(readlink -f "$0")")
>>> +TESTDIR="${PTEST_PATH}/test"
>>> +PGBIN=$(pg_config --bindir)
>>> +PKGLIBDIR=$(pg_config --pkglibdir)
>>> +
>>> +cleanup() {
>>> +    su - postgres -c "pg_ctl -D ${PGDATA} stop -m immediate" 2>/dev/null || true
>>> +    rm -rf "${PGDATA}"
>>> +}
>>> +trap cleanup EXIT
>>> +
>>> +# Initialize the database cluster
>>> +rm -rf "${PGDATA}"
>>> +su - postgres -c "${PGBIN}/initdb -D ${PGDATA} --no-locale" || exit 1
>>> +
>>> +# Start the server
>>> +su - postgres -c "pg_ctl -D ${PGDATA} -l ${PGDATA}/logfile start -w -t 120" || exit 1
>>> +
>>> +# Ensure the test directory is writable by the postgres user for
>>> +# regression output files (regression.out, regression.diffs, results/).
>>> +chown -R postgres:postgres "${TESTDIR}"
>>> +
>>> +# Prepare the tablespace test directory
>>> +mkdir -p "${TESTDIR}/testtablespace"
>>> +chmod 0700 "${TESTDIR}/testtablespace"
>>> +chown postgres:postgres "${TESTDIR}/testtablespace"
>>> +
>>> +# Run the regression tests.
>>> +# --dlpath points to the standard PostgreSQL package library directory
>>> +# where regress.so and contrib modules (autoinc.so, refint.so, etc.)
>>> +# are installed, so that CREATE FUNCTION ... AS tests can locate them.
>>> +su - postgres -c "cd ${TESTDIR} && \
>>> +    ${TESTDIR}/pg_regress \
>>> +        --inputdir=. \
>>> +        --bindir=${PGBIN} \
>>> +        --dlpath=${PKGLIBDIR} \
>>> +        --max-concurrent-tests=20 \
>>> +        --schedule=parallel_schedule"
>>> +RESULT=$?
>>> +
>>> +exit ${RESULT}
>>> diff --git a/meta-oe/recipes-dbs/postgresql/postgresql.inc b/meta-oe/recipes-dbs/postgresql/postgresql.inc
>>> index 040b3d5e34..dfc624f07e 100644
>>> --- a/meta-oe/recipes-dbs/postgresql/postgresql.inc
>>> +++ b/meta-oe/recipes-dbs/postgresql/postgresql.inc
>>> @@ -29,6 +29,7 @@ SRC_URI = "https://ftp.postgresql.org/pub/source/v${PV}/${BP}.tar.bz2 \
>>>       file://postgresql.pam \
>>>       file://postgresql-setup \
>>>       file://postgresql.service \
>>> +    file://run-ptest \
>>>   "
>>>
>>>   LEAD_SONAME = "libpq.so"
>>> @@ -37,7 +38,7 @@ LEAD_SONAME = "libpq.so"
>>>   export LDFLAGS_SL = "${LDFLAGS}"
>>>   export LDFLAGS_EX_BE = "-Wl,--export-dynamic"
>>>
>>> -inherit autotools pkgconfig perlnative python3native python3targetconfig useradd update-rc.d systemd gettext perl-version multilib_header
>>> +inherit autotools pkgconfig perlnative python3native python3targetconfig useradd update-rc.d systemd gettext perl-version multilib_header ptest
>>>
>>>   CFLAGS += "-I${STAGING_INCDIR}/${PYTHON_DIR}"
>>>
>>> @@ -184,6 +185,45 @@ do_compile:append() {
>>>       done
>>>   }
>>>
>>> +do_compile_ptest() {
>>> +    oe_runmake -C src/test/regress all
>>> +}
>>> +
>>> +do_install_ptest() {
>>> +    mkdir -p ${D}${PTEST_PATH}/test
>>> +
>>> +    # Install pg_regress binary
>>> +    install -m 0755 ${B}/src/test/regress/pg_regress ${D}${PTEST_PATH}/test/
>>> +
>>> +    # Install test schedules and resultmap
>>> +    for f in parallel_schedule serial_schedule resultmap; do
>>> +        [ -f ${S}/src/test/regress/$f ] && install -m 0644 ${S}/src/test/regress/$f ${D}${PTEST_PATH}/test/
>>> +    done
>>> +
>>> +    # Install SQL, expected, input, output, and data files
>>> +    for d in sql expected input output data; do
>>> +        if [ -d ${S}/src/test/regress/$d ]; then
>>> +            cp -r ${S}/src/test/regress/$d ${D}${PTEST_PATH}/test/
>>> +        fi
>>> +    done
>>> +
>>> +    # Install the regress test shared library into the standard PostgreSQL
>>> +    # package library directory (PKGLIBDIR) alongside contrib modules such
>>> +    # as autoinc.so and refint.so. This allows pg_regress --dlpath to
>>> +    # resolve all required shared libraries from a single location.
>>> +    install -d ${D}${libdir}/${BPN}
>>> +    install -m 0755 ${B}/src/test/regress/regress.so ${D}${libdir}/${BPN}/
>>> +
>>> +    # Install run-ptest
>>> +    install -m 0755 ${UNPACKDIR}/run-ptest ${D}${PTEST_PATH}/
>>> +
>>> +    # Set ownership to postgres user for running tests
>>> +    chown -R postgres:postgres ${D}${PTEST_PATH}
>>> +}
>>> +
>>> +RDEPENDS:${PN}-ptest += "${PN} ${PN}-client ${PN}-contrib perl"
>>
>> ${PN} is part of this RDEPENDS implicitly, no need to add it separately
>> (granted, it also does no harm by being here)
>>
>>
>>> +FILES:${PN}-ptest += "${libdir}/${BPN}/regress.so"
>>> +
>>>   # server needs to configure user and group
>>>   usernum = "28"
>>>   groupnum = "28"
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> -=-=-=-=-=-=-=-=-=-=-=-
>>> Links: You receive all messages sent to this group.
>>> View/Reply Online (#125545): https://lists.openembedded.org/g/openembedded-devel/message/125545
>>> Mute This Topic: https://lists.openembedded.org/mt/118479820/6084445
>>> Group Owner: openembedded-devel+owner@lists.openembedded.org
>>> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [skandigraun@gmail.com]
>>> -=-=-=-=-=-=-=-=-=-=-=-
>>>
He, Guocai March 24, 2026, 8:21 a.m. UTC | #5
On 3/24/26 16:16, Gyorgy Sarvari wrote:
> CAUTION: This email comes from a non Wind River email account!
> Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
> On 3/24/26 09:05, guocai he via lists.openembedded.org wrote:
>> On 3/24/26 15:36, Gyorgy Sarvari wrote:
>>> CAUTION: This email comes from a non Wind River email account!
>>> Do not click links or open attachments unless you recognize the sender and know the content is safe.
>>>
>>> On 3/24/26 08:16, guocai he via lists.openembedded.org wrote:
>>>> From: Guocai He <guocai.he.cn@windriver.com>
>>>>
>>>> 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
>>>> ......
>>>> ......
>>> I'd like to ask just one confirmation question about this "....." here
>>>
>>> Is the output machine parseable, i.e. do the results have PASS:/FAIL:
>>> prefix, at least as a final summary?
>>> The run-ptest script doesn't seem to do such conversion, so I'm just
>>> curious if the output is usable out of the box.
>> if one case fail, the logs like:
>>
>> .......
>>
>> not ok 78    + triggers                                38360 ms
>>
>> ......
>>
>> # 1 of 224 tests failed.
>>
> Thanks. The problem with this is that it will always show up as a
> failure on the autobuilder, because it can't parse any results - the
> logparser looks explicitly for PASS: and FAIL: patterns at the start of
> the output to detect passing/failing tests.
>
> Most frequently this is done by sed commands in the run-ptest script,
> converting the test output to something ptest-compatible. But at the
> least, could you please add a summary to the end of the run-ptest
> script, something like
>
> if [ "${RESULT}" == "0" ]; then
>    echo PASS: all tests passed
> else
>    echo FAIL: some tests failed
> fi
>
> This would allow automatic evaluation of the results.

Thanks.

I will send V2 after updated.

>
>>>
>>>> All 224 tests passed.
>>>> 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>
>>>> ---
>>>>    .../include/ptest-packagelists-meta-oe.inc    |  1 +
>>>>    .../recipes-dbs/postgresql/files/run-ptest    | 53 +++++++++++++++++++
>>>>    meta-oe/recipes-dbs/postgresql/postgresql.inc | 42 ++++++++++++++-
>>>>    3 files changed, 95 insertions(+), 1 deletion(-)
>>>>    create mode 100644 meta-oe/recipes-dbs/postgresql/files/run-ptest
>>>>
>>>> diff --git a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
>>>> index 4de602ac1c..0e395db48a 100644
>>>> --- a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
>>>> +++ b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
>>>> @@ -76,6 +76,7 @@ PTESTS_SLOW_META_OE = "\
>>>>        fftw \
>>>>        libusb-compat \
>>>>        mariadb \
>>>> +    postgresql \
>>>>        re2 \
>>>>        rocksdb \
>>>>    "
>>>> 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..004cf2ba87
>>>> --- /dev/null
>>>> +++ b/meta-oe/recipes-dbs/postgresql/files/run-ptest
>>>> @@ -0,0 +1,53 @@
>>>> +#!/bin/sh
>>>> +#
>>>> +# PostgreSQL regression test runner for ptest
>>>> +#
>>>> +# This script initializes a temporary PostgreSQL database cluster,
>>>> +# starts a server instance, and executes the standard regression test
>>>> +# suite via pg_regress against the installed PostgreSQL binaries.
>>>> +#
>>>> +
>>>> +set -e
>>>> +
>>>> +PGDATA=/tmp/ptest_pgdata
>>>> +PTEST_PATH=$(dirname "$(readlink -f "$0")")
>>>> +TESTDIR="${PTEST_PATH}/test"
>>>> +PGBIN=$(pg_config --bindir)
>>>> +PKGLIBDIR=$(pg_config --pkglibdir)
>>>> +
>>>> +cleanup() {
>>>> +    su - postgres -c "pg_ctl -D ${PGDATA} stop -m immediate" 2>/dev/null || true
>>>> +    rm -rf "${PGDATA}"
>>>> +}
>>>> +trap cleanup EXIT
>>>> +
>>>> +# Initialize the database cluster
>>>> +rm -rf "${PGDATA}"
>>>> +su - postgres -c "${PGBIN}/initdb -D ${PGDATA} --no-locale" || exit 1
>>>> +
>>>> +# Start the server
>>>> +su - postgres -c "pg_ctl -D ${PGDATA} -l ${PGDATA}/logfile start -w -t 120" || exit 1
>>>> +
>>>> +# Ensure the test directory is writable by the postgres user for
>>>> +# regression output files (regression.out, regression.diffs, results/).
>>>> +chown -R postgres:postgres "${TESTDIR}"
>>>> +
>>>> +# Prepare the tablespace test directory
>>>> +mkdir -p "${TESTDIR}/testtablespace"
>>>> +chmod 0700 "${TESTDIR}/testtablespace"
>>>> +chown postgres:postgres "${TESTDIR}/testtablespace"
>>>> +
>>>> +# Run the regression tests.
>>>> +# --dlpath points to the standard PostgreSQL package library directory
>>>> +# where regress.so and contrib modules (autoinc.so, refint.so, etc.)
>>>> +# are installed, so that CREATE FUNCTION ... AS tests can locate them.
>>>> +su - postgres -c "cd ${TESTDIR} && \
>>>> +    ${TESTDIR}/pg_regress \
>>>> +        --inputdir=. \
>>>> +        --bindir=${PGBIN} \
>>>> +        --dlpath=${PKGLIBDIR} \
>>>> +        --max-concurrent-tests=20 \
>>>> +        --schedule=parallel_schedule"
>>>> +RESULT=$?
>>>> +
>>>> +exit ${RESULT}
>>>> diff --git a/meta-oe/recipes-dbs/postgresql/postgresql.inc b/meta-oe/recipes-dbs/postgresql/postgresql.inc
>>>> index 040b3d5e34..dfc624f07e 100644
>>>> --- a/meta-oe/recipes-dbs/postgresql/postgresql.inc
>>>> +++ b/meta-oe/recipes-dbs/postgresql/postgresql.inc
>>>> @@ -29,6 +29,7 @@ SRC_URI = "https://ftp.postgresql.org/pub/source/v${PV}/${BP}.tar.bz2 \
>>>>        file://postgresql.pam \
>>>>        file://postgresql-setup \
>>>>        file://postgresql.service \
>>>> +    file://run-ptest \
>>>>    "
>>>>
>>>>    LEAD_SONAME = "libpq.so"
>>>> @@ -37,7 +38,7 @@ LEAD_SONAME = "libpq.so"
>>>>    export LDFLAGS_SL = "${LDFLAGS}"
>>>>    export LDFLAGS_EX_BE = "-Wl,--export-dynamic"
>>>>
>>>> -inherit autotools pkgconfig perlnative python3native python3targetconfig useradd update-rc.d systemd gettext perl-version multilib_header
>>>> +inherit autotools pkgconfig perlnative python3native python3targetconfig useradd update-rc.d systemd gettext perl-version multilib_header ptest
>>>>
>>>>    CFLAGS += "-I${STAGING_INCDIR}/${PYTHON_DIR}"
>>>>
>>>> @@ -184,6 +185,45 @@ do_compile:append() {
>>>>        done
>>>>    }
>>>>
>>>> +do_compile_ptest() {
>>>> +    oe_runmake -C src/test/regress all
>>>> +}
>>>> +
>>>> +do_install_ptest() {
>>>> +    mkdir -p ${D}${PTEST_PATH}/test
>>>> +
>>>> +    # Install pg_regress binary
>>>> +    install -m 0755 ${B}/src/test/regress/pg_regress ${D}${PTEST_PATH}/test/
>>>> +
>>>> +    # Install test schedules and resultmap
>>>> +    for f in parallel_schedule serial_schedule resultmap; do
>>>> +        [ -f ${S}/src/test/regress/$f ] && install -m 0644 ${S}/src/test/regress/$f ${D}${PTEST_PATH}/test/
>>>> +    done
>>>> +
>>>> +    # Install SQL, expected, input, output, and data files
>>>> +    for d in sql expected input output data; do
>>>> +        if [ -d ${S}/src/test/regress/$d ]; then
>>>> +            cp -r ${S}/src/test/regress/$d ${D}${PTEST_PATH}/test/
>>>> +        fi
>>>> +    done
>>>> +
>>>> +    # Install the regress test shared library into the standard PostgreSQL
>>>> +    # package library directory (PKGLIBDIR) alongside contrib modules such
>>>> +    # as autoinc.so and refint.so. This allows pg_regress --dlpath to
>>>> +    # resolve all required shared libraries from a single location.
>>>> +    install -d ${D}${libdir}/${BPN}
>>>> +    install -m 0755 ${B}/src/test/regress/regress.so ${D}${libdir}/${BPN}/
>>>> +
>>>> +    # Install run-ptest
>>>> +    install -m 0755 ${UNPACKDIR}/run-ptest ${D}${PTEST_PATH}/
>>>> +
>>>> +    # Set ownership to postgres user for running tests
>>>> +    chown -R postgres:postgres ${D}${PTEST_PATH}
>>>> +}
>>>> +
>>>> +RDEPENDS:${PN}-ptest += "${PN} ${PN}-client ${PN}-contrib perl"
>>> ${PN} is part of this RDEPENDS implicitly, no need to add it separately
>>> (granted, it also does no harm by being here)
>>>
>>>
>>>> +FILES:${PN}-ptest += "${libdir}/${BPN}/regress.so"
>>>> +
>>>>    # server needs to configure user and group
>>>>    usernum = "28"
>>>>    groupnum = "28"
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -=-=-=-=-=-=-=-=-=-=-=-
>>>> Links: You receive all messages sent to this group.
>>>> View/Reply Online (#125545): https://lists.openembedded.org/g/openembedded-devel/message/125545
>>>> Mute This Topic: https://lists.openembedded.org/mt/118479820/6084445
>>>> Group Owner: openembedded-devel+owner@lists.openembedded.org
>>>> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [skandigraun@gmail.com]
>>>> -=-=-=-=-=-=-=-=-=-=-=-
>>>>
diff mbox series

Patch

diff --git a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
index 4de602ac1c..0e395db48a 100644
--- a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
+++ b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc
@@ -76,6 +76,7 @@  PTESTS_SLOW_META_OE = "\
     fftw \
     libusb-compat \
     mariadb \
+    postgresql \
     re2 \
     rocksdb \
 "
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..004cf2ba87
--- /dev/null
+++ b/meta-oe/recipes-dbs/postgresql/files/run-ptest
@@ -0,0 +1,53 @@ 
+#!/bin/sh
+#
+# PostgreSQL regression test runner for ptest
+#
+# This script initializes a temporary PostgreSQL database cluster,
+# starts a server instance, and executes the standard regression test
+# suite via pg_regress against the installed PostgreSQL binaries.
+#
+
+set -e
+
+PGDATA=/tmp/ptest_pgdata
+PTEST_PATH=$(dirname "$(readlink -f "$0")")
+TESTDIR="${PTEST_PATH}/test"
+PGBIN=$(pg_config --bindir)
+PKGLIBDIR=$(pg_config --pkglibdir)
+
+cleanup() {
+    su - postgres -c "pg_ctl -D ${PGDATA} stop -m immediate" 2>/dev/null || true
+    rm -rf "${PGDATA}"
+}
+trap cleanup EXIT
+
+# Initialize the database cluster
+rm -rf "${PGDATA}"
+su - postgres -c "${PGBIN}/initdb -D ${PGDATA} --no-locale" || exit 1
+
+# Start the server
+su - postgres -c "pg_ctl -D ${PGDATA} -l ${PGDATA}/logfile start -w -t 120" || exit 1
+
+# Ensure the test directory is writable by the postgres user for
+# regression output files (regression.out, regression.diffs, results/).
+chown -R postgres:postgres "${TESTDIR}"
+
+# Prepare the tablespace test directory
+mkdir -p "${TESTDIR}/testtablespace"
+chmod 0700 "${TESTDIR}/testtablespace"
+chown postgres:postgres "${TESTDIR}/testtablespace"
+
+# Run the regression tests.
+# --dlpath points to the standard PostgreSQL package library directory
+# where regress.so and contrib modules (autoinc.so, refint.so, etc.)
+# are installed, so that CREATE FUNCTION ... AS tests can locate them.
+su - postgres -c "cd ${TESTDIR} && \
+    ${TESTDIR}/pg_regress \
+        --inputdir=. \
+        --bindir=${PGBIN} \
+        --dlpath=${PKGLIBDIR} \
+        --max-concurrent-tests=20 \
+        --schedule=parallel_schedule"
+RESULT=$?
+
+exit ${RESULT}
diff --git a/meta-oe/recipes-dbs/postgresql/postgresql.inc b/meta-oe/recipes-dbs/postgresql/postgresql.inc
index 040b3d5e34..dfc624f07e 100644
--- a/meta-oe/recipes-dbs/postgresql/postgresql.inc
+++ b/meta-oe/recipes-dbs/postgresql/postgresql.inc
@@ -29,6 +29,7 @@  SRC_URI = "https://ftp.postgresql.org/pub/source/v${PV}/${BP}.tar.bz2 \
     file://postgresql.pam \
     file://postgresql-setup \
     file://postgresql.service \
+    file://run-ptest \
 "
 
 LEAD_SONAME = "libpq.so"
@@ -37,7 +38,7 @@  LEAD_SONAME = "libpq.so"
 export LDFLAGS_SL = "${LDFLAGS}"
 export LDFLAGS_EX_BE = "-Wl,--export-dynamic"
 
-inherit autotools pkgconfig perlnative python3native python3targetconfig useradd update-rc.d systemd gettext perl-version multilib_header
+inherit autotools pkgconfig perlnative python3native python3targetconfig useradd update-rc.d systemd gettext perl-version multilib_header ptest
 
 CFLAGS += "-I${STAGING_INCDIR}/${PYTHON_DIR}"
 
@@ -184,6 +185,45 @@  do_compile:append() {
     done
 }
 
+do_compile_ptest() {
+    oe_runmake -C src/test/regress all
+}
+
+do_install_ptest() {
+    mkdir -p ${D}${PTEST_PATH}/test
+
+    # Install pg_regress binary
+    install -m 0755 ${B}/src/test/regress/pg_regress ${D}${PTEST_PATH}/test/
+
+    # Install test schedules and resultmap
+    for f in parallel_schedule serial_schedule resultmap; do
+        [ -f ${S}/src/test/regress/$f ] && install -m 0644 ${S}/src/test/regress/$f ${D}${PTEST_PATH}/test/
+    done
+
+    # Install SQL, expected, input, output, and data files
+    for d in sql expected input output data; do
+        if [ -d ${S}/src/test/regress/$d ]; then
+            cp -r ${S}/src/test/regress/$d ${D}${PTEST_PATH}/test/
+        fi
+    done
+
+    # Install the regress test shared library into the standard PostgreSQL
+    # package library directory (PKGLIBDIR) alongside contrib modules such
+    # as autoinc.so and refint.so. This allows pg_regress --dlpath to
+    # resolve all required shared libraries from a single location.
+    install -d ${D}${libdir}/${BPN}
+    install -m 0755 ${B}/src/test/regress/regress.so ${D}${libdir}/${BPN}/
+
+    # Install run-ptest
+    install -m 0755 ${UNPACKDIR}/run-ptest ${D}${PTEST_PATH}/
+
+    # Set ownership to postgres user for running tests
+    chown -R postgres:postgres ${D}${PTEST_PATH}
+}
+
+RDEPENDS:${PN}-ptest += "${PN} ${PN}-client ${PN}-contrib perl"
+FILES:${PN}-ptest += "${libdir}/${BPN}/regress.so"
+
 # server needs to configure user and group
 usernum = "28"
 groupnum = "28"