diff options
Diffstat (limited to 'tests/ts/minix')
-rw-r--r-- | tests/ts/minix/broken-root | bin | 0 -> 5120 bytes | |||
-rw-r--r-- | tests/ts/minix/debian.bug.773892 | bin | 0 -> 16384 bytes | |||
-rwxr-xr-x | tests/ts/minix/fsck | 56 | ||||
-rwxr-xr-x | tests/ts/minix/fsck-images | 90 | ||||
-rwxr-xr-x | tests/ts/minix/mkfs | 57 |
5 files changed, 203 insertions, 0 deletions
diff --git a/tests/ts/minix/broken-root b/tests/ts/minix/broken-root Binary files differnew file mode 100644 index 0000000..37ee84e --- /dev/null +++ b/tests/ts/minix/broken-root diff --git a/tests/ts/minix/debian.bug.773892 b/tests/ts/minix/debian.bug.773892 Binary files differnew file mode 100644 index 0000000..db97848 --- /dev/null +++ b/tests/ts/minix/debian.bug.773892 diff --git a/tests/ts/minix/fsck b/tests/ts/minix/fsck new file mode 100755 index 0000000..21fbde8 --- /dev/null +++ b/tests/ts/minix/fsck @@ -0,0 +1,56 @@ +#!/bin/bash +# +# Copyright (C) 2009 Karel Zak <kzak@redhat.com> +# +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +TS_TOPDIR="${0%/*}/../.." +TS_DESC="mkfs fsck" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MKMINIX" +ts_check_test_command "$TS_CMD_FSCKMINIX" + +mkfs_and_fsck_minix() { + local ret + ts_log "#####################################" + ts_log "$ mkfs.minix $1 image" + $TS_CMD_MKMINIX $1 $img >> $TS_OUTPUT 2>&1 + ret=$? + echo "return mkfs: $ret" >> $TS_OUTPUT + test $ret = 0 || return $ret + + ts_log "$ fsck.minix -lavsf image" + $TS_CMD_FSCKMINIX -lavsf $img >> $TS_OUTPUT 2>&1 + ret=$? + echo "return fsck: $ret" >> $TS_OUTPUT + return $ret +} + +img=$(ts_image_init) + +# TODO looping over arbitrary badblock files (-l bad) gives a lot segfaults +for ver in "" "-1" "-2" "-3"; do +for n in "" "-n 14" "-n 30" "-n 60"; do + mkfs_and_fsck_minix "$ver $n" +done +done + +rm -f $img + +sed -i "s@$img@image@g" $TS_OUTPUT + +ts_finalize + diff --git a/tests/ts/minix/fsck-images b/tests/ts/minix/fsck-images new file mode 100755 index 0000000..0cfa760 --- /dev/null +++ b/tests/ts/minix/fsck-images @@ -0,0 +1,90 @@ +#!/bin/bash +# +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +TS_TOPDIR="${0%/*}/../.." +TS_DESC="fsck images" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +# inode contains UID and GID, use always UID=0 to get the same checksum +# TODO any mkfs should use UID=0 per default (custom uid optionally) like mk2fs +ts_skip_nonroot + +ts_check_test_command "$TS_CMD_FSCKMINIX" +ts_check_test_command "$TS_HELPER_MKFS_MINIX" +ts_check_test_command "$TS_CMD_HEXDUMP" + +# on big endian systems some of the subtests have different expected output +BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order) +BE_EXT=$(test "$BYTE_ORDER" = "BE" && echo ".BE") + +export MKFS_MINIX_TEST_SECOND_SINCE_EPOCH='1438460212' + +check_minix_fs_type() { + ts_init_subtest $1 + TS_EXPECTED+=$BE_EXT + img=${TS_OUTPUT}.img + dd if=/dev/zero bs=1024 count=16 of=$img >/dev/null 2>&1 + $TS_HELPER_MKFS_MINIX $2 $img >> $TS_OUTPUT 2>&1 + echo "mkfs return value: $?" >> $TS_OUTPUT + $TS_CMD_FSCKMINIX $img >> $TS_OUTPUT 2>&1 + echo "fsck return value: $?" >> $TS_OUTPUT + $TS_CMD_HEXDUMP -C $img >> $TS_OUTPUT 2>&1 + rm -f $img + ts_finalize_subtest +} + +check_minix_fs_type 'v1c14' '-1 -n 14' +check_minix_fs_type 'v1c30' '-1 -n 30' +check_minix_fs_type 'v2c14' '-2 -n 14' +check_minix_fs_type 'v2c30' '-2 -n 30' +check_minix_fs_type 'v3c60' '-3 -n 60' + +bad="$TS_OUTDIR/${TS_TESTNAME}.badlist" +# TODO seems that mkfs produces non-sense if badblocks are greater than device. +echo -e "8\n9" > $bad + +# NOTE, -c with -l ignores -l. +check_minix_fs_type 'check-blocks' "-l $bad -c" +check_minix_fs_type 'badblocks' "-l $bad" + +rm -f $bad + +# no more big endian tests below +if test "$BYTE_ORDER" = "BE"; then + ts_finalize +fi + +# NOTE this seems odd: a 2nd fsck run would again modify the FS +ts_init_subtest "auto-fix" +img=${TS_OUTPUT}.img +cp "$TS_SELF/broken-root" $img +$TS_CMD_FSCKMINIX -sav $img >> $TS_OUTPUT 2>&1 +echo "fsck reports changed and uncorrected: $?" >> $TS_OUTPUT +$TS_CMD_HEXDUMP -C $img >> $TS_OUTPUT 2>&1 +sed -i 's/Filesystem on .* is dirty/Filesystem auto-fix is dirty/' $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "bug.773892" +"$TS_CMD_FSCKMINIX" -f "$TS_SELF/debian.bug.773892" >>$TS_OUTPUT 2>&1 >/dev/null +echo "fsck reports uncorrected: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "broken-root" +"$TS_CMD_FSCKMINIX" "$TS_SELF/broken-root" > $TS_OUTPUT 2>&1 +echo "fsck reports uncorrected: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/minix/mkfs b/tests/ts/minix/mkfs new file mode 100755 index 0000000..6c3a002 --- /dev/null +++ b/tests/ts/minix/mkfs @@ -0,0 +1,57 @@ +#!/bin/bash +# +# Copyright (C) 2009 Karel Zak <kzak@redhat.com> +# +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +TS_TOPDIR="${0%/*}/../.." +TS_DESC="mkfs mount" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MKMINIX" +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_skip_nonroot + +ts_scsi_debug_init dev_size_mb=10 num_parts=1 +dev=${TS_DEVICE}1 + +# hotfix, wait for partition to appear (slow on Debian 7/linux-3.2) +test -b $dev || sleep 1 + +mkfs_and_mount_minix() { + ts_init_subtest $1 + ts_log "create minix fs $2" + $TS_CMD_MKMINIX $2 $dev >> $TS_OUTPUT 2>&1 + echo "mkfs return value: $?" >> $TS_OUTPUT + udevadm settle + [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + ts_mount "minix" $dev $TS_MOUNTPOINT + ts_is_mounted $dev || ts_die "Cannot find $dev in /proc/mounts" + ts_log "umount the image" + udevadm settle + $TS_CMD_UMOUNT $dev + ts_finalize_subtest +} + +mkfs_and_mount_minix 'v1c14' '-1 -n 14' +mkfs_and_mount_minix 'v1c30' '-1 -n 30' +mkfs_and_mount_minix 'v2c14' '-2 -n 14' +mkfs_and_mount_minix 'v2c30' '-2 -n 30' +mkfs_and_mount_minix 'v2i65535' '-2 -i 65535' +mkfs_and_mount_minix 'v3c60' '-3 -n 60' + +ts_finalize + |