fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: fstests@vger.kernel.org, Eryu Guan <guan@eryu.me>,
	Christoph Hellwig <hch@lst.de>
Cc: Christian Brauner <christian.brauner@ubuntu.com>
Subject: [PATCH v2 1/6] idmapped-mounts: prepare for additional tests
Date: Sat, 31 Jul 2021 18:58:29 +0200	[thread overview]
Message-ID: <20210731165834.479633-2-brauner@kernel.org> (raw)
In-Reply-To: <20210731165834.479633-1-brauner@kernel.org>

From: Christian Brauner <christian.brauner@ubuntu.com>

- 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@vger.kernel.org
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
---
/* 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


  reply	other threads:[~2021-07-31 16:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-31 16:58 [PATCH v2 0/6] Extend idmapped mount testsuite Christian Brauner
2021-07-31 16:58 ` Christian Brauner [this message]
2021-08-10  8:15   ` [PATCH v2 1/6] idmapped-mounts: prepare for additional tests Christoph Hellwig
2021-08-10 14:03     ` Christian Brauner
2021-07-31 16:58 ` [PATCH v2 2/6] generic/640: add fscaps regression test Christian Brauner
2021-08-10  8:17   ` Christoph Hellwig
2021-07-31 16:58 ` [PATCH v2 3/6] idmapped-mounts: refactor helpers Christian Brauner
2021-08-10  8:18   ` Christoph Hellwig
2021-07-31 16:58 ` [PATCH v2 4/6] idmapped-mounts: add nested userns creation helpers Christian Brauner
2021-08-10  8:18   ` Christoph Hellwig
2021-07-31 16:58 ` [PATCH v2 5/6] generic/641: add nested user namespace tests Christian Brauner
2021-08-10  8:20   ` Christoph Hellwig
2021-07-31 17:06 ` [PATCH v2 0/6] Extend idmapped mount testsuite Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210731165834.479633-2-brauner@kernel.org \
    --to=brauner@kernel.org \
    --cc=christian.brauner@ubuntu.com \
    --cc=fstests@vger.kernel.org \
    --cc=guan@eryu.me \
    --cc=hch@lst.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).