#1 Add CI tests using the standard test interface
Merged a year ago by green. Opened a year ago by sturivny.
git://fedorapeople.org/~sturivny/libffi add-tests  into  master

Add CI tests using the standard test interface
Sergey Turivniy • a year ago  
tests/tests.yml
file added
+17

@@ -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

tests/testsuite/Makefile
file added
+63

@@ -0,0 +1,63 @@

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Makefile of /tools/libffi/Sanity/testsuite

+ #   Description: Runs upstream testsuite

+ #   Author: Michal Nowak <mnowak@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   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 <mnowak@redhat.com>" > $(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)

tests/testsuite/PURPOSE
file added
+3

@@ -0,0 +1,3 @@

+ PURPOSE of /tools/libffi/Sanity/testsuite

+ Description: Runs upstream testsuite

+ Author: Michal Nowak <mnowak@redhat.com>

tests/testsuite/dynamic_linking-dg.patch
file added
+29

@@ -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}]

tests/testsuite/dynamic_linking.patch
file added
+29

@@ -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}]

tests/testsuite/runtest.sh
file added
+86

@@ -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 <mnowak@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   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

no initial comment

Justification

Adds tests according to the CI wiki specifically the standard test interface in the spec.

The playbook includes Tier1 level test cases that have been tested in the following contexts and is passing reliably: Classic and Container. Test logs are stored in the artifacts directory.

The following steps are used to execute the tests using the standard test interface:


Test environment

Make sure you have installed packages from the spec

$ rpm -q ansible python2-dnf libselinux-python standard-test-roles
ansible-2.3.2.0-1.fc26.noarch
python2-dnf-2.6.3-11.fc26.noarch
libselinux-python-2.6-7.fc26.x86_64
standard-test-roles-2.4-1.fc26.noarch



Clone tests to your PC

$ git clone git://fedorapeople.org/~sturivny/libffi
$ cd libffi/



Run tests for Classic

All test should be run under the root

# tests/
# sudo ansible-playbook --tags=classic tests.yml

Snip of the example test run:

TASK [standard-test-beakerlib : Copy tests to target] ***************************************************************************************************************************************************************
changed: [localhost]

TASK [standard-test-beakerlib : Fix up beakerlib] *******************************************************************************************************************************************************************
changed: [localhost]

TASK [standard-test-beakerlib : Make artifacts directory] ***********************************************************************************************************************************************************
changed: [localhost]

TASK [standard-test-beakerlib : Execute beakerlib tests] ************************************************************************************************************************************************************
changed: [localhost] => (item=testsuite)

TASK [standard-test-beakerlib : Make the master test summary log artifact] ******************************************************************************************************************************************
changed: [localhost] => (item=testsuite)

TASK [standard-test-beakerlib : Pull out the logs] ******************************************************************************************************************************************************************
changed: [localhost]

TASK [standard-test-beakerlib : Check the results] ******************************************************************************************************************************************************************
changed: [localhost]

PLAY RECAP **********************************************************************************************************************************************************************************************************
localhost                  : ok=18   changed=11   unreachable=0    failed=0   



Run tests for Container

All test should be run under the root

# export ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)
# export TEST_SUBJECTS=docker:docker.io/library/fedora:27
# ansible-playbook --tags=container tests.yml

Snip of the example test run:

changed: [1f73d8631e00ac5e5667632dcbad7b7d042ee59f7f215e5b0955c6287d71a614] => (item={u'glib-utf8-pointer.test': {u'run': u'./runtest.sh glib/utf8-pointer.test', u'dir': u'upstream-testset'}})
changed: [1f73d8631e00ac5e5667632dcbad7b7d042ee59f7f215e5b0955c6287d71a614] => (item={u'glib-utf8-validate.test': {u'run': u'./runtest.sh glib/utf8-validate.test', u'dir': u'upstream-testset'}})
changed: [1f73d8631e00ac5e5667632dcbad7b7d042ee59f7f215e5b0955c6287d71a614] => (item={u'glib-utils.test': {u'run': u'./runtest.sh glib/utils.test', u'dir': u'upstream-testset'}})
changed: [1f73d8631e00ac5e5667632dcbad7b7d042ee59f7f215e5b0955c6287d71a614] => (item={u'glib-value.test': {u'run': u'./runtest.sh glib/value.test', u'dir': u'upstream-testset'}})
changed: [1f73d8631e00ac5e5667632dcbad7b7d042ee59f7f215e5b0955c6287d71a614] => (item={u'glib-vfs.test': {u'run': u'./runtest.sh glib/vfs.test', u'dir': u'upstream-testset'}})
changed: [1f73d8631e00ac5e5667632dcbad7b7d042ee59f7f215e5b0955c6287d71a614] => (item={u'glib-volumemonitor.test': {u'run': u'./runtest.sh glib/volumemonitor.test', u'dir': u'upstream-testset'}})

