From 796bab9b45a7a81700f1186b3f3b22178076a2e5 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Wed, 14 Jun 2023 11:35:55 +0200 Subject: [PATCH] Sanity/valgrind-scripts-smoke: Sanity test to check that the script are usable --- Sanity/valgrind-scripts-smoke/main.fmf | 10 +++++ Sanity/valgrind-scripts-smoke/runtest.sh | 48 ++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 Sanity/valgrind-scripts-smoke/main.fmf create mode 100755 Sanity/valgrind-scripts-smoke/runtest.sh diff --git a/Sanity/valgrind-scripts-smoke/main.fmf b/Sanity/valgrind-scripts-smoke/main.fmf new file mode 100644 index 0000000..9b05b94 --- /dev/null +++ b/Sanity/valgrind-scripts-smoke/main.fmf @@ -0,0 +1,10 @@ +summary: Smoke test for valgrind scripts +contact: Jesus Checa Hidalgo +component: + - valgrind +test: ./runtest.sh +framework: beakerlib +require: + - valgrind +tier: 1 +duration: 5m \ No newline at end of file diff --git a/Sanity/valgrind-scripts-smoke/runtest.sh b/Sanity/valgrind-scripts-smoke/runtest.sh new file mode 100755 index 0000000..6b10516 --- /dev/null +++ b/Sanity/valgrind-scripts-smoke/runtest.sh @@ -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