Skip to contentSkip to conversation

RFC: ptest for danny

PATCH In review Björn Stenberg 2 participants 11 messages Nov 21, 2012 – Nov 22, 2012

lore
Share & tools
lore
#0 lore raw

cover RFC: ptest for danny

Hi all.

Here is an update of the "ptest" concept I introduced a few months back. The idea is to create a new package group called -ptest which contains the test suites included with many source packages, compiled to run on target.

A new package, ptest-runnner, contains a simple shell script to find and run all installed ptests.

Making ptest package recipes present a number of challenges. First, the task of building and running the tests have to be split in two. Then, the test files must be installed in the file system in a sane way.

I have included recipe patches for glib-2.0 and dbus here. They solve the building and running relatively cleanly but the install bit is still a rather kludgy list of cp and sed lines. I'm working on a more generic "make ptest-install" solution.

These patches are against the "danny" branch.

Björn Stenberg (4):
Add a new distro feature "ptest"
New recipe: ptest-runner
Add ptest for glib-2.0.
Add ptest for dbus.

 meta/classes/image.bbclass                         |    6 +-
 meta/classes/packagegroup.bbclass                  |    2 +-
 meta/conf/bitbake.conf                             |   15 +++-
 meta/recipes-core/dbus/dbus-1.6.4/run-ptest        |    3 +
 .../dbus/dbus-1.6.4/test-run-path.patch            |   26 ++++++
 meta/recipes-core/dbus/dbus-test_1.6.4.bb          |   84 ++++++++++++++++++++
 meta/recipes-core/dbus/dbus.inc                    |    3 +
 .../glib-2.0/glib-2.0/Makefile-ptest.patch         |   30 +++++++
 meta/recipes-core/glib-2.0/glib-2.0/run-ptest      |    3 +
 meta/recipes-core/glib-2.0/glib-2.0_2.32.4.bb      |   57 +++++++++++++
 .../automake/automake/buildtest.patch              |   33 ++++++++
 meta/recipes-devtools/automake/automake_1.12.3.bb  |    3 +-
 .../ptest-runner/files/ptest-runner                |   19 +++++
 .../ptest-runner/ptest-runner_1.0.bb               |   17 ++++
 14 files changed, 296 insertions(+), 5 deletions(-)
 create mode 100755 meta/recipes-core/dbus/dbus-1.6.4/run-ptest
 create mode 100644 meta/recipes-core/dbus/dbus-1.6.4/test-run-path.patch
 create mode 100644 meta/recipes-core/dbus/dbus-test_1.6.4.bb
 create mode 100644 meta/recipes-core/glib-2.0/glib-2.0/Makefile-ptest.patch
 create mode 100644 meta/recipes-core/glib-2.0/glib-2.0/run-ptest
 create mode 100644 meta/recipes-devtools/automake/automake/buildtest.patch
 create mode 100644 meta/recipes-support/ptest-runner/files/ptest-runner
 create mode 100644 meta/recipes-support/ptest-runner/ptest-runner_1.0.bb
Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 2/4 New recipe: ptest-runner

This recipe installs a simple shell script which searches for all installed ptests on the rootfs and runs each test in sequence.

---
 meta/conf/bitbake.conf                             |    2 +-
 .../ptest-runner/files/ptest-runner                |   16 ++++++++++++++++
 .../ptest-runner/ptest-runner_1.0.bb               |   17 +++++++++++++++++
 3 files changed, 34 insertions(+), 1 deletions(-)
 create mode 100644 meta/recipes-support/ptest-runner/files/ptest-runner
 create mode 100644 meta/recipes-support/ptest-runner/ptest-runner_1.0.bb
