TESTS: Initial test directory.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
libnfs-4.0.0-vitalif
Ronnie Sahlberg 2017-06-16 12:37:42 -07:00
parent d3af23322a
commit bbf38735d8
5 changed files with 73 additions and 1 deletions

View File

@ -227,6 +227,7 @@ AC_HEADER_MAJOR
#output
AC_CONFIG_FILES([Makefile]
[doc/Makefile]
[examples/Makefile]
[include/Makefile]
[lib/Makefile]
[mount/Makefile]
@ -236,8 +237,8 @@ AC_CONFIG_FILES([Makefile]
[nsm/Makefile]
[portmap/Makefile]
[rquota/Makefile]
[tests/Makefile]
[utils/Makefile]
[examples/Makefile]
)
AC_OUTPUT([libnfs.pc])

17
tests/Makefile.am Normal file
View File

@ -0,0 +1,17 @@
AM_CPPFLAGS = -I${srcdir}/../include "-D_U_=__attribute__((unused))" \
"-D_R_(A,B)=__attribute__((format(printf,A,B)))"
AM_CFLAGS = $(WARN_CFLAGS)
LDADD = ../lib/libnfs.la
#noinst_PROGRAMS = prog_reconnect
T = `ls test_*.sh`
test: $(noinst_PROGRAMS)
for TEST in $(T); do \
echo "Running $$TEST"; \
echo "--------------"; \
sh $$TEST || exit 1; \
echo "--------------"; \
echo; \
done

8
tests/README Normal file
View File

@ -0,0 +1,8 @@
Testsuite for libnfs.
To run the tests :
sudo make test
It needs to run under sudo as it needs to create/remove nfs shares to test
against.

25
tests/functions.sh Executable file
View File

@ -0,0 +1,25 @@
export TGT_IPC_SOCKET=`pwd`/tgtd.socket
TESTDIR=`pwd`/testdata
TESTSHARE="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}"
}
stop_share() {
exportfs -u "${TESTSHARE}"
rm -rf "${TESTDIR}"
}
success() {
echo "[OK]"
}
failure() {
echo "[FAILED]"
exit 1
}

21
tests/test_0100_ls_basic.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
. ./functions.sh
echo "basic ls test"
start_share
echo -n "Testing nfs-ls on root of export ... "
../utils/nfs-ls "${TESTURL}" > /dev/null || failure
success
echo -n "Create a file and verify nfs-ls can see it ... "
touch "${TESTDIR}/testfile"
../utils/nfs-ls "${TESTURL}" > "${TESTDIR}/output" || failure
grep testfile "${TESTDIR}/output" > /dev/null || failure
success
stop_share
exit 0