blob: d183f472f4d27c3fdae1bbbfd465651c96bdc1d0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#!/bin/bash
#
# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
#
# This file is part of util-linux-ng.
#
# 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.
#
# 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.
#
# Test cramfs
. commands.sh
. functions.sh
TS_COMPONENT="mkfs.cramfs"
TS_DESC="mkfs"
ts_init
ts_skip_nonroot
set -o pipefail
IMAGE="$TS_OUTDIR/cramfs-loop.img"
IMAGE_DATA="$TS_OUTDIR/cramfs-data"
IMAGE_RE=$( echo $IMAGE | sed 's:/:\\/:g' )
LABEL="testCramfs"
MOUNTPOINT="$TS_OUTDIR/cramfs-mnt"
echo "create mountpoint dir" >> $TS_OUTPUT
[ -d "$MOUNTPOINT" ] || mkdir -p $MOUNTPOINT
echo "generate data" >> $TS_OUTPUT
if [ ! -d "$IMAGE_DATA" ]; then
mkdir -p $IMAGE_DATA
for d in `seq 0 110`; do
DIRNAME="$IMAGE_DATA/$(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
echo "list checksums from original data" >> $TS_OUTPUT
find $IMAGE_DATA -type f -exec md5sum {} \; >> $TS_OUTPUT
echo >> $TS_OUTPUT
echo "create cramfs image" >> $TS_OUTPUT
$TS_CMD_MKCRAMFS -n $LABEL $IMAGE_DATA $IMAGE 2>&1 >> $TS_OUTPUT
[ -s "$IMAGE" ] || ts_die "Cannot create $IMAGE"
echo "count MD5 from the image" >> $TS_OUTPUT
md5sum $IMAGE 2>&1 >> $TS_OUTPUT
echo >> $TS_OUTPUT
echo "create loop device from image" >> $TS_OUTPUT
DEVICE=$( $TS_CMD_LOSETUP -f )
$TS_CMD_LOSETUP $DEVICE $IMAGE 2>&1 >> $TS_OUTPUT
echo "check the image" >> $TS_OUTPUT
ts_device_has "TYPE" "cramfs" $DEVICE
[ "$?" == "0" ] || ts_die "Cannot found cramfs on $DEVICE" $DEVICE
ts_udev_dev_support "by-label" $LABEL
[ "$?" == "0" ] || ts_skip "udev ignores /dev/loop*" $DEVICE
echo "mount the image" >> $TS_OUTPUT
$TS_CMD_MOUNT -L $LABEL $MOUNTPOINT 2>&1 >> $TS_OUTPUT
# check it
grep -q $DEVICE /proc/mounts
[ "$?" == "0" ] || ts_die "Cannot found $DEVICE in /proc/mounts" $DEVICE
echo "list the image" >> $TS_OUTPUT
ls -laR $MOUNTPOINT >> $TS_OUTPUT
echo >> $TS_OUTPUT
echo "list checksums from new data" >> $TS_OUTPUT
find $MOUNTPOINT -type f -exec md5sum {} \; >> $TS_OUTPUT
echo >> $TS_OUTPUT
echo "umount the image" >> $TS_OUTPUT
$TS_CMD_UMOUNT $DEVICE
$TS_CMD_LOSETUP -d $DEVICE 2>&1 >> $TS_OUTPUT
ts_finalize
|