From 917a2a954290249b0e060f6d712e662f1cfc3b19 Mon Sep 17 00:00:00 2001 From: Braiden Vasco Date: Mon, 25 Sep 2017 18:47:11 +0000 Subject: [PATCH] Finalize test script at fail --- test/partuuid.sh | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/test/partuuid.sh b/test/partuuid.sh index ee77f5e..2f1b05d 100644 --- a/test/partuuid.sh +++ b/test/partuuid.sh @@ -18,23 +18,27 @@ mount -v $ROOT_DEV "$MOUNT_DIR" -t ext4 mkdir -p "$MOUNT_DIR/boot/" mount -v $BOOT_DEV "$MOUNT_DIR/boot/" -t vfat +echo + +function finalize { + echo + + umount -v "$MOUNT_DIR/boot/" + umount -v "$MOUNT_DIR" + + rmdir "$MOUNT_DIR" + + losetup -d "$BOOT_DEV" + losetup -d "$ROOT_DEV" +} + +trap finalize EXIT + IMGID="$(fdisk -l "$IMG_FILE" | sed -n 's/Disk identifier: 0x\([^ ]*\)/\1/p')" BOOT_PARTUUID="$IMGID-01" ROOT_PARTUUID="$IMGID-02" -echo - grep --color "PARTUUID=$BOOT_PARTUUID" "$MOUNT_DIR/etc/fstab" grep --color "PARTUUID=$ROOT_PARTUUID" "$MOUNT_DIR/etc/fstab" grep --color "PARTUUID=$ROOT_PARTUUID" "$MOUNT_DIR/boot/cmdline.txt" - -echo - -umount -v "$MOUNT_DIR/boot/" -umount -v "$MOUNT_DIR" - -rmdir "$MOUNT_DIR" - -losetup -d "$BOOT_DEV" -losetup -d "$ROOT_DEV"