Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Jesus Checa Hidalgo
796bab9b45 Sanity/valgrind-scripts-smoke: Sanity test to check that the script are usable 2023-06-14 11:35:55 +02:00
2 changed files with 58 additions and 0 deletions

View file

@ -0,0 +1,10 @@
summary: Smoke test for valgrind scripts
contact: Jesus Checa Hidalgo <jchecahi@redhat.com>
component:
- valgrind
test: ./runtest.sh
framework: beakerlib
require:
- valgrind
tier: 1
duration: 5m

View file

@ -0,0 +1,48 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
. /usr/share/beakerlib/beakerlib.sh || exit 1
VERSION=$(rpm -q --queryformat="%{version}" valgrind)
rlJournalStart
rlPhaseStartSetup
rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
rlRun "pushd $tmp"
rlRun "set -o pipefail"
rlPhaseEnd
rlPhaseStartTest
for prog in $(rpm -ql valgrind | grep ^/usr/bin); do
if file $prog | grep -q ELF; then
rlLogDebug "Skipping ELF executable"
continue
fi
LOGFILE="$(basename $prog).log"
if $prog --version &> $LOGFILE; then
rlPass "[ok] $prog"
continue
fi
# Perl scripts might return other than 0 but still be correct.
# This is because some of them print the version/help message with
# die() instead doing a print() and exit. die() always set the
# return code to 255. Hence we rely on grepping the version string,
# and make sure that the log contains only one line.
if grep -q "$(basename $prog)-${VERSION}" $LOGFILE \
&& [[ $(wc -l < $LOGFILE) -eq "1" ]];
then
rlPass "[ok] $prog"
continue
fi
# Anything else is a failure
rlFail "[fail] $prog"
rlLog "$(cat $LOGFILE)"
done
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $tmp" 0 "Remove tmp directory"
rlPhaseEnd
rlJournalEnd