File: common_funcs.sh

package info (click to toggle)
rdfind 1.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 628 kB
  • sloc: cpp: 1,715; sh: 1,696; makefile: 33
file content (90 lines) | stat: -rwxr-xr-x 1,645 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
#!/bin/sh
# common functionality for the unit tests



#bail out on the first error
set -e

me=$(basename $0)


/bin/echo -n "$me: checking for rdfind ..."
rdfind=$PWD/rdfind
if [ ! -x "$rdfind" ]; then
   echo "could not find $rdfind"
   exit 1
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"
}


verify() {
   if ! $@ ; then
      echo "failed asserting $@"
      exit 1
   fi
}

# where to mount disorderfs for the determinism tests
DISORDERED_MNT=$datadir/disordered_mnt
DISORDERED_ROOT=$datadir/disordered_root

# do we have a working disorder fs?
hasdisorderfs=false
if which disorderfs fusermount >/dev/null 2>&1; then
   mkdir -p $DISORDERED_MNT $DISORDERED_ROOT
   if disorderfs $DISORDERED_ROOT $DISORDERED_MNT >/dev/null 2>&1 ; then
      # "Sälj inte skinnet förrän björnen är skjuten - Don't count your chickens until they're hatched"
      fusermount -z -u $DISORDERED_MNT
      hasdisorderfs=true
   fi
fi