diff mbox series

[master] libsdl2: Add tests package and ptest support

Message ID 20250827222051.367093-1-a-christidis@ti.com
State New
Headers show
Series [master] libsdl2: Add tests package and ptest support | expand

Commit Message

Antonios Christidis Aug. 27, 2025, 10:20 p.m. UTC
From: Antonios Christidis <a-christidis@ti.com>

The SDL2 software comes with its own set of tests. Following that
introduce support for ptest.

Signed-off-by: Antonios Christidis <a-christidis@ti.com>
---
 .../distro/include/ptest-packagelists.inc     |  1 +
 .../libsdl2/libsdl2/run-ptest                 | 15 ++++++++++++++
 .../libsdl2/libsdl2_2.32.8.bb                 | 20 +++++++++++++++++--
 3 files changed, 34 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-graphics/libsdl2/libsdl2/run-ptest

Comments

Yoann Congal Aug. 28, 2025, 6:56 a.m. UTC | #1
Hello,

Le jeu. 28 août 2025 à 00:21, Antonios Christidis via lists.openembedded.org
<a-christidis=ti.com@lists.openembedded.org> a écrit :

> From: Antonios Christidis <a-christidis@ti.com>
>
> The SDL2 software comes with its own set of tests. Following that
> introduce support for ptest.
>
> Signed-off-by: Antonios Christidis <a-christidis@ti.com>
> ---
>  .../distro/include/ptest-packagelists.inc     |  1 +
>  .../libsdl2/libsdl2/run-ptest                 | 15 ++++++++++++++
>  .../libsdl2/libsdl2_2.32.8.bb                 | 20 +++++++++++++++++--
>  3 files changed, 34 insertions(+), 2 deletions(-)
>  create mode 100644 meta/recipes-graphics/libsdl2/libsdl2/run-ptest
>
> diff --git a/meta/conf/distro/include/ptest-packagelists.inc
> b/meta/conf/distro/include/ptest-packagelists.inc
> index 9a7b25a916..a5476927b5 100644
> --- a/meta/conf/distro/include/ptest-packagelists.inc
> +++ b/meta/conf/distro/include/ptest-packagelists.inc
> @@ -32,6 +32,7 @@ PTESTS_FAST = "\
>      libgpg-error\
>      libnl \
>      libpcre \
> +    libsdl2 \
>      libssh2 \
>      libtest-fatal-perl \
>      libtest-needs-perl \
> diff --git a/meta/recipes-graphics/libsdl2/libsdl2/run-ptest
> b/meta/recipes-graphics/libsdl2/libsdl2/run-ptest
> new file mode 100644
> index 0000000000..1cd1f9ceaf
> --- /dev/null
> +++ b/meta/recipes-graphics/libsdl2/libsdl2/run-ptest
> @@ -0,0 +1,15 @@
> +#!/bin/sh
> +
> +test_array=("testdraw2" "testgeometry" "testsprite2" "testgles2"
> "testoffscreen")
> +
> +test_path="/usr/bin/sdl2_tests/"
> +
> +for test in "${test_array[@]}"
> +do
> +    timeout --preserve-status 10 "$test_path""$test"
> +    if [ $? -eq 0 ]; then
> +        echo "PASS: $test"
> +    else
> +        echo "FAIL: $test"
> +    fi
> +done
>

You should explicitly return 0 (if all tests succeeded) or 1 (if any test
failed).
If I read correctly, your script will always return 0 (success) because the
last command is an 'echo'.

See https://docs.yoctoproject.org/dev/test-manual/ptest.html#running-ptest
(that was added recently)


