Add nbd-trdump manpage
[nbd.git] / simple_test
index 0f12126..1ccf84b 100755 (executable)
@@ -1,9 +1,10 @@
 #!/bin/sh
 # Yes, that's POSIX sh, not bash!
 
-tmpnam=`mktemp`
-conffile=${tmpnam}.conf
-pidfile=${tmpnam}.pid
+tmpdir=`mktemp -d`
+conffile=${tmpdir}/nbd.conf
+pidfile=${tmpdir}/nbd.pid
+tmpnam=${tmpdir}/nbd.dd
 
 ulimit -c unlimited
 
@@ -75,13 +76,12 @@ EOF
                        if [ -f ${pidfile} ]
                        then
                                kill `cat ${pidfile}`
-                               rm -f ${pidfile}
                        else
                                kill $PID
                        fi
                        if [ -z "$2" ]
                        then
-                               rm -f $tmpnam ${conffile}
+                               rm -rf $tmpdir
                        fi
                        exit $retval
                fi
@@ -130,6 +130,24 @@ EOF
                ./nbd-tester-client localhost -N export1 -w -f
                retval=$?
        ;;
+       */integrity)
+               # Integrity test
+               cat >${conffile} <<EOF
+[generic]
+[export1]
+       exportname = $tmpnam
+       flush = true
+       fua = true
+       rotational = true
+EOF
+               # we need a bigger disk
+               dd if=/dev/zero of=$tmpnam bs=1M count=50 >/dev/null 2>&1
+               ./nbd-server -C ${conffile} -p ${pidfile} &
+               PID=$!
+               sleep 1
+               ./nbd-tester-client localhost -N export1 -i -t $(dirname $1)/integrity-test.tr
+               retval=$?
+       ;;
        *)
                echo "E: unknown test $1"
                exit 1
@@ -138,13 +156,12 @@ esac
 if [ -f ${pidfile} ]
 then
        kill `cat ${pidfile}`
-       rm -f ${pidfile}
 else
        kill $PID
 fi
 if [ -z "$2" ]
 then
-       rm -f $tmpnam ${conffile}
+       rm -rf $tmpdir
 fi
 if [ $retval -ne 0 ]
 then