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