]> www.infradead.org Git - mtd-utils.git/commitdiff
fs-tests: integck: introduce power cut testing arguments
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Thu, 14 Apr 2011 09:20:31 +0000 (12:20 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 22 Apr 2011 11:29:50 +0000 (14:29 +0300)
Introduce new command line arguments for power cut testing:
-p to enable the power cut testing mode and -v to be verbose
about the errors. The real functionality is not implemented
so far.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
tests/fs-tests/integrity/integck.c

index 61fb12c5944e43cc59343e54cee4aa19c123ba85..73b66226fd9079b453dff71ea6c58d7c6eab7b73 100644 (file)
@@ -65,6 +65,8 @@
 /* The variables below are set by command line arguments */
 static struct {
        long repeat_cnt;
+       int power_cut_mode;
+       int verbose;
        const char *mount_point;
 } args = {
        .repeat_cnt = 1,
@@ -2339,18 +2341,29 @@ static const char doc[] = PROGRAM_NAME " version " PROGRAM_VERSION
 "and hardlinks, randomly writes and truncate files, sometimes makes holes in\n"
 "files, sometimes fsync()'s them. Then it un-mounts and re-mounts the test file\n"
 "system and checks the contents - everything (files, dirs, etc) should be there\n"
-"and the contents of the files should be correct.\n"
-"This is repeated a number of times (set with -n, default 1).";
+"and the contents of the files should be correct. This is repeated a number of\n"
+"times (set with -n, default 1).\n\n"
+"This test is also able to perform powe cut testing. The underlying file-system\n"
+"or the device driver should be able to emulate power-cuts, e.g., but switching\n"
+"to R/O mode at random points of time. And the file-system should return EROFS\n"
+"(read-only file-system error) for all operations which modify it. In this case\n"
+"this test program re-mounts the file-system and checks that all files and\n"
+"directories which have been successfully synchronized before the power cut are\n"
+"there and contains correct data. Then the test continues.\n";
 
 static const char optionsstr[] =
 "-n, --repeat=<count> repeat count, default is 1; zero value - repeat forever\n"
+"-p, --power-cut      power cut testing mode\n"
+"-v, --verbose        be verbose about failure during power cut testing\n"
 "-h, -?, --help       print help message\n"
 "-V, --version        print program version\n";
 
 static const struct option long_options[] = {
-       { .name = "repeat",  .has_arg = 1, .flag = NULL, .val = 'n' },
-       { .name = "help",    .has_arg = 0, .flag = NULL, .val = 'h' },
-       { .name = "version", .has_arg = 0, .flag = NULL, .val = 'V' },
+       { .name = "repeat",    .has_arg = 1, .flag = NULL, .val = 'n' },
+       { .name = "power-cut", .has_arg = 0, .flag = NULL, .val = 'p' },
+       { .name = "verbose",   .has_arg = 0, .flag = NULL, .val = 'v' },
+       { .name = "help",      .has_arg = 0, .flag = NULL, .val = 'h' },
+       { .name = "version",   .has_arg = 0, .flag = NULL, .val = 'V' },
        { NULL, 0, NULL, 0},
 };
 
@@ -2365,7 +2378,7 @@ static int parse_opts(int argc, char * const argv[])
        while (1) {
                int key, error = 0;
 
-               key = getopt_long(argc, argv, "n:Vh?", long_options, NULL);
+               key = getopt_long(argc, argv, "n:pvVh?", long_options, NULL);
                if (key == -1)
                        break;
 
@@ -2375,6 +2388,12 @@ static int parse_opts(int argc, char * const argv[])
                        if (error || args.repeat_cnt < 0)
                                return errmsg("bad repeat count: \"%s\"", optarg);
                        break;
+               case 'p':
+                       args.power_cut_mode = 1;
+                       break;
+               case 'v':
+                       args.verbose = 1;
+                       break;
                case 'V':
                        fprintf(stderr, "%s\n", PROGRAM_VERSION);
                        exit(EXIT_SUCCESS);