2 # Yes, that's POSIX sh, not bash!
5 conffile=${tmpdir}/nbd.conf
6 pidfile=${tmpdir}/nbd.pid
7 tmpnam=${tmpdir}/nbd.dd
11 # Create a one-meg device
12 dd if=/dev/zero of=$tmpnam bs=1024 count=4096 >/dev/null 2>&1
18 # Test with export specified on command line
19 ./nbd-server -C /dev/null -p ${pidfile} 11111 $tmpnam &
20 # -p only works if nbd-server wasn't compiled with -DNOFORK or
21 # -DNODAEMON, which I sometimes do for testing and debugging.
24 ./nbd-tester-client 127.0.0.1 11111
28 # Test oversized requests
29 ./nbd-server -C /dev/null -p ${pidfile} 11111 $tmpnam &
30 # -p only works if nbd-server wasn't compiled with -DNOFORK or
31 # -DNODAEMON, which I sometimes do for testing and debugging.
34 ./nbd-tester-client 127.0.0.1 11111 -o
38 # Test with export specified in config file
39 cat > ${conffile} <<EOF
46 ./nbd-server -C ${conffile} -p ${pidfile} &
49 ./nbd-tester-client 127.0.0.1 11112
53 # Test with multiple exports specified in config file, and
54 # testing more options too
55 cat >${conffile} <<EOF
62 listenaddr = 127.0.0.1
67 listenaddr = 127.0.0.1
69 ./nbd-server -C ${conffile} -p ${pidfile} &
72 ./nbd-tester-client localhost 11113
88 ./nbd-tester-client localhost 11114
92 # Test new-style exports
93 cat >${conffile} <<EOF
98 ./nbd-server -C ${conffile} -p ${pidfile} &
101 ./nbd-tester-client localhost -N export1
106 cat >${conffile} <<EOF
111 ./nbd-server -C ${conffile} -p ${pidfile} &
114 ./nbd-tester-client localhost -N export1 -w
118 # Test writes with flush
119 cat >${conffile} <<EOF
127 ./nbd-server -C ${conffile} -p ${pidfile} &
130 ./nbd-tester-client localhost -N export1 -w -f
135 cat >${conffile} <<EOF
143 # we need a bigger disk
144 dd if=/dev/zero of=$tmpnam bs=1M count=50 >/dev/null 2>&1
145 ./nbd-server -C ${conffile} -p ${pidfile} &
148 ./nbd-tester-client localhost -N export1 -i
152 echo "E: unknown test $1"
158 kill `cat ${pidfile}`