tests: (fdisk) avoid hardcoding of errno string
The test fdisk/oddinput hardcodes strings returned by strerror(3P) for both the errors ENOENT and ENOTTY. As these strings are unportable, convert the tests to use the test_strerror helper instead to convert them with sed(1). Signed-off-by: Patrick Steinhardt <ps@pks.im>
This commit is contained in:
parent
f612c4c674
commit
2ede7ec214
|
@ -6,6 +6,6 @@ Units: cylinders of 16065 * 512 = 8225280 bytes
|
||||||
Sector size (logical/physical): 512 bytes / 512 bytes
|
Sector size (logical/physical): 512 bytes / 512 bytes
|
||||||
I/O size (minimum/optimal): 512 bytes / 512 bytes
|
I/O size (minimum/optimal): 512 bytes / 512 bytes
|
||||||
Nonexistent file
|
Nonexistent file
|
||||||
fdisk: cannot open _a_file_that_does_not_exist_: No such file or directory
|
fdisk: cannot open _a_file_that_does_not_exist_: ENOENT
|
||||||
Too small file
|
Too small file
|
||||||
fdisk: cannot open oddinput.toosmall: Inappropriate ioctl for device
|
fdisk: cannot open oddinput.toosmall: ENOTTY
|
||||||
|
|
|
@ -18,6 +18,8 @@ static struct {
|
||||||
const char *str;
|
const char *str;
|
||||||
int error;
|
int error;
|
||||||
} errors[] = {
|
} errors[] = {
|
||||||
|
E(ENOENT),
|
||||||
|
E(ENOTTY),
|
||||||
E(EILSEQ)
|
E(EILSEQ)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,12 @@ ts_log "Empty image listing" # this should report empty partition table
|
||||||
$TS_CMD_FDISK -c=dos -u=cylinders -l ${TEST_IMAGE_NAME} 2>&1 | sed -e "s/${TEST_IMAGE_NAME//\//\\/}/testimage/" >> $TS_OUTPUT
|
$TS_CMD_FDISK -c=dos -u=cylinders -l ${TEST_IMAGE_NAME} 2>&1 | sed -e "s/${TEST_IMAGE_NAME//\//\\/}/testimage/" >> $TS_OUTPUT
|
||||||
|
|
||||||
ts_log "Nonexistent file" # this originally does absolutely nothing
|
ts_log "Nonexistent file" # this originally does absolutely nothing
|
||||||
$TS_CMD_FDISK -c=dos -u=cylinders -l _a_file_that_does_not_exist_ >> $TS_OUTPUT 2>&1
|
$TS_CMD_FDISK -c=dos -u=cylinders -l _a_file_that_does_not_exist_ 2>&1 |
|
||||||
|
sed -e "s@$($TS_HELPER_STRERROR ENOENT)@ENOENT@" >> $TS_OUTPUT
|
||||||
|
|
||||||
ts_log "Too small file" # same here
|
ts_log "Too small file" # same here
|
||||||
echo "This file is too small" >> oddinput.toosmall
|
echo "This file is too small" >> oddinput.toosmall
|
||||||
$TS_CMD_FDISK -c=dos -u=cylinders -l oddinput.toosmall >> $TS_OUTPUT 2>&1
|
$TS_CMD_FDISK -c=dos -u=cylinders -l oddinput.toosmall 2>&1 |
|
||||||
|
sed -e "s@$($TS_HELPER_STRERROR ENOTTY)@ENOTTY@" >> $TS_OUTPUT
|
||||||
rm oddinput.toosmall
|
rm oddinput.toosmall
|
||||||
ts_finalize
|
ts_finalize
|
||||||
|
|
Loading…
Reference in New Issue