[LTP] [PATCH 1/2] lib/tst_kvercmp: Add support to get distname for Ubuntu in tst_kvcmp_distname

Cyril Hrubis chrubis@suse.cz
Mon Aug 17 14:34:03 CEST 2020


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


More information about the ltp mailing list