meta/conf/bitbake.conf +1 -1
index 783ca37..64014d3 100644
@@ -225,7 +225,7 @@ This package contains ELF symbols and related sources for debugging purposes."
 
 SUMMARY_${PN}-ptest ?= "${SUMMARY} - Package test files"
 DESCRIPTION_${PN}-ptest ?= "${DESCRIPTION}  \
-This package contains test directory with the name ${PTEST_NAME} for package test purposes."
+This package contains a test directory ${PTEST_PATH} for package test purposes."
 
 SUMMARY_${PN}-dev ?= "${SUMMARY} - Development files"
 DESCRIPTION_${PN}-dev ?= "${DESCRIPTION}  \
meta/recipes-support/ptest-runner/files/ptest-runner new file +16 -0
new file mode 100644
index 0000000..4f3c7ce
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+echo "START: $0"
+cd /usr/lib
+for x in *
+do
+    if [ -x "/usr/lib/$x/ptest/run-ptest" ]; then
+       date "+%Y-%m-%dT%H:%M"
+        echo "BEGIN: $x"
+        cd /usr/lib/$x/ptest
+        ./run-ptest
+        echo "END: $x"
+       date "+%Y-%m-%dT%H:%M"
+    fi
+done
+echo "STOP: $0"
meta/recipes-support/ptest-runner/ptest-runner_1.0.bb new file +17 -0
new file mode 100644
index 0000000..6b866d4
@@ -0,0 +1,17 @@
+SRC_URI += "file://ptest-runner"
+
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58 \
+                    file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
+
+INHIBIT_DEFAULT_DEPS = "1"
+
+do_install () {
+    mkdir -p ${D}${bindir}
+    install -m 0755 ${WORKDIR}/ptest-runner ${D}${bindir}
+}
+
+do_patch[noexec] = "1"
+do_configure[noexec] = "1"
+do_compile[noexec] = "1"
+do_build[noexec] = "1"
Signature · 1 line
1.7.5.4
#4 lore raw

PATCH 4/4 Add ptest for dbus.

In reply to Björn Stenberg

This patch adds a new recipe dbus-test to build and package the dbus test suite. The reason for a separate recipe is that the dbus test suite depends on dbus-glib, so it cannot be compiled at the same time as dbus.

An RDEPENDS rule is added to the dbus recipe to include the dbus-test package into the image when ptest is enabled, since the standard -ptest suffix mechanism does not apply to this package.

---
 meta/recipes-core/dbus/dbus-1.6.4/run-ptest        |    3 +
 .../dbus/dbus-1.6.4/test-run-path.patch            |   26 ++++++
 meta/recipes-core/dbus/dbus-test_1.6.4.bb          |   84 ++++++++++++++++++++
 meta/recipes-core/dbus/dbus.inc                    |    3 +
 4 files changed, 116 insertions(+), 0 deletions(-)
 create mode 100755 meta/recipes-core/dbus/dbus-1.6.4/run-ptest
 create mode 100644 meta/recipes-core/dbus/dbus-1.6.4/test-run-path.patch
 create mode 100644 meta/recipes-core/dbus/dbus-test_1.6.4.bb
meta/recipes-core/dbus/dbus-1.6.4/run-ptest new file +3 -0
new file mode 100755
index 0000000..e08ecb1
@@ -0,0 +1,3 @@
+#!/bin/sh
+cd test
+make -k runtest-TESTS
meta/recipes-core/dbus/dbus-1.6.4/test-run-path.patch new file +26 -0
new file mode 100644
index 0000000..5c08c93
@@ -0,0 +1,26 @@
+
+
+Signed-off-by: Björn Stenberg <[email protected]>
+Upstream-Status: Pending
+
+--- a/test/Makefile.am	2012-06-15 15:25:43.000000000 +0200
++++ b/test/Makefile.am	2012-11-16 09:24:44.263140840 +0100
+@@ -119,12 +119,13 @@
+ 	DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus \
+ 	DBUS_TEST_SYSCONFDIR=$(DESTDIR)$(sysconfdir)
+ 
++ptest_run_dir = ..
++
+ TESTS_ENVIRONMENT = \
+-	DBUS_BLOCK_ON_ABORT=1 \
+-	DBUS_FATAL_WARNINGS=1 \
+-	DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT) \
+-	DBUS_TEST_DATA=@abs_top_builddir@/test/data \
+-	DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus \
++	DBUS_FATAL_WARNINGS=0 \
++	DBUS_TEST_DAEMON=$(ptest_run_dir)/bus/dbus-daemon$(EXEEXT) \
++	DBUS_TEST_DATA=$(ptest_run_dir)/test/data \
++	DBUS_TEST_HOMEDIR=$(ptest_run_dir)/dbus \
+ 	$(NULL)
+ 
+ test_corrupt_SOURCES = corrupt.c
meta/recipes-core/dbus/dbus-test_1.6.4.bb new file +84 -0

