X-Git-Url: http://git.alex.org.uk diff --git a/simple_test b/simple_test index 3432592..1ccf84b 100755 --- a/simple_test +++ b/simple_test @@ -1,23 +1,169 @@ #!/bin/sh # Yes, that's POSIX sh, not bash! -tmpnam=`mktemp` +tmpdir=`mktemp -d` +conffile=${tmpdir}/nbd.conf +pidfile=${tmpdir}/nbd.pid +tmpnam=${tmpdir}/nbd.dd + +ulimit -c unlimited # Create a one-meg device -dd if=/dev/zero of=$tmpnam bs=1024 count=1024 +dd if=/dev/zero of=$tmpnam bs=1024 count=4096 >/dev/null 2>&1 + +echo $1 -./nbd-server -C /dev/null -p ./nbd-server.pid 11111 $tmpnam & -# -p only works if nbd-server wasn't compiled with -DNOFORK or -DNODAEMON, -# which I sometimes do for testing and debugging. -PID=$! -sleep 1 -./nbd-tester-client localhost 11111 -retval=$? -if [ -f nbd-server.pid ] +case $1 in + */cmd) + # Test with export specified on command line + ./nbd-server -C /dev/null -p ${pidfile} 11111 $tmpnam & + # -p only works if nbd-server wasn't compiled with -DNOFORK or + # -DNODAEMON, which I sometimes do for testing and debugging. + PID=$! + sleep 1 + ./nbd-tester-client 127.0.0.1 11111 + retval=$? + ;; + */cfgsize) + # Test oversized requests + ./nbd-server -C /dev/null -p ${pidfile} 11111 $tmpnam & + # -p only works if nbd-server wasn't compiled with -DNOFORK or + # -DNODAEMON, which I sometimes do for testing and debugging. + PID=$! + sleep 1 + ./nbd-tester-client 127.0.0.1 11111 -o + retval=$? + ;; + */cfg1) + # Test with export specified in config file + cat > ${conffile} <${conffile} <${conffile} <${conffile} <${conffile} <${conffile} </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 + ;; +esac +if [ -f ${pidfile} ] then - kill `cat nbd-server.pid` + kill `cat ${pidfile}` else kill $PID fi -rm -f nbd-server.pid -exit $retval +if [ -z "$2" ] +then + rm -rf $tmpdir +fi +if [ $retval -ne 0 ] +then + exit $retval +fi