|
Alexandra Hájková |
b410fd |
#!/bin/bash
|
|
Alexandra Hájková |
b410fd |
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
|
Alexandra Hájková |
b410fd |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
Alexandra Hájková |
b410fd |
#
|
|
Alexandra Hájková |
b410fd |
# runtest.sh of /tools/valgrind/Sanity/quick-valgrind-sanity
|
|
Alexandra Hájková |
b410fd |
# Description: Very fast check that valgrind is working
|
|
Alexandra Hájková |
b410fd |
# Author: Miroslav Franc <mfranc@redhat.com>
|
|
Alexandra Hájková |
b410fd |
#
|
|
Alexandra Hájková |
b410fd |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
Alexandra Hájková |
b410fd |
#
|
|
Alexandra Hájková |
b410fd |
# Copyright (c) 2013 Red Hat, Inc. All rights reserved.
|
|
Alexandra Hájková |
b410fd |
#
|
|
Alexandra Hájková |
b410fd |
# This copyrighted material is made available to anyone wishing
|
|
Alexandra Hájková |
b410fd |
# to use, modify, copy, or redistribute it subject to the terms
|
|
Alexandra Hájková |
b410fd |
# and conditions of the GNU General Public License version 2.
|
|
Alexandra Hájková |
b410fd |
#
|
|
Alexandra Hájková |
b410fd |
# This program is distributed in the hope that it will be
|
|
Alexandra Hájková |
b410fd |
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
Alexandra Hájková |
b410fd |
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
Alexandra Hájková |
b410fd |
# PURPOSE. See the GNU General Public License for more details.
|
|
Alexandra Hájková |
b410fd |
#
|
|
Alexandra Hájková |
b410fd |
# You should have received a copy of the GNU General Public
|
|
Alexandra Hájková |
b410fd |
# License along with this program; if not, write to the Free
|
|
Alexandra Hájková |
b410fd |
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
Alexandra Hájková |
b410fd |
# Boston, MA 02110-1301, USA.
|
|
Alexandra Hájková |
b410fd |
#
|
|
Alexandra Hájková |
b410fd |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
Alexandra Hájková |
b410fd |
|
|
Alexandra Hájková |
b410fd |
# Include Beaker environment
|
|
Alexandra Hájková |
b410fd |
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
|
Alexandra Hájková |
b410fd |
|
|
Alexandra Hájková |
b410fd |
VALGRIND="${VALGRIND:-$(which valgrind)}"
|
|
Alexandra Hájková |
b410fd |
PACKAGES="${PACKAGES:-$(rpm --qf '%{name}\n' -qf $(which $VALGRIND) | head -1)}"
|
|
Alexandra Hájková |
b410fd |
|
|
Alexandra Hájková |
b410fd |
rlJournalStart
|
|
Alexandra Hájková |
b410fd |
rlPhaseStartSetup
|
|
Alexandra Hájková |
b410fd |
rlLogInfo "VALGRIND=$VALGRIND"
|
|
Alexandra Hájková |
b410fd |
rlLogInfo "PACKAGES=$PACKAGES"
|
|
Alexandra Hájková |
b410fd |
rlLogInfo "REQUIRES=$REQUIRES"
|
|
Alexandra Hájková |
b410fd |
rlLogInfo "$(type valgrind)"
|
|
Alexandra Hájková |
b410fd |
rlLogInfo "$(type gcc)"
|
|
Alexandra Hájková |
b410fd |
|
|
Alexandra Hájková |
b410fd |
rlLogInfo "SKIP_COLLECTION_METAPACKAGE_CHECK=$SKIP_COLLECTION_METAPACKAGE_CHECK"
|
|
Alexandra Hájková |
b410fd |
|
|
Alexandra Hájková |
b410fd |
# We optionally need to skip checking for the presence of the metapackage
|
|
Alexandra Hájková |
b410fd |
# because that would pull in all the dependent toolset subrpms. We do not
|
|
Alexandra Hájková |
b410fd |
# always want that, especially in CI.
|
|
Alexandra Hájková |
b410fd |
_COLLECTIONS="$COLLECTIONS"
|
|
Alexandra Hájková |
b410fd |
if ! test -z $SKIP_COLLECTION_METAPACKAGE_CHECK; then
|
|
Alexandra Hájková |
b410fd |
for c in $SKIP_COLLECTION_METAPACKAGE_CHECK; do
|
|
Alexandra Hájková |
b410fd |
rlLogInfo "ignoring metapackage check for collection $c"
|
|
Alexandra Hájková |
b410fd |
export COLLECTIONS=$(shopt -s extglob && echo ${COLLECTIONS//$c/})
|
|
Alexandra Hájková |
b410fd |
done
|
|
Alexandra Hájková |
b410fd |
fi
|
|
Alexandra Hájková |
b410fd |
|
|
Alexandra Hájková |
b410fd |
rlLogInfo "(without skipped) COLLECTIONS=$COLLECTIONS"
|
|
Alexandra Hájková |
b410fd |
|
|
Alexandra Hájková |
b410fd |
rlAssertRpm --all
|
|
Alexandra Hájková |
b410fd |
|
|
Alexandra Hájková |
b410fd |
export COLLECTIONS="$_COLLECTIONS"
|
|
Alexandra Hájková |
b410fd |
|
|
Alexandra Hájková |
b410fd |
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
|
|
Alexandra Hájková |
b410fd |
rlRun "cp unitialized.c rv.c alloc.c $TmpDir"
|
|
Alexandra Hájková |
b410fd |
rlRun "pushd $TmpDir"
|
|
Alexandra Hájková |
b410fd |
rlRun "gcc -g unitialized.c -o unitialized"
|
|
Alexandra Hájková |
b410fd |
rlPhaseEnd
|
|
Alexandra Hájková |
b410fd |
|
|
Alexandra Hájková |
b410fd |
rlPhaseStartTest "good"
|
|
Alexandra Hájková |
b410fd |
rlRun "valgrind --log-file=./log0 ./unitialized 0" 42
|
|
Alexandra Hájková |
b410fd |
rlAssertNotGrep 'contains uninitialised byte' ./log0
|
|
Alexandra Hájková |
b410fd |
rlAssertGrep 'ERROR SUMMARY: 0' ./log0
|
|
Alexandra Hájková |
b410fd |
rlLog "$(
|
|
Alexandra Hájková |
b410fd |
rlPhaseEnd
|
|
Alexandra Hájková |
b410fd |
|
|
Alexandra Hájková |
b410fd |
rlPhaseStartTest "bad"
|
|
Alexandra Hájková |
b410fd |
rlRun "valgrind --log-file=./log2 ./unitialized 2" 0-41,43-255
|
|
Alexandra Hájková |
b410fd |
rlAssertGrep 'contains uninitialised byte' ./log2
|
|
Alexandra Hájková |
b410fd |
rlAssertGrep 'ERROR SUMMARY: 1' ./log2
|
|
Alexandra Hájková |
b410fd |
rlLog "$(
|
|
Alexandra Hájková |
b410fd |
rlPhaseEnd
|
|
Alexandra Hájková |
b410fd |
|
|
Alexandra Hájková |
b410fd |
rlPhaseStartTest "client request"
|
|
Alexandra Hájková |
b410fd |
rlRun "gcc -g rv.c -o rv"
|
|
Alexandra Hájková |
b410fd |
rlRun "valgrind ./rv > with-valgrind"
|
|
Alexandra Hájková |
b410fd |
rlAssertGrep "I'm running on valgrind" with-valgrind
|
|
Alexandra Hájková |
b410fd |
rlLog "$(
|
|
Alexandra Hájková |
b410fd |
rlRun "./rv > without-valgrind"
|
|
Alexandra Hájková |
b410fd |
rlAssertGrep "I'm not running on valgrind" without-valgrind
|
|
Alexandra Hájková |
b410fd |
rlLog "$(
|
|
Alexandra Hájková |
b410fd |
rlPhaseEnd
|
|
Alexandra Hájková |
b410fd |
|
|
Alexandra Hájková |
b410fd |
rlPhaseStartTest "client request with leak checking"
|
|
Alexandra Hájková |
b410fd |
rlRun "gcc -g alloc.c -o alloc"
|
|
Alexandra Hájková |
b410fd |
rlRun "valgrind --log-file=./log ./alloc 42"
|
|
Alexandra Hájková |
b410fd |
rlAssertGrep 'still reachable: 42 bytes in 1 blocks' log
|
|
Alexandra Hájková |
b410fd |
rlLog "$(
|
|
Alexandra Hájková |
b410fd |
rlPhaseEnd
|
|
Alexandra Hájková |
b410fd |
|
|
Alexandra Hájková |
b410fd |
rlPhaseStartCleanup
|
|
Alexandra Hájková |
b410fd |
rlRun "popd" # $TmpDir
|
|
Alexandra Hájková |
b410fd |
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
|
Alexandra Hájková |
b410fd |
rlPhaseEnd
|
|
Alexandra Hájková |
b410fd |
rlJournalPrintText
|
|
Alexandra Hájková |
b410fd |
rlJournalEnd
|