84 lines not on this page · raw message

meta/recipes-core/dbus/dbus.inc +3 -0
index 550eb0a..9e791d2 100644
@@ -9,6 +9,9 @@ X11DEPENDS = "virtual/libx11 libsm"
 DEPENDS = "expat virtual/libintl ${@base_contains('DISTRO_FEATURES', 'x11', '${X11DEPENDS}', '', d)}"
 DEPENDS_virtclass-native = "expat-native virtual/libintl-native"
 DEPENDS_virtclass-nativesdk = "nativesdk-expat virtual/nativesdk-libintl virtual/libx11"
+RDEPENDS = "${@base_contains('DISTRO_FEATURES', 'ptest', 'dbus-test', '', d)}"
+RDEPENDS_virtclass-native = ""
+
 
 INC_PR = "r5"
 
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/4 Add a new distro feature "ptest"

In reply to Björn Stenberg

This patch creates a new distro feature "ptest", which creates -ptest packages containing the test suite of the package for running on the target. Test files are installed in /usr/lib/<pkg>/ptest.

The patch also includes a change to automake, splitting the "make check" target into separate steps for building and running the tests.

---
 meta/classes/image.bbclass                         |    6 ++-
 meta/classes/packagegroup.bbclass                  |    2 +-
 meta/conf/bitbake.conf                             |   15 ++++++++-
 .../automake/automake/buildtest.patch              |   33 ++++++++++++++++++++
 meta/recipes-devtools/automake/automake_1.12.3.bb  |    3 +-
 5 files changed, 54 insertions(+), 5 deletions(-)
 create mode 100644 meta/recipes-devtools/automake/automake/buildtest.patch
meta/classes/image.bbclass +4 -2
index ab212b3..94182d1 100644
@@ -29,13 +29,13 @@ ROOTFS_BOOTSTRAP_INSTALL = "${@base_contains("IMAGE_FEATURES", "package-manageme
 FEATURE_INSTALL = "${@' '.join(oe.packagegroup.required_packages(oe.data.typed_value('IMAGE_FEATURES', d), d))}"
 FEATURE_INSTALL_OPTIONAL = "${@' '.join(oe.packagegroup.optional_packages(oe.data.typed_value('IMAGE_FEATURES', d), d))}"
 
-# packages to install from features, excluding dev/dbg/doc
+# packages to install from features, excluding dev/dbg/doc/ptest
 NORMAL_FEATURE_INSTALL = "${@' '.join(oe.packagegroup.required_packages(normal_groups(d), d))}"
 NORMAL_FEATURE_INSTALL_OPTIONAL = "${@' '.join(oe.packagegroup.optional_packages(normal_groups(d), d))}"
 
 def normal_groups(d):
     """Return all the IMAGE_FEATURES, with the exception of our special package groups"""
-    extras = set(['dev-pkgs', 'staticdev-pkgs', 'doc-pkgs', 'dbg-pkgs'])
+    extras = set(['dev-pkgs', 'staticdev-pkgs', 'doc-pkgs', 'dbg-pkgs', 'ptest-pkgs'])
     features = set(oe.data.typed_value('IMAGE_FEATURES', d))
     return features.difference(extras)
 
@@ -57,6 +57,8 @@ def complementary_globs(featurevar, d):
             globs.append('*-doc')
         elif feature == 'dbg-pkgs':
             globs.append('*-dbg')
