--- /dev/null
+#!/usr/bin/env bats
+
+export TESTLAB_SCRIPTS="./tct"
+
+. "${TESTLAB_SCRIPTS}/common.sh"
+. "${TESTLAB_SCRIPTS}/prepare/prepare.sh"
+
+TAR_1="${BATS_TMPDIR}/foo1.tar"
+TAR_2="${BATS_TMPDIR}/bar1.tar"
+DEST="${BATS_TMPDIR}/foo_bar_dest"
+MOUNT="${BATS_TMPDIR}/foo_bar_mount"
+
+setup() {
+ FOO_1="$BATS_TMPDIR/foo_1"
+ FOO_2="$BATS_TMPDIR/foo_2"
+ BAR_1="$BATS_TMPDIR/bar_1"
+ BAR_2="$BATS_TMPDIR/bar_2"
+ BAR_3="$BATS_TMPDIR/bar_3"
+ dd if="/dev/urandom" of="$FOO_1" bs=1M count=16
+ truncate -s 100M "$FOO_2"
+ mkfs.ext4 -F "$FOO_2"
+ dd if="/dev/urandom" of="$BAR_1" bs=1M count=24
+ dd if="/dev/urandom" of="$BAR_2" bs=2M count=16
+ dd if="/dev/urandom" of="$BAR_3" bs=2M count=8
+ for i in "$FOO_1" "$FOO_2" "$BAR_1" "$BAR_2" "$BAR_3"
+ do
+ [ -f "$i" ]
+ done
+ tar -C "${BATS_TMPDIR}" -cf "$TAR_1" "foo_1" "foo_2"
+ tar -C "${BATS_TMPDIR}" -cf "$TAR_2" "bar_1" "bar_2" "bar_3"
+ for i in "$FOO_1" "$FOO_2" "$BAR_1" "$BAR_2" "$BAR_3"
+ do
+ [ -f "$i" ]
+ rm "$i"
+ done
+}
+
+teardown() {
+ rm -rf "${TAR_1}" "${TAR_2}" "${MOUNT}" "${DEST}"
+}
+
+@test "image prepare" {
+#test "unpack_image"
+ rm -rf "$DEST"
+ unpack_image "$TAR_1" "$TAR_2" "$DEST"
+ FOO_1="$DEST/foo_1"
+ FOO_2="$DEST/foo_2"
+ BAR_1="$DEST/bar_1"
+ BAR_2="$DEST/bar_2"
+ BAR_3="$DEST/bar_3"
+ for i in "$FOO_1" "$FOO_2" "$BAR_1" "$BAR_2" "$BAR_3"
+ do
+ [ -f "$i" ]
+ done
+#test "mount_image"
+ mount_image "$DEST/foo_2" "$MOUNT"
+ [ -d "$MOUNT/lost+found" ]
+#test "install_iserial"
+ ID="foo_bar"
+ sudo mkdir -p "$MOUNT/usr/lib/systemd/system"
+ sudo mkdir -p "$MOUNT/usr/sbin"
+ sudo mkdir -p "$MOUNT/etc/systemd/system/multi-user.target.wants/"
+ install_iserial "$ID" "$MOUNT"
+ [ -L "$MOUNT/etc/systemd/system/multi-user.target.wants/iserial.service" ]
+ [ -f "$MOUNT/usr/sbin/iserial.sh" ]
+ [ -f "$MOUNT/usr/lib/systemd/system/iserial.service" ]
+#test "unmount_image"
+ unmount_image "$MOUNT"
+ [ ! -d "$MOUNT/lost+found" ]
+}