From 463d3e379d63e37764bc190be6c2f790769bea58 Mon Sep 17 00:00:00 2001 From: Atin Mukherjee Date: Thu, 13 Nov 2014 07:03:54 +0530 Subject: tests: spurious failure fix for quota-anon-fd-nfs.t Change-Id: I4f7ee68c514d8d322e25cf74167f288a8b6f8164 BUG: 1163543 Signed-off-by: Atin Mukherjee Reviewed-on: http://review.gluster.org/9108 Tested-by: Gluster Build System Reviewed-by: Niels de Vos --- tests/basic/quota-anon-fd-nfs.c | 47 +++++++++++++++++++++++++++++++++++++++++ tests/basic/quota-anon-fd-nfs.t | 7 +++++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tests/basic/quota-anon-fd-nfs.c (limited to 'tests/basic') diff --git a/tests/basic/quota-anon-fd-nfs.c b/tests/basic/quota-anon-fd-nfs.c new file mode 100644 index 00000000000..4cc0322e132 --- /dev/null +++ b/tests/basic/quota-anon-fd-nfs.c @@ -0,0 +1,47 @@ +#include +#include +#include +#include +#include + +int +file_write (char *filename, int filesize) +{ + int fd, ret = 0; + int 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 \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 -- cgit