| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# |
| 4 |
# This file is part of util-linux. |
| 5 |
# |
| 6 |
# This file is free software; you can redistribute it and/or modify |
| 7 |
# it under the terms of the GNU General Public License as published by |
| 8 |
# the Free Software Foundation; either version 2 of the License, or |
| 9 |
# (at your option) any later version. |
| 10 |
# |
| 11 |
# This file is distributed in the hope that it will be useful, |
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
# GNU General Public License for more details. |
| 15 |
# |
| 16 |
|
| 17 |
TS_TOPDIR="${0%/*}/../.." |
| 18 |
TS_DESC="invalid input tests" |
| 19 |
|
| 20 |
. "$TS_TOPDIR"/functions.sh |
| 21 |
ts_init "$*" |
| 22 |
|
| 23 |
ts_check_test_command "$TS_CMD_FDISK" |
| 24 |
ts_check_test_command "$TS_HELPER_MD5" |
| 25 |
ts_check_test_command "$TS_HELPER_STRERROR" |
| 26 |
|
| 27 |
#set -x |
| 28 |
|
| 29 |
ts_log "---Initialize empty image" |
| 30 |
TEST_IMAGE_NAME=$(ts_image_init 10) |
| 31 |
ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 32 |
|
| 33 |
# |
| 34 |
# Note that since 2.23 the DOS-mode has effect only if there is a MBR on the device. |
| 35 |
# |
| 36 |
|
| 37 |
ts_log "---Empty image listing" # this should report empty partition table |
| 38 |
# TEST_IMAGE_NAME has absolute path, and is by definition different on each computer, we need to sed it away |
| 39 |
$TS_CMD_FDISK -c=dos -u=cylinders -x ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 40 |
sed -i -e "s/${TEST_IMAGE_NAME//\//\\/}/testimage/" $TS_OUTPUT $TS_ERRLOG |
| 41 |
|
| 42 |
# |
| 43 |
# Errors |
| 44 |
# |
| 45 |
ts_logerr "---Nonexistent file" |
| 46 |
$TS_CMD_FDISK -c=dos -u=cylinders -x _a_file_that_does_not_exist_ >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 47 |
sed -i -e "s@$($TS_HELPER_STRERROR ENOENT)@ENOENT@" $TS_OUTPUT $TS_ERRLOG |
| 48 |
|
| 49 |
ts_logerr "---Too small file" |
| 50 |
echo "This file is too small" >> oddinput.toosmall |
| 51 |
$TS_CMD_FDISK -c=dos -u=cylinders -x oddinput.toosmall >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 52 |
sed -i -e "s@$($TS_HELPER_STRERROR EINVAL)@EINVAL@" $TS_OUTPUT $TS_ERRLOG |
| 53 |
rm oddinput.toosmall |
| 54 |
ts_finalize |