From: Christian Brauner <christian.brauner@xxxxxxxxxx> - Use sequential option numbering for option parsing since we're only using longopts anyway and to easier correlate test parsing in the switch with the options specified in longopts. - Introduce an explicit command line switch to runs the basic test suite. This prepares for the introduction of additional command line switches to run tests. - Update help output. - Use die() when logging test failure. Cc: fstests@xxxxxxxxxxxxxxx Signed-off-by: Christian Brauner <christian.brauner@xxxxxxxxxx> --- /* v2 */ new patch --- src/idmapped-mounts/idmapped-mounts.c | 44 +++++++++++++++------------ tests/generic/633 | 3 +- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/idmapped-mounts/idmapped-mounts.c b/src/idmapped-mounts/idmapped-mounts.c index 2c212131..c8635362 100644 --- a/src/idmapped-mounts/idmapped-mounts.c +++ b/src/idmapped-mounts/idmapped-mounts.c @@ -8717,19 +8717,24 @@ static void usage(void) fprintf(stderr, " Run idmapped mount tests\n\n"); fprintf(stderr, "Arguments:\n"); - fprintf(stderr, "-d --device Device used in the tests\n"); - fprintf(stderr, "-m --mountpoint Mountpoint of device\n"); + fprintf(stderr, "--device Device used in the tests\n"); + fprintf(stderr, "--fstype Filesystem type used in the tests\n"); + fprintf(stderr, "--help Print help\n"); + fprintf(stderr, "--mountpoint Mountpoint of device\n"); + fprintf(stderr, "--supported Test whether idmapped mounts are supported on this filesystem\n"); + fprintf(stderr, "--test-core Run core idmapped mount testsuite\n"); _exit(EXIT_SUCCESS); } static const struct option longopts[] = { - {"device", required_argument, 0, 'd'}, - {"fstype", required_argument, 0, 'f'}, - {"mountpoint", required_argument, 0, 'm'}, - {"supported", no_argument, 0, 's'}, - {"help", no_argument, 0, 'h'}, - {NULL, 0, 0, 0 }, + {"device", required_argument, 0, 1}, + {"fstype", required_argument, 0, 2}, + {"mountpoint", required_argument, 0, 3}, + {"supported", no_argument, 0, 4}, + {"help", no_argument, 0, 5}, + {"test-core", no_argument, 0, 6}, + {NULL, 0, 0, 0}, }; struct t_idmapped_mounts { @@ -8804,10 +8809,8 @@ static bool run_test(struct t_idmapped_mounts suite[], size_t suite_size) if (pid == 0) { ret = t->test(); - if (ret) { - fprintf(stderr, "failure: %s\n", t->description); - exit(EXIT_FAILURE); - } + if (ret) + die("failure: %s", t->description); exit(EXIT_SUCCESS); } @@ -8826,23 +8829,26 @@ int main(int argc, char *argv[]) { int fret, ret; int index = 0; - bool supported = false; + bool supported = false, test_core = false; while ((ret = getopt_long(argc, argv, "", longopts, &index)) != -1) { switch (ret) { - case 'd': + case 1: t_device = optarg; break; - case 'f': + case 2: t_fstype = optarg; break; - case 'm': + case 3: t_mountpoint = optarg; break; - case 's': + case 4: supported = true; break; - case 'h': + case 6: + test_core = true; + break; + case 5: /* fallthrough */ default: usage(); @@ -8911,7 +8917,7 @@ int main(int argc, char *argv[]) fret = EXIT_FAILURE; - if (!run_test(basic_suite, ARRAY_SIZE(basic_suite))) + if (test_core && !run_test(basic_suite, ARRAY_SIZE(basic_suite))) goto out; fret = EXIT_SUCCESS; diff --git a/tests/generic/633 b/tests/generic/633 index 6be8a69e..67501177 100755 --- a/tests/generic/633 +++ b/tests/generic/633 @@ -20,7 +20,8 @@ _require_test echo "Silence is golden" -$here/src/idmapped-mounts/idmapped-mounts --device "$TEST_DEV" --mount "$TEST_DIR" --fstype "$FSTYP" +$here/src/idmapped-mounts/idmapped-mounts --test-core --device "$TEST_DEV" \ + --mount "$TEST_DIR" --fstype "$FSTYP" status=$? exit -- 2.30.2