2 # Yes, that's POSIX sh, not bash!
5 conffile=${tmpdir}/nbd.conf
6 pidfile=${tmpdir}/nbd.pid
7 tmpnam=${tmpdir}/nbd.dd
8 mydir=$(dirname "`readlink -f $0`")
12 # Create a one-meg device
13 dd if=/dev/zero of=$tmpnam bs=1024 count=4096 >/dev/null 2>&1
19 # Test with export specified on command line
20 ./nbd-server -C /dev/null -p ${pidfile} 11111 $tmpnam &
21 # -p only works if nbd-server wasn't compiled with -DNOFORK or
22 # -DNODAEMON, which I sometimes do for testing and debugging.
25 ./nbd-tester-client 127.0.0.1 11111
29 # Test oversized requests
30 ./nbd-server -C /dev/null -p ${pidfile} 11111 $tmpnam &
31 # -p only works if nbd-server wasn't compiled with -DNOFORK or
32 # -DNODAEMON, which I sometimes do for testing and debugging.
35 ./nbd-tester-client 127.0.0.1 11111 -o
39 # Test with export specified in config file
40 cat > ${conffile} <<EOF
47 ./nbd-server -C ${conffile} -p ${pidfile} &
50 ./nbd-tester-client 127.0.0.1 11112
54 # Test with multiple exports specified in config file, and
55 # testing more options too
56 cat >${conffile} <<EOF
63 listenaddr = 127.0.0.1
68 listenaddr = 127.0.0.1
70 ./nbd-server -C ${conffile} -p ${pidfile} &
73 ./nbd-tester-client localhost 11113
89 ./nbd-tester-client localhost 11114
93 # Test new-style exports
94 cat >${conffile} <<EOF
99 ./nbd-server -C ${conffile} -p ${pidfile} &
102 ./nbd-tester-client localhost -N export1
107 cat >${conffile} <<EOF
112 ./nbd-server -C ${conffile} -p ${pidfile} &
115 ./nbd-tester-client localhost -N export1 -w
119 # Test writes with flush
120 cat >${conffile} <<EOF
128 ./nbd-server -C ${conffile} -p ${pidfile} &
131 ./nbd-tester-client localhost -N export1 -w -f
136 cat >${conffile} <<EOF
144 # we need a bigger disk
145 dd if=/dev/zero of=$tmpnam bs=1M count=50 >/dev/null 2>&1
146 ./nbd-server -C ${conffile} -p ${pidfile} &
149 ./nbd-tester-client localhost -N export1 -i -t ${mydir}/integrity-test.tr
154 cat >${conffile} <<EOF
162 # we need a bigger disk
163 dd if=/dev/zero of=$tmpnam bs=1M count=50 >/dev/null 2>&1
164 ./nbd-server -C ${conffile} -p ${pidfile} &
167 ./nbd-tester-client localhost -N export1 -i -t ${mydir}/integrityhuge-test.tr
171 echo "E: unknown test $1"
177 kill `cat ${pidfile}`