4 # Copyright (C) 2007 Karel Zak <kzak@redhat.com>
6 # This file is part of util-linux-ng.
8 # This file is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This file is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 TS_TOPDIR="$(dirname $0)/../.."
19 TS_DESC="mkfs checksums"
21 . $TS_TOPDIR/functions.sh
28 IMAGE_NAME="${TS_TESTNAME}-loop.img"
29 IMAGE_PATH="$TS_OUTDIR/$IMAGE_NAME"
30 IMAGE_SRC="$TS_OUTDIR/${TS_TESTNAME}-data"
33 ts_log "create mountpoint dir"
35 [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
37 ts_log "generate data"
38 if [ ! -d "$IMAGE_SRC" ]; then
40 for d in `seq 0 110`; do
41 DIRNAME="$IMAGE_SRC/$(printf "dir-%03d" $d)"
43 for f in `seq 0 10`; do
44 FILENAME="$DIRNAME/$(printf "data.%03d" $f)"
45 printf "data in %03d-%03d" $d $f >> $FILENAME
52 ts_log "list checksums from original data"
53 find -type f -exec md5sum {} \; | sort >> $TS_OUTPUT
56 ts_log "create cramfs image"
57 $TS_CMD_MKCRAMFS -n $LABEL $IMAGE_SRC $IMAGE_PATH 2>&1 >> $TS_OUTPUT
58 [ -s "$IMAGE_PATH" ] || ts_die "Cannot create $IMAGE_PATH"
62 ts_log "count MD5 from the image"
63 md5sum $IMAGE_NAME 2>&1 | sort >> $TS_OUTPUT
66 ts_log "create loop device from image"
67 DEVICE=$($TS_CMD_LOSETUP -s -f $IMAGE_PATH)
69 ts_log "check the image"
70 ts_device_has "TYPE" "cramfs" $DEVICE
71 [ "$?" == "0" ] || ts_die "Cannot found cramfs on $DEVICE" $DEVICE
73 ts_udev_dev_support "by-label" $LABEL
74 [ "$?" == "0" ] || ts_skip "udev ignores /dev/loop*" $DEVICE
76 ts_log "mount the image"
77 $TS_CMD_MOUNT -L $LABEL $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT
80 ts_is_mounted $DEVICE || ts_die "Cannot found $DEVICE in /proc/mounts" $DEVICE
84 ts_log "list the image"
85 ls -laR --time-style=long-iso . >> $TS_OUTPUT
88 ts_log "list checksums from new data"
89 find . -type f -exec md5sum {} \; | sort >> $TS_OUTPUT
94 ts_log "umount the image"
95 $TS_CMD_UMOUNT $DEVICE
96 $TS_CMD_LOSETUP -d $DEVICE 2>&1 >> $TS_OUTPUT