TASK [standard-test-basic : Pull out the logs] **********************************************************************************************************************************************************************
changed: [1f73d8631e00ac5e5667632dcbad7b7d042ee59f7f215e5b0955c6287d71a614]

TASK [standard-test-basic : Check the results] **********************************************************************************************************************************************************************
changed: [1f73d8631e00ac5e5667632dcbad7b7d042ee59f7f215e5b0955c6287d71a614]

PLAY [localhost] ****************************************************************************************************************************************************************************************************

TASK [Gathering Facts] **********************************************************************************************************************************************************************************************
ok: [1f73d8631e00ac5e5667632dcbad7b7d042ee59f7f215e5b0955c6287d71a614]

PLAY RECAP **********************************************************************************************************************************************************************************************************
1f73d8631e00ac5e5667632dcbad7b7d042ee59f7f215e5b0955c6287d71a614 : ok=13   changed=8    unreachable=0    failed=0   



Run tests for Atomic Host

All test should be run under the root

# export ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)
# curl -Lo atomic.qcow2 https://ci.centos.org/artifacts/fedora-atomic/f27/images/latest-atomic.qcow2
# export TEST_SUBJECTS=$PWD/atomic.qcow2
# ansible-playbook --tags=atomic tests.yml

Snip of the example test run:

changed: [/home/fedora/images/atomic.qcow2] => (item={u'glib-utf8-pointer.test': {u'run': u'./runtest.sh glib/utf8-pointer.test', u'dir': u'upstream-testset'}})
changed: [/home/fedora/images/atomic.qcow2] => (item={u'glib-utf8-validate.test': {u'run': u'./runtest.sh glib/utf8-validate.test', u'dir': u'upstream-testset'}})
changed: [/home/fedora/images/atomic.qcow2] => (item={u'glib-utils.test': {u'run': u'./runtest.sh glib/utils.test', u'dir': u'upstream-testset'}})
changed: [/home/fedora/images/atomic.qcow2] => (item={u'glib-value.test': {u'run': u'./runtest.sh glib/value.test', u'dir': u'upstream-testset'}})
changed: [/home/fedora/images/atomic.qcow2] => (item={u'glib-vfs.test': {u'run': u'./runtest.sh glib/vfs.test', u'dir': u'upstream-testset'}})
changed: [/home/fedora/images/atomic.qcow2] => (item={u'glib-volumemonitor.test': {u'run': u'./runtest.sh glib/volumemonitor.test', u'dir': u'upstream-testset'}})

TASK [standard-test-basic : Pull out the logs] **********************************************************************************************************************************************************************
changed: [/home/fedora/images/atomic.qcow2]

TASK [standard-test-basic : Check the results] **********************************************************************************************************************************************************************
changed: [/home/fedora/images/atomic.qcow2]

PLAY RECAP **********************************************************************************************************************************************************************************************************
/home/fedora/images/atomic.qcow2 : ok=13   changed=7    unreachable=0    failed=0  



Notes

Tests will be enabled in CI, yet gating is currently disabled, so nothing will change. Tests will run on each dist-git commit, they are not triggered by koji builds and if you are using FMN, it should notify you of failures normally.

The RH QE maintainer contact in case you have questions: Michal Nowak mnowak@redhat.com
The idea is that these tests become yours just as you're maintaining the package, there will, of course, be people around if you have questions or troubles.

Commit c2ca464 fixes this pull-request

Pull-Request has been merged by green

a year ago

Pull-Request has been merged by green

a year ago