fab351
From 0f0b8c8f90cbcd56140e85b9997deda906c71118 Mon Sep 17 00:00:00 2001
fab351
From: Lubomir Rintel <lkundrak@v3.sk>
fab351
Date: Tue, 25 Jun 2019 17:39:57 +0200
fab351
Subject: [PATCH] test/TEST-14-IMSM: detect failure to compose the test setup
fab351
 root
fab351
fab351
The dracut-root-block-created line should not be created if we fail to copy
fab351
in the required files to sysroot. Let's turn on -e to trap failures and
fab351
poweroff on them, like some other tests do.
fab351
fab351
Also remove the &&. Not only it is unnecessary with -e, but defeats it.
fab351
From bash(1):
fab351
fab351
  The shell does not exit if the command that fails is [...] part of any
fab351
  command executed in a && or || list except the command following the
fab351
  final && or || [...]
fab351
fab351
(cherry picked from commit c27ed38bb2986d31b08257782ce2b24a80415c6c)
fab351
---
fab351
 test/TEST-14-IMSM/create-root.sh | 23 +++++++++++++----------
fab351
 1 file changed, 13 insertions(+), 10 deletions(-)
fab351
fab351
diff --git a/test/TEST-14-IMSM/create-root.sh b/test/TEST-14-IMSM/create-root.sh
fab351
index f637ec88..a0324c6f 100755
fab351
--- a/test/TEST-14-IMSM/create-root.sh
fab351
+++ b/test/TEST-14-IMSM/create-root.sh
fab351
@@ -1,4 +1,7 @@
fab351
 #!/bin/sh
fab351
+
fab351
+trap 'poweroff -f' EXIT
fab351
+
fab351
 # don't let udev and this script step on eachother's toes
fab351
 for x in 61-dmraid-imsm.rules 64-md-raid.rules 65-md-incremental-imsm.rules 65-md-incremental.rules 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
fab351
     rm -f -- "/etc/udev/rules.d/$x"
fab351
@@ -55,20 +58,20 @@ mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 \
fab351
 # wait for the array to finish initailizing, otherwise this sometimes fails
fab351
 # randomly.
fab351
 mdadm -W /dev/md0
fab351
+set -e
fab351
 lvm pvcreate -ff  -y /dev/md0
fab351
-lvm vgcreate dracut /dev/md0 && \
fab351
-lvm lvcreate -l 100%FREE -n root dracut && \
fab351
-lvm vgchange -ay && \
fab351
-mke2fs -L root /dev/dracut/root && \
fab351
-mkdir -p /sysroot && \
fab351
-mount /dev/dracut/root /sysroot && \
fab351
-cp -a -t /sysroot /source/* && \
fab351
-umount /sysroot && \
fab351
-lvm lvchange -a n /dev/dracut/root && \
fab351
+lvm vgcreate dracut /dev/md0
fab351
+lvm lvcreate -l 100%FREE -n root dracut
fab351
+lvm vgchange -ay
fab351
+mke2fs -L root /dev/dracut/root
fab351
+mkdir -p /sysroot
fab351
+mount /dev/dracut/root /sysroot
fab351
+cp -a -t /sysroot /source/*
fab351
+umount /sysroot
fab351
+lvm lvchange -a n /dev/dracut/root
fab351
 udevadm settle
fab351
 mdadm --detail --export /dev/md0 |grep -F MD_UUID > /tmp/mduuid
fab351
 . /tmp/mduuid
fab351
 echo "MD_UUID=$MD_UUID"
fab351
 { echo "dracut-root-block-created"; echo MD_UUID=$MD_UUID;} > /dev/sda
fab351
 mdadm --wait-clean /dev/md0
fab351
-poweroff -f
fab351