| 1 | #!/bin/bash |
| 2 | |
| 3 | # |
| 4 | # Copyright (C) 2007 Karel Zak <[email protected]> |
| 5 | # |
| 6 | # This file is part of util-linux. |
| 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="${0%/*}/../.." |
| 19 | TS_DESC="fsck endianness" |
| 20 | |
| 21 | . "$TS_TOPDIR"/functions.sh |
| 22 | ts_init "$*" |
| 23 | |
| 24 | ts_check_test_command "$TS_CMD_MKCRAMFS" |
| 25 | ts_check_test_command "$TS_CMD_FSCKCRAMFS" |
| 26 | ts_check_test_command "$TS_HELPER_MD5" |
| 27 | |
| 28 | ts_skip_nonroot |
| 29 | |
| 30 | IMAGE_LITTLE="$TS_SELF/cramfs-little.img" #Known good little endian image |
| 31 | IMAGE_BIG="$TS_SELF/cramfs-big.img" #Known good big endian image |
| 32 | |
| 33 | IMAGE_CREATED="$TS_OUTDIR/${TS_TESTNAME}-cramfs.img" #Image created during the test and compared against the known images. |
| 34 | IMAGE_DATA="$TS_OUTDIR/${TS_TESTNAME}-data" |
| 35 | |
| 36 | test_image() { |
| 37 | local FROM_ENDIANNESS="$1"; shift |
| 38 | local TO_ENDIANNESS="$1"; shift |
| 39 | local FROM_IMAGE="$1"; shift |
| 40 | |
| 41 | rm -rf "$IMAGE_DATA" |
| 42 | ts_log "extract from $FROM_ENDIANNESS endian" |
| 43 | $TS_CMD_FSCKCRAMFS -v -b 4096 --extract=$IMAGE_DATA $FROM_IMAGE | head -n1 | cut -d" " -f4 >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 44 | |
| 45 | ts_log "create $TO_ENDIANNESS endian" |
| 46 | $TS_CMD_MKCRAMFS -N "$TO_ENDIANNESS" -b 4096 "$IMAGE_DATA" \ |
| 47 | "$IMAGE_CREATED" >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 48 | |
| 49 | "$TS_HELPER_MD5" < "$IMAGE_CREATED" >> $TS_OUTPUT |
| 50 | |
| 51 | rm "$IMAGE_CREATED" |
| 52 | } |
| 53 | |
| 54 | test_image "little" "big" "$IMAGE_LITTLE" |
| 55 | test_image "big" "little" "$IMAGE_BIG" |
| 56 | |
| 57 | ts_finalize |
| 58 |