Skip to contentSkip to conversation

pTest-quilt: pTest-quilt failed fixed

PATCH In review Dengke Du 2 participants 3 messages Mar 23, 2016 – Mar 24, 2016

lore
Share & tools
lore

Dengke Du

author
#0 lore raw

cover pTest-quilt: pTest-quilt failed fixed

The following changes since commit 8037ba4d86a65ee296cfdcee736dfd614c568818:

bitbake: bb/tests/fetch: Update cups url (2016-03-21 12:43:12 +0000)

are available in the git repository at:

git://git.openembedded.org/openembedded-core-contrib dengke/pTest-quilt-fail-fixed
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=ptest-quilt

Dengke Du (1):
pTest-quilt: fixed the quilt ptest fail

 meta/recipes-devtools/quilt/quilt.inc       | 9 +++++++--
 meta/recipes-devtools/quilt/quilt/run-ptest | 3 ++-
 meta/recipes-devtools/quilt/quilt/test.sh   | 1 +
 3 files changed, 10 insertions(+), 3 deletions(-)
 create mode 100755 meta/recipes-devtools/quilt/quilt/test.sh
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/1 pTest-quilt: pTest-quilt failed fixed

When run the pTest-quilt, the faildiff.test failed, because the user is root. The faildiff.test had the following:

	$ chmod -r test.txt
	$ quilt refresh
Then we drop the read permission of the file test.txt, we can't
"quilt refresh" as normal user, so we got the following:
	>~ .*diff: test\.txt: Permission denied
	> Diff failed on file 'test.txt', aborting
But when the user is root, we can access the file, so we get the
following:
	> Nothing in patch patchs/test.dfff
So I add a user who named "test" to run the pTest, when we run the
run-ptest script. In this way, we should add the user at the begining.
Add the useradd inherit to the meta/recipes-devtools/quilt/quilt.inc
and set the USERADD_PACKAGES and USERADD_PARAM_${PN}-ptest variable
respectively.
In the end, change the authority of the directory of test which collect
all the test case under the directory /usr/lib/quilt/ptest/ on the
target to 777. Because the test case would write this directory, if
the user is test user, it can't write this directory.
---
 meta/recipes-devtools/quilt/quilt.inc       | 9 +++++++--
 meta/recipes-devtools/quilt/quilt/run-ptest | 3 ++-
 meta/recipes-devtools/quilt/quilt/test.sh   | 1 +
 3 files changed, 10 insertions(+), 3 deletions(-)
 create mode 100755 meta/recipes-devtools/quilt/quilt/test.sh
meta/recipes-devtools/quilt/quilt.inc +7 -2
index 837b36b..65d40cc 100644
@@ -8,12 +8,13 @@ SRC_URI = "${SAVANNAH_GNU_MIRROR}/quilt/quilt-${PV}.tar.gz \
         file://install.patch \
         file://run-ptest \
         file://Makefile \
+        file://test.sh \
 "
 
 SRC_URI[md5sum] = "fc0310db5868a0873d602d4332a76d43"
 SRC_URI[sha256sum] = "c4bfd3282214a288e8d3e921ae4d52e73e24c4fead72b5446752adee99a7affd"
 
-inherit autotools-brokensep ptest
+inherit autotools-brokensep ptest useradd
 
 EXTRA_OECONF_darwin += "--without-date \
                         --without-getopt \
@@ -35,6 +36,9 @@ EXTRA_OE_MAKE_ARGS ?= "BUILD_ROOT=${D}"
 
 CACHED_CONFIGUREVARS += "ac_cv_path_BASH=/bin/bash"
 
