All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Yang Xu <xuyang2018.jy@fujitsu.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v3 07/12] syscalls/quotactl08: Test quoatctl01 but quota info hidden in filesystem
Date: Wed, 10 Nov 2021 17:32:42 +0100	[thread overview]
Message-ID: <YYv0Kn16GGGgJpIn@yuki> (raw)
In-Reply-To: <1636455285-8372-2-git-send-email-xuyang2018.jy@fujitsu.com>

Hi!
> +	f = SAFE_POPEN("mkfs.ext4 -V 2>&1", "r");
> +	rc = fscanf(f, "mke2fs %d.%d.%d", &major, &minor, &patch);
> +	if (rc != 3)
> +		tst_res(TWARN, "Unable parse version number");
> +	else if (major * 10000 + minor * 100 + patch < 14300)
> +		tst_brk(TCONF, "Test needs mkfs.ext4 >= 1.43 for quota option, test skipped");
> +	pclose(f);

Ideally this should be added to the .needs_cmds instead so that we get
the minimal version in the test metadata too.

I wonder how this should be done.

One possibility would be adding support for version in the needs_cmds
strings as:

"mkfs.ext4 >= 1.43"

Then we would have to add a table of version checks to the library as
well so that we could lookup a function based on the command name.

Something as:

static long mkfs_ext4_version_parser(void)
{
	f = SAFE_POPEN("mkfs.ext4 -V 2>&1", "r");
	rc = fscanf(f, "mke2fs %d.%d.%d", &major, &minor, &patch);
	pclose(f);
	if (rc != 3) {
		tst_res(TWARN, "Unable to parse mkfs.ext4 version");
		return -1;
	}

	return major * 10000 * minor * 100 + patch;
}

static struct version_parser {
	const char *name,
	long (*parser)(void);
} version_parsers[] = {
	{.cmd = "mkfs.ext4", .parser = mkfs_ext4_version_parser},
	{},
};

Then the library would do:

	struct version_parser *p;
	size_t cmd_len;
	long version;
	char *str, *version;

	str = strchr(cmd, ' ');
	if (!str)
		return;

	version = strchr(str, ' ');
	if (!version)
		tst_brk(TBROK, "Missing version in %s", cmd);

	//TODO: check that the string between str and version is a
	//correct operator

	cmd_len = str - cmd;

	for (p = *version_parsers; *p; p++) {
		if (strlen(p->name) != cmd_len)
			continue;

		if (!strncmp(p->name, cmd, cmd_len))
			break;
	}

	if (!p->name)
		tst_brk(TBROK, "No version parser for %s implemented!");

	long ver = p->parser();
	if (ver < 0)
		tst_brk(TBROK, "Failed to parse %s version", p->name);

	/* now we have to parse the version from the version variable
	 * and compare it with the ver variable */

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2021-11-10 16:31 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-09 10:54 [LTP] [PATCH v3 06/12] lapi/quotactl.h: Add fallback for quotactl_fd Yang Xu
2021-11-09 10:54 ` [LTP] [PATCH v3 07/12] syscalls/quotactl08: Test quoatctl01 but quota info hidden in filesystem Yang Xu
2021-11-10 16:32   ` Cyril Hrubis [this message]
2021-11-11  8:48     ` xuyang2018.jy
2021-11-11 14:30       ` Cyril Hrubis
2021-11-26  9:32         ` xuyang2018.jy
2021-12-13  7:26         ` [LTP] [PATCH v4 1/6] " Yang Xu
2021-12-13  7:26           ` [LTP] [PATCH v4 2/6] syscalls/quotactl02, 5: Add quotactl_fd test variant Yang Xu
2022-01-07 14:30             ` Cyril Hrubis
2021-12-13  7:26           ` [LTP] [PATCH v4 3/6] syscalls/quotactl03: " Yang Xu
2022-01-07 14:59             ` Cyril Hrubis
2021-12-13  7:26           ` [LTP] [PATCH v4 4/6] syscalls/quotactl04: " Yang Xu
2022-01-07 15:35             ` Cyril Hrubis
2022-01-10 10:09               ` xuyang2018.jy
2021-12-13  7:26           ` [LTP] [PATCH v4 5/6] syscalls/quotactl09: Test error when quota info hidden in filesystem Yang Xu
2022-01-07 15:50             ` Cyril Hrubis
2022-01-10  6:48               ` xuyang2018.jy
2022-01-10 14:46                 ` Cyril Hrubis
2022-01-11  6:51                   ` xuyang2018.jy
2022-01-11 10:55                     ` Cyril Hrubis
2022-01-12  1:52                       ` xuyang2018.jy
2022-01-12  8:31                         ` Cyril Hrubis
2022-01-12  9:24                           ` xuyang2018.jy
2021-12-13  7:26           ` [LTP] [PATCH v4 6/6] syscalls/quotactl07: Add quotactl_fd test variant Yang Xu
2022-01-07 16:03             ` Cyril Hrubis
2022-01-10  9:03               ` xuyang2018.jy
2021-12-23  8:03           ` [LTP] [PATCH v4 1/6] syscalls/quotactl08: Test quoatctl01 but quota info hidden in filesystem xuyang2018.jy
2022-01-07 14:09           ` Cyril Hrubis
2022-01-10  6:37             ` xuyang2018.jy
2022-01-10 14:46               ` Cyril Hrubis
2021-11-09 10:54 ` [LTP] [PATCH v3 08/12] syscalls/quotactl02, 5: Add quotactl_fd test variant Yang Xu
2021-11-09 10:54 ` [LTP] [PATCH v3 09/12] syscalls/quotactl03: " Yang Xu

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=YYv0Kn16GGGgJpIn@yuki \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=xuyang2018.jy@fujitsu.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.