xfstests: convert tests to use new results directory
[xfstests-dev.git] / tests / xfs / 296
1 #! /bin/bash
2 # FS QA Test No. 296
3 #
4 # Test that xfsdump/restore preserves file capabilities
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #-----------------------------------------------------------------------
22 #
23
24 seq=`basename $0`
25 seqres=$RESULT_DIR/$seq
26 seqres=$RESULT_DIR/$seq
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 _cleanup()
36 {
37     cd /
38     rm -f $tmp.*
39 }
40
41 # get standard environment, filters and checks
42 . ./common.rc
43 . ./common.filter
44 . ./common.dump
45
46 # real QA test starts here
47
48 # Modify as appropriate.
49 _supported_fs xfs
50 _supported_os Linux
51 _require_scratch
52
53 rm -f $seqres.full
54
55 _wipe_fs
56
57 mkdir -p $dump_dir
58 echo test > $dump_dir/testfile
59 # Set a generic xattr
60 setfattr -n user.name -v value $dump_dir/testfile
61 # Now set the cap (which is also an xattr)
62 setcap cap_setgid,cap_setuid+ep $dump_dir/testfile
63 # And make sure they are there on the source
64 echo "Checking for xattr on source file"
65 getfattr --absolute-names -m user.name $dump_dir/testfile | _dir_filter
66 echo "Checking for capability on source file"
67 getcap $dump_dir/testfile | _dir_filter
68 getfattr --absolute-names -m security.capability $dump_dir/testfile | _dir_filter
69
70 _do_dump_file -f $tmp.df.0
71 _prepare_restore_dir
72 _do_restore_file
73 # Basic dump/restore checks first - the file is there, right?
74 _ls_compare_sub
75 _diff_compare
76
77 echo "Checking for xattr on restored file"
78 getfattr --absolute-names -m user.name $restore_dir/$dump_sdir/testfile | _dir_filter
79 echo "Checking for capability on restored file"
80 getcap $restore_dir/$dump_sdir/testfile | _dir_filter
81 getfattr --absolute-names -m security.capability $restore_dir/$dump_sdir/testfile | _dir_filter
82
83 status=0
84 exit