+USERADD_PACKAGES = "${PN}-ptest"
+USERADD_PARAM_${PN}-ptest = "--create-home --user-group test"
+
 # quilt ignores DESTDIR
 do_install () {
 	oe_runmake ${EXTRA_OE_MAKE_ARGS} install
@@ -50,8 +54,9 @@ do_install_ptest() {
 	tar -cf - bin/ --exclude \*.in | ( cd ${D}${PTEST_PATH} && tar -xf - )
 	tar -cf - compat/ --exclude \*.in | ( cd ${D}${PTEST_PATH} && tar -xf - )
 	tar -cf - quilt/ --exclude \*.in | ( cd ${D}${PTEST_PATH} && tar -xf - )
-	tar -cf - test/ --exclude mail.test --exclude delete.test | ( cd ${D}${PTEST_PATH} && tar -xf - )
+	tar -cf - test/ --exclude mail.test --exclude delete.test | ( cd ${D}${PTEST_PATH} && tar -xf - && chmod 777 test)
 	cp ${WORKDIR}/Makefile ${D}${PTEST_PATH}
+	cp ${WORKDIR}/test.sh ${D}${PTEST_PATH}
 }
 
 RDEPENDS_${PN}-ptest = "make file sed gawk diffutils findutils ed perl \
meta/recipes-devtools/quilt/quilt/run-ptest +2 -1
index 958a9df..14430a2 100755
@@ -1,5 +1,6 @@
 #!/bin/sh
 
+THIS_SH=/bin/sh
 ln -sf /bin/ed /usr/bin/ed
-for i in `ls test/*.test |awk -F. '{print $1}' |awk -F/ '{print $2}'`; do make check-$i; if [ $? -eq 0 ]; then echo PASS: $i.test; else echo FAIL: $i.test; fi; done
+su -c "${THIS_SH} ./test.sh" test
 rm -f /usr/bin/ed
meta/recipes-devtools/quilt/quilt/test.sh new file +1 -0
new file mode 100755
index 0000000..6563e4a
@@ -0,0 +1 @@
+for i in `ls test/*.test |awk -F. '{print $1}' |awk -F/ '{print $2}'`; do make check-$i; if [ $? -eq 0 ]; then echo PASS: $i.test; else echo FAIL: $i.test; fi; done
Signature · 1 line
1.9.1
#2 lore raw

A few comments:

1. (Editorial) Please use the appropriate package name and description of the fix in the commit message:
e.g.: "quilt: run ptest as normal user" or similar

2. I would avoid using the user "test" in this context. "test" user might be a legitimate one in some actual deployment and could interfere this this one.

3. I'd avoid having the user persistent on rootfs (created on post-install script) Instead I would create a regular user at the beginning of test and removing it at the end. You may take a look on libpam recipe tests.

Regards,
Tudor.

Quoted 89 lines · Dengke Du

When run the pTest-quilt, the faildiff.test failed, because the user is root. The faildiff.test had the following:

	$ chmod -r test.txt
	$ quilt refresh
Then we drop the read permission of the file test.txt, we can't
"quilt refresh" as normal user, so we got the following:
	>~ .*diff: test\.txt: Permission denied
	> Diff failed on file 'test.txt', aborting
But when the user is root, we can access the file, so we get the
following:
	> Nothing in patch patchs/test.dfff
So I add a user who named "test" to run the pTest, when we run the
run-ptest script. In this way, we should add the user at the begining.
Add the useradd inherit to the meta/recipes-devtools/quilt/quilt.inc
and set the USERADD_PACKAGES and USERADD_PARAM_${PN}-ptest variable
respectively.
In the end, change the authority of the directory of test which collect
all the test case under the directory /usr/lib/quilt/ptest/ on the
target to 777. Because the test case would write this directory, if
the user is test user, it can't write this directory.
---
 meta/recipes-devtools/quilt/quilt.inc       | 9 +++++++--
 meta/recipes-devtools/quilt/quilt/run-ptest | 3 ++-
 meta/recipes-devtools/quilt/quilt/test.sh   | 1 +
 3 files changed, 10 insertions(+), 3 deletions(-)
 create mode 100755 meta/recipes-devtools/quilt/quilt/test.sh
meta/recipes-devtools/quilt/quilt.inc +7 -2
index 837b36b..65d40cc 100644
@@ -8,12 +8,13 @@ SRC_URI = "${SAVANNAH_GNU_MIRROR}/quilt/quilt-${PV}.tar.gz \
         file://install.patch \
         file://run-ptest \
         file://Makefile \
+        file://test.sh \
 "
 
 SRC_URI[md5sum] = "fc0310db5868a0873d602d4332a76d43"
 SRC_URI[sha256sum] = "c4bfd3282214a288e8d3e921ae4d52e73e24c4fead72b5446752adee99a7affd"
 
-inherit autotools-brokensep ptest
+inherit autotools-brokensep ptest useradd
 
 EXTRA_OECONF_darwin += "--without-date \
                         --without-getopt \
@@ -35,6 +36,9 @@ EXTRA_OE_MAKE_ARGS ?= "BUILD_ROOT=${D}"
 
 CACHED_CONFIGUREVARS += "ac_cv_path_BASH=/bin/bash"
 
+USERADD_PACKAGES = "${PN}-ptest"
+USERADD_PARAM_${PN}-ptest = "--create-home --user-group test"
+
 # quilt ignores DESTDIR
 do_install () {
 	oe_runmake ${EXTRA_OE_MAKE_ARGS} install
@@ -50,8 +54,9 @@ do_install_ptest() {
 	tar -cf - bin/ --exclude \*.in | ( cd ${D}${PTEST_PATH} && tar -xf - )
 	tar -cf - compat/ --exclude \*.in | ( cd ${D}${PTEST_PATH} && tar -xf - )
 	tar -cf - quilt/ --exclude \*.in | ( cd ${D}${PTEST_PATH} && tar -xf - )
-	tar -cf - test/ --exclude mail.test --exclude delete.test | ( cd ${D}${PTEST_PATH} && tar -xf - )
+	tar -cf - test/ --exclude mail.test --exclude delete.test | ( cd ${D}${PTEST_PATH} && tar -xf - && chmod 777 test)
 	cp ${WORKDIR}/Makefile ${D}${PTEST_PATH}
+	cp ${WORKDIR}/test.sh ${D}${PTEST_PATH}
 }
 
 RDEPENDS_${PN}-ptest = "make file sed gawk diffutils findutils ed perl \
meta/recipes-devtools/quilt/quilt/run-ptest +2 -1
index 958a9df..14430a2 100755
@@ -1,5 +1,6 @@
 #!/bin/sh
 
+THIS_SH=/bin/sh
 ln -sf /bin/ed /usr/bin/ed
-for i in `ls test/*.test |awk -F. '{print $1}' |awk -F/ '{print $2}'`; do make check-$i; if [ $? -eq 0 ]; then echo PASS: $i.test; else echo FAIL: $i.test; fi; done
+su -c "${THIS_SH} ./test.sh" test
 rm -f /usr/bin/ed
meta/recipes-devtools/quilt/quilt/test.sh new file +1 -0
new file mode 100755
index 0000000..6563e4a
@@ -0,0 +1 @@
+for i in `ls test/*.test |awk -F. '{print $1}' |awk -F/ '{print $2}'`; do make check-$i; if [ $? -eq 0 ]; then echo PASS: $i.test; else echo FAIL: $i.test; fi; done