diff mbox series

[blktests] common/rc: fix kernel version parse failure

Message ID 20230501041415.49939-1-shinichiro.kawasaki@wdc.com (mailing list archive)
State New, archived
Headers show
Series [blktests] common/rc: fix kernel version parse failure | expand

Commit Message

Shin'ichiro Kawasaki May 1, 2023, 4:14 a.m. UTC
When kernel version numbers have postfix letters, _have_fio_ver fail to
parse the version. For example, uname -r returns "6.3.0+", it handles
"0+" as a number and fails to parse. Fix it by dropping all letters
other than numbers or period.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 common/rc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Chaitanya Kulkarni May 1, 2023, 4:32 a.m. UTC | #1
On 4/30/23 21:14, Shin'ichiro Kawasaki wrote:
> When kernel version numbers have postfix letters, _have_fio_ver fail to
> parse the version. For example, uname -r returns "6.3.0+", it handles
> "0+" as a number and fails to parse. Fix it by dropping all letters
> other than numbers or period.
>
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> ---
>   common/rc | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/common/rc b/common/rc
> index af4c0b1..525867c 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -207,7 +207,7 @@ _have_kernel_option() {
>   _have_kver() {
>   	local d=$1 e=$2 f=$3
>   
> -	IFS='.' read -r a b c < <(uname -r | sed 's/-.*//')
> +	IFS='.' read -r a b c < <(uname -r | sed 's/-.*//' | sed 's/[^.0-9]//')
>   	if [ $((a * 65536 + b * 256 + c)) -lt $((d * 65536 + e * 256 + f)) ];
>   	then
>   		SKIP_REASONS+=("Kernel version too old")

I was about to post the same fix as nvme queue count testcase if not running
with postfix letters. Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck
Bart Van Assche May 1, 2023, 4:38 p.m. UTC | #2
On 4/30/23 21:14, Shin'ichiro Kawasaki wrote:
> When kernel version numbers have postfix letters, _have_fio_ver fail to
> parse the version. For example, uname -r returns "6.3.0+", it handles
> "0+" as a number and fails to parse. Fix it by dropping all letters
> other than numbers or period.
> 
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> ---
>   common/rc | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/rc b/common/rc
> index af4c0b1..525867c 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -207,7 +207,7 @@ _have_kernel_option() {
>   _have_kver() {
>   	local d=$1 e=$2 f=$3
>   
> -	IFS='.' read -r a b c < <(uname -r | sed 's/-.*//')
> +	IFS='.' read -r a b c < <(uname -r | sed 's/-.*//' | sed 's/[^.0-9]//')
>   	if [ $((a * 65536 + b * 256 + c)) -lt $((d * 65536 + e * 256 + f)) ];
>   	then
>   		SKIP_REASONS+=("Kernel version too old")

Please combine the two sed statements into a single sed statement, e.g. as
follows:

sed 's/-.*//;s/[^.0-9]//'

Thanks,

Bart.
Shin'ichiro Kawasaki May 2, 2023, 4:12 a.m. UTC | #3
On May 01, 2023 / 09:38, Bart Van Assche wrote:
[...]
> Please combine the two sed statements into a single sed statement, e.g. as
> follows:
> 
> sed 's/-.*//;s/[^.0-9]//'

Thanks. I've applied the patch with the suggested change.
diff mbox series

Patch

diff --git a/common/rc b/common/rc
index af4c0b1..525867c 100644
--- a/common/rc
+++ b/common/rc
@@ -207,7 +207,7 @@  _have_kernel_option() {
 _have_kver() {
 	local d=$1 e=$2 f=$3
 
-	IFS='.' read -r a b c < <(uname -r | sed 's/-.*//')
+	IFS='.' read -r a b c < <(uname -r | sed 's/-.*//' | sed 's/[^.0-9]//')
 	if [ $((a * 65536 + b * 256 + c)) -lt $((d * 65536 + e * 256 + f)) ];
 	then
 		SKIP_REASONS+=("Kernel version too old")