TESTS: Add path adn valgrind tests for nfs_stat64()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>libnfs-4.0.0-vitalif
parent
abf2f7fc70
commit
422713e701
|
@ -32,7 +32,7 @@
|
|||
|
||||
void usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: prog-stat <file>\n");
|
||||
fprintf(stderr, "Usage: prog-stat <url> <cwd> <path>\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ int main(int argc, char *argv[])
|
|||
struct nfs_stat_64 st;
|
||||
int ret = 0;
|
||||
|
||||
if (argc != 2) {
|
||||
if (argc != 4) {
|
||||
usage();
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
nfs_set_timeout(nfs, 1000);
|
||||
|
||||
url = nfs_parse_url_full(nfs, argv[argc - 1]);
|
||||
url = nfs_parse_url_full(nfs, argv[1]);
|
||||
if (url == NULL) {
|
||||
fprintf(stderr, "%s\n", nfs_get_error(nfs));
|
||||
exit(1);
|
||||
|
@ -68,7 +68,14 @@ int main(int argc, char *argv[])
|
|||
goto finished;
|
||||
}
|
||||
|
||||
if (nfs_stat64(nfs, url->file, &st)) {
|
||||
if (nfs_chdir(nfs, argv[2]) != 0) {
|
||||
fprintf(stderr, "Failed to chdir to \"%s\" : %s\n",
|
||||
argv[2], nfs_get_error(nfs));
|
||||
ret = 1;
|
||||
goto finished;
|
||||
}
|
||||
|
||||
if (nfs_stat64(nfs, argv[3], &st)) {
|
||||
fprintf(stderr, "Failed to stat file : %s\n",
|
||||
nfs_get_error(nfs));
|
||||
ret = 1;
|
||||
|
|
|
@ -7,46 +7,49 @@ echo "basic stat test"
|
|||
start_share
|
||||
|
||||
dd if=/dev/zero of=testdata/testfile count=1 bs=32768 2>/dev/null
|
||||
chmod 644 testdata/testfile
|
||||
chmod 644 "${TESTDIR}/testfile"
|
||||
|
||||
./prog_stat "${TESTURL}/testfile" > "${TESTDIR}/output" || failure
|
||||
|
||||
echo -n "Testing nfs_ino ... "
|
||||
echo -n "test nfs_stat64() ... "
|
||||
./prog_stat "${TESTURL}/" "." /testfile > "${TESTDIR}/output" || failure
|
||||
success
|
||||
|
||||
echo -n "test nfs_ino ... "
|
||||
INO=`stat --printf="%i" testdata/testfile`
|
||||
grep "nfs_ino:$INO" "${TESTDIR}/output" >/dev/null || failure
|
||||
success
|
||||
|
||||
echo -n "Testing nfs_mode ... "
|
||||
echo -n "test nfs_mode ... "
|
||||
grep "nfs_mode:100644" "${TESTDIR}/output" >/dev/null || failure
|
||||
success
|
||||
|
||||
echo -n "Testing nfs_nlink ... "
|
||||
echo -n "test nfs_nlink ... "
|
||||
grep "nfs_nlink:1" "${TESTDIR}/output" >/dev/null || failure
|
||||
success
|
||||
|
||||
echo -n "Testing nfs_uid ... "
|
||||
echo -n "test nfs_uid ... "
|
||||
grep "nfs_uid:$UID" "${TESTDIR}/output" >/dev/null || failure
|
||||
success
|
||||
|
||||
echo -n "Testing nfs_gid ... "
|
||||
echo -n "test nfs_gid ... "
|
||||
grep "nfs_gid:$GID" "${TESTDIR}/output" >/dev/null || failure
|
||||
success
|
||||
|
||||
echo -n "Testing nfs_size ... "
|
||||
echo -n "test nfs_size ... "
|
||||
grep "nfs_size:32768" "${TESTDIR}/output" >/dev/null || failure
|
||||
success
|
||||
|
||||
echo -n "Testing nfs_atime ... "
|
||||
echo -n "test nfs_atime ... "
|
||||
ATIME=`stat --printf="%X" testdata/testfile`
|
||||
grep "nfs_atime:$ATIME" "${TESTDIR}/output" >/dev/null || failure
|
||||
success
|
||||
|
||||
echo -n "Testing nfs_mtime ... "
|
||||
echo -n "test nfs_mtime ... "
|
||||
MTIME=`stat --printf="%Y" testdata/testfile`
|
||||
grep "nfs_mtime:$MTIME" "${TESTDIR}/output" >/dev/null || failure
|
||||
success
|
||||
|
||||
echo -n "Testing nfs_ctime ... "
|
||||
echo -n "test nfs_ctime ... "
|
||||
CTIME=`stat --printf="%Z" testdata/testfile`
|
||||
grep "nfs_ctime:$CTIME" "${TESTDIR}/output" >/dev/null || failure
|
||||
success
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
#!/bin/sh
|
||||
|
||||
. ./functions.sh
|
||||
|
||||
echo "basic nfs_stat64() test"
|
||||
|
||||
start_share
|
||||
|
||||
mkdir "${TESTDIR}/subdir"
|
||||
mkdir "${TESTDIR}/subdir2"
|
||||
|
||||
echo -n "Test nfs_stat64() for a root file (abs) (1)... "
|
||||
touch "${TESTDIR}/stat1"
|
||||
./prog_stat "${TESTURL}/" "." /stat1 >/dev/null || failure
|
||||
success
|
||||
|
||||
echo -n "Test nfs_stat64() for a root file (rel) (2)... "
|
||||
./prog_stat "${TESTURL}/" "." stat1 >/dev/null || failure
|
||||
success
|
||||
|
||||
echo -n "Test nfs_stat64() for a subdir file (abs) (3)... "
|
||||
touch "${TESTDIR}/subdir/stat3"
|
||||
./prog_stat "${TESTURL}/" "." /subdir/stat3 >/dev/null || failure
|
||||
success
|
||||
|
||||
echo -n "Test nfs_stat64() for a subdir file (rel) (4)... "
|
||||
./prog_stat "${TESTURL}/" "." subdir/stat3 >/dev/null || failure
|
||||
success
|
||||
|
||||
echo -n "Test nfs_stat64() from a different cwd (rel) (5)... "
|
||||
./prog_stat "${TESTURL}/" "subdir2" ../subdir/stat3 >/dev/null || failure
|
||||
success
|
||||
|
||||
echo -n "Test nfs_stat64() outside the share (rel) (6)... "
|
||||
./prog_stat "${TESTURL}/" "subdir2" ../../subdir/stat3 >/dev/null 2>&1 && failure
|
||||
success
|
||||
|
||||
stop_share
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/sh
|
||||
|
||||
. ./functions.sh
|
||||
|
||||
echo "basic valgrind leak check for nfs_stat64()"
|
||||
|
||||
start_share
|
||||
|
||||
mkdir "${TESTDIR}/subdir"
|
||||
mkdir "${TESTDIR}/subdir2"
|
||||
|
||||
|
||||
echo -n "test nfs_stat64() (1) ... "
|
||||
touch "${TESTDIR}/stat1"
|
||||
libtool --mode=execute valgrind --leak-check=full --error-exitcode=99 ./prog_stat "${TESTURL}/" "." /stat1 >/dev/null 2>&1 || failure
|
||||
success
|
||||
|
||||
echo -n "test nfs_stat64() (2) ... "
|
||||
libtool --mode=execute valgrind --leak-check=full --error-exitcode=99 ./prog_stat "${TESTURL}/" "." stat1 >/dev/null 2>&1 || failure
|
||||
success
|
||||
|
||||
echo -n "test nfs_stat64() (3) ... "
|
||||
touch "${TESTDIR}/subdir/stat3"
|
||||
libtool --mode=execute valgrind --leak-check=full --error-exitcode=99 ./prog_stat "${TESTURL}/" "." /subdir/stat3 >/dev/null 2>&1 || failure
|
||||
success
|
||||
|
||||
echo -n "test nfs_stat64() (4) ... "
|
||||
libtool --mode=execute valgrind --leak-check=full --error-exitcode=99 ./prog_stat "${TESTURL}/" "." subdir/stat3 >/dev/null 2>&1 || failure
|
||||
success
|
||||
|
||||
echo -n "test nfs_stat64() (5) ... "
|
||||
libtool --mode=execute valgrind --leak-check=full --error-exitcode=99 ./prog_stat "${TESTURL}/" "subdir2" ../subdir/stat3 >/dev/null 2>&1 || failure
|
||||
success
|
||||
|
||||
echo -n "test nfs_stat64() (6) ... "
|
||||
libtool --mode=execute valgrind --leak-check=full --error-exitcode=99 ./prog_stat "${TESTURL}/" "subdir2" ../../subdir/stat3 2>/dev/null || expr $? != 99 >/dev/null || failure
|
||||
success
|
||||
|
||||
|
||||
stop_share
|
||||
|
||||
exit 0
|
|
@ -14,7 +14,7 @@ echo -n "Create a root directory (abs) (1) ... "
|
|||
success
|
||||
|
||||
echo -n "Stat the new directory ... "
|
||||
./prog_stat "${TESTURL}/testdir" > "${TESTDIR}/output" || failure
|
||||
./prog_stat "${TESTURL}/" "." testdir > "${TESTDIR}/output" || failure
|
||||
success
|
||||
|
||||
echo -n "Verifying it is a directory ... "
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
. ./functions.sh
|
||||
|
||||
echo "basic creat/unlink test"
|
||||
echo "basic nfs_unlink() test"
|
||||
|
||||
start_share
|
||||
|
||||
|
@ -15,7 +15,7 @@ touch "${TESTDIR}/unlink"
|
|||
success
|
||||
|
||||
echo -n "Verify the file is gone ... "
|
||||
./prog_stat "${TESTURL}/unlink" 2>/dev/null && failure
|
||||
./prog_stat "${TESTURL}/" "." unlink 2>/dev/null && failure
|
||||
success
|
||||
|
||||
echo -n "Unlink a file from the root (rel) (2)... "
|
||||
|
|
|
@ -17,7 +17,7 @@ echo -n "Create a chrdev in the root (abs) (1)... "
|
|||
success
|
||||
|
||||
echo -n "Stat the node ... "
|
||||
./prog_stat "${TESTURL}/mknod1" > "${TESTDIR}/output" || failure
|
||||
./prog_stat "${TESTURL}/" "." mknod1 > "${TESTDIR}/output" || failure
|
||||
success
|
||||
|
||||
echo -n "Testing nfs_mode and verify it is a CHRDEV ... "
|
||||
|
|
|
@ -14,7 +14,7 @@ echo -n "Create a file in root (abs) (1) ... "
|
|||
success
|
||||
|
||||
echo -n "Stat the new file ... "
|
||||
./prog_stat "${TESTURL}/creat1" > "${TESTDIR}/output" || failure
|
||||
./prog_stat "${TESTURL}/" "." creat1 > "${TESTDIR}/output" || failure
|
||||
success
|
||||
|
||||
echo -n "Verifying it is a regular file ... "
|
||||
|
|
|
@ -29,7 +29,7 @@ echo -n "test nfs_creat() for memory leaks (5) ... "
|
|||
libtool --mode=execute valgrind --leak-check=full --error-exitcode=99 ./prog_create "${TESTURL}/" "subdir" ../subdir2/creat5 0750 >/dev/null 2>&1 || failure
|
||||
success
|
||||
|
||||
echo -n "test nfs_link() for memory leaks (6) ... "
|
||||
echo -n "test nfs_creat() for memory leaks (6) ... "
|
||||
libtool --mode=execute valgrind --leak-check=full --error-exitcode=99 ./prog_create "${TESTURL}/" "subdir" ../../subdir2/creat6 0750 2>/dev/null || expr $? != 99 >/dev/null || failure
|
||||
success
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ start_share
|
|||
touch "${TESTDIR}/testfile"
|
||||
for IDX in `seq 1 28`; do
|
||||
echo -n "Test timeout at socket event ${IDX} ... "
|
||||
TIMEOUT_START=${IDX} LD_PRELOAD=./ld_timeout.so ./prog_stat "${TESTURL}/testfile" >/dev/null 2>&1 && failure
|
||||
TIMEOUT_START=${IDX} LD_PRELOAD=./ld_timeout.so ./prog_stat "${TESTURL}/" "." testfile >/dev/null 2>&1 && failure
|
||||
success
|
||||
done
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ libtool --mode=execute valgrind --leak-check=full --error-exitcode=1 ../examples
|
|||
success
|
||||
|
||||
echo -n "test nfs_stat64() for memory leaks ... "
|
||||
libtool --mode=execute valgrind --leak-check=full --error-exitcode=1 ./prog_stat "${TESTURL}/file.99" >/dev/null 2>&1 || failure
|
||||
libtool --mode=execute valgrind --leak-check=full --error-exitcode=1 ./prog_stat "${TESTURL}/" "." file.99 >/dev/null 2>&1 || failure
|
||||
success
|
||||
|
||||
echo -n "test nfs_fstat64() for memory leaks ... "
|
||||
|
|
Loading…
Reference in New Issue