Skip to content
Permalink
Browse files

ZTS: Avoid using PCRE with grep in zdb tests

On FreeBSD grep does not support Perl extensions

Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
  • Loading branch information
freqlabs committed Jan 11, 2020
1 parent 61152d1 commit 662425481f13514620dd8a64a1da9a389a8889b4
@@ -53,9 +53,9 @@ log_note "file $init_data has object number $obj"

output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \
|grep -m 1 "L0 DVA" |head -n1)
dva=$(grep -oP 'DVA\[0\]=<\K.*?(?=>)' <<< "$output")
dva=$(sed -Ene 's/^.+DVA\[0\]=<(.+)>.*$/\1/p' <<< "$output")
log_note "block 0 of $init_data has a DVA of $dva"
cksum_expected=$(grep -oP '(?<=cksum=)[ A-Za-z0-9:]*' <<< "$output")
cksum_expected=$(sed -Ene 's/^.+ cksum=([a-z0-9:]+)$/\1/p' <<< "$output")
log_note "expecting cksum $cksum_expected"
output=$(zdb -R $TESTPOOL $dva:c 2> /dev/null)
result=$(grep $cksum_expected <<< "$output")
@@ -74,11 +74,11 @@ log_note "file $init_data has object number $obj"

output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \
|grep -m 1 "L0 DVA" |head -n1)
dva=$(grep -oP 'DVA\[0\]=<\K.*?(?=>)' <<< "$output")
dva=$(sed -Ene 's/^.+DVA\[0\]=<(.+)>.*$/\1/p' <<< "$output")
log_note "block 0 of $init_data has a DVA of $dva"

# use the length reported by zdb -ddddddbbbbbb
size_str=$(grep -oP 'size=\K.*?(?= )' <<< "$output")
size_str=$(sed -Ene 's/^.+ size=([^ ]+) .*$/\1/p' <<< "$output")
log_note "block size $size_str"

vdev=$(echo "$dva" |awk '{split($0,array,":")} END{print array[1]}')

0 comments on commit 6624254

Please sign in to comment.
You can’t perform that action at this time.