Print this page
7290 ZFS test suite needs to control what utilities it can run
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/test/zfs-tests/tests/functional/xattr/xattr_common.kshlib
+++ new/usr/src/test/zfs-tests/tests/functional/xattr/xattr_common.kshlib
1 1 #
2 2 # CDDL HEADER START
3 3 #
4 4 # The contents of this file are subject to the terms of the
5 5 # Common Development and Distribution License (the "License").
6 6 # You may not use this file except in compliance with the License.
7 7 #
8 8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 # or http://www.opensolaris.org/os/licensing.
10 10 # See the License for the specific language governing permissions
11 11 # and limitations under the License.
12 12 #
13 13 # When distributing Covered Code, include this CDDL HEADER in each
14 14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 # If applicable, add the following below this CDDL HEADER, with the
16 16 # fields enclosed by brackets "[]" replaced with your own identifying
17 17 # information: Portions Copyright [yyyy] [name of copyright owner]
|
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
18 18 #
19 19 # CDDL HEADER END
20 20 #
21 21
22 22 #
23 23 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 24 # Use is subject to license terms.
25 25 #
26 26
27 27 #
28 -# Copyright (c) 2013 by Delphix. All rights reserved.
28 +# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
29 29 #
30 30
31 31 . $STF_SUITE/include/libtest.shlib
32 32
33 33 # a function that takes a file, then creates and verifies
34 34 # an xattr on that file. The xattr_contents is the file
35 35 # that should appear in the xattr namespace.
36 36 function create_xattr { # filename xattr_name xattr_contents
37 37 typeset FILE=$1
38 38 typeset XATTR_NAME=$2
39 39 typeset XATTR_CONTENTS=$3
40 40
41 41 # read any empty xattr on that file
42 - log_must $RUNAT $FILE $LS
42 + log_must runat $FILE ls
43 43 # create the xattr
44 - log_must $RUNAT $FILE $CP $XATTR_CONTENTS $XATTR_NAME
44 + log_must runat $FILE cp $XATTR_CONTENTS $XATTR_NAME
45 45
46 46 verify_xattr $FILE $XATTR_NAME $XATTR_CONTENTS
47 47 }
48 48
49 49 # a function that compares the a single xattr between two files
50 50 # and checks to see if their contents are identical
51 51 function compare_xattrs { # filename1 filename2 xattr_name
52 52 typeset FILE1=$1
53 53 typeset FILE2=$2
54 54 typeset XATTR_NAME=$3
55 55
56 - $RUNAT $FILE1 $CAT $XATTR_NAME > /tmp/file1.$$
57 - $RUNAT $FILE2 $CAT $XATTR_NAME > /tmp/file2.$$
56 + runat $FILE1 cat $XATTR_NAME > /tmp/file1.$$
57 + runat $FILE2 cat $XATTR_NAME > /tmp/file2.$$
58 58
59 - log_must $DIFF /tmp/file1.$$ /tmp/file2.$$
60 - log_must $RM /tmp/file1.$$ /tmp/file2.$$
59 + log_must diff /tmp/file1.$$ /tmp/file2.$$
60 + log_must rm /tmp/file1.$$ /tmp/file2.$$
61 61 }
62 62
63 63 function verify_xattr { # filename xattr_name xattr_contents
64 64 typeset FILE=$1
65 65 typeset XATTR_NAME=$2
66 66 typeset XATTR_CONTENTS=$3
67 67
68 68 # read the xattr, writing it to a temp file
69 - log_must eval "$RUNAT $FILE $CAT $XATTR_NAME > /tmp/$XATTR_NAME.$$ 2>&1"
70 - log_must $DIFF $XATTR_CONTENTS /tmp/$XATTR_NAME.$$
71 - $RM /tmp/$XATTR_NAME.$$
69 + log_must eval "runat $FILE cat $XATTR_NAME > /tmp/$XATTR_NAME.$$ 2>&1"
70 + log_must diff $XATTR_CONTENTS /tmp/$XATTR_NAME.$$
71 + rm /tmp/$XATTR_NAME.$$
72 72 }
73 73
74 74 function delete_xattr { # filename xattr_name
75 75 typeset FILE=$1
76 76 typeset XATTR_NAME=$2
77 77
78 78 # delete the xattr
79 - log_must $RUNAT $FILE $RM $XATTR_NAME
80 - log_mustnot eval "$RUNAT $FILE $LS $XATTR_NAME > /dev/null 2>&1"
79 + log_must runat $FILE rm $XATTR_NAME
80 + log_mustnot eval "runat $FILE ls $XATTR_NAME > /dev/null 2>&1"
81 81 }
82 82
83 83 # not sure about this : really this should be testing write/append
84 84 function verify_write_xattr { # filename xattr_name
85 85 typeset FILE=$1
86 86 typeset XATTR_NAME=$2
87 87
88 - log_must eval "$RUNAT $FILE $DD if=/etc/passwd of=$XATTR_NAME"
89 - log_must eval "$RUNAT $FILE $CAT $XATTR_NAME > /tmp/$XATTR_NAME.$$ 2>&1"
90 - log_must $DD if=/etc/passwd of=/tmp/passwd_dd.$$
91 - log_must $DIFF /tmp/passwd_dd.$$ /tmp/$XATTR_NAME.$$
92 - log_must $RM /tmp/passwd_dd.$$ /tmp/$XATTR_NAME.$$
88 + log_must eval "runat $FILE dd if=/etc/passwd of=$XATTR_NAME"
89 + log_must eval "runat $FILE cat $XATTR_NAME > /tmp/$XATTR_NAME.$$ 2>&1"
90 + log_must dd if=/etc/passwd of=/tmp/passwd_dd.$$
91 + log_must diff /tmp/passwd_dd.$$ /tmp/$XATTR_NAME.$$
92 + log_must rm /tmp/passwd_dd.$$ /tmp/$XATTR_NAME.$$
93 93 }
94 94
95 95 # this function is to create the expected output
96 96 function create_expected_output { # expected_output_file contents_of_the_output
97 97 typeset FILE=$1
98 98 shift
99 99 if [[ -f $FILE ]]; then
100 - log_must $RM $FILE
100 + log_must rm $FILE
101 101 fi
102 102
103 103 for line in $@
104 104 do
105 - log_must eval "$ECHO $line >> $FILE"
105 + log_must eval "echo $line >> $FILE"
106 106 done
107 107 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX