From 15e20ba802088e5d6af11cacaf1d53e3e9ee84cf Mon Sep 17 00:00:00 2001 From: Sergey Turivniy Date: Feb 05 2018 16:24:23 +0000 Subject: Add CI tests using the standard test interface --- diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..4ca04f0 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,17 @@ +--- +# This first play always runs on the local staging system +- hosts: localhost + roles: + - role: standard-test-beakerlib + tags: + - classic + tests: + - testsuite + required_packages: + - libffi + - libffi-devel + - gcc + - dejagnu + - rpm-build + - gcc-c++ + - strace diff --git a/tests/testsuite/Makefile b/tests/testsuite/Makefile new file mode 100644 index 0000000..f729bae --- /dev/null +++ b/tests/testsuite/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/libffi/Sanity/testsuite +# Description: Runs upstream testsuite +# Author: Michal Nowak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/tools/libffi/Sanity/testsuite +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE dynamic_linking.patch dynamic_linking-dg.patch + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Michal Nowak " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Runs upstream testsuite" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 19m" >> $(METADATA) + @echo "RunFor: libffi" >> $(METADATA) + @echo "Requires: libffi libffi-devel gcc dejagnu rpm-build gcc-c++ texinfo strace" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv3" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Releases: -RHEL4 -RHEL5" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/testsuite/PURPOSE b/tests/testsuite/PURPOSE new file mode 100644 index 0000000..688fefb --- /dev/null +++ b/tests/testsuite/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/libffi/Sanity/testsuite +Description: Runs upstream testsuite +Author: Michal Nowak diff --git a/tests/testsuite/dynamic_linking-dg.patch b/tests/testsuite/dynamic_linking-dg.patch new file mode 100644 index 0000000..fb10ae3 --- /dev/null +++ b/tests/testsuite/dynamic_linking-dg.patch @@ -0,0 +1,29 @@ +--- testsuite/lib/libffi-dg.exp 2008-02-14 19:45:33.000000000 -0500 ++++ testsuite/lib/libffi-dg.exp 2015-02-13 13:32:08.422053435 -0500 +@@ -110,7 +110,7 @@ + } + verbose "gccdir $gccdir" + +- set ld_library_path "." ++ set ld_library_path "" + append ld_library_path ":${gccdir}" + + set compiler "${gccdir}/xgcc" +@@ -127,16 +127,13 @@ + } + } + } +- # add the library path for libffi. +- append ld_library_path ":${blddirffi}/.libs" +- + verbose "ld_library_path: $ld_library_path" + + # Point to the Libffi headers in libffi. + set libffi_include "${blddirffi}/include" + verbose "libffi_include $libffi_include" + +- set libffi_dir "${blddirffi}/.libs" ++ set libffi_dir "/usr/LIBRARY_DIR" + verbose "libffi_dir $libffi_dir" + if { $libffi_dir != "" } { + set libffi_dir [file dirname ${libffi_dir}] diff --git a/tests/testsuite/dynamic_linking.patch b/tests/testsuite/dynamic_linking.patch new file mode 100644 index 0000000..65de4d7 --- /dev/null +++ b/tests/testsuite/dynamic_linking.patch @@ -0,0 +1,29 @@ +--- testsuite/lib/libffi.exp 2013-03-16 07:19:39.000000000 -0400 ++++ testsuite/lib/libffi.exp 2014-10-22 11:10:42.449143642 -0400 +@@ -118,7 +118,7 @@ + } + verbose "gccdir $gccdir" + +- set ld_library_path "." ++ set ld_library_path "" + append ld_library_path ":${gccdir}" + + set compiler "${gccdir}/xgcc" +@@ -142,16 +142,13 @@ + + } + +- # add the library path for libffi. +- append ld_library_path ":${blddirffi}/.libs" +- + verbose "ld_library_path: $ld_library_path" + + # Point to the Libffi headers in libffi. + set libffi_include "${blddirffi}/include" + verbose "libffi_include $libffi_include" + +- set libffi_dir "${blddirffi}/.libs" ++ set libffi_dir "/usr/LIBRARY_DIR" + verbose "libffi_dir $libffi_dir" + if { $libffi_dir != "" } { + set libffi_dir [file dirname ${libffi_dir}] diff --git a/tests/testsuite/runtest.sh b/tests/testsuite/runtest.sh new file mode 100755 index 0000000..92c2f0f --- /dev/null +++ b/tests/testsuite/runtest.sh @@ -0,0 +1,86 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/libffi/Sanity/testsuite +# Description: Runs upstream testsuite +# Author: Michal Nowak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include rhts environment +. /usr/lib/beakerlib/beakerlib.sh + +PACKAGES=(libffi libffi-devel gcc dejagnu rpm-build gcc-c++) + +rlJournalStart + rlPhaseStartSetup + for p in "${PACKAGES[@]}"; do + if ! rlCheckRpm "$p"; then + rlRun "yum -y install $p" + rlAssertRpm "$p" + fi + done; + + rlRun "TmpDir=`mktemp -d`" 0 "Creating tmp directory" + rlRun "cp *.patch $TmpDir/" + rlRun "pushd $TmpDir" + rlFetchSrcForInstalled libffi + rlRun "rpm -ivh libffi*.src.rpm" + rlRun "popd" + rlRun "specfile=$(rpm --eval='%_specdir')/libffi.spec" + rlRun "rpmbuild -bp $specfile" + rlRun "builddir=$(rpm --eval='%_builddir')" + rlRun "pushd $builddir/libffi-*/" + rlRun "./configure" + rlRUn "make" + rlPhaseEnd + + rlPhaseStartTest "Run testsuite" + + # patching the testsuite to test the installed libraries instead of the built ones + if [ -e /usr/lib64/libffi.so ]; then + export LD_LIBRARY_PATH=/usr/lib64 + perl -i -pe 's/LIBRARY_DIR/lib64/' $TmpDir/dynamic_linking.patch + perl -i -pe 's/LIBRARY_DIR/lib64/' $TmpDir/dynamic_linking-dg.patch + else + export LD_LIBRARY_PATH=/usr/lib + perl -i -pe 's/LIBRARY_DIR/lib/' $TmpDir/dynamic_linking.patch + perl -i -pe 's/LIBRARY_DIR/lib/' $TmpDir/dynamic_linking-dg.patch + fi + test -e testsuite/lib/libffi.exp && rlRun "patch testsuite/lib/libffi.exp < $TmpDir/dynamic_linking.patch" + test -e testsuite/lib/libffi-dg.exp && rlRun "patch testsuite/lib/libffi-dg.exp < $TmpDir/dynamic_linking-dg.patch" + rlLog "Checking whether we test really the installed libraries." + strace -F -e open,openat,stat -o strace.log -- make check + LIBFFI_SO_CALLS=`cat strace.log | grep libffi.so | grep -v ENOENT | grep -v 'usr/lib' | grep -v '\"\/lib' | grep -v 'unfinished' | wc -l` + rlAssertGreater "The just built libraries should not be used, everything should be taken from /usr" 5 $LIBFFI_SO_CALLS + rlRun "cat strace.log | grep libffi.so | grep usr" + rlRun "cat strace.log | grep libffi.so | grep rpmbuild" 1 + rlRun "make check" 0 "RUNNING THE TESTSUITE" + rlRun "popd" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "ls -al $TmpDir" + rlBundleLogs logs $(find . -name 'libffi.sum') $(find . -name 'libffi.log') + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd