All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpio: Run ptests under ptest user
@ 2023-04-29  1:29 Khem Raj
  2023-05-04 21:16 ` [OE-core] " Richard Purdie
  0 siblings, 1 reply; 3+ messages in thread
From: Khem Raj @ 2023-04-29  1:29 UTC (permalink / raw)
  To: openembedded-core; +Cc: Khem Raj

Running these tests under root user on musl works ok but it emits
additional diagnostic

cpio: dir: Cannot change ownership to uid 0, gid 0: Not supported

Ideally its better to run this test suite under non-root user which
is often how these are run. Moreover, tests work on musl as well.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/recipes-extended/cpio/cpio-2.13/run-ptest   |  9 +--------
 .../cpio/cpio-2.13/{run-ptest => test.sh}        |  0
 meta/recipes-extended/cpio/cpio_2.13.bb          | 16 ++++++++++++++++
 3 files changed, 17 insertions(+), 8 deletions(-)
 mode change 100644 => 100755 meta/recipes-extended/cpio/cpio-2.13/run-ptest
 copy meta/recipes-extended/cpio/cpio-2.13/{run-ptest => test.sh} (100%)

diff --git a/meta/recipes-extended/cpio/cpio-2.13/run-ptest b/meta/recipes-extended/cpio/cpio-2.13/run-ptest
old mode 100644
new mode 100755
index f027574e86..f35a756d6b
--- a/meta/recipes-extended/cpio/cpio-2.13/run-ptest
+++ b/meta/recipes-extended/cpio/cpio-2.13/run-ptest
@@ -1,10 +1,3 @@
 #!/bin/sh
 
-# Define cpio test work dir
-WORKDIR=@PTEST_PATH@/tests/
-
-# Run test
-cd ${WORKDIR}
-./atconfig ./atlocal ./testsuite
-
-./testsuite 2>&1 | grep -E '[0-9]{1,3}: ' | sed -e 's/^.....//' -e '/[ok]$/s/^/PASS: /;/FAILED (.*)/s/^/FAIL: /;/skipped (.*)/s/^/SKIP: /;/expected failure/ s/^/PASS: /;/UNEXPECTED PASS/s/^/FAIL: /' -e 's/ok$//g' -e 's/FAILED.*//g' -e 's/skipped.*//g' -e 's/expected failure.*//g' -e 's/UNEXPECTED PASS.*//g'
+su -c ./test.sh ptest
diff --git a/meta/recipes-extended/cpio/cpio-2.13/run-ptest b/meta/recipes-extended/cpio/cpio-2.13/test.sh
similarity index 100%
copy from meta/recipes-extended/cpio/cpio-2.13/run-ptest
copy to meta/recipes-extended/cpio/cpio-2.13/test.sh
diff --git a/meta/recipes-extended/cpio/cpio_2.13.bb b/meta/recipes-extended/cpio/cpio_2.13.bb
index df5e09cae8..943fa9b3ab 100644
--- a/meta/recipes-extended/cpio/cpio_2.13.bb
+++ b/meta/recipes-extended/cpio/cpio_2.13.bb
@@ -14,6 +14,7 @@ SRC_URI = "${GNU_MIRROR}/cpio/cpio-${PV}.tar.gz \
            file://0001-Use-__alignof__-with-clang.patch \
            file://0001-Wrong-CRC-with-ASCII-CRC-for-large-files.patch \
            file://run-ptest \
+           file://test.sh \
            "
 
 SRC_URI[md5sum] = "389c5452d667c23b5eceb206f5000810"
@@ -57,9 +58,24 @@ do_install_ptest() {
     install --mode=755 ${B}/tests/atlocal ${D}${PTEST_PATH}/tests/
     install --mode=755 ${B}/tests/genfile ${D}${PTEST_PATH}/tests/
     install --mode=755 ${S}/tests/testsuite ${D}${PTEST_PATH}/tests/
+    install --mode=755 ${WORKDIR}/test.sh ${D}${PTEST_PATH}/test.sh
     sed -i "s#@PTEST_PATH@#${PTEST_PATH}#g" ${D}${PTEST_PATH}/run-ptest
 }
 
+# ptest.bbclass currently chowns the ptest directory explicitly, so we need to
+# change permission after that has happened so the ptest user can write a
+# temporary directory.
+do_install_ptest_base:append() {
+    chgrp -R ptest ${D}${PTEST_PATH}/
+    chmod -R g+w ${D}${PTEST_PATH}/
+}
+
+# The tests need to run as a non-root user, so pull in the ptest user
+DEPENDS:append:class-target = "${@bb.utils.contains('PTEST_ENABLED', '1', ' ptest-runner', '', d)}"
+PACKAGE_WRITE_DEPS += "ptest-runner"
+
+RDEPENDS:${PN}-ptest += "ptest-runner"
+
 PACKAGES =+ "${PN}-rmt"
 
 FILES:${PN}-rmt = "${sbindir}/rmt*"
-- 
2.40.1



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

* Re: [OE-core] [PATCH] cpio: Run ptests under ptest user
  2023-04-29  1:29 [PATCH] cpio: Run ptests under ptest user Khem Raj
@ 2023-05-04 21:16 ` Richard Purdie
  2023-05-04 23:30   ` Khem Raj
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Purdie @ 2023-05-04 21:16 UTC (permalink / raw)
  To: Khem Raj, openembedded-core

On Fri, 2023-04-28 at 18:29 -0700, Khem Raj wrote:
> Running these tests under root user on musl works ok but it emits
> additional diagnostic
> 
> cpio: dir: Cannot change ownership to uid 0, gid 0: Not supported
> 
> Ideally its better to run this test suite under non-root user which
> is often how these are run. Moreover, tests work on musl as well.
> 
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
>  meta/recipes-extended/cpio/cpio-2.13/run-ptest   |  9 +--------
>  .../cpio/cpio-2.13/{run-ptest => test.sh}        |  0
>  meta/recipes-extended/cpio/cpio_2.13.bb          | 16 ++++++++++++++++
>  3 files changed, 17 insertions(+), 8 deletions(-)
>  mode change 100644 => 100755 meta/recipes-extended/cpio/cpio-2.13/run-ptest
>  copy meta/recipes-extended/cpio/cpio-2.13/{run-ptest => test.sh} (100%)
> 
> diff --git a/meta/recipes-extended/cpio/cpio-2.13/run-ptest b/meta/recipes-extended/cpio/cpio-2.13/run-ptest
> old mode 100644
> new mode 100755
> index f027574e86..f35a756d6b
> --- a/meta/recipes-extended/cpio/cpio-2.13/run-ptest
> +++ b/meta/recipes-extended/cpio/cpio-2.13/run-ptest
> @@ -1,10 +1,3 @@
>  #!/bin/sh
>  
> -# Define cpio test work dir
> -WORKDIR=@PTEST_PATH@/tests/
> -
> -# Run test
> -cd ${WORKDIR}
> -./atconfig ./atlocal ./testsuite
> -
> -./testsuite 2>&1 | grep -E '[0-9]{1,3}: ' | sed -e 's/^.....//' -e '/[ok]$/s/^/PASS: /;/FAILED (.*)/s/^/FAIL: /;/skipped (.*)/s/^/SKIP: /;/expected failure/ s/^/PASS: /;/UNEXPECTED PASS/s/^/FAIL: /' -e 's/ok$//g' -e 's/FAILED.*//g' -e 's/skipped.*//g' -e 's/expected failure.*//g' -e 's/UNEXPECTED PASS.*//g'
> +su -c ./test.sh ptest
> diff --git a/meta/recipes-extended/cpio/cpio-2.13/run-ptest b/meta/recipes-extended/cpio/cpio-2.13/test.sh
> similarity index 100%
> copy from meta/recipes-extended/cpio/cpio-2.13/run-ptest
> copy to meta/recipes-extended/cpio/cpio-2.13/test.sh
> diff --git a/meta/recipes-extended/cpio/cpio_2.13.bb b/meta/recipes-extended/cpio/cpio_2.13.bb
> index df5e09cae8..943fa9b3ab 100644
> --- a/meta/recipes-extended/cpio/cpio_2.13.bb
> +++ b/meta/recipes-extended/cpio/cpio_2.13.bb
> @@ -14,6 +14,7 @@ SRC_URI = "${GNU_MIRROR}/cpio/cpio-${PV}.tar.gz \
>             file://0001-Use-__alignof__-with-clang.patch \
>             file://0001-Wrong-CRC-with-ASCII-CRC-for-large-files.patch \
>             file://run-ptest \
> +           file://test.sh \
>             "
>  
>  SRC_URI[md5sum] = "389c5452d667c23b5eceb206f5000810"
> @@ -57,9 +58,24 @@ do_install_ptest() {
>      install --mode=755 ${B}/tests/atlocal ${D}${PTEST_PATH}/tests/
>      install --mode=755 ${B}/tests/genfile ${D}${PTEST_PATH}/tests/
>      install --mode=755 ${S}/tests/testsuite ${D}${PTEST_PATH}/tests/
> +    install --mode=755 ${WORKDIR}/test.sh ${D}${PTEST_PATH}/test.sh
>      sed -i "s#@PTEST_PATH@#${PTEST_PATH}#g" ${D}${PTEST_PATH}/run-ptest
>  }
>  
> +# ptest.bbclass currently chowns the ptest directory explicitly, so we need to
> +# change permission after that has happened so the ptest user can write a
> +# temporary directory.
> +do_install_ptest_base:append() {
> +    chgrp -R ptest ${D}${PTEST_PATH}/
> +    chmod -R g+w ${D}${PTEST_PATH}/
> +}
> +
> +# The tests need to run as a non-root user, so pull in the ptest user
> +DEPENDS:append:class-target = "${@bb.utils.contains('PTEST_ENABLED', '1', ' ptest-runner', '', d)}"
> +PACKAGE_WRITE_DEPS += "ptest-runner"
> +
> +RDEPENDS:${PN}-ptest += "ptest-runner"
> +
>  PACKAGES =+ "${PN}-rmt"
>  
>  FILES:${PN}-rmt = "${sbindir}/rmt*"

This seems to break the ptests as it stops returning results:

https://autobuilder.yoctoproject.org/typhoon/#/builders/81/builds/5010

Cheers,

Richard



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

* Re: [OE-core] [PATCH] cpio: Run ptests under ptest user
  2023-05-04 21:16 ` [OE-core] " Richard Purdie
