Add test for "list exports"
authorWouter Verhelst <w@uter.be>
Fri, 25 May 2012 08:31:32 +0000 (10:31 +0200)
committerWouter Verhelst <w@uter.be>
Fri, 25 May 2012 08:38:17 +0000 (10:38 +0200)
occasionally, since this uses the regular nbd-client, it also tests
whether it will at least do something useful, and not crash and burn at
startup. We can't test whether it will connect properly, since we're not
sure we have the environment set up for that completely, but this is a
good idea regardless.

Makefile.am
simple_test

index fb380f8fb28d8ea7b211cc51f49e74ece6528b07..105ae7268a17de30302dea0d3622671cb6fefa4a 100644 (file)
@@ -3,7 +3,7 @@ bin_PROGRAMS = nbd-server nbd-trdump
 sbin_PROGRAMS = @NBD_CLIENT_NAME@
 EXTRA_PROGRAMS = nbd-client make-integrityhuge
 TESTS_ENVIRONMENT=$(srcdir)/simple_test
-TESTS = cmd cfg1 cfgmulti cfgnew cfgsize write flush integrity dirconfig #integrityhuge
+TESTS = cmd cfg1 cfgmulti cfgnew cfgsize write flush integrity dirconfig list #integrityhuge
 check_PROGRAMS = nbd-tester-client
 nbd_client_SOURCES = nbd-client.c cliserv.h
 nbd_server_SOURCES = nbd-server.c cliserv.h lfs.h nbd.h
@@ -28,3 +28,4 @@ flush:
 integrity:
 integrityhuge:
 dirconfig:
+list:
index c152b37a3a51465520df26afdd782ced73a91fed..f46d23391214277b55da78aba1aee44928d22144 100755 (executable)
@@ -184,6 +184,30 @@ EOF
                ./nbd-tester-client localhost -N export1 -i -t ${mydir}/integrityhuge-test.tr
                retval=$?
        ;;
+       */list)
+               # List exports
+               # This only works if we built nbd-client, which only exists on
+               # Linux. But hey, testing nbd-client itself isn't a bad idea,
+               # so here goes.
+               if [ ! -x ./nbd-client ]
+               then
+                       retval=0
+               else
+                       cat >${conffile} <<EOF
+[generic]
+       listenaddr = 127.0.0.1
+       allowlist = true
+[export1]
+       exportname = $tmpnam
+       readonly = true
+EOF
+                       ./nbd-server -C ${conffile} -p ${pidfile} &
+                       PID=$!
+                       sleep 1
+                       ./nbd-client -l localhost
+                       retval=$?
+               fi
+               ;;
        *)
                echo "E: unknown test $1"
                exit 1