public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/2] lib/tst_kvercmp: Add support to get distname for Ubuntu in tst_kvcmp_distname
Date: Mon, 17 Aug 2020 14:34:03 +0200	[thread overview]
Message-ID: <20200817123403.GA8445@yuki.lan> (raw)
In-Reply-To: <20200817120644.9401-2-po-hsu.lin@canonical.com>

Hi!
> * 4.4.0-187-generic
> * 5.4.0-1021-kvm
> * 4.15.0-1093-azure
> 
> So it's better to grep for ^ID=ubuntu in /etc/os-release to determine
> the distname, instead of doing this from checking kver substring like
> what we did for RHEL / Oracle Linux
> 
> Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
> ---
>  lib/tst_kvercmp.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/lib/tst_kvercmp.c b/lib/tst_kvercmp.c
> index dc3bb669b..349d45543 100644
> --- a/lib/tst_kvercmp.c
> +++ b/lib/tst_kvercmp.c
> @@ -139,6 +139,11 @@ const char *tst_kvcmp_distname(const char *kver)
>  	if (strstr(kver, ".el6"))
>  		return "RHEL6";
>  
> +	// Special case for Ubuntu, kernel version cannot reveal the dist_name
> +	int rc = WEXITSTATUS(system("grep -q ^ID=ubuntu /etc/os-release 2>/dev/null"));
> +	if (rc == 0)
> +		return "UBUNTU";

Can we please properly parse the /etc/os-release file insetad of this
hackery?

It should be as easy as one SAFE_FILE_SCANF() in the case that the file
exists.

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2020-08-17 12:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-17 12:06 [LTP] [PATCH 0/2] Fix for syscalls/utimensat01 test on Ubuntu 4.4 kernel Po-Hsu Lin
2020-08-17 12:06 ` [LTP] [PATCH 1/2] lib/tst_kvercmp: Add support to get distname for Ubuntu in tst_kvcmp_distname Po-Hsu Lin
2020-08-17 12:34   ` Cyril Hrubis [this message]
2020-08-17 12:45     ` Cyril Hrubis
2020-08-18  9:37       ` Po-Hsu Lin
2020-08-17 12:06 ` [LTP] [PATCH 2/2] syscalls/utimensat01: add exception for Ubuntu 4.4 kernel Po-Hsu Lin
2020-08-17 12:42   ` Cyril Hrubis
2020-08-18  9:40     ` Po-Hsu Lin

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=20200817123403.GA8445@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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