summaryrefslogtreecommitdiffstats
path: root/tests/basic/quota-anon-fd-nfs.c
diff options
context:
space:
mode:
authorAtin Mukherjee <amukherj@redhat.com>2014-11-13 07:03:54 +0530
committerRaghavendra Bhat <raghavendra@redhat.com>2014-12-10 10:10:11 -0800
commita86be91a2ae01fc79539dece6a67d1845badba35 (patch)
treee095c3398ccd505db433c01190fe00f47643e95e /tests/basic/quota-anon-fd-nfs.c
parent54d2cbc033dadcd017376584b70af5849146ee4f (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/basic/quota-anon-fd-nfs.c')
-rwxr-xr-xtests/basic/quota-anon-fd-nfs.c47
1 files changed, 47 insertions, 0 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;
+}