]> code.ossystems Code Review - openembedded-core.git/commitdiff
glibc: ptest: Add running glibc time related test suite (Y2038) with ptest
authorLukasz Majewski <lukma@denx.de>
Tue, 9 Nov 2021 15:28:51 +0000 (16:28 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 23 Nov 2021 14:03:43 +0000 (14:03 +0000)
This patch introduces new recipe - namely 'glibc-tests', which
builds and installs time related (to check if Y2038 support works) glibc
test suite to OE/Yocto built image.

It reuses code from already available 'glibc-testsuite' recipe,
which is run with 'bitbake glibc-testsuite -c check' and uses qemu
to execute remotely (via SSH) tests on some emulated machine.

This recipe installs time related glibc tests on some rootfs image.
Afterwards, those tests can be executed on the real hardware, to
facilitate validation of it with Y2038 problem compliance.

To test time related subset - one needs to call:
ptest-runner glibc-tests
then change the date after Y2038 threshold for 32 bit systems:
date -s "20 JAN 2038 18:00:00"
and then run ptest-runner again.

To facilitate debugging, source files are provided by default with
the unstripped debugging symbols. Such approach would reduce the
already complex recipe (as it inherits base glibc one), so there
is no need to also install *-dbg and *-src packages.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/conf/distro/include/maintainers.inc
meta/conf/distro/include/ptest-packagelists.inc
meta/recipes-core/glibc/glibc-tests_2.34.bb [new file with mode: 0644]
meta/recipes-core/glibc/glibc/run-ptest [new file with mode: 0755]

index ed21fbf39a49566025cbecef00518f2854db5a39..5423358e77679676c170fe7f60e839d560451a61 100644 (file)
@@ -209,6 +209,7 @@ RECIPE_MAINTAINER:pn-glibc = "Khem Raj <raj.khem@gmail.com>"
 RECIPE_MAINTAINER:pn-glibc-locale = "Khem Raj <raj.khem@gmail.com>"
 RECIPE_MAINTAINER:pn-glibc-mtrace = "Khem Raj <raj.khem@gmail.com>"
 RECIPE_MAINTAINER:pn-glibc-scripts = "Khem Raj <raj.khem@gmail.com>"
+RECIPE_MAINTAINER:pn-glibc-tests = "Lukasz Majewski <lukma@denx.de>"
 RECIPE_MAINTAINER:pn-glibc-testsuite = "Khem Raj <raj.khem@gmail.com>"
 RECIPE_MAINTAINER:pn-glide = "Otavio Salvador <otavio.salvador@ossystems.com.br>"
 RECIPE_MAINTAINER:pn-gmp = "Khem Raj <raj.khem@gmail.com>"
index 9559f611d09d786261a0774fdaa63264c5b30f9d..0277ddaf1af284c14eadb699af6ce4a487b6ae74 100644 (file)
@@ -61,6 +61,7 @@ PTESTS_FAST = "\
     slang-ptest \
     wayland-ptest \
     zlib-ptest \
+    glibc-tests-ptest \
 "
 PTESTS_FAST:remove:mips64 = "qemu-ptest"
 PTESTS_PROBLEMS:append:mips64 = " qemu-ptest"
diff --git a/meta/recipes-core/glibc/glibc-tests_2.34.bb b/meta/recipes-core/glibc/glibc-tests_2.34.bb
new file mode 100644 (file)
index 0000000..42b510c
--- /dev/null
@@ -0,0 +1,113 @@
+require glibc_${PV}.bb
+require glibc-tests.inc
+
+inherit ptest
+
+SRC_URI:append = " \
+       file://run-ptest \
+"
+
+SUMMARY = "glibc tests to be run with ptest"
+
+# Erase some variables already set by glibc_${PV}
+python __anonymous() {
+       # Remove packages provided by glibc build, we only need a subset of them
+       d.setVar("PACKAGES", "${PN} ${PN}-ptest")
+
+       d.setVar("PROVIDES", "${PN} ${PN}-ptest")
+       d.setVar("RPROVIDES", "${PN} ${PN}-ptest")
+
+       d.setVar("BBCLASSEXTEND", "")
+       d.setVar("RRECOMMENDS", "")
+}
+
+# Remove any leftovers from original glibc recipe
+RPROVIDES:${PN} = "${PN}"
+RRECOMMENDS:${PN} = ""
+RDEPENDS:${PN} = " glibc sed"
+DEPENDS:append = " sed"
+
+# Just build tests for target - do not run them
+do_check:append () {
+       oe_runmake -i check run-built-tests=no
+}
+addtask do_check after do_compile before do_install_ptest_base
+
+glibc_strip_build_directory () {
+       # Delete all non executable files from build directory
+       find ${B} ! -executable -type f -delete
+
+       # Remove build dynamic libraries and links to them as
+       # those are already installed in the target device
+       find ${B} -type f -name "*.so" -delete
+       find ${B} -type l -name "*.so*" -delete
+
+       # Remove headers (installed with glibc)
+       find ${B} -type f -name "*.h" -delete
+
+       find ${B} -type f -name "isomac" -delete
+       find ${B} -type f -name "annexc" -delete
+}
+
+do_install_ptest_base () {
+       glibc_strip_build_directory
+
+       ls -r ${B}/*/*-time64 > ${B}/tst_time64
+
+       # Remove '-time64' suffix - those tests are also time related
+       sed -e "s/-time64$//" ${B}/tst_time64 > ${B}/tst_time_tmp
+       tst_time=$(cat ${B}/tst_time_tmp ${B}/tst_time64)
+
+       rm ${B}/tst_time_tmp ${B}/tst_time64
+       echo "${tst_time}"
+
+       # Install build test programs to the image
+       install -d ${D}${PTEST_PATH}/tests/glibc-ptest/
+
+       for f in "${tst_time}"
+       do
+           cp -r ${f} ${D}${PTEST_PATH}/tests/glibc-ptest/
+       done
+
+       install -d ${D}${PTEST_PATH}
+       cp ${WORKDIR}/run-ptest ${D}${PTEST_PATH}/
+
+}
+
+# The datadir directory is required to allow core (and reused)
+# glibc cleanup function to finish correctly, as this directory
+# is not created for ptests
+stash_locale_package_cleanup:prepend () {
+       mkdir -p ${PKGD}${datadir}
+}
+
+stash_locale_sysroot_cleanup:prepend () {
+       mkdir -p ${SYSROOT_DESTDIR}${datadir}
+}
+
+# Prevent the do_package() task to set 'libc6' prefix
+# for glibc tests related packages
+python populate_packages:prepend () {
+    if d.getVar('DEBIAN_NAMES'):
+        d.setVar('DEBIAN_NAMES', '')
+}
+
+FILES:${PN} = "${PTEST_PATH}/* /usr/src/debug/glibc-tests/*"
+
+EXCLUDE_FROM_SHLIBS = "1"
+
+# Install debug data in .debug and sources in /usr/src/debug
+# It is more handy to have _all_ the sources and symbols in one
+# place (package) as this recipe will be used for validation and
+# debugging.
+PACKAGE_DEBUG_SPLIT_STYLE = "debug"
+
+# glibc test cases violate by default some Yocto/OE checks (staticdev,
+# textrel)
+# 'debug-files' - add everything (including debug) into one package
+#                 (no need to install/build *-src package)
+INSANE_SKIP:${PN} += "staticdev textrel debug-files rpaths"
+
+deltask do_stash_locale
+do_install[noexec] = "1"
+do_populate_sysroot[noexec] = "1"
diff --git a/meta/recipes-core/glibc/glibc/run-ptest b/meta/recipes-core/glibc/glibc/run-ptest
new file mode 100755 (executable)
index 0000000..f637986
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/sh
+# ptest script for glibc - to run time related tests to
+# facilitate Y2038 validation
+# Run with 'ptest-runner glibc-tests'
+
+output() {
+  retcode=$?
+  if [ $retcode -eq 0 ]
+    then echo "PASS: $i"
+  elif [ $retcode -eq 77 ]
+    then echo "SKIP: $i"
+  else echo "FAIL: $i"
+  fi
+}
+
+# Allow altering time on the target
+export GLIBC_TEST_ALLOW_TIME_SETTING="1"
+
+tst_time64=$(ls -r ${PWD}/tests/glibc-ptest/*-time64)
+
+# Remove '-time64' suffix - those tests are also time
+# related
+tst_time_tmp=$(sed -e "s/-time64$//" <<< ${tst_time64})
+
+# Run tests supporting only 32 bit time
+for i in ${tst_time_tmp}
+do
+       $i >/dev/null 2>&1
+       output
+done
+
+# Run tests supporting only 64 bit time
+for i in ${tst_time64}
+do
+       $i >/dev/null 2>&1
+       output
+done