2 # Yes, that's POSIX sh, not bash!
5 conffile=${tmpnam}.conf
10 # Create a one-meg device
11 dd if=/dev/zero of=$tmpnam bs=1024 count=4096 >/dev/null 2>&1
17 # Test with export specified on command line
18 ./nbd-server -C /dev/null -p ${pidfile} 11111 $tmpnam &
19 # -p only works if nbd-server wasn't compiled with -DNOFORK or
20 # -DNODAEMON, which I sometimes do for testing and debugging.
23 ./nbd-tester-client 127.0.0.1 11111
27 # Test oversized requests
28 ./nbd-server -C /dev/null -p ${pidfile} 11111 $tmpnam &
29 # -p only works if nbd-server wasn't compiled with -DNOFORK or
30 # -DNODAEMON, which I sometimes do for testing and debugging.
33 ./nbd-tester-client 127.0.0.1 11111 -o
37 # Test with export specified in config file
38 cat > ${conffile} <<EOF
45 ./nbd-server -C ${conffile} -p ${pidfile} &
48 ./nbd-tester-client 127.0.0.1 11112
52 # Test with multiple exports specified in config file, and
53 # testing more options too
54 cat >${conffile} <<EOF
61 listenaddr = 127.0.0.1
66 listenaddr = 127.0.0.1
68 ./nbd-server -C ${conffile} -p ${pidfile} &
71 ./nbd-tester-client localhost 11113
84 rm -f $tmpnam ${conffile}
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}`
165 rm -f $tmpnam ${conffile}