@ 2023-05-04 23:30   ` Khem Raj
  0 siblings, 0 replies; 3+ messages in thread
From: Khem Raj @ 2023-05-04 23:30 UTC (permalink / raw)
  To: Richard Purdie; +Cc: openembedded-core

On Thu, May 4, 2023 at 2:16 PM Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
>
> On Fri, 2023-04-28 at 18:29 -0700, Khem Raj wrote:
> > Running these tests under root user on musl works ok but it emits
> > additional diagnostic
> >
> > cpio: dir: Cannot change ownership to uid 0, gid 0: Not supported
> >
> > Ideally its better to run this test suite under non-root user which
> > is often how these are run. Moreover, tests work on musl as well.
> >
> > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > ---
> >  meta/recipes-extended/cpio/cpio-2.13/run-ptest   |  9 +--------
> >  .../cpio/cpio-2.13/{run-ptest => test.sh}        |  0
> >  meta/recipes-extended/cpio/cpio_2.13.bb          | 16 ++++++++++++++++
> >  3 files changed, 17 insertions(+), 8 deletions(-)
> >  mode change 100644 => 100755 meta/recipes-extended/cpio/cpio-2.13/run-ptest
> >  copy meta/recipes-extended/cpio/cpio-2.13/{run-ptest => test.sh} (100%)
> >
> > diff --git a/meta/recipes-extended/cpio/cpio-2.13/run-ptest b/meta/recipes-extended/cpio/cpio-2.13/run-ptest
> > old mode 100644
> > new mode 100755
> > index f027574e86..f35a756d6b
> > --- a/meta/recipes-extended/cpio/cpio-2.13/run-ptest
> > +++ b/meta/recipes-extended/cpio/cpio-2.13/run-ptest
> > @@ -1,10 +1,3 @@
> >  #!/bin/sh
> >
> > -# Define cpio test work dir
> > -WORKDIR=@PTEST_PATH@/tests/
> > -
> > -# Run test
> > -cd ${WORKDIR}
> > -./atconfig ./atlocal ./testsuite
> > -
> > -./testsuite 2>&1 | grep -E '[0-9]{1,3}: ' | sed -e 's/^.....//' -e '/[ok]$/s/^/PASS: /;/FAILED (.*)/s/^/FAIL: /;/skipped (.*)/s/^/SKIP: /;/expected failure/ s/^/PASS: /;/UNEXPECTED PASS/s/^/FAIL: /' -e 's/ok$//g' -e 's/FAILED.*//g' -e 's/skipped.*//g' -e 's/expected failure.*//g' -e 's/UNEXPECTED PASS.*//g'
> > +su -c ./test.sh ptest
> > diff --git a/meta/recipes-extended/cpio/cpio-2.13/run-ptest b/meta/recipes-extended/cpio/cpio-2.13/test.sh
> > similarity index 100%
> > copy from meta/recipes-extended/cpio/cpio-2.13/run-ptest
> > copy to meta/recipes-extended/cpio/cpio-2.13/test.sh
> > diff --git a/meta/recipes-extended/cpio/cpio_2.13.bb b/meta/recipes-extended/cpio/cpio_2.13.bb
> > index df5e09cae8..943fa9b3ab 100644
> > --- a/meta/recipes-extended/cpio/cpio_2.13.bb
> > +++ b/meta/recipes-extended/cpio/cpio_2.13.bb
> > @@ -14,6 +14,7 @@ SRC_URI = "${GNU_MIRROR}/cpio/cpio-${PV}.tar.gz \
> >             file://0001-Use-__alignof__-with-clang.patch \
> >             file://0001-Wrong-CRC-with-ASCII-CRC-for-large-files.patch \
> >             file://run-ptest \
> > +           file://test.sh \
> >             "
> >
> >  SRC_URI[md5sum] = "389c5452d667c23b5eceb206f5000810"
> > @@ -57,9 +58,24 @@ do_install_ptest() {
> >      install --mode=755 ${B}/tests/atlocal ${D}${PTEST_PATH}/tests/
> >      install --mode=755 ${B}/tests/genfile ${D}${PTEST_PATH}/tests/
> >      install --mode=755 ${S}/tests/testsuite ${D}${PTEST_PATH}/tests/
> > +    install --mode=755 ${WORKDIR}/test.sh ${D}${PTEST_PATH}/test.sh
> >      sed -i "s#@PTEST_PATH@#${PTEST_PATH}#g" ${D}${PTEST_PATH}/run-ptest
> >  }
> >
> > +# ptest.bbclass currently chowns the ptest directory explicitly, so we need to
> > +# change permission after that has happened so the ptest user can write a
> > +# temporary directory.
> > +do_install_ptest_base:append() {
> > +    chgrp -R ptest ${D}${PTEST_PATH}/
> > +    chmod -R g+w ${D}${PTEST_PATH}/
> > +}
> > +
> > +# The tests need to run as a non-root user, so pull in the ptest user
> > +DEPENDS:append:class-target = "${@bb.utils.contains('PTEST_ENABLED', '1', ' ptest-runner', '', d)}"
> > +PACKAGE_WRITE_DEPS += "ptest-runner"
> > +
> > +RDEPENDS:${PN}-ptest += "ptest-runner"
> > +
> >  PACKAGES =+ "${PN}-rmt"
> >
> >  FILES:${PN}-rmt = "${sbindir}/rmt*"
>
> This seems to break the ptests as it stops returning results:
>
> https://autobuilder.yoctoproject.org/typhoon/#/builders/81/builds/5010

Good catch and my bad, I forgot to move PTEST_PATH substitution to
test.sh, sent a v2 which should fix it

>
> Cheers,
>
> Richard
>


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

end of thread, other threads:[~2023-05-04 23:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-29  1:29 [PATCH] cpio: Run ptests under ptest user Khem Raj
2023-05-04 21:16 ` [OE-core] " Richard Purdie
2023-05-04 23:30   ` Khem Raj

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.