File: runtest.in

package info (click to toggle)
xapian-core 1.4.3-2~bpo8+1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 21,224 kB
  • sloc: cpp: 113,806; ansic: 8,723; sh: 4,433; perl: 836; makefile: 567; tcl: 317; python: 40
file content (134 lines) | stat: -rw-r--r-- 4,751 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/sh
# @configure_input@
#
# Wrapper script for running test programs (using libtool, valgrind and
# eatmydata if required).
#
# Copyright (C) 2003,2004,2007,2008,2009,2010,2013 Olly Betts
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
# USA

if test 0 = "$#"; then
   echo "syntax: $0 <test program> [<arguments>]"
   echo "syntax: $0 gdb <test program> [<arguments>]"
   echo "syntax: $0 <tool> <test program> [<arguments>]"
   exit 1
fi

# Set srcdir if it isn't already.
: ${srcdir="@srcdir@"}
export srcdir

case $1 in
  *test|*test@EXEEXT@) ;;
  *gdb|"*gdb *")
    # gdb needs special handling (--args)
    gdb=$1
    shift
    : ${top_builddir=`echo "$0"|sed 's![^/]*$!..!'`}
    export top_builddir
    LIBTOOL=`echo '@LIBTOOL@'|sed 's,\$(SHELL),@SHELL@,g;s,\$(top_builddir),'"$top_builddir"',g'`
    echo "Running test '$@' under $gdb"
    exec $LIBTOOL --mode=execute $gdb --args "$@" ;;
  *)
    # Handles any tool which can just be run as:
    #   TOOL TOOL-ARGS PROGRAM PROGRAM-ARGS
    tool=$1
    shift
    : ${top_builddir=`echo "$0"|sed 's![^/]*$!..!'`}
    export top_builddir
    LIBTOOL=`echo '@LIBTOOL@'|sed 's,\$(SHELL),@SHELL@,g;s,\$(top_builddir),'"$top_builddir"',g'`
    echo "Running test '$@' under $tool"
    exec $LIBTOOL --mode=execute $tool "$@" ;;
esac

if [ -n "$XAPIAN_TESTSUITE_LD_PRELOAD" ] ; then
  if [ -n "$LD_PRELOAD" ] ; then
    LD_PRELOAD=$LD_PRELOAD:$XAPIAN_TESTSUITE_LD_PRELOAD
  else
    LD_PRELOAD=$XAPIAN_TESTSUITE_LD_PRELOAD
  fi
  export LD_PRELOAD
fi

# Allow configure probed value for EATMYDATA to be overridden by e.g.
#   EATMYDATA= ./runtest ./apitest
test -z "${EATMYDATA+set}" && EATMYDATA="@EATMYDATA@"

# Allow configure probed value for VALGRIND to be overridden by e.g.
#   VALGRIND= ./runtest ./apitest
test -z "${VALGRIND+set}" && VALGRIND="@VALGRIND@"
if test -z "$VALGRIND" ; then
    # valgrind isn't involved, so just run the test program directly.

    # If we're using glibc, tell it to call abort if malloc heap corruption is
    # detected.  This incurs a small time penalty, but is probably worth it.
    # See "man malloc" on a recent Linux distro for details.
    MALLOC_CHECK_=2
    export MALLOC_CHECK_

    # If we're using glibc, tell it to fill newly allocated memory (unless
    # allocated by calloc) with this byte value and overwrite memory released
    # by free with this value xor 0xff.
    # http://udrepper.livejournal.com/11429.html
    # Just some value, y'know?
    MALLOC_PERTURB_=42
    export MALLOC_PERTURB_

    if test -n "$EATMYDATA" ; then
	echo "Running test '$@' under eatmydata"
    fi
    exec $EATMYDATA "$@"
    exit 1
fi

# Get libtool to run the test program under valgrind.  We have to use
# libtool --mode=execute because we want to run valgrind on the compiled
# C++ test program, not on the shell running the shell script wrapper libtool
# generates.
: ${top_builddir=`echo "$0"|sed 's![^/]*$!..!'`}
export top_builddir
LIBTOOL=`echo '@LIBTOOL@'|sed 's,\$(SHELL),@SHELL@,g;s,\$(top_builddir),'"$top_builddir"',g'`

# For GCC 3.4 and newer, force the GNU C++ STL to not pool memory, which gives
# more accurate memory leak reports with valgrind.
GLIBCXX_FORCE_NEW=1
export GLIBCXX_FORCE_NEW

# Tell the testsuite to hook into valgrind.
XAPIAN_TESTSUITE_VALGRIND=1
export XAPIAN_TESTSUITE_VALGRIND

vg_opts='--log-file=.valgrind.log.%p --leak-resolution=high'
vg_opts="$vg_opts --suppressions=$srcdir/valgrind.supp"
if test -n "$EATMYDATA" ; then
    echo "Running test '$@' under eatmydata and valgrind"
else
    echo "Running test '$@' under valgrind"
fi
# zlib can produce "uninitialised" output from "initialised" input - the output
# does decode to the input, so this is presumably just some unused bits in the
# output, so we use an LD_PRELOAD hack to get valgrind to check the input is
# initialised and then tell it that the output is initialised.
if [ -f zlib-vg.so ] ; then
  if [ -n "$LD_PRELOAD" ] ; then
    LD_PRELOAD=$LD_PRELOAD:./zlib-vg.so
  else
    LD_PRELOAD=./zlib-vg.so
  fi
  export LD_PRELOAD
fi
exec $EATMYDATA $LIBTOOL --mode=execute $VALGRIND $vg_opts "$@"