~ubuntu-branches/debian/sid/nbd/sid

« back to all changes in this revision

Viewing changes to tests/run/testlib.sh

  • Committer: Package Import Robot
  • Author(s): Wouter Verhelst
  • Date: 2015-02-25 21:06:01 UTC
  • Revision ID: package-import@ubuntu.com-20150225210601-ktbl44z8e2c5wc7i
Tags: 1:3.8-4
Rebuild without loads of junk from other branches. My previous build
happened in an unclean git checkout; there was a lot of stuff in the
source package that was not changing the behaviour of the code, yet
was still producing noise in the package. Removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
set -e
2
 
 
3
 
if [ -z "$TMPDIR" ]
4
 
then
5
 
        TMPDIR=/tmp
6
 
fi
7
 
tmpdir=`mktemp -d $TMPDIR/tmp.XXXXXX`
8
 
conffile=${tmpdir}/nbd.conf
9
 
pidfile=${tmpdir}/nbd.pid
10
 
tmpnam=${tmpdir}/nbd.dd
11
 
mydir=$(dirname "`readlink -f $0`")
12
 
cleanup="$2"
13
 
PID=""
14
 
 
15
 
set -e
16
 
 
17
 
trap cleanup EXIT
18
 
 
19
 
cleanup() {
20
 
        if [ -f ${pidfile} ]
21
 
        then
22
 
                kill `cat ${pidfile}` || true
23
 
        else
24
 
                if [ ! -z "$PID" ]
25
 
                then
26
 
                        kill $PID || true
27
 
                fi
28
 
        fi
29
 
        if [ -z "$cleanup" ]
30
 
        then
31
 
                rm -rf $tmpdir
32
 
        fi
33
 
}
34
 
 
35
 
devfile() {
36
 
        size=${1:-4096}
37
 
        dd if=/dev/zero of=$tmpnam bs=1024 count=4096 >/dev/null 2>&1
38
 
}
39
 
 
40
 
conffile() {
41
 
        echo ${confdata} >${conffile}
42
 
}