Blame tests/does-hunspell-works-under-valgrind/runtest.sh

Alexandra Hájková 858fa4
#!/bin/bash
Alexandra Hájková 858fa4
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
Alexandra Hájková 858fa4
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Alexandra Hájková 858fa4
#
Alexandra Hájková 858fa4
#   Description: Testing sanity of valgrind by comparing outputs of hunspell with/without valgrind.
Alexandra Hájková 858fa4
#   Author: Miroslav Franc <mfranc@redhat.com>
Alexandra Hájková 858fa4
#
Alexandra Hájková 858fa4
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Alexandra Hájková 858fa4
#
Alexandra Hájková 858fa4
#   Copyright (c) 2011 Red Hat, Inc. All rights reserved.
Alexandra Hájková 858fa4
#
Alexandra Hájková 858fa4
#   This copyrighted material is made available to anyone wishing
Alexandra Hájková 858fa4
#   to use, modify, copy, or redistribute it subject to the terms
Alexandra Hájková 858fa4
#   and conditions of the GNU General Public License version 2 or later.
Alexandra Hájková 858fa4
#
Alexandra Hájková 858fa4
#   This program is distributed in the hope that it will be
Alexandra Hájková 858fa4
#   useful, but WITHOUT ANY WARRANTY; without even the implied
Alexandra Hájková 858fa4
#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
Alexandra Hájková 858fa4
#   PURPOSE. See the GNU General Public License for more details.
Alexandra Hájková 858fa4
#
Alexandra Hájková 858fa4
#   You should have received a copy of the GNU General Public
Alexandra Hájková 858fa4
#   License along with this program; if not, write to the Free
Alexandra Hájková 858fa4
#   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Alexandra Hájková 858fa4
#   Boston, MA 02110-1301, USA.
Alexandra Hájková 858fa4
#
Alexandra Hájková 858fa4
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Alexandra Hájková 858fa4
Alexandra Hájková 858fa4
# Include rhts environment
Alexandra Hájková 858fa4
. /usr/share/beakerlib/beakerlib.sh || exit 1
Alexandra Hájková 858fa4
Alexandra Hájková 9a0a8d
SPELL_CHECKER="${SPELL_CHECKER:-hunspell}"
Alexandra Hájková 858fa4
Alexandra Hájková 858fa4
VALGRIND="${VALGRIND:-$(which valgrind)}"
Alexandra Hájková 858fa4
PACKAGES="${PACKAGES:-$(rpm --qf '%{name}\n' -qf $(which $VALGRIND) | head -1)}"
Alexandra Hájková 858fa4
REQUIRES="${REQUIRES:-$SPELL_CHECKER}"
Alexandra Hájková 858fa4
Alexandra Hájková 858fa4
rlJournalStart
Alexandra Hájková 858fa4
    rlPhaseStartSetup
Alexandra Hájková 858fa4
        rlLogInfo "VALGRIND=$VALGRIND"
Alexandra Hájková 858fa4
        rlLogInfo "PACKAGES=$PACKAGES"
Alexandra Hájková 858fa4
        rlLogInfo "REQUIRES=$REQUIRES"
Alexandra Hájková 858fa4
        rlLogInfo "SPELL_CHECKER=$SPELL_CHECKER"
Alexandra Hájková 858fa4
        rlLogInfo "$(type valgrind)"
Alexandra Hájková 858fa4
Alexandra Hájková 858fa4
        rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
Alexandra Hájková 858fa4
        rlRun "pushd $TmpDir"
Alexandra Hájková 858fa4
    rlPhaseEnd
Alexandra Hájková 858fa4
Alexandra Hájková 858fa4
    rlPhaseStartTest
Alexandra Hájková 858fa4
Alexandra Hájková 9a0a8d
    rlRun "echo \"NEWSX\"|hunspell -a;echo -e '#include <time.h>\nclock_t clock(void) { return 0; }'|gcc -o libclock.so -Wall -g -shared -fPIC -x c -;echo "NEWSX"|LD_PRELOAD=./libclock.so hunspell -a > out"
Alexandra Hájková 858fa4
Alexandra Hájková 9a0a8d
    rlRun "echo \"NEWSX\"|hunspell -a;echo -e '#include <time.h>\nclock_t clock(void) { return 0; }'|gcc -o libclock.so -Wall -g -shared -fPIC -x c -;echo \"NEWSX\"|LD_PRELOAD=./libclock.so valgrind -q hunspell -a > valgrind_out"
Alexandra Hájková 858fa4
Alexandra Hájková 858fa4
    # Remove dictionary to avoid possibility of different results with
Alexandra Hájková 858fa4
    # already present dictionary. After this all commands start with
Alexandra Hájková 858fa4
    # the clean sheet.
Alexandra Hájková 858fa4
    rlRun "rm -f $HOME/.hunspell_en_US"
Alexandra Hájková 858fa4
Alexandra Hájková 9a0a8d
    rlAssertNotDiffer "out" "valgrind_out"
Alexandra Hájková 9a0a8d
    [ "$?" -ne 0 ] && rlLogWarning "$(diff out valgrind_out)"
Alexandra Hájková 858fa4
    rlPhaseEnd
Alexandra Hájková 858fa4
Alexandra Hájková 858fa4
    rlPhaseStartCleanup
Alexandra Hájková 858fa4
        rlRun "popd" # $TmpDir
Alexandra Hájková 858fa4
        rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
Alexandra Hájková 858fa4
    rlPhaseEnd
Alexandra Hájková 858fa4
rlJournalPrintText
Alexandra Hájková 858fa4
rlJournalEnd