| 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="mkfs 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_HEXDUMP" |
| 26 | |
| 27 | ts_skip_nonroot |
| 28 | |
| 29 | IMAGE_DATA="$TS_OUTDIR/${TS_TESTNAME}-data" |
| 30 | IMAGE_CREATED="$TS_OUTDIR/${TS_TESTNAME}-cramfs.img" #Image created during the test and compared against the known images. |
| 31 | |
| 32 | umask 133 |
| 33 | |
| 34 | test_image() { |
| 35 | local TO_ENDIANNESS="$1"; shift |
| 36 | ts_log "create $TO_ENDIANNESS endian" |
| 37 | |
| 38 | $TS_CMD_MKCRAMFS -N "$TO_ENDIANNESS" -b 4096 "$IMAGE_DATA" \ |
| 39 | "$IMAGE_CREATED" >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 40 | |
| 41 | $TS_CMD_HEXDUMP -C $IMAGE_CREATED >> $TS_OUTPUT |
| 42 | |
| 43 | rm "$IMAGE_CREATED" |
| 44 | } |
| 45 | |
| 46 | #generate test data, must be owner root |
| 47 | rm -rf "$IMAGE_DATA" |
| 48 | mkdir -m 755 $IMAGE_DATA |
| 49 | mkdir -m 755 $IMAGE_DATA/dirA |
| 50 | mkdir -m 755 $IMAGE_DATA/dirA/dirB |
| 51 | |
| 52 | cp $TS_SELF/mkfs-endianness_testdata_a $IMAGE_DATA/dirA/dirB/a |
| 53 | cp $TS_SELF/mkfs-endianness_testdata_b $IMAGE_DATA/dirA/dirB/b |
| 54 | |
| 55 | # sudo may use whatever group |
| 56 | chgrp -R 0 $IMAGE_DATA |
| 57 | |
| 58 | #perform tests for both endians |
| 59 | test_image "little" |
| 60 | test_image "big" |
| 61 | |
| 62 | ts_finalize |
| 63 |