Add CI tests using the standard test interface

This commit is contained in:
Bruno Goncalves 2017-10-10 11:03:55 +02:00
parent 5843a188a0
commit 582a0c86d8
7 changed files with 178 additions and 0 deletions

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /tools/dwz/dwz-quick-test
# Description: Quick sanity test
# Author: Miroslav Franc <mfranc@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2013 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# 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, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/tools/dwz/dwz-quick-test
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE something.c cmd.txt
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Miroslav Franc <mfranc@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Quick sanity test" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 2m" >> $(METADATA)
@echo "RunFor: dwz" >> $(METADATA)
@echo "Requires: dwz gcc gdb glibc-debuginfo" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /tools/dwz/dwz-quick-test
Description: Quick sanity test
Author: Miroslav Franc <mfranc@redhat.com>

View File

@ -0,0 +1,7 @@
b f
r
s
p x
p/x var
c
q

60
tests/dwz-quick-test/runtest.sh Executable file
View File

@ -0,0 +1,60 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /tools/dwz/dwz-quick-test
# Description: Quick sanity test
# Author: Miroslav Franc <mfranc@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2013 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# 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, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
rlJournalStart
rlPhaseStartSetup
rlAssertRpm gcc
rlAssertRpm gdb
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "cp something.c cmd.txt $TmpDir"
rlRun "pushd $TmpDir"
rlRun "gcc -g -O2 something.c -o something.out"
rlRun "cp something.out something.dwz"
rlPhaseEnd
rlPhaseStartTest "no crash + saved space"
rlRun "dwz something.dwz"
rlRun "[[ $(wc -c <something.out) -gt $(wc -c <something.dwz) ]]"
rlPhaseEnd
rlPhaseStartTest "can we debug it?"
rlRun "gdb -x cmd.txt -batch -q ./something.dwz > log 2>&1"
rlRun "[[ $(grep -c 'hello, world' log) -eq 2 ]]"
rlAssertGrep '$1 = -1' log
rlAssertGrep '$2 = 0x2a' log
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,21 @@
#include <stdio.h>
void f (int x);
int
main (int argc, char *argv[])
{
int a = -1;
f(a);
return 0;
}
void
f (int x)
{
static int var __attribute__ ((used)) = 42;
if(x)
puts("hello, world");
}

4
tests/inventory Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
export TEST_DOCKER_EXTRA_ARGS="--cap-add=SYS_PTRACE"
exec merge-standard-inventory "$@"

20
tests/tests.yml Normal file
View File

@ -0,0 +1,20 @@
- hosts: localhost
tags:
- classic
- container # needs SYS_PTRACE
pre_tasks:
- name: Install deguginfo-install
shell: dnf -y install "dnf-command(debuginfo-install)"
- name: Install debuginfo for packages
shell: dnf -y debuginfo-install --best {{item}}
with_items:
- glibc
roles:
- role: standard-test-beakerlib
tests:
- dwz-quick-test
required_packages:
- dwz
- gcc
- gdb
- glibc-debuginfo