+        elif feature == 'ptest-pkgs':
+            globs.append('*-ptest')
     return ' '.join(globs)
 
 IMAGE_INSTALL_COMPLEMENTARY = '${@complementary_globs("IMAGE_FEATURES", d)}'
meta/classes/packagegroup.bbclass +1 -1
index e0e5b1c..b5be048 100644
@@ -25,7 +25,7 @@ python () {
     packages = d.getVar('PACKAGES', True).split()
     genpackages = []
     for pkg in packages:
-        for postfix in ['-dbg', '-dev']:
+        for postfix in ['-dbg', '-dev', '-ptest']:
             genpackages.append(pkg+postfix)
     d.setVar('PACKAGES', ' '.join(packages+genpackages))
 }
meta/conf/bitbake.conf +14 -1
index 5cb5b13..783ca37 100644
@@ -223,6 +223,10 @@ SUMMARY_${PN}-dbg ?= "${SUMMARY} - Debugging files"
 DESCRIPTION_${PN}-dbg ?= "${DESCRIPTION}  \
 This package contains ELF symbols and related sources for debugging purposes."
 
+SUMMARY_${PN}-ptest ?= "${SUMMARY} - Package test files"
+DESCRIPTION_${PN}-ptest ?= "${DESCRIPTION}  \
+This package contains test directory with the name ${PTEST_NAME} for package test purposes."
+
 SUMMARY_${PN}-dev ?= "${SUMMARY} - Development files"
 DESCRIPTION_${PN}-dev ?= "${DESCRIPTION}  \
 This package contains symbolic links, header files, and \
@@ -266,7 +270,7 @@ SOLIBSDEV_darwin8 = ".dylib"
 SOLIBSDEV_darwin9 = ".dylib"
 
 PACKAGE_BEFORE_PN ?= ""
-PACKAGES = "${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PACKAGE_BEFORE_PN} ${PN}"
+PACKAGES = "${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PN}-ptest ${PACKAGE_BEFORE_PN} ${PN}"
 PACKAGES_DYNAMIC = "${PN}-locale-*"
 FILES = ""
 
@@ -310,6 +314,15 @@ SECTION_${PN}-dbg = "devel"
 ALLOW_EMPTY_${PN}-dbg = "1"
 RRECOMMENDS_${PN}-dbg = "${PN} (= ${EXTENDPKGV})"
 
+PTEST_PATH ?= "${libdir}/${PN}/ptest"
+FILES_${PN}-ptest = "${PTEST_PATH}/*"
+SECTION_${PN}-ptest = "devel"
+ALLOW_EMPTY_${PN}-ptest = "1"
+RDEPENDS_${PN}-ptest = "${PN} (= ${EXTENDPKGV})"
+PTEST_ENABLED = "${@base_contains("DISTRO_FEATURES", "ptest", "1", "0", d)}"
+RDEPENDS_${PN}-ptest_virtclass-native = ""
+RDEPENDS_${PN}-ptest_virtclass-nativesdk = ""
+
 FILES_${PN}-locale = "${datadir}/locale"
 
 # File manifest
