From 12022fc87ee6b12c07bff0381701e2977e722382 Mon Sep 17 00:00:00 2001 From: Emmanuel Dreyfus Date: Sat, 10 Jan 2015 05:49:42 +0100 Subject: Spare spurious regression in quota.t Like quota-nfs.t, quota.t shows spurious regressions because dd writes too fast. Reuse the C program used by quota-nfs.t to write slowly, and rename it to show it is not specific to quota-nfs.t BUG: 1129939 Change-Id: I14b50e368023e88dc8bcc76c266cc908d62f89e2 Signed-off-by: Emmanuel Dreyfus Reviewed-on: http://review.gluster.org/9410 Reviewed-by: Vijay Bellur Tested-by: Gluster Build System --- tests/basic/quota-nfs.c | 47 ----------------------------------------------- tests/basic/quota-nfs.t | 4 ++-- tests/basic/quota.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ tests/basic/quota.t | 5 ++++- 4 files changed, 53 insertions(+), 50 deletions(-) delete mode 100644 tests/basic/quota-nfs.c create mode 100644 tests/basic/quota.c diff --git a/tests/basic/quota-nfs.c b/tests/basic/quota-nfs.c deleted file mode 100644 index 4cc0322e132..00000000000 --- a/tests/basic/quota-nfs.c +++ /dev/null @@ -1,47 +0,0 @@ -#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-nfs.t b/tests/basic/quota-nfs.t index 501d8ab6381..ea1fce93a3e 100755 --- a/tests/basic/quota-nfs.t +++ b/tests/basic/quota-nfs.t @@ -41,9 +41,9 @@ TEST dd if=/dev/zero of=$N0/$deep/newfile_1 bs=512 count=10240 EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "15.0MB" usage "/" # compile the test write program and run it -TEST $CC $(dirname $0)/quota-nfs.c -o $(dirname $0)/quota-nfs; +TEST $CC $(dirname $0)/quota.c -o $(dirname $0)/quota; # Try to create a 100Mb file which should fail -TEST ! $(dirname $0)/quota-nfs $N0/$deep/newfile_2 "104857600" +TEST ! $(dirname $0)/quota $N0/$deep/newfile_2 "104857600" TEST rm -f $N0/$deep/newfile_2 ## Before killing daemon to avoid deadlocks diff --git a/tests/basic/quota.c b/tests/basic/quota.c new file mode 100644 index 00000000000..4cc0322e132 --- /dev/null +++ b/tests/basic/quota.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.t b/tests/basic/quota.t index f4bcfdc0267..25a5fbfd4a3 100755 --- a/tests/basic/quota.t +++ b/tests/basic/quota.t @@ -72,7 +72,10 @@ TEST $CLI volume quota $V0 hard-timeout 0 ## Verify quota enforcement ## ----------------------------- -TEST ! dd if=/dev/urandom of=$M0/test_dir/1.txt bs=1024k count=12 +# compile the test write program and run it +TEST $CC $(dirname $0)/quota.c -o $(dirname $0)/quota; +# Try to create a 12MB file which should fail +TEST ! $(dirname $0)/quota $M0/test_dir/1.txt "12582912" TEST rm $M0/test_dir/1.txt # wait for marker's accounting to complete -- cgit