From c98825acab98e9154881025fdd35e6445b85f27e Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 22 May 2007 16:01:55 +0200 Subject: tests: add support for fstab modification The patch adds ts_fstab_add and ts_fstab_clean routines. Signed-off-by: Karel Zak --- tests/functions.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'tests/functions.sh') diff --git a/tests/functions.sh b/tests/functions.sh index 24308f696..ba94ad4de 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -56,6 +56,7 @@ function ts_init { TS_DIFF="$TS_DIFFDIR/$TS_NAME" TS_EXPECTED="$TS_EXPECTEDDIR/$TS_NAME" TS_INPUT="$TS_INPUTDIR/$TS_NAME" + TS_MOUNTPOINT="$(pwd)/$TS_OUTDIR/${TS_NAME}_mnt" rm -f $TS_OUTPUT touch $TS_OUTPUT @@ -90,6 +91,7 @@ function ts_die { ts_log "$1" if [ -n "$2" ] && [ -b "$2" ]; then ts_device_deinit "$2" + ts_fstab_clean # for sure... fi ts_finalize } @@ -203,3 +205,39 @@ function ts_swapoff { rm -f $TS_CMD_SWAPOFF fi } + +function ts_fstab_open { + echo "# " >> /etc/fstab +} + +function ts_fstab_addline { + local SPEC="$1" + local MNT=${2:-"$TS_MOUNTPOINT"} + local FS=${3:-"auto"} + local OPT=${4:-"default"} + + echo "$SPEC $MNT $FS defaults 0 0" >> /etc/fstab +} + +function ts_fstab_add { + ts_fstab_open + ts_fstab_addline "$*" + ts_fstab_close +} + +function ts_fstab_clean { + sed --in-place " +/# /!{ + N + ba +} +s/# //; +/^$/d" /etc/fstab +} + -- cgit v1.2.3-55-g7522