Commit 8debcf9f authored by Milan Broz's avatar Milan Broz

Do not use too complicated regular expression in test.

parent db0a21b9
......@@ -36,6 +36,8 @@ add_device() {
function check_version()
{
VER_STR=$(dmsetup targets | grep crypt | cut -f 2 -dv)
[ -z "$VER_STR" ] && fail "Failed to parse dm-crypt version."
VER_MAJ=$(echo $VER_STR | cut -f 1 -d.)
VER_MIN=$(echo $VER_STR | cut -f 2 -d.)
......
......@@ -54,20 +54,15 @@ function load_key()
function dm_crypt_keyring_support()
{
local str
local major=0
local minor=0
VER_STR=$(dmsetup targets | grep crypt | cut -f2 -dv)
[ -z "$VER_STR" ] && fail "Failed to parse dm-crypt version."
str=$(dmsetup targets | grep crypt | sed -e 's/crypt[[:space:]]\+v\(.*\)/\1/g')
[ -z "$str" ] && fail "failed to parse dm-crypt version"
VER_MAJ=$(echo $VER_STR | cut -f 1 -d.)
VER_MIN=$(echo $VER_STR | cut -f 2 -d.)
major=${str%%.*}
minor=${str#*.}
minor=${minor%.*}
[ $major -gt 1 ] && return 0
[ $major -lt 1 ] && return 1
[ $minor -ge 15 ]
[ $VER_MAJ -gt 1 ] && return 0
[ $VER_MAJ -lt 1 ] && return 1
[ $VER_MIN -ge 15 ]
}
[ $(id -u) != 0 ] && skip "WARNING: You must be root to run this test, test skipped."
......
......@@ -60,6 +60,8 @@ function check_exists()
function check_version()
{
VER_STR=$(dmsetup targets | grep verity | cut -f 3 -dv)
[ -z "$VER_STR" ] && fail "Failed to parse dm-verity version."
VER_MAJ=$(echo $VER_STR | cut -f 1 -d.)
VER_MIN=$(echo $VER_STR | cut -f 2 -d.)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment