1 #
2 # CDDL HEADER START
3 #
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
7 #
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
12 #
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 #
19 # CDDL HEADER END
20 #
21
22 #
23 # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
25 #
26 # TCL procedure for ACCESS operation testing
27
28 set DEBUG $env(DEBUG)
29
30 #---------------------------------------------------------
31 # Test procedure to verify ACCESS bit masks
32 # Usage: ckaccess access_list explist continue-flag prn-pass
33 # acl: the access_list to be checked
34 # exp: the expected access bit to check against the list
35 # cont: continue-flag (true|false) if we should continue
36 # prn: flag to indication if PASS message should be printed
37 #
38 # Return:
39 # true: if all expected bits match
40 # false: if the access_list do not match the ck_bits
41 #
42 proc ckaccess {acl exp cont prn} {
43 global DEBUG
44
45 # stop the verification if 'continue-flag' is FALSE
46 if {[string equal $cont "false"]} { return false }
47
48 # parse the access_list list
49 set nomatch ""
50 set aclist [split $acl ","]
51 foreach b [split $exp ""] {
52 if {"$b" == "r"} {
53 if {[lsearch -exact $aclist "READ"] == -1} {
54 set nomatch [append $nomatch "r"]
55 }
56 } elseif {"$b" == "l"} {
57 if {[lsearch -exact $aclist "LOOKUP"] == -1} {
58 set nomatch [append $nomatch l]
59 }
60 } elseif {"$b" == "m"} {
61 if {[lsearch -exact $aclist "MODIFY"] == -1} {
62 set nomatch [append $nomatch m]
63 }
64 } elseif {"$b" == "t"} {
65 if {[lsearch -exact $aclist "EXTEND"] == -1} {
66 set nomatch [append $nomatch t]
67 }
68 } elseif {"$b" == "d"} {
69 if {[lsearch -exact $aclist "DELETE"] == -1} {
70 set nomatch [append $nomatch d]
71 }
72 } elseif {"$b" == "x"} {
73 if {[lsearch -exact $aclist "EXECUTE"] == -1} {
74 set nomatch [append $nomatch x]
75 }
76 } else {
77 putmsg stderr 0 "\t Test UNRESOLVED: invalid expect bits ($exp)."
78 putmsg stderr 1 "\t acl=($acl)"
79 putmsg stderr 1 " "
80 return false
81 }
82 }
83 if {$nomatch != ""} {
84 putmsg stderr 0 "\t Test FAIL: \[$nomatch\] bit(s) has no match"
85 putmsg stderr 1 "\t acl=($acl)"
86 putmsg stderr 1 "\t exp=($exp)"
87 putmsg stderr 1 " "
88 return false
89 }
90 if {$prn == 0} {
91 putmsg stdout 0 "\t Test PASS"
92 }
93 return true
94 }
95