summaryrefslogtreecommitdiff
path: root/tests/ts/cramfs/mkfs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ts/cramfs/mkfs')
-rwxr-xr-xtests/ts/cramfs/mkfs95
1 files changed, 95 insertions, 0 deletions
diff --git a/tests/ts/cramfs/mkfs b/tests/ts/cramfs/mkfs
new file mode 100755
index 0000000..db9b08c
--- /dev/null
+++ b/tests/ts/cramfs/mkfs
@@ -0,0 +1,95 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="$(dirname $0)/../.."
+TS_DESC="mkfs checksums"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+ts_skip_nonroot
+
+set -o pipefail
+
+ORIGPWD=$(pwd)
+IMAGE_NAME="${TS_TESTNAME}-loop.img"
+IMAGE_PATH="$TS_OUTDIR/$IMAGE_NAME"
+IMAGE_SRC="$TS_OUTDIR/${TS_TESTNAME}-data"
+LABEL="testCramfs"
+
+ts_log "create mountpoint dir"
+
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+
+ts_log "generate data"
+if [ ! -d "$IMAGE_SRC" ]; then
+ mkdir -p $IMAGE_SRC
+ for d in `seq 0 110`; do
+ DIRNAME="$IMAGE_SRC/$(printf "dir-%03d" $d)"
+ mkdir -p $DIRNAME
+ for f in `seq 0 10`; do
+ FILENAME="$DIRNAME/$(printf "data.%03d" $f)"
+ printf "data in %03d-%03d" $d $f >> $FILENAME
+ done
+ done
+fi
+
+cd $IMAGE_SRC
+
+ts_log "list checksums from original data"
+find -type f -exec md5sum {} \; | sort >> $TS_OUTPUT
+echo >> $TS_OUTPUT
+
+ts_log "create cramfs image"
+$TS_CMD_MKCRAMFS -n $LABEL $IMAGE_SRC $IMAGE_PATH 2>&1 >> $TS_OUTPUT
+[ -s "$IMAGE_PATH" ] || ts_die "Cannot create $IMAGE_PATH"
+
+cd $TS_OUTDIR
+
+ts_log "count MD5 from the image"
+md5sum $IMAGE_NAME 2>&1 | sort >> $TS_OUTPUT
+echo >> $TS_OUTPUT
+
+ts_log "create loop device from image"
+DEVICE=$($TS_CMD_LOSETUP --show -f $IMAGE_PATH)
+
+ts_log "check the image"
+ts_device_has "TYPE" "cramfs" $DEVICE
+[ "$?" == "0" ] || ts_die "Cannot find cramfs on $DEVICE" $DEVICE
+
+ts_log "mount the image"
+$TS_CMD_MOUNT -r -L $LABEL $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT
+
+# check it
+ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" $DEVICE
+
+cd $TS_MOUNTPOINT
+
+ts_log "list the image"
+ls -laR --time-style=long-iso . >> $TS_OUTPUT
+echo >> $TS_OUTPUT
+
+ts_log "list checksums from new data"
+find . -type f -exec md5sum {} \; | sort >> $TS_OUTPUT
+echo >> $TS_OUTPUT
+
+cd $ORIGPWD
+
+ts_log "umount the image"
+$TS_CMD_UMOUNT $DEVICE
+$TS_CMD_LOSETUP -d $DEVICE 2>&1 >> $TS_OUTPUT
+ts_finalize
+