2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle. All Rights Reserved.
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
13 _begin_fstest auto quick admin
15 # Import common functions.
18 # real QA test starts here
21 _require_command "$XFS_ADMIN_PROG" "xfs_admin"
24 echo "$@" | tee -a $seqres.full
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?"
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?"
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?"
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?"
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?"
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?"
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"
64 _scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
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
73 echo "UUID = babababa-baba-baba-baba-babababababa"