]> www.infradead.org Git - mtd-utils.git/commitdiff
fs-tests: make integrity test shrink better
authorAdrian Hunter <ext-adrian.hunter@nokia.com>
Mon, 22 Oct 2007 11:06:07 +0000 (14:06 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Mon, 16 Jun 2008 15:02:31 +0000 (18:02 +0300)
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
tests/fs-tests/integrity/integck.c

index 753a3179b4092330f8517704ba3b4cc7b478b105..3da4bac0e0c33ba9aab2fa2eb0c39b8ace4c9e5e 100644 (file)
@@ -1211,7 +1211,7 @@ static void operate_on_open_file(struct fd_info *fdi)
        size_t r;
 
        r = tests_random_no(1000);
-       if (shrink && r == 0)
+       if (shrink && r < 5)
                file_truncate(fdi->file, fdi->fd);
        else if (r < 21)
                file_close(fdi);
@@ -1227,6 +1227,17 @@ static void operate_on_an_open_file(void)
        size_t r;
        struct open_file_info *ofi;
 
+       /* When shrinking, close all open files 1 time in 128 */
+       if (shrink) {
+               static int x = 0;
+
+               x += 1;
+               x &= 127;
+               if (x == 0) {
+                       close_open_files();
+                       return;
+               }
+       }
        /* Close any open files that have errored */
        ofi = open_files;
        while (ofi) {