xfs/530: skip test if user MKFS_OPTIONS screw up formatting
[xfstests-dev.git] / tests / xfs / 156
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test No. 156
6 #
7 # Functional testing for xfs_admin to make sure that it handles option parsing
8 # correctly for functionality that's relevant to V5 filesystems.  It doesn't
9 # test the options that apply only to V4 filesystems because that disk format
10 # is deprecated.
11
12 . ./common/preamble
13 _begin_fstest auto quick admin
14
15 # Import common functions.
16 . ./common/filter
17
18 # real QA test starts here
19 _supported_fs xfs
20 _require_scratch
21 _require_command "$XFS_ADMIN_PROG" "xfs_admin"
22
23 note() {
24         echo "$@" | tee -a $seqres.full
25 }
26
27 note "S0: Initialize filesystem"
28 _scratch_mkfs -L origlabel -m uuid=babababa-baba-baba-baba-babababababa >> $seqres.full
29 _scratch_xfs_db -c label -c uuid
30 _scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
31
32 note "S1: Set a filesystem label"
33 _scratch_xfs_admin -L newlabel >> $seqres.full
34 _scratch_xfs_db -c label
35 _scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
36
37 note "S2: Clear filesystem label"
38 _scratch_xfs_admin -L -- >> $seqres.full
39 _scratch_xfs_db -c label
40 _scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
41
42 note "S3: Try to set oversized label"
43 _scratch_xfs_admin -L thisismuchtoolongforxfstohandle >> $seqres.full
44 _scratch_xfs_db -c label
45 _scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
46
47 note "S4: Set filesystem UUID"
48 _scratch_xfs_admin -U deaddead-dead-dead-dead-deaddeaddead >> $seqres.full
49 _scratch_xfs_db -c uuid
50 _scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
51
52 note "S5: Zero out filesystem UUID"
53 _scratch_xfs_admin -U nil >> $seqres.full
54 _scratch_xfs_db -c uuid
55 _scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
56
57 note "S6: Randomize filesystem UUID"
58 old_uuid="$(_scratch_xfs_db -c uuid)"
59 _scratch_xfs_admin -U generate >> $seqres.full
60 new_uuid="$(_scratch_xfs_db -c uuid)"
61 if [ "$new_uuid" = "$old_uuid" ]; then
62         echo "UUID randomization failed? $old_uuid == $new_uuid"
63 fi
64 _scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
65
66 note "S7: Restore original filesystem UUID"
67 if _check_scratch_xfs_features V5 >/dev/null; then
68         # Only V5 supports the metauuid feature that enables us to restore the
69         # original UUID after a change.
70         _scratch_xfs_admin -U restore >> $seqres.full
71         _scratch_xfs_db -c uuid
72 else
73         echo "UUID = babababa-baba-baba-baba-babababababa"
74 fi
75
76 # success, all done
77 status=0
78 exit