File: common_funcs.sh

package info (click to toggle)
rdfind 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 648 kB
  • sloc: cpp: 1,670; sh: 1,622; makefile: 32
file content (63 lines) | stat: -rwxr-xr-x 1,006 bytes parent folder | download
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
#!/bin/sh
# common functionality for the unit tests



#bail out on the first error
set -e

/bin/echo -n "checking for rdfind ..."
rdfind=$(readlink -f $(dirname $0)/../rdfind)
if [ ! -x "$rdfind" ]; then
    echo "could not find $rdfind"
fi
echo " OK."

/bin/echo -n "checking for valgrind ..."
if [ -z $VALGRIND ] ; then
  echo "not used."
else
  echo "active! here is the command: $VALGRIND"
fi	

rdfind="$VALGRIND $rdfind"

#where is the test scripts dir?
testscriptsdir=$(dirname $(readlink -f $0))


dbgecho() {
    echo "$0 debug: " "$@"
}


echo -n "checking for mktemp ..."
which mktemp >/dev/null
echo " OK."

#create a temporary directory, which is automatically deleted
#on exit
datadir=$(mktemp -d -t rdfindtestcases.d.XXXXXXXXXXXX)
dbgecho "temp dir is $datadir"

cleanup () {
cd /
rm -rf "$datadir"
}

if [ -z $KEEPTEMPDIR ] ; then
   trap cleanup INT QUIT EXIT
fi

[ -d $datadir ]
cd $datadir

reset_teststate() {
    cd /
    rm -rf "$datadir"
    mkdir -p $datadir
    cd "$datadir"
}