fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 379
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. 379
6 #
7 # Check behavior of chown with both user and group quota enabled,
8 # and changing both user and group together via chown(2).
9 #
10 . ./common/preamble
11 _begin_fstest quota auto quick
12
13 # Import common functions.
14 . ./common/filter
15 . ./common/quota
16
17 # Override the default cleanup function.
18 _cleanup()
19 {
20         _scratch_unmount 2>/dev/null
21         rm -f $tmp.*
22 }
23
24 # real QA test starts here
25 _supported_fs generic
26
27 cp /dev/null $seqres.full
28 chmod ugo+rwx $seqres.full
29
30 _require_scratch
31 _require_quota
32 _require_xfs_quota_foreign
33
34 _filter_stat()
35 {
36     sed "
37         /^Access:/d;
38         /^Modify:/d;
39         /^Change:/d;
40         s/Device: *[0-9][0-9]*,[0-9][0-9]*/Device: <DEVICE>/;
41         s/Inode: *[0-9][0-9]*/Inode: <INODE>/;
42         s,$SCRATCH_MNT,<MOUNT>,;
43     " | tr -s ' '
44 }
45
46 _exercise()
47 {
48         _scratch_mkfs >/dev/null 2>&1
49         _qmount
50
51         umask 022
52         touch $SCRATCH_MNT/testfile
53         if $here/src/feature -c $SCRATCH_MNT/testfile; then
54                 :
55         else
56                 _notrun "Installed fileutils doesn't support 32 bit uids/gids"
57         fi
58
59         chown 12345 $SCRATCH_MNT/testfile
60         chgrp 54321 $SCRATCH_MNT/testfile
61         $here/src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
62
63         chown 34567 $SCRATCH_MNT/testfile
64         chgrp 76543 $SCRATCH_MNT/testfile
65         $here/src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
66
67         chown 56789 $SCRATCH_MNT/testfile
68         chgrp 98765 $SCRATCH_MNT/testfile
69         $here/src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
70
71         # finally give back to original owners
72         chown 12345 $SCRATCH_MNT/testfile
73         chgrp 54321 $SCRATCH_MNT/testfile
74         $here/src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
75
76         echo
77         _scratch_unmount 2>/dev/null
78 }
79
80 _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed!"
81
82 _qmount_option "usrquota,grpquota"
83 _qmount
84 if $here/src/feature -G $SCRATCH_DEV ; then
85         :
86 else
87         _notrun "No quota support at mount time"
88 fi
89 _scratch_unmount 2>/dev/null
90
91 _qmount_option "rw" # no quota options
92 echo "*** Default mount options"
93 _exercise
94
95 _qmount_option "usrquota"
96 echo "*** User quota mount option"
97 _exercise
98
99 _qmount_option "grpquota"
100 echo "*** Group quota mount option"
101 _exercise
102
103 _qmount_option "usrquota,grpquota"
104 echo "*** User and Group quota mount options"
105 _exercise
106
107 # success, all done
108 status=0
109 exit