blob: 90630ebf7c0ad187984066c5b60b506e31c99c17 (
plain)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#!/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="${0%/*}/../.."
TS_DESC="mkfs checksums"
. $TS_TOPDIR/functions.sh
ts_init "$*"
ts_check_test_command "$TS_CMD_MKCRAMFS"
ts_check_test_command "$TS_CMD_MOUNT"
ts_check_test_command "$TS_CMD_UMOUNT"
ts_check_test_command "$TS_CMD_BLKID"
ts_check_test_command "$TS_HELPER_MD5"
ts_check_test_command "$TS_HELPER_SYSINFO"
ts_skip_nonroot
ts_check_losetup
ORIGPWD=$(pwd)
IMAGE_NAME="${TS_TESTNAME}-loop.img"
IMAGE_PATH="$TS_OUTDIR/$IMAGE_NAME"
IMAGE_SRC="$TS_OUTDIR/${TS_TESTNAME}-data"
LABEL="testCramfs"
BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order)
PAGE_SIZE=$($TS_HELPER_SYSINFO pagesize)
case "${BYTE_ORDER}:${PAGE_SIZE}" in
LE:4096)
MD5_EXP="a6667acb1cb0685d9eb5b9cd3724766c" ;;
LE:16384 | LE:65536)
MD5_EXP="b60133682603b0118592b55f1dba017c" ;;
BE:4096)
MD5_EXP="eaf05031dc8ec97c91ba5c773635cc89" ;;
BE:8192 | BE:65536)
MD5_EXP="5859f87b185b1187fca3b2b00c809c03" ;;
*)
echo "warning ${TS_NS}: unknown checksum for ${BYTE_ORDER}:${PAGE_SIZE}"
MD5_EXP="unknown" ;;
esac
ts_log "create mountpoint dir"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
ts_log "generate data"
rm -rf "$IMAGE_SRC"
mkdir -m 755 -p $IMAGE_SRC
umask 133
for d in `seq 0 110`; do
DIRNAME="$IMAGE_SRC/$(printf "dir-%03d" $d)"
mkdir -m 755 $DIRNAME
for f in `seq 0 10`; do
FILENAME="$DIRNAME/$(printf "data.%03d" $f)"
printf "data in %03d-%03d" $d $f >> $FILENAME
done
done
chgrp -R 0 "$IMAGE_SRC"
ts_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 >> $TS_OUTPUT 2>> $TS_ERRLOG
[ -s "$IMAGE_PATH" ] || ts_die "Cannot create $IMAGE_PATH"
ts_cd "$TS_OUTDIR"
ts_log "count MD5 from the image"
MD5_OUT=$("$TS_HELPER_MD5" < "$IMAGE_NAME") >> $TS_OUTPUT 2>> $TS_ERRLOG
if [ "$MD5_EXP" != "$MD5_OUT" -a "$MD5_EXP" != "unknown" ]; then
ts_log "is $MD5_OUT, should be $MD5_EXP"
fi
echo >> $TS_OUTPUT
ts_log "create loop device from image"
DEVICE=$($TS_CMD_LOSETUP --show -f $IMAGE_PATH)
ts_register_loop_device "$DEVICE"
ts_log "check the image"
ts_device_has "TYPE" "cramfs" $DEVICE
[ "$?" == "0" ] || ts_die "Cannot find cramfs on $DEVICE"
ts_log "mount the image"
ts_mount "cramfs" -r -L $LABEL $TS_MOUNTPOINT
# check it
ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
ts_cd "$TS_MOUNTPOINT"
ts_log "list the image"
export TZ='GMT-1'
ls -laR --time-style=long-iso . | sed 's:\. : :g' >> $TS_OUTPUT
echo >> $TS_OUTPUT
ts_log "list checksums from new data"
find . -type f -exec md5sum {} \; | sort >> $TS_OUTPUT
echo >> $TS_OUTPUT
ts_cd "$ORIGPWD"
ts_log "umount the image"
ts_finalize
|