TESTS: Add tests for server discovery and share enumeration

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
libnfs-4.0.0-vitalif
Ronnie Sahlberg 2017-06-16 14:21:19 -07:00
parent bbf38735d8
commit 1a3c8c23ef
4 changed files with 38 additions and 6 deletions

View File

@ -1,8 +1,8 @@
Testsuite for libnfs.
To run the tests :
sudo make test
make test
It needs to run under sudo as it needs to create/remove nfs shares to test
against.
The tests will ask for your password as it needs sudo access to
run exportfs to create/remove the share we use for testing.

View File

@ -2,15 +2,15 @@ export TGT_IPC_SOCKET=`pwd`/tgtd.socket
TESTDIR=`pwd`/testdata
TESTSHARE="127.0.0.1:${TESTDIR}"
TESTURL="nfs://127.0.0.1/${TESTDIR}"
TESTURL="nfs://127.0.0.1${TESTDIR}"
start_share() {
mkdir "${TESTDIR}" 2>/dev/null
exportfs -o rw,no_root_squash "${TESTSHARE}"
sudo exportfs -o rw,insecure,no_root_squash "${TESTSHARE}"
}
stop_share() {
exportfs -u "${TESTSHARE}"
sudo exportfs -u "${TESTSHARE}"
rm -rf "${TESTDIR}"
}

View File

@ -0,0 +1,16 @@
#!/bin/sh
. ./functions.sh
echo "discover servers test"
start_share
echo -n "Testing nfs-ls to discover servers ... "
../utils/nfs-ls -D nfs:// > "${TESTDIR}/output" || failure
grep nfs:// "${TESTDIR}/output" > /dev/null || failure
success
stop_share
exit 0

View File

@ -0,0 +1,16 @@
#!/bin/sh
. ./functions.sh
echo "discover shares test"
start_share
echo -n "Testing nfs-ls to discover shares on a server ... "
../utils/nfs-ls -D nfs://127.0.0.1 > "${TESTDIR}/output" || failure
grep "${TESTURL}" "${TESTDIR}/output" > /dev/null || failure
success
stop_share
exit 0