Skip to content

Commit

Permalink
tests: Fix targets/kernel version detection
Browse files Browse the repository at this point in the history
It is really not a good idea to check minor version without
checking major version is not lower first.

Also try to prepare for situation when major target versions
increases.
  • Loading branch information
mbroz committed Feb 19, 2025
1 parent 52c63b5 commit 93bc899
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/compat-test2
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ dm_crypt_capi_support()
VER_MAJ=$(echo $VER_STR | cut -f 1 -d.)
VER_MIN=$(echo $VER_STR | cut -f 2 -d.)

[ $VER_MAJ -gt 1 ] && return 0
if [ $VER_MIN -ge 16 ]; then
return 0
fi
Expand Down Expand Up @@ -239,6 +240,7 @@ dm_crypt_sector_size_support()
VER_MIN=$(echo $VER_STR | cut -f 2 -d.)
VER_PTC=$(echo $VER_STR | cut -f 3 -d.)

[ $VER_MAJ -gt 1 ] && return 0
if [ $VER_MIN -ge 17 -o \( $VER_MIN -eq 14 -a $VER_PTC -ge 5 \) ]; then
return 0
fi
Expand Down
9 changes: 9 additions & 0 deletions tests/integrity-compat-test
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ dm_integrity_features()
VER_PTC=$(echo $VER_STR | cut -f 3 -d.)

[ $VER_MAJ -lt 1 ] && return
[ $VER_MAJ -gt 1 ] && {
DM_INTEGRITY_META=1
DM_INTEGRITY_RECALC=1
DM_INTEGRITY_BITMAP=1
DM_INTEGRITY_RESIZE_SUPPORTED=1
DM_INTEGRITY_HMAC_FIX=1
DM_INTEGRITY_RESET=1
return
}
[ $VER_MIN -gt 1 ] && {
DM_INTEGRITY_META=1
DM_INTEGRITY_RECALC=1
Expand Down
1 change: 1 addition & 0 deletions tests/mode-test
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ dm_crypt_capi_support()
VER_MIN=$(echo $VER_STR | cut -f 2 -d.)
VER_PTC=$(echo $VER_STR | cut -f 3 -d.)

[ $VER_MAJ -gt 1 ] && return 0
if [ $VER_MIN -ge 16 ]; then
return 0
fi
Expand Down
3 changes: 3 additions & 0 deletions tests/verity-compat-test
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ check_version() # MAJ MIN
VER_MIN=$(echo $VER_STR | cut -f 2 -d.)

test $VER_MAJ -gt $1 && return 0
test $VER_MAJ -lt $1 && return 1
test $VER_MIN -ge $2 && return 0

return 1
}

Expand All @@ -95,6 +97,7 @@ check_version_kernel()
KER_MIN=$(echo $KER_STR | cut -f 2 -d.)

test $KER_MAJ -gt $1 && return 0
test $KER_MAJ -lt $1 && return 1
test $KER_MIN -ge $2 && return 0

return 1
Expand Down

0 comments on commit 93bc899

Please sign in to comment.