test: use proper if-then-fi sequence
authorZdenek Kabelac <zkabelac@redhat.com>
Sat, 12 Jul 2025 11:43:40 +0000 (13:43 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Sun, 13 Jul 2025 18:55:43 +0000 (20:55 +0200)
Adapting the test for the changed behavior of lvconvert
where the mirror leg and log count is not changing.

Properly test for this condition - checking only leg count is
not enough to expect error return code.

And finaly fixing invalid bash scripting logic since:

test && TRUE || FALSE

is not bash equivalent of:

if test ; then
   TRUE
else
   FALSE
fi

test/shell/lvconvert-mirror-basic.sh

index 99d17f645b4b50e70fc1616bcb9d1d32df2a5acc..3f76883e26a7f3e43cd2bba1a256c35fc1644fac 100644 (file)
@@ -100,13 +100,16 @@ test_lvconvert() {
        if [ "$finish_count" -eq 0 ]; then
                mirrorlog=""
                finish_log_type=""
+               finish_log_count=$start_log_count
        else
                mirrorlog="--mirrorlog"
        fi
 
-       [ $start_count -eq $finish_count ] && \
-               not lvconvert --type mirror -m $finish_count $mirrorlog $finish_log_type $vg/$lv1 $alloc || \
+       if [ $start_count -eq $finish_count ] && [ $start_log_count -eq $finish_log_count ]; then
+               not lvconvert --type mirror -m $finish_count $mirrorlog $finish_log_type $vg/$lv1 $alloc
+       else
                lvconvert --type mirror -m $finish_count $mirrorlog $finish_log_type $vg/$lv1 $alloc
+       fi
 
        test "$active" = "-an" || lvchange "$active" $vg/$lv1
 
This page took 0.082629 seconds and 5 git commands to generate.