> diff --git a/meta/recipes-graphics/libsdl2/libsdl2_2.32.8.bb
> b/meta/recipes-graphics/libsdl2/libsdl2_2.32.8.bb
> index 98291e0f80..5aeb333bc7 100644
> --- a/meta/recipes-graphics/libsdl2/libsdl2_2.32.8.bb
> +++ b/meta/recipes-graphics/libsdl2/libsdl2_2.32.8.bb
> @@ -21,13 +21,15 @@ LIC_FILES_CHKSUM:append = "
> ${@bb.utils.contains('PACKAGECONFIG', 'arm-neon', 'f
>
>  PROVIDES = "virtual/libsdl2"
>
> -SRC_URI = "https://www.libsdl.org/release/SDL2-${PV}.tar.gz"
> +SRC_URI = "https://www.libsdl.org/release/SDL2-${PV}.tar.gz \
> +          file://run-ptest \
> +          "
>
>  S = "${UNPACKDIR}/SDL2-${PV}"
>
>  SRC_URI[sha256sum] =
> "0ca83e9c9b31e18288c7ec811108e58bac1f1bb5ec6577ad386830eac51c787e"
>
> -inherit cmake lib_package binconfig-disabled pkgconfig
> upstream-version-is-even
> +inherit cmake lib_package binconfig-disabled pkgconfig
> upstream-version-is-even ptest
>  UPSTREAM_CHECK_REGEX = "SDL2-(?P<pver>\d+\.(\d*[02468])+(\.\d+)+)\.tar"
>
>  BINCONFIG = "${bindir}/sdl2-config"
> @@ -48,6 +50,7 @@ EXTRA_OECMAKE = "-DSDL_OSS=OFF -DSDL_ESD=OFF
> -DSDL_ARTS=OFF \
>                   -DSDL_X11_XRANDR=OFF \
>                   -DSDL_X11_XSCRNSAVER=OFF \
>                   -DSDL_X11_XSHAPE=OFF \
> +                -DSDL_TESTS=ON \
>  "
>
>  # opengl packageconfig factored out to make it easy for distros
> @@ -80,8 +83,21 @@ PACKAGECONFIG[vulkan]    =
> "-DSDL_VULKAN=ON,-DSDL_VULKAN=OFF"
>  PACKAGECONFIG[wayland]    =
> "-DSDL_WAYLAND=ON,-DSDL_WAYLAND=OFF,wayland-native wayland
> wayland-protocols libxkbcommon"
>  PACKAGECONFIG[x11]        = "-DSDL_X11=ON,-DSDL_X11=OFF,virtual/libx11
> libxext libxrandr libxrender"
>
> +do_install:append() {
> +       install -d ${D}${bindir}/sdl2_tests
> +       cp -r ${B}/test/* ${D}${bindir}/sdl2_tests
> +
> +       # Delete any leftover cmake files within the sdl2_tests dir
> +       find ${D}${bindir}/sdl2_tests -type f -name "*.cmake" -delete
> +}
> +
>  CFLAGS:append:class-native = " -DNO_SHARED_MEMORY"
>
> +PACKAGE_BEFORE_PN = "${PN}-tests"
> +
>  FILES:${PN} += "${datadir}/licenses/SDL2/LICENSE.txt"
> +FILES:${PN}-tests += "${bindir}/sdl2_tests"
> +
> +RDEPENDS:${PN}-ptest = "${PN}-tests"
>

Why not put the tests directly in the -ptest package?
(This is mostly out of curiosity. I like the simplicity of a single -ptest
package but I may have missed a reason for the split)

Thanks!


>
>  BBCLASSEXTEND = "native nativesdk"
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#222542):
> https://lists.openembedded.org/g/openembedded-core/message/222542
> Mute This Topic: https://lists.openembedded.org/mt/114926113/4316185
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> yoann.congal@smile.fr]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Alexander Kanavin Aug. 28, 2025, 12:51 p.m. UTC | #2
On Thu, 28 Aug 2025 at 08:56, Yoann Congal via lists.openembedded.org
<yoann.congal=smile.fr@lists.openembedded.org> wrote:
> You should explicitly return 0 (if all tests succeeded) or 1 (if any test failed).
> If I read correctly, your script will always return 0 (success) because the last command is an 'echo'.
>
> See https://docs.yoctoproject.org/dev/test-manual/ptest.html#running-ptest (that was added recently)

The documentation does not impose such requirements on run-ptest. It
can exit with 0 even if something failed (and many run-ptest examples
in core do exactly that). I think you misread the exit codes for
ptest-runner.

The only requirement on run-ptest is that it prints PASS and FAIL markers.

Alex
Alexander Kanavin Aug. 28, 2025, 12:51 p.m. UTC | #3
On Thu, 28 Aug 2025 at 00:21, Antonios Christidis via
lists.openembedded.org <a-christidis=ti.com@lists.openembedded.org>
wrote:
> +test_array=("testdraw2" "testgeometry" "testsprite2" "testgles2" "testoffscreen")
> +
> +test_path="/usr/bin/sdl2_tests/"

I know this somewhat contradicts what I said before, but now I think
we should just keep this simple and install these under
/usr/lib/libsdl2/ptest/tests, and package them in $PN-ptest. Putting
something executable in a sub-directory under /usr/bin is very
non-standard.

Also run-ptest should not hardcode the list of tests, and just run
everything in a directory.

> @@ -48,6 +50,7 @@ EXTRA_OECMAKE = "-DSDL_OSS=OFF -DSDL_ESD=OFF -DSDL_ARTS=OFF \
>                   -DSDL_X11_XRANDR=OFF \
>                   -DSDL_X11_XSCRNSAVER=OFF \
>                   -DSDL_X11_XSHAPE=OFF \
> +                -DSDL_TESTS=ON \

This should stay as PACKAGECONFIG, and be enabled subject to ptest in
DISTRO_FEATURES.

Alex
Joao Marcos Costa Aug. 28, 2025, 1:29 p.m. UTC | #4
Hello,

I hope this email finds you well.

On 8/28/25 00:20, Antonios Christidis via lists.openembedded.org wrote:
> From: Antonios Christidis <a-christidis@ti.com>
> 
> The SDL2 software comes with its own set of tests. Following that
> introduce support for ptest.
> 
> Signed-off-by: Antonios Christidis <a-christidis@ti.com>
> ---
>   .../distro/include/ptest-packagelists.inc     |  1 +
>   .../libsdl2/libsdl2/run-ptest                 | 15 ++++++++++++++
>   .../libsdl2/libsdl2_2.32.8.bb                 | 20 +++++++++++++++++--
>   3 files changed, 34 insertions(+), 2 deletions(-)
>   create mode 100644 meta/recipes-graphics/libsdl2/libsdl2/run-ptest
> 

There's a syntax error in run-ptest, as it seems:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/73/builds/2183/steps/12/logs/stdio 
(line 2250).

Could you please take a look? Thanks!
Yoann Congal Aug. 28, 2025, 3:23 p.m. UTC | #5
Le jeu. 28 août 2025 à 14:51, Alexander Kanavin <alex.kanavin@gmail.com> a
écrit :

> On Thu, 28 Aug 2025 at 08:56, Yoann Congal via lists.openembedded.org
> <yoann.congal=smile.fr@lists.openembedded.org> wrote:
> > You should explicitly return 0 (if all tests succeeded) or 1 (if any
> test failed).
> > If I read correctly, your script will always return 0 (success) because
> the last command is an 'echo'.
> >
> > See
> https://docs.yoctoproject.org/dev/test-manual/ptest.html#running-ptest
> (that was added recently)
>
> The documentation does not impose such requirements on run-ptest. It
> can exit with 0 even if something failed (and many run-ptest examples
> in core do exactly that). I think you misread the exit codes for
> ptest-runner.
>

Some time ago, I created
https://bugzilla.yoctoproject.org/show_bug.cgi?id=15832 to try to clarify
exactly this.

Right now, ptest-runner will fail if a run-ptest script it calls fails. And
that, in turn, will cause failures on AB regardless of PASS:/FAIL: markers.

The only requirement on run-ptest is that it prints PASS and FAIL markers.
>

Those markers are parsed at testimage level, but the return code of
ptest-runner is also used to check for success/failure.

That is the whole point of the ticket: realign what the existings run-ptest
scripts do, what the dos says, what the code running tests expects
(ptest-runner & testimage)
Maybe we should talk about it in a tuesday call?

Alex
>
Alexander Kanavin Aug. 28, 2025, 6:08 p.m. UTC | #6
On Thu, 28 Aug 2025 at 17:24, Yoann Congal <yoann.congal@smile.fr> wrote:

> That is the whole point of the ticket: realign what the existings run-ptest scripts do, what the dos says, what the code running tests expects (ptest-runner & testimage)
> Maybe we should talk about it in a tuesday call?

We can talk, but I do not think it is realistic to have new
requirements on run-ptest, especially around return codes. They are
expected to print at least one PASS or FAIL, and it stops there.

Alex
Antonios Christidis Sept. 2, 2025, 3:20 p.m. UTC | #7
Dear Alexander,

Firstly, let me apologize for the late reply I have been out of office.

On 8/28/25 7:51 AM, Alexander Kanavin wrote:
> On Thu, 28 Aug 2025 at 00: 21, Antonios Christidis via 
> lists. openembedded. org 
> <a-christidis=ti. com@ lists. openembedded. org> wrote: > 
> +test_array=("testdraw2" "testgeometry" "testsprite2" "testgles2" 
> "testoffscreen") > + > +test_path="/usr/bin/sdl2_tests/"
> ZjQcmQRYFpfptBannerStart
> This message was sent from outside of Texas Instruments.
> Do not click links or open attachments unless you recognize the source 
> of this email and know the content is safe.
> Report Suspicious
> <https://us-phishalarm-ewt.proofpoint.com/EWT/v1/G3vK!tDdkczhAu0BQayjEE53DlJ0ytQAfSnNSsAwaZZ6yMwLiJIuXLljNpENyKyUvPwWHY4FZNPKxMRcNExZlXWUX0mmQrEBfjWJom99n7qlVvJ7-UcRwcWlWG7GV1ds$> 
>
> ZjQcmQRYFpfptBannerEnd
> On Thu, 28 Aug 2025 at 00:21, Antonios Christidis via
> lists.openembedded.org <a-christidis=ti.com@lists.openembedded.org>
> wrote:
> > +test_array=("testdraw2" "testgeometry" "testsprite2" "testgles2" "testoffscreen")
> > +
> > +test_path="/usr/bin/sdl2_tests/"
>
> I know this somewhat contradicts what I said before, but now I think
> we should just keep this simple and install these under
> /usr/lib/libsdl2/ptest/tests, and package them in $PN-ptest. Putting
> something executable in a sub-directory under /usr/bin is very
> non-standard.

I understand your point about keeping things simple and installing the 
tests under |/usr/lib/libsdl2/ptest/tests|, but I have some concerns 
about merging the packages.

I believe it's beneficial to keep the |$PN-tests| and |$PN-ptest| 
packages separate. The tests can run without the need for ptest tools, 
and by keeping them separate, we avoid creating a needless dependency. 
Merging the two, can lead to users making a false assumption that the 
tests need some sort of tooling provided by ptest to run.

Moreover, having the tests in a separate package allows users to easily 
include them in their filesystem without having to rebuild the entire 
package with |DISTRO_FEATURES| including |ptest|. This is particularly 
important since rebuilding with |ptest| enabled in my experience can 
cause a significant increase in build time, as it often triggers the 
rebuild of basic package dependencies.


I do agree with the placement of tests being non-standard, do you have 
any suggestions on elsewhere to place them ? Aside from 
|/usr/lib/libsdl2/ptest/tests| .

> Also run-ptest should not hardcode the list of tests, and just run
> everything in a directory.
>
> > @@ -48,6 +50,7 @@ EXTRA_OECMAKE = "-DSDL_OSS=OFF -DSDL_ESD=OFF -DSDL_ARTS=OFF \
> >                   -DSDL_X11_XRANDR=OFF \
> >                   -DSDL_X11_XSCRNSAVER=OFF \
> >                   -DSDL_X11_XSHAPE=OFF \
> > +                -DSDL_TESTS=ON \
>
> This should stay as PACKAGECONFIG, and be enabled subject to ptest in
> DISTRO_FEATURES.

Looking over other packages that have ptest support, they often 
automatically build tests without the need for setting PACKAGECONFIGS.

> Alex
>
Kind Regards,
Antonios
Antonios Christidis Sept. 2, 2025, 3:22 p.m. UTC | #8
Dear all,

What meeting is being referenced ? What was the conclusion of such?

Kind Regards,

Antonios

On 8/28/25 1:08 PM, Alexander Kanavin wrote:
> On Thu, 28 Aug 2025 at 17: 24, Yoann Congal <yoann. congal@ smile. fr> 
> wrote: > That is the whole point of the ticket: realign what the 
> existings run-ptest scripts do, what the dos says, what the code 
> running tests expects (ptest-runner
> ZjQcmQRYFpfptBannerStart
> This message was sent from outside of Texas Instruments.
> Do not click links or open attachments unless you recognize the source 
> of this email and know the content is safe.
> Report Suspicious
> <https://us-phishalarm-ewt.proofpoint.com/EWT/v1/G3vK!tDdkczhAu0BQayqqdF8IsugIjX7zadsugLmM-EbBW8Oq0a4_NJqc3VSXvZy3_udB9hIMqaoUjEqvKMEG22xp083xtuY8ML3NRgyFVVZtLOCIG2rqv1J7v14pKoM$> 
>
> ZjQcmQRYFpfptBannerEnd
> On Thu, 28 Aug 2025 at 17:24, Yoann Congal <yoann.congal@smile.fr> wrote:
>
> > That is the whole point of the ticket: realign what the existings run-ptest scripts do, what the dos says, what the code running tests expects (ptest-runner & testimage)
> > Maybe we should talk about it in a tuesday call?
>
> We can talk, but I do not think it is realistic to have new
> requirements on run-ptest, especially around return codes. They are
> expected to print at least one PASS or FAIL, and it stops there.
>
> Alex
Yoann Congal Sept. 2, 2025, 4:32 p.m. UTC | #9
Hello!

Le mar. 2 sept. 2025 à 17:22, Antonios Christidis <a-christidis@ti.com> a
écrit :

> Dear all,
>
> What meeting is being referenced ?


That was the "weekly Engineering Sync" referenced here :
https://www.yoctoproject.org/community/get-involved/#virtual-meetings


> What was the conclusion of such?
>

I did not have time to open this subject at this meeting.
I don't want to hold your patch for this. Feel free to ignore my comment on
the return code.

Thanks!

Regards,


> Kind Regards,
>
> Antonios
>
> On 8/28/25 1:08 PM, Alexander Kanavin wrote:
> > On Thu, 28 Aug 2025 at 17: 24, Yoann Congal <yoann. congal@ smile. fr>
> > wrote: > That is the whole point of the ticket: realign what the
> > existings run-ptest scripts do, what the dos says, what the code
> > running tests expects (ptest-runner
> > ZjQcmQRYFpfptBannerStart
> > This message was sent from outside of Texas Instruments.
> > Do not click links or open attachments unless you recognize the source
> > of this email and know the content is safe.
> > Report Suspicious
> > <
> https://us-phishalarm-ewt.proofpoint.com/EWT/v1/G3vK!tDdkczhAu0BQayqqdF8IsugIjX7zadsugLmM-EbBW8Oq0a4_NJqc3VSXvZy3_udB9hIMqaoUjEqvKMEG22xp083xtuY8ML3NRgyFVVZtLOCIG2rqv1J7v14pKoM$>
>
> >
> > ZjQcmQRYFpfptBannerEnd
> > On Thu, 28 Aug 2025 at 17:24, Yoann Congal <yoann.congal@smile.fr>
> wrote:
> >
> > > That is the whole point of the ticket: realign what the existings
> run-ptest scripts do, what the dos says, what the code running tests
> expects (ptest-runner & testimage)
> > > Maybe we should talk about it in a tuesday call?
> >
> > We can talk, but I do not think it is realistic to have new
> > requirements on run-ptest, especially around return codes. They are
> > expected to print at least one PASS or FAIL, and it stops there.
> >
> > Alex
>
Mathieu Dubois-Briand Sept. 3, 2025, 6:48 a.m. UTC | #10
On Thu Aug 28, 2025 at 12:20 AM CEST, a-christidis wrote:
> From: Antonios Christidis <a-christidis@ti.com>
>
> The SDL2 software comes with its own set of tests. Following that
> introduce support for ptest.
>
> Signed-off-by: Antonios Christidis <a-christidis@ti.com>
> ---

Hi Antonios,

> --- /dev/null
> +++ b/meta/recipes-graphics/libsdl2/libsdl2/run-ptest
> @@ -0,0 +1,15 @@
> +#!/bin/sh
> +
> +test_array=("testdraw2" "testgeometry" "testsprite2" "testgles2" "testoffscreen")

Arrays are only valid with bash, not with POSIX shell. This is failing
on the autobuilder:

AssertionError:
Failed ptests:
{'libsdl2': 'START: ptest-runner\n'
            '2025-09-03T06:28\n'
            '/usr/lib/libsdl2/ptest/run-ptest: line 3: syntax error: '
            'unexpected "("\n'
            '\n'
            'ERROR: Exit status is 2\n'
            'DURATION: 0\n'}

https://autobuilder.yoctoproject.org/valkyrie/#/builders/73/builds/2215

Can you fix the syntax please?

Thanks,
Mathieu
Alexander Kanavin Sept. 3, 2025, 12:46 p.m. UTC | #11
On Tue, 2 Sept 2025 at 17:20, Antonios Christidis <a-christidis@ti.com> wrote:

> Moreover, having the tests in a separate package allows users to easily
> include them in their filesystem without having to rebuild the entire
> package with |DISTRO_FEATURES| including |ptest|. This is particularly
> important since rebuilding with |ptest| enabled in my experience can
> cause a significant increase in build time, as it often triggers the
> rebuild of basic package dependencies.

You can enable ptests per-recipe by setting PTEST_ENABLED = "1" for
that particular recipe only (via bbappend or distro config).

> I do agree with the placement of tests being non-standard, do you have
> any suggestions on elsewhere to place them ? Aside from
> |/usr/lib/libsdl2/ptest/tests| .

Once again, if you want to install the tests, and upstream does not
currently install them, then you need to write a patch for sdl
upstream that does it and get it accepted. Otherwise, what this change
is doing (installing the tests ad hoc) is entirely non-standard and
deviates from what upstream expects, and as such the tests would
belong only in ptest package, but not in the test package.
Openembedded, as a rule, does not cherry-pick items from the build
tree in do_install because they might be useful to someone, with ptest
the only exception.

> > This should stay as PACKAGECONFIG, and be enabled subject to ptest in
> > DISTRO_FEATURES.
>
> Looking over other packages that have ptest support, they often
> automatically build tests without the need for setting PACKAGECONFIGS.

This lengthens the build times and increases disk usage, and is
wasteful if the tests aren't actually installed and packaged. Other
recipes aren't always perfect, or they build components that do not
have a way to disable tests.

Alex
Antonios Christidis Sept. 3, 2025, 11:57 p.m. UTC | #12
I'm about to send a v2 of the patch, I'm going to put my thoughts here:

On 9/3/25 7:46 AM, Alexander Kanavin wrote:
> On Tue, 2 Sept 2025 at 17: 20, Antonios Christidis 
> <a-christidis@ ti. com> wrote: > Moreover, having the tests in a 
> separate package allows users to easily > include them in their 
> filesystem without having to rebuild the entire >
> ZjQcmQRYFpfptBannerStart
> This message was sent from outside of Texas Instruments.
> Do not click links or open attachments unless you recognize the source 
> of this email and know the content is safe.
> Report Suspicious
> <https://us-phishalarm-ewt.proofpoint.com/EWT/v1/G3vK!tDdkczhAu0BQayXPUP0olvN75LhXkzNe47Xria24XTS9579FCRTzKSpEtnSjV_XpryRBCT0_RcgdO14WAihF0O6xEmDhbBFOuEfufIFcK3tHa1IKqjAO6Iius84$> 
>
> ZjQcmQRYFpfptBannerEnd
> On Tue, 2 Sept 2025 at 17:20, Antonios Christidis <a-christidis@ti.com> wrote:
>
> > Moreover, having the tests in a separate package allows users to easily
> > include them in their filesystem without having to rebuild the entire
> > package with |DISTRO_FEATURES| including |ptest|. This is particularly
> > important since rebuilding with |ptest| enabled in my experience can
> > cause a significant increase in build time, as it often triggers the
> > rebuild of basic package dependencies.
>
> You can enable ptests per-recipe by setting PTEST_ENABLED = "1" for
> that particular recipe only (via bbappend or distro config).
>
> > I do agree with the placement of tests being non-standard, do you have
> > any suggestions on elsewhere to place them ? Aside from
> > |/usr/lib/libsdl2/ptest/tests| .
>
> Once again, if you want to install the tests, and upstream does not
> currently install them, then you need to write a patch for sdl
> upstream that does it and get it accepted. Otherwise, what this change

Missed a cmake configuration parameter that does the above, so now tests 
are installed under |usr/libexec| and |usr/share|.

> is doing (installing the tests ad hoc) is entirely non-standard and
> deviates from what upstream expects, and as such the tests would
> belong only in ptest package, but not in the test package.
> Openembedded, as a rule, does not cherry-pick items from the build
> tree in do_install because they might be useful to someone, with ptest
> the only exception.
>
> > > This should stay as PACKAGECONFIG, and be enabled subject to ptest in
> > > DISTRO_FEATURES.
> >
> > Looking over other packages that have ptest support, they often
> > automatically build tests without the need for setting PACKAGECONFIGS.
>
> This lengthens the build times and increases disk usage, and is
> wasteful if the tests aren't actually installed and packaged. Other
> recipes aren't always perfect, or they build components that do not
> have a way to disable tests.

I would like for the tests to be built automatically, without the need 
for a |PACKAKECONFIG|. I don't think it is a good idea for a ptest 
package to depend on another package that conditionally exists 
(PN-tests). What I mean, there's a dependency on the PN-ptest (enabled 
via DISTRO_FEATURES or PTEST_ENABLE) and PN-tests (if using 
PACKAGECONFIG). The recipe would be over complicated if I were to 
introduce all the logic required to make sure the right packages exist 
at the right time.

The build time increase is negligible. No comment on disk usage, as 
yocto is not disk usage friendly to begin with. All recipes create 
needless packages, the |PACKAGES| variable specifies packages like  
PN-dbg  PN-doc. I would agree with you in not automatically building 
packages if the tests took an insane amount of time to built, but that 
is not the case, or if they required additional dependencies .... etc .


To anyone else reading this, what are your opinions on ptest dependency 
chains like the above.

> Alex

Antonios
diff mbox series

Patch

diff --git a/meta/conf/distro/include/ptest-packagelists.inc b/meta/conf/distro/include/ptest-packagelists.inc
index 9a7b25a916..a5476927b5 100644
--- a/meta/conf/distro/include/ptest-packagelists.inc
+++ b/meta/conf/distro/include/ptest-packagelists.inc
@@ -32,6 +32,7 @@  PTESTS_FAST = "\
     libgpg-error\
     libnl \
     libpcre \
+    libsdl2 \
     libssh2 \
     libtest-fatal-perl \
     libtest-needs-perl \
diff --git a/meta/recipes-graphics/libsdl2/libsdl2/run-ptest b/meta/recipes-graphics/libsdl2/libsdl2/run-ptest
new file mode 100644
index 0000000000..1cd1f9ceaf
--- /dev/null
+++ b/meta/recipes-graphics/libsdl2/libsdl2/run-ptest
@@ -0,0 +1,15 @@ 
+#!/bin/sh
+
+test_array=("testdraw2" "testgeometry" "testsprite2" "testgles2" "testoffscreen")
+
+test_path="/usr/bin/sdl2_tests/"
+
+for test in "${test_array[@]}"
+do
+    timeout --preserve-status 10 "$test_path""$test"
+    if [ $? -eq 0 ]; then
+        echo "PASS: $test"
+    else
+        echo "FAIL: $test"
+    fi
+done
diff --git a/meta/recipes-graphics/libsdl2/libsdl2_2.32.8.bb b/meta/recipes-graphics/libsdl2/libsdl2_2.32.8.bb
index 98291e0f80..5aeb333bc7 100644
--- a/meta/recipes-graphics/libsdl2/libsdl2_2.32.8.bb
+++ b/meta/recipes-graphics/libsdl2/libsdl2_2.32.8.bb
@@ -21,13 +21,15 @@  LIC_FILES_CHKSUM:append = " ${@bb.utils.contains('PACKAGECONFIG', 'arm-neon', 'f
 
 PROVIDES = "virtual/libsdl2"
 
-SRC_URI = "https://www.libsdl.org/release/SDL2-${PV}.tar.gz"
+SRC_URI = "https://www.libsdl.org/release/SDL2-${PV}.tar.gz \
+	   file://run-ptest \
+	   "
 
 S = "${UNPACKDIR}/SDL2-${PV}"
 
 SRC_URI[sha256sum] = "0ca83e9c9b31e18288c7ec811108e58bac1f1bb5ec6577ad386830eac51c787e"
 
-inherit cmake lib_package binconfig-disabled pkgconfig upstream-version-is-even
+inherit cmake lib_package binconfig-disabled pkgconfig upstream-version-is-even ptest
 UPSTREAM_CHECK_REGEX = "SDL2-(?P<pver>\d+\.(\d*[02468])+(\.\d+)+)\.tar"
 
 BINCONFIG = "${bindir}/sdl2-config"
@@ -48,6 +50,7 @@  EXTRA_OECMAKE = "-DSDL_OSS=OFF -DSDL_ESD=OFF -DSDL_ARTS=OFF \
                  -DSDL_X11_XRANDR=OFF \
                  -DSDL_X11_XSCRNSAVER=OFF \
                  -DSDL_X11_XSHAPE=OFF \
+		 -DSDL_TESTS=ON \
 "
 
 # opengl packageconfig factored out to make it easy for distros
@@ -80,8 +83,21 @@  PACKAGECONFIG[vulkan]    = "-DSDL_VULKAN=ON,-DSDL_VULKAN=OFF"
 PACKAGECONFIG[wayland]    = "-DSDL_WAYLAND=ON,-DSDL_WAYLAND=OFF,wayland-native wayland wayland-protocols libxkbcommon"
 PACKAGECONFIG[x11]        = "-DSDL_X11=ON,-DSDL_X11=OFF,virtual/libx11 libxext libxrandr libxrender"
 
+do_install:append() {
+	install -d ${D}${bindir}/sdl2_tests
+	cp -r ${B}/test/* ${D}${bindir}/sdl2_tests
+
+	# Delete any leftover cmake files within the sdl2_tests dir
+	find ${D}${bindir}/sdl2_tests -type f -name "*.cmake" -delete
+}
+
 CFLAGS:append:class-native = " -DNO_SHARED_MEMORY"
 
+PACKAGE_BEFORE_PN = "${PN}-tests"
+
 FILES:${PN} += "${datadir}/licenses/SDL2/LICENSE.txt"
+FILES:${PN}-tests += "${bindir}/sdl2_tests"
+
+RDEPENDS:${PN}-ptest = "${PN}-tests"
 
 BBCLASSEXTEND = "native nativesdk"