From f13b2a4cea69d8c4c079d03d58f55d32a54a9679 Mon Sep 17 00:00:00 2001 From: Steve Guminski Date: Thu, 3 Nov 2016 11:44:04 -0400 Subject: [PATCH] LU-6210 tests: Change positional struct initializers to C99 This patch makes no functional changes. Struct initializers in the tests directory that use C89 or GCC-only syntax are updated to C99 syntax. The C99 syntax prevents incorrect initialization if values are accidently placed in the wrong position, allows changes in the struct definition, and clears any members that are not given an explicit value. The following struct initializers have been updated: lustre/tests/checkfiemap.c: struct option long_opts[] lustre/tests/llapi_layout_test.c: static struct test_tbl_entry test_tbl[] lustre/tests/mcreate.c: struct option opts[] lustre/tests/mmap_sanity.c: struct test_case tests[] lustre/tests/mpi/mdsrate.c: struct option longOpts[] lustre/tests/statmany.c: struct option longopts[] Test-Parameters: trivial Signed-off-by: Steve Guminski Change-Id: Iadc141507664c97dcc3112c382d4e379a1bf8041 Reviewed-on: https://review.whamcloud.com/23568 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Frank Zago Reviewed-by: James Simmons Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- lustre/tests/checkfiemap.c | 4 +-- lustre/tests/llapi_layout_test.c | 60 +++++++++++++++++------------------ lustre/tests/mcreate.c | 16 +++++----- lustre/tests/mmap_sanity.c | 68 +++++++++++++++++++++++++++++++++------- lustre/tests/mpi/mdsrate.c | 61 +++++++++++++++++------------------ lustre/tests/statmany.c | 8 ++--- 6 files changed, 131 insertions(+), 86 deletions(-) diff --git a/lustre/tests/checkfiemap.c b/lustre/tests/checkfiemap.c index cfb6445..925c4b2 100644 --- a/lustre/tests/checkfiemap.c +++ b/lustre/tests/checkfiemap.c @@ -103,8 +103,8 @@ int main(int argc, char **argv) { int c; struct option long_opts[] = { - {"test", no_argument, 0, 't'}, - {NULL, 0, NULL, 0} + { .name = "test", .has_arg = no_argument, .val = 't' }, + { .name = NULL } }; int fd; int rc; diff --git a/lustre/tests/llapi_layout_test.c b/lustre/tests/llapi_layout_test.c index 9d4dac6..3d6311e 100644 --- a/lustre/tests/llapi_layout_test.c +++ b/lustre/tests/llapi_layout_test.c @@ -1317,36 +1317,36 @@ struct test_tbl_entry { }; static struct test_tbl_entry test_tbl[] = { - { &test0, T0_DESC, false }, - { &test1, T1_DESC, false }, - { &test2, T2_DESC, false }, - { &test3, T3_DESC, false }, - { &test4, T4_DESC, false }, - { &test5, T5_DESC, false }, - { &test6, T6_DESC, false }, - { &test7, T7_DESC, false }, - { &test8, T8_DESC, false }, - { &test9, T9_DESC, false }, - { &test10, T10_DESC, false }, - { &test11, T11_DESC, false }, - { &test12, T12_DESC, false }, - { &test13, T13_DESC, false }, - { &test14, T14_DESC, false }, - { &test15, T15_DESC, false }, - { &test16, T16_DESC, false }, - { &test17, T17_DESC, false }, - { &test18, T18_DESC, false }, - { &test19, T19_DESC, false }, - { &test20, T20_DESC, false }, - { &test21, T21_DESC, false }, - { &test22, T22_DESC, false }, - { &test23, T23_DESC, false }, - { &test24, T24_DESC, false }, - { &test25, T25_DESC, false }, - { &test26, T26_DESC, false }, - { &test27, T27_DESC, false }, - { &test28, T28_DESC, false }, - { &test29, T29_DESC, false }, + { .tte_fn = &test0, .tte_desc = T0_DESC, .tte_skip = false }, + { .tte_fn = &test1, .tte_desc = T1_DESC, .tte_skip = false }, + { .tte_fn = &test2, .tte_desc = T2_DESC, .tte_skip = false }, + { .tte_fn = &test3, .tte_desc = T3_DESC, .tte_skip = false }, + { .tte_fn = &test4, .tte_desc = T4_DESC, .tte_skip = false }, + { .tte_fn = &test5, .tte_desc = T5_DESC, .tte_skip = false }, + { .tte_fn = &test6, .tte_desc = T6_DESC, .tte_skip = false }, + { .tte_fn = &test7, .tte_desc = T7_DESC, .tte_skip = false }, + { .tte_fn = &test8, .tte_desc = T8_DESC, .tte_skip = false }, + { .tte_fn = &test9, .tte_desc = T9_DESC, .tte_skip = false }, + { .tte_fn = &test10, .tte_desc = T10_DESC, .tte_skip = false }, + { .tte_fn = &test11, .tte_desc = T11_DESC, .tte_skip = false }, + { .tte_fn = &test12, .tte_desc = T12_DESC, .tte_skip = false }, + { .tte_fn = &test13, .tte_desc = T13_DESC, .tte_skip = false }, + { .tte_fn = &test14, .tte_desc = T14_DESC, .tte_skip = false }, + { .tte_fn = &test15, .tte_desc = T15_DESC, .tte_skip = false }, + { .tte_fn = &test16, .tte_desc = T16_DESC, .tte_skip = false }, + { .tte_fn = &test17, .tte_desc = T17_DESC, .tte_skip = false }, + { .tte_fn = &test18, .tte_desc = T18_DESC, .tte_skip = false }, + { .tte_fn = &test19, .tte_desc = T19_DESC, .tte_skip = false }, + { .tte_fn = &test20, .tte_desc = T20_DESC, .tte_skip = false }, + { .tte_fn = &test21, .tte_desc = T21_DESC, .tte_skip = false }, + { .tte_fn = &test22, .tte_desc = T22_DESC, .tte_skip = false }, + { .tte_fn = &test23, .tte_desc = T23_DESC, .tte_skip = false }, + { .tte_fn = &test24, .tte_desc = T24_DESC, .tte_skip = false }, + { .tte_fn = &test25, .tte_desc = T25_DESC, .tte_skip = false }, + { .tte_fn = &test26, .tte_desc = T26_DESC, .tte_skip = false }, + { .tte_fn = &test27, .tte_desc = T27_DESC, .tte_skip = false }, + { .tte_fn = &test28, .tte_desc = T28_DESC, .tte_skip = false }, + { .tte_fn = &test29, .tte_desc = T29_DESC, .tte_skip = false } }; #define NUM_TESTS (sizeof(test_tbl) / sizeof(struct test_tbl_entry)) diff --git a/lustre/tests/mcreate.c b/lustre/tests/mcreate.c index dd530ae..f3fa364 100644 --- a/lustre/tests/mcreate.c +++ b/lustre/tests/mcreate.c @@ -54,14 +54,14 @@ void usage(const char *prog, int status) int main(int argc, char ** argv) { - struct option opts[] = { - { "device", 1, NULL, 'd' }, - { "help", 0, NULL, 'h' }, - { "mode", 1, NULL, 'm' }, - { "major", 1, NULL, 'M' }, - { "minor", 1, NULL, 'N' }, - { NULL }, - }; + struct option opts[] = { + { .name = "device", .has_arg = required_argument, .val = 'd' }, + { .name = "help", .has_arg = no_argument, .val = 'h' }, + { .name = "mode", .has_arg = required_argument, .val = 'm' }, + { .name = "major", .has_arg = required_argument, .val = 'M' }, + { .name = "minor", .has_arg = required_argument, .val = 'N' }, + { .name = NULL } + }; const char *path; mode_t mode = S_IFREG | 0644; dev_t dev = 0; diff --git a/lustre/tests/mmap_sanity.c b/lustre/tests/mmap_sanity.c index 09d35b6..ba6063b 100644 --- a/lustre/tests/mmap_sanity.c +++ b/lustre/tests/mmap_sanity.c @@ -775,18 +775,62 @@ struct test_case { }; struct test_case tests[] = { - { 1, "mmap test1: basic mmap operation", mmap_tst1, 1 }, - { 2, "mmap test2: MAP_PRIVATE not write back", mmap_tst2, 1 }, - { 3, "mmap test3: concurrent mmap ops on two nodes", mmap_tst3, 2 }, - { 4, "mmap test4: c1 write to f1 from mmapped f2, " - "c2 write to f1 from mmapped f1", mmap_tst4, 2 }, - { 5, "mmap test5: read/write file to/from the buffer " - "which mmapped to just this file", mmap_tst5, 1 }, - { 6, "mmap test6: check mmap write/read content on two nodes", - mmap_tst6, 2 }, - { 7, "mmap test7: file i/o with an unmapped buffer", mmap_tst7, 1}, - { 8, "mmap test8: SIGBUS for beyond file size", mmap_tst8, 1 }, - { 0, NULL, 0, 0 } + { + .tc = 1, + .desc = "mmap test1: basic mmap operation", + .test_fn = mmap_tst1, + .node_cnt = 1 + }, + { + .tc = 2, + .desc = "mmap test2: MAP_PRIVATE not write back", + .test_fn = mmap_tst2, + .node_cnt = 1 + }, + { + .tc = 3, + .desc = "mmap test3: concurrent mmap ops on " + "two nodes", + .test_fn = mmap_tst3, + .node_cnt = 2 + }, + { + .tc = 4, + .desc = "mmap test4: c1 write to f1 from mmapped f2, " + "c2 write to f1 from mmapped f1", + .test_fn = mmap_tst4, + .node_cnt = 2 + }, + { + .tc = 5, + .desc = "mmap test5: read/write file to/from the " + "buffer which mmapped to just this file", + .test_fn = mmap_tst5, + .node_cnt = 1 + }, + { + .tc = 6, + .desc = "mmap test6: check mmap write/read content " + "on two nodes", + .test_fn = mmap_tst6, + .node_cnt = 2 + }, + { + .tc = 7, + .desc = "mmap test7: file i/o with an unmapped " + "buffer", + .test_fn = mmap_tst7, + .node_cnt = 1 + }, + { + .tc = 8, + .desc = "mmap test8: SIGBUS for beyond file size", + .test_fn = mmap_tst8, + .node_cnt = 1 + }, + { + .tc = 0 + } }; int main(int argc, char **argv) diff --git a/lustre/tests/mpi/mdsrate.c b/lustre/tests/mpi/mdsrate.c index 48efb1d..9040656 100644 --- a/lustre/tests/mpi/mdsrate.c +++ b/lustre/tests/mpi/mdsrate.c @@ -72,36 +72,37 @@ enum { }; struct option longOpts[] = { - {"create", 0, NULL, CREATE }, - {"lookup", 0, NULL, LOOKUP }, - {"mknod", 0, NULL, MKNOD }, - {"open", 0, NULL, OPEN }, - {"stat", 0, NULL, STAT }, - {"unlink", 0, NULL, UNLINK }, - {"begin", 1, NULL, BEGIN }, - {"iters", 1, NULL, ITERS }, - {"time", 1, NULL, TIME }, /* seconds */ - {"dirfmt", 1, NULL, DIRFMT }, - {"ndirs", 1, NULL, NDIRS }, - {"filefmt", 1, NULL, FILEFMT }, - {"nfiles", 1, NULL, NFILES }, - {"noexcl", 0, NULL, NOEXCL }, - {"stripes", 1, NULL, STRIPES }, - {"seed", 1, NULL, SEED }, - {"seedfile", 1, NULL, SEEDFILE }, - {"random_order", 0, NULL, RANDOM }, - {"readdir_order", 0, NULL, READDIR }, - {"recreate", 0, NULL, RECREATE }, - {"setxattr", 0, NULL, SETXATTR }, - {"smallwrite", 0, NULL, SMALLWRITE }, - {"ignore", 0, NULL, IGNORE }, - {"verbose", 0, NULL, VERBOSE }, - {"debug", 0, NULL, DEBUG }, - {"help", 0, NULL, HELP }, - {"mdtcount", 1, NULL, MDTCOUNT }, - {"mntcount", 1, NULL, MNTCOUNT }, - {"mntfmt", 1, NULL, MNT }, - { 0, 0, NULL, 0 } + { .name = "create", .has_arg = no_argument, .val = CREATE }, + { .name = "lookup", .has_arg = no_argument, .val = LOOKUP }, + { .name = "mknod", .has_arg = no_argument, .val = MKNOD }, + { .name = "open", .has_arg = no_argument, .val = OPEN }, + { .name = "stat", .has_arg = no_argument, .val = STAT }, + { .name = "unlink", .has_arg = no_argument, .val = UNLINK }, + { .name = "begin", .has_arg = required_argument, .val = BEGIN }, + { .name = "iters", .has_arg = required_argument, .val = ITERS }, + /* time is in seconds */ + { .name = "time", .has_arg = required_argument, .val = TIME }, + { .name = "dirfmt", .has_arg = required_argument, .val = DIRFMT }, + { .name = "ndirs", .has_arg = required_argument, .val = NDIRS }, + { .name = "filefmt", .has_arg = required_argument, .val = FILEFMT }, + { .name = "nfiles", .has_arg = required_argument, .val = NFILES }, + { .name = "noexcl", .has_arg = no_argument, .val = NOEXCL }, + { .name = "stripes", .has_arg = required_argument, .val = STRIPES }, + { .name = "seed", .has_arg = required_argument, .val = SEED }, + { .name = "seedfile", .has_arg = required_argument, .val = SEEDFILE }, + { .name = "random_order", .has_arg = no_argument, .val = RANDOM }, + { .name = "readdir_order", .has_arg = no_argument, .val = READDIR }, + { .name = "recreate", .has_arg = no_argument, .val = RECREATE }, + { .name = "setxattr", .has_arg = no_argument, .val = SETXATTR }, + { .name = "smallwrite", .has_arg = no_argument, .val = SMALLWRITE }, + { .name = "ignore", .has_arg = no_argument, .val = IGNORE }, + { .name = "verbose", .has_arg = no_argument, .val = VERBOSE }, + { .name = "debug", .has_arg = no_argument, .val = DEBUG }, + { .name = "help", .has_arg = no_argument, .val = HELP }, + { .name = "mdtcount", .has_arg = required_argument, .val = MDTCOUNT }, + { .name = "mntcount", .has_arg = required_argument, .val = MNTCOUNT }, + { .name = "mntfmt", .has_arg = required_argument, .val = MNT }, + { .name = NULL } }; int foo1, foo2; diff --git a/lustre/tests/statmany.c b/lustre/tests/statmany.c index fc7efa9..4f83434 100644 --- a/lustre/tests/statmany.c +++ b/lustre/tests/statmany.c @@ -46,10 +46,10 @@ #include struct option longopts[] = { - {"lookup", 0, 0, 'l'}, - {"random", 0, 0, 'r'}, - {"stat", 0, 0, 's'}, - {NULL, 0, 0, 0}, + { .name = "lookup", .has_arg = no_argument, .val = 'l' }, + { .name = "random", .has_arg = no_argument, .val = 'r' }, + { .name = "stat", .has_arg = no_argument, .val = 's' }, + { .name = NULL } }; char *shortopts = "hlr:s0123456789"; -- 1.8.3.1