meta/recipes-devtools/automake/automake/buildtest.patch new file +33 -0
new file mode 100644
index 0000000..7efff6b
@@ -0,0 +1,33 @@
+Split "check-TESTS" into a buildtest and runtest target, so that they can
+be run separately.
+
+Signed-off-by: Björn Stenberg <[email protected]>
+Upstream-Status: Pending
+
+--- a/lib/am/check.am	2012-11-14 13:46:16.335475995 +0100
++++ b/lib/am/check.am	2012-08-13 18:40:12.000000000 +0200
+@@ -44,7 +44,7 @@
+ am__tty_colors = $(am__tty_colors_dummy)
+ endif !%?COLOR%
+
+-.PHONY: check-TESTS
++.PHONY: check-TESTS buildtest-TESTS runtest-TESTS
+
+ if %?PARALLEL_TESTS%
+
+@@ -465,7 +465,14 @@
+
+ else !%?PARALLEL_TESTS%
+
+-check-TESTS: $(TESTS)
++AM_RECURSIVE_TARGETS += buildtest runtest
++
++buildtest-TESTS: $(TESTS)
++
++check-TESTS: buildtest-TESTS
++	$(MAKE) $(AM_MAKEFLAGS) runtest-TESTS
++
++runtest-TESTS:
+	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
+	srcdir=$(srcdir); export srcdir; \
+ ## Make sure Solaris VPATH-expands all members of this list, even
meta/recipes-devtools/automake/automake_1.12.3.bb +2 -1
index af99dfa..40169d3 100644
@@ -37,7 +37,8 @@ PATHFIXPATCH_virtclass-nativesdk = ""
 SRC_URI += "${PATHFIXPATCH} \
 	    file://prefer-cpio-over-pax-for-ustar-archives.patch \
 	    file://python-libdir.patch \
-            file://py-compile-compile-only-optimized-byte-code.patch"
+            file://py-compile-compile-only-optimized-byte-code.patch \
+            file://buildtest.patch"
 
 SRC_URI[md5sum] = "d2af8484de94cdee16d89c50aaa1c729"
 SRC_URI[sha256sum] = "095ffaa3ac887d1eb3511bf13d7f1fc9ec0503c6a06aeae05c93730cdda9a5a0"
Signature · 1 line
1.7.5.4
#3 lore raw

PATCH 3/4 Add ptest for glib-2.0.

In reply to Björn Stenberg
---
 .../glib-2.0/glib-2.0/Makefile-ptest.patch         |   30 ++++++++++
 meta/recipes-core/glib-2.0/glib-2.0/run-ptest      |    3 +
 meta/recipes-core/glib-2.0/glib-2.0_2.32.4.bb      |   57 ++++++++++++++++++++
 .../ptest-runner/files/ptest-runner                |    3 +
 4 files changed, 93 insertions(+), 0 deletions(-)
 create mode 100644 meta/recipes-core/glib-2.0/glib-2.0/Makefile-ptest.patch
 create mode 100644 meta/recipes-core/glib-2.0/glib-2.0/run-ptest
meta/recipes-core/glib-2.0/glib-2.0/Makefile-ptest.patch new file +30 -0
new file mode 100644
index 0000000..b5b1498
@@ -0,0 +1,30 @@
+Add 'ptest' target to Makefile, to run tests without checking dependencies.
+
+Signed-off-by: Björn Stenberg <[email protected]>
+Upstream-status: Pending
+---
+ Makefile.decl |   13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+--- a/Makefile.decl	2012-03-12 01:42:39.000000000 +0100
++++ b/Makefile.decl	2012-11-12 17:02:36.838107381 +0100
+@@ -25,6 +25,19 @@
+ test-nonrecursive:
+ endif
+ 
++ptest: ptest-nonrecursive
++if OS_UNIX
++	@ for subdir in $(SUBDIRS) .; do \
++	    test -d "$$subdir" -a "$$subdir" != "." -a "$$subdir" != "po" && \
++	    ( test -d $$subdir && cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) \
++	  done
++
++ptest-nonrecursive:
++	@test -z "${TEST_PROGS}" || ${GTESTER} --keep-going --verbose ${TEST_PROGS}
++else
++ptest-nonrecursive:
++endif
++
+ # test-report: run tests in subdirs and generate report
+ # perf-report: run tests in subdirs with -m perf and generate report
+ # full-report: like test-report: with -m perf and -m slow
meta/recipes-core/glib-2.0/glib-2.0/run-ptest new file +3 -0
new file mode 100644
index 0000000..3deb586
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+make -k ptest
meta/recipes-core/glib-2.0/glib-2.0_2.32.4.bb +57 -0

73 lines not on this page · raw message

meta/recipes-support/ptest-runner/files/ptest-runner +3 -0
index 4f3c7ce..5022218 100644
@@ -1,5 +1,8 @@
 #!/bin/sh
 
+export MALLOC_CHECK_=2
+export MALLOC_PERTURB_=$(($RANDOM % 255 + 1))
+
 echo "START: $0"
 cd /usr/lib
 for x in *
