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