diff options
author | Atin Mukherjee <amukherj@redhat.com> | 2014-11-13 07:03:54 +0530 |
---|---|---|
committer | Raghavendra Bhat <raghavendra@redhat.com> | 2014-12-10 10:10:11 -0800 |
commit | a86be91a2ae01fc79539dece6a67d1845badba35 (patch) | |
tree | e095c3398ccd505db433c01190fe00f47643e95e /tests | |
parent | 54d2cbc033dadcd017376584b70af5849146ee4f (diff) |
tests: spurious failures fix for quota-anon-fd-nfs.t
Change-Id: I4f7ee68c514d8d322e25cf74167f288a8b6f8164
BUG: 1165938
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-on: http://review.gluster.org/9108
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/9148
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Tested-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/basic/quota-anon-fd-nfs.c | 47 | ||||
-rwxr-xr-x | tests/basic/quota-anon-fd-nfs.t | 7 | ||||
-rw-r--r-- | tests/include.rc | 2 | ||||
-rw-r--r-- | tests/nfs.rc | 5 |
4 files changed, 59 insertions, 2 deletions
diff --git a/tests/basic/quota-anon-fd-nfs.c b/tests/basic/quota-anon-fd-nfs.c new file mode 100755 index 00000000000..c9a3627336d --- /dev/null +++ b/tests/basic/quota-anon-fd-nfs.c @@ -0,0 +1,47 @@ +#include <stdlib.h> +#include <stdio.h> +#include <fcntl.h> +#include <sys/types.h> +#include <sys/stat.h> + +int +file_write (char *filename, int filesize) +{ + int fd, ret = 0, i = 0; + char buf[1024] = {'a',}; + + fd = open (filename, O_RDWR|O_CREAT|O_APPEND, 0600); + while (i < filesize) { + ret = write(fd, buf, sizeof(buf)); + if (ret == -1) { + close (fd); + return ret; + } + i += sizeof(buf); + ret = fdatasync(fd); + if (ret) { + close (fd); + return ret; + } + } + ret = close(fd); + if (ret) + return ret; + + return 0; +} + +int +main (int argc, char **argv) +{ + if (argc != 3) { + printf("Usage: %s <filename> <size(in bytes)>\n", argv[0]); + return EXIT_FAILURE; + } + + printf ("argv[2] is %s\n", argv[2]); + if (file_write (argv[1], atoi(argv[2])) == -1) + return EXIT_FAILURE; + + return EXIT_SUCCESS; +} diff --git a/tests/basic/quota-anon-fd-nfs.t b/tests/basic/quota-anon-fd-nfs.t index 25f3474bcea..0f7a9aac52e 100755 --- a/tests/basic/quota-anon-fd-nfs.t +++ b/tests/basic/quota-anon-fd-nfs.t @@ -39,7 +39,12 @@ TEST $CLI volume quota $V0 hard-timeout 0 TEST dd if=/dev/zero of=$N0/$deep/newfile_1 bs=512 count=10240 # wait for write behind to complete. EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "15.0MB" usage "/" -TEST ! dd if=/dev/zero of=$N0/$deep/newfile_2 bs=1k count=10240 + +# compile the test write program and run it +TEST $CC $(dirname $0)/quota-anon-fd-nfs.c -o $(dirname $0)/quota-anon-fd-nfs; +# Try to create a 100Mb file which should fail +TEST ! $(dirname $0)/quota-anon-fd-nfs $N0/$deep/newfile_2 "104857600" +TEST rm -f $N0/$deep/newfile_2 ## Before killing daemon to avoid deadlocks umount_nfs $N0 diff --git a/tests/include.rc b/tests/include.rc index 60a177fc851..572e68ac1ec 100644 --- a/tests/include.rc +++ b/tests/include.rc @@ -8,7 +8,7 @@ V1=${V1:=patchy1}; # volume name to use in tests B0=${B0:=/d/backends}; # top level of brick directories H0=${H0:=`hostname --fqdn`}; # hostname DEBUG=${DEBUG:=0} # turn on debugging? - +CC=cc OSTYPE=$(uname -s) ENV_RC=$(dirname $0)/../env.rc diff --git a/tests/nfs.rc b/tests/nfs.rc index c27452395e1..5ca35af8a85 100644 --- a/tests/nfs.rc +++ b/tests/nfs.rc @@ -25,3 +25,8 @@ function mount_nfs () if [ ! -z "$opt" ]; then opt=",$opt"; fi mount -t nfs -o soft,intr,vers=3"$opt" $e $m } + +function umount_nfs { + umount -f $1 + if [ $? -eq 0 ]; then echo "Y"; else echo "N"; fi +} |