From ffdcce923d9817573b218b1031c725800dd837d6 Mon Sep 17 00:00:00 2001 From: Sergei Shtepa Date: Fri, 2 Feb 2024 19:10:18 +0100 Subject: [PATCH] add 1400-simple.sh test --- tests/1400-simple.sh | 109 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 tests/1400-simple.sh diff --git a/tests/1400-simple.sh b/tests/1400-simple.sh new file mode 100644 index 0000000..4a221de --- /dev/null +++ b/tests/1400-simple.sh @@ -0,0 +1,109 @@ +#!/bin/bash -e +# +# SPDX-License-Identifier: GPL-2.0+ + + +if [ -z $1 ] +then + echo "Should be specified empty test block device." + exit 255 +else + DEVICE=$1 +fi + +if [ -z $2 ] +then + DIFF_STORAGE_DIR=${HOME} +else + DIFF_STORAGE_DIR=$1 +fi +echo "Diff storage directory ${DIFF_STORAGE_DIR}" + +. ./functions.sh +. ./blksnap.sh +BLOCK_SIZE=$(block_size_mnt ${DIFF_STORAGE_DIR}) + +echo "---" +echo "Simple test start" + +blksnap_load + +# check module is ready +blksnap_version + +MPDIR=/mnt/blksnap-test +rm -rf ${MPDIR} +mkdir -p ${MPDIR} + +DIFF_STORAGE="${DIFF_STORAGE_DIR}/diff_storage" +fallocate --length 4KiB ${DIFF_STORAGE} + +echo "Create new filesystem on ${DEVICE}" +#echo "press ..." +#read -n 1 +mkfs.ext4 ${DEVICE} + +MOUNTPOINT=${MPDIR}/simple +mkdir -p ${MOUNTPOINT} +mount ${DEVICE} ${MOUNTPOINT} + +generate_files_direct ${MOUNTPOINT} "before" 9 +drop_cache + +#echo "Block device prepared, press ..." +#read -n 1 + +blksnap_snapshot_create "${DEVICE}" "${DIFF_STORAGE}" "2G" +blksnap_snapshot_take + +#echo "Snapshot was token, press ..." +#read -n 1 + +#echo "Write something" > ${MOUNTPOINT}/something.txt +echo "Write to original" +generate_files_direct ${MOUNTPOINT} "after" 3 +drop_cache + +check_files ${MOUNTPOINT} + +echo "Check snapshots" +DEVICE_IMAGE=$(blksnap_get_image ${DEVICE}) +IMAGE=${TESTDIR}/image0 +mkdir -p ${IMAGE} +mount ${DEVICE_IMAGE} ${IMAGE} +#echo "pause, press ..." +#read -n 1 +check_files ${IMAGE} + +echo "Write to snapshot" +generate_files_direct ${IMAGE} "snapshot" 3 + +drop_cache +umount ${DEVICE_IMAGE} +mount ${DEVICE_IMAGE} ${IMAGE} + +#echo "pause, press ..." +#read -n 1 +check_files ${IMAGE} + +umount ${IMAGE} + +blksnap_snapshot_destroy + +#echo "Destroy snapshot, press ..." +#read -n 1 + +drop_cache +umount ${DEVICE} +mount ${DEVICE} ${MOUNTPOINT} + +check_files ${MOUNTPOINT} + +echo "Destroy first device" +blksnap_detach ${DEVICE} +umount ${MOUNTPOINT} + +blksnap_unload + +echo "Simple test finish" +echo "---"