fstests: move test group info to test files
[xfstests-dev.git] / tests / shared / 032
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 032
6 #
7 # cross check mkfs detection of foreign filesystems
8 #
9 . ./common/preamble
10 _begin_fstest mkfs auto quick
11
12 # Import common functions.
13 . ./common/filter
14
15 # real QA test starts here
16 _supported_fs xfs btrfs
17
18 _require_scratch_nocheck
19 _require_no_large_scratch_dev
20
21 # mkfs.btrfs did not have overwrite detection at first
22 if [ "$FSTYP" == "btrfs" ]; then
23         grep -q 'force overwrite' `echo $MKFS_BTRFS_PROG | awk '{print $1}'` || \
24                 _notrun "Installed mkfs.btrfs does not support -f option"
25 fi
26
27 echo "Silence is golden."
28 for fs in `echo ${MKFS_PROG}.* | sed -e "s:${MKFS_PROG}.::g"`
29 do
30         preop=""        # for special input needs
31         preargs=""      # for any special pre-device options
32         postargs=""     # for any special post-device options
33
34         # minix, msdos and vfat mkfs fails for large devices, restrict to 2000 blocks
35         [ $fs = minix ] && postargs=2000
36         [ $fs = msdos ] && postargs=2000
37         [ $fs = vfat ] && postargs=2000
38         # these folks prompt before writing
39         [ $fs = jfs ] && preop="echo Y |"
40         [ $fs = gfs ] && preop="echo y |" && preargs="-p lock_nolock -j 1"
41         [ $fs = gfs2 ] && preop="echo y |" && preargs="-p lock_nolock -j 1"
42         [ $fs = reiserfs ] && preop="echo y |" && preargs="-f"
43         [ $fs = reiser4 ] && preop="echo y |" && preargs="-f"
44         # cramfs mkfs requires a directory argument
45         [ $fs = cramfs ] && preargs=/proc/fs
46         [ $fs = ext2 ] && preargs="-F"
47         [ $fs = ext3 ] && preargs="-F"
48         [ $fs = ext4 ] && preargs="-F"
49         [ $fs = ext4dev ] && preargs="-F"
50         # jffs2 mkfs requires '-r $directory' and '-o $image'
51         [ $fs = jffs2 ] && preargs="-r /proc/fs -o"
52
53         # overwite the first few Kb - should blow away superblocks
54         $here/src/devzero -n 20 $SCRATCH_DEV >/dev/null
55
56         # create a filesystem of this type
57         echo "=== Creating $fs filesystem..." >>$seqres.full
58         echo "    ( $preop mkfs -t $fs $preargs $SCRATCH_DEV $postargs )" >>$seqres.full
59         eval $preop mkfs -t $fs $preargs $SCRATCH_DEV $postargs >>$seqres.full 2>&1
60
61         if [ $? -eq 0 ] ; then
62                 # next, ensure we don't overwrite it
63                 # jffs2 mkfs doesn't check overwrite case
64                 [ $fs = jffs2 ] && continue
65
66                 echo "=== Attempting $FSTYP overwrite of $fs..." >>$seqres.full
67                 ${MKFS_PROG} -t $FSTYP $SCRATCH_DEV >>$seqres.full 2>&1
68
69                 [ $? -eq 0 ] && echo "Failed - overwrote fs type ${fs}!"
70         else
71                 echo "mkfs of type ${fs} failed" >>$seqres.full
72         fi
73 done
74
75 # success, all done
76 status=0
77 exit