582a0c8
#!/bin/bash
582a0c8
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
582a0c8
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
582a0c8
#
582a0c8
#   runtest.sh of /tools/dwz/dwz-quick-test
582a0c8
#   Description: Quick sanity test
582a0c8
#   Author: Miroslav Franc <mfranc@redhat.com>
582a0c8
#
582a0c8
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
582a0c8
#
582a0c8
#   Copyright (c) 2013 Red Hat, Inc. All rights reserved.
582a0c8
#
582a0c8
#   This copyrighted material is made available to anyone wishing
582a0c8
#   to use, modify, copy, or redistribute it subject to the terms
582a0c8
#   and conditions of the GNU General Public License version 2.
582a0c8
#
582a0c8
#   This program is distributed in the hope that it will be
582a0c8
#   useful, but WITHOUT ANY WARRANTY; without even the implied
582a0c8
#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
582a0c8
#   PURPOSE. See the GNU General Public License for more details.
582a0c8
#
582a0c8
#   You should have received a copy of the GNU General Public
582a0c8
#   License along with this program; if not, write to the Free
582a0c8
#   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
582a0c8
#   Boston, MA 02110-1301, USA.
582a0c8
#
582a0c8
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
582a0c8
582a0c8
# Include Beaker environment
582a0c8
. /usr/share/beakerlib/beakerlib.sh || exit 1
582a0c8
f41c299
export PACKAGE="${PACKAGE:-$(rpm -qf --qf='%{name}\n' `which dwz`)}"
f41c299
REQUIRES="$PACKAGE gcc glibc gdb"
582a0c8
f41c299
rlJournalStart
f41c299
  rlPhaseStartSetup
f41c299
    rlShowRunningKernel
f41c299
    rlAssertRpm --all
f41c299
    rlRun "TmpDir=\$(mktemp -d)"
f41c299
    rlRun "cp -r testcase.c cmds $TmpDir"
f41c299
    rlRun "pushd $TmpDir"
f41c299
    rlRun "gcc -g -O0 -o testcase testcase.c"
f41c299
    rlRun "cp testcase testcase.dwz"
f41c299
  rlPhaseEnd
582a0c8
f41c299
  rlPhaseStartTest
f41c299
    rlRun "dwz testcase.dwz"
f41c299
    rlRun "BYTES_BASE_FILE=`wc -c 
f41c299
    rlRun "BYTES_DWZED_FILE=`wc -c 
f41c299
    [ $BYTES_DWZED_FILE -gt $BYTES_BASE_FILE ] && rlFail "DWZed file should not be greater than the original file."
f41c299
    rlRun "gdb --command=cmds --quiet --batch testcase.dwz |& tee $TmpDir/testcase.log; test \${PIPESTATUS[0]} -eq 0"
f41c299
    rlRun "grep 'hello, world' $TmpDir/testcase.log"
f41c299
    rlRun "grep '\$1 = -1' $TmpDir/testcase.log"
f41c299
    rlRun "grep '\$2 = 0x2a' $TmpDir/testcase.log"
f41c299
  rlPhaseEnd
582a0c8
f41c299
  rlPhaseStartCleanup
f41c299
    rlRun "popd"
f41c299
    rlRun "rm -r $TmpDir"
f41c299
  rlPhaseEnd
582a0c8
rlJournalPrintText
582a0c8
rlJournalEnd