Signature · 1 line
1.7.5.4
#5 lore raw
In reply to Björn Stenberg
Quoted 1 line · Björn Stenberg

These patches are against the "danny" branch.

Please base it in master branch as danny is now stable and this is a new feature which might include regresions.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
E-mail: [email protected]  http://www.ossystems.com.br
Mobile: +55 53 9981-7854              http://projetos.ossystems.com.br
#7 lore raw
In reply to Björn Stenberg

I have a few specific issues I would like help and/or feedback on:

- The -ptest .ipk packages get installed with "Status: install user unpacked" rather than "install user installed", causing them to be processed by postinst. What do I have to do to take them from "unpacked" to "installed"?

- I have to add a lot of paths to the FILES-dbg to avoid QA warnings. It feels a bit kludgy, is there a cleaner way to handle this?

- What should we do with packages that don't have an upstream test suite? My first thought was to just ignore them, but one could also argue that a "SKIP: no package test" message would be more informative than no message at all, since it separate the package from yet-to-be-processed ones. Opinions?

- We have modified our buildbot to parse and collect the ptest output. Where would be a suitable place to discuss these modifications?

Signature · 1 line
Björn
#8 lore raw
Quoted 3 lines · Björn Stenberg

I have a few specific issues I would like help and/or feedback on:

- The -ptest .ipk packages get installed with "Status: install user unpacked" rather than "install user installed", causing them to be processed by postinst. What do I have to do to take them from "unpacked" to "installed"?

Your package postinst needs to be able to be run offline.

Quoted 1 line

- I have to add a lot of paths to the FILES-dbg to avoid QA warnings. It feels a bit kludgy, is there a cleaner way to handle this?

You might want to cook a python snip to automate it.

Quoted 1 line

- What should we do with packages that don't have an upstream test suite? My first thought was to just ignore them, but one could also argue that a "SKIP: no package test" message would be more informative than no message at all, since it separate the package from yet-to-be-processed ones. Opinions?

I agree an informative message would be good to have; maybe it could be print only when have a verbose or debug option?

Quoted 1 line

- We have modified our buildbot to parse and collect the ptest output. Where would be a suitable place to discuss these modifications?

No clue here heheh

Signature · 3 lines
Otavio Salvador                             O.S. Systems
E-mail: [email protected]  http://www.ossystems.com.br
Mobile: +55 53 9981-7854              http://projetos.ossystems.com.br
#6 lore raw
In reply to Otavio Salvador
Quoted 2 lines · Otavio Salvador

Please base it in master branch as danny is now stable and this is a new feature which might include regresions.

I will post patches against master soon.

Signature · 1 line
Björn
#9 lore raw
In reply to Otavio Salvador
Quoted 2 lines · Otavio Salvador
Quoted 1 line

What do I have to do to take them from "unpacked" to "installed"?

Your package postinst needs to be able to be run offline.

But they don't have any postinst. There are no .postinst files installed for these packages in /var/lib/opkg/info. run-postinst.awk goes through the motions and prints "Configuring:" for these packages only because the package status says "unpacked" instead of "installed". Nothing is ever ran.

Signature · 1 line
Björn
#10 lore raw
Quoted 5 lines · Björn Stenberg
Quoted 2 lines · Otavio Salvador
Quoted 1 line

What do I have to do to take them from "unpacked" to "installed"?

Your package postinst needs to be able to be run offline.

But they don't have any postinst. There are no .postinst files installed for these packages in /var/lib/opkg/info. run-postinst.awk goes through the motions and prints "Configuring:" for these packages only because the package status says "unpacked" instead of "installed". Nothing is ever ran.

When first booting it always try to run the post insts; this is need to finish the configuration for the cases where it cannot be done offline.

I think something is failing in your rootfs; please check the rootfs log.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
E-mail: [email protected]  http://www.ossystems.com.br
Mobile: +55 53 9981-7854              http://projetos.ossystems.com.br