Upload Tizen:Base source
[framework/base/util-linux-ng.git] / tests / ts / cramfs / mkfs-endianness
1 #!/bin/bash
2
3 #
4 # Copyright (C) 2007 Karel Zak <kzak@redhat.com>
5 #
6 # This file is part of util-linux-ng.
7 #
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.
12 #
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.
17 #
18 TS_TOPDIR="$(dirname $0)/../.."
19 TS_DESC="mkfs endianness"
20
21 . $TS_TOPDIR/functions.sh
22 ts_init "$*"
23 ts_skip_nonroot
24
25 set -o pipefail
26
27 IMAGE_DATA="$TS_OUTDIR/${TS_TESTNAME}-data"
28 IMAGE_CREATED="$TS_OUTDIR/${TS_TESTNAME}-cramfs.img"    #Image created during the test and compared against the known images.
29
30 test_image() {
31         local TO_ENDIANNESS="$1"; shift
32         ts_log "create $TO_ENDIANNESS endian"
33
34         $TS_CMD_MKCRAMFS -N "$TO_ENDIANNESS" "$IMAGE_DATA" "$IMAGE_CREATED" 2>&1 >> $TS_OUTPUT
35
36         md5sum $IMAGE_CREATED | cut -d" " -f1 >> $TS_OUTPUT
37
38         rm "$IMAGE_CREATED"
39 }
40
41 #generate test data
42 mkdir -p $IMAGE_DATA/dirA/dirB
43 yes "Testing cramfs 1234567890 Endianness check 1234567890 Endianness check" \
44         | dd of=$IMAGE_DATA/dirA/dirB/a bs=512 count=1 &> /dev/null
45 yes "Testing cramfs 1234567890 Endianness check 1234567890 Endianness check" \
46         | dd of=$IMAGE_DATA/dirA/dirB/b bs=512 count=30 &> /dev/null
47
48 #perform tests for both endians
49 test_image "little"
50 test_image "big"
51
52 ts_finalize
53