configure: make use of LIBREPLACE_NETWORK_LIBS instead of redoing the tests
[Samba.git] / testsuite / nsswitch / getent.exp
blob72bf2ea1ebec60252c6b4f72aa8cdf66956ce7f3
2 # @(#) Test the getent command returns domain/local users and groups
5 load_lib util-defs.exp
6 load_lib compile.exp
7 load_lib $srcdir/lib/nsswitch-config.exp
10 # @(#) Test getent passwd returns domain users
13 set wbinfo_output [util_start "bin/wbinfo" "-u"]
14 set getent_output [util_start "getent" "passwd" ""]
16 if { ![regexp "$domain/" $getent_output] } {
17 fail "no domain users in getent passwd"
18 return
21 if { [regexp "Error" $wbinfo_output] } {
22 fail "wbinfo -u failed"
23 return
27 # @(#) Test each user in the output of wbinfo is also in the output of
28 # @(#) getent.
31 # Test wbinfo user names are in getent user names
33 foreach { user } [split $wbinfo_output "\n"] {
35 verbose "looking for $user"
37 set test_desc "getent passwd does not contain $user"
39 if { ![regexp "$user" $getent_output] } {
40 fail $test_desc
41 } else {
42 pass $test_desc
46 # Test getent user names are in wbinfo user names
48 foreach { user } [split $getent_output "\n"] {
50 set user_info [split $user ":"]
51 set username [lindex $user_info 0]
53 if { [regexp {^[^/]+/} $username] } {
55 set test_desc "wbinfo -u does not contain $username"
57 if { ![regexp "$username" $wbinfo_output] } {
58 fail $test_desc
59 } else {
60 pass $test_desc
62 } else {
63 verbose "ignoring non-domain user $username"
68 # @(#) Test each group in the output of wbinfo is also in the output of
69 # @(#) getent.
72 set wbinfo_output [util_start "bin/wbinfo" "-g"]
73 set getent_output [util_start "getent" "group" ""]
75 if { ![regexp "$domain/" $getent_output] } {
76 fail "no domain groups in getent passwd"
77 return
80 if { [regexp "Error" $wbinfo_output] } {
81 fail "wbinfo -g failed"
82 return
85 # Test wbinfo group names are in getent group names
87 foreach { group } [split $wbinfo_output "\n"] {
89 verbose "looking for $group"
91 set test_desc "getent group does not contain $group"
93 if { ![regexp "$group" $getent_output] } {
94 fail $test_desc
95 } else {
96 pass $test_desc
100 # Test getent group names are in wbinfo group names
102 foreach { group } [split $getent_output "\n"] {
104 set group_info [split $group ":"]
105 set groupname [lindex $group_info 0]
107 if { [regexp {^[^/]+/} $groupname] } {
109 set test_desc "wbinfo -g does not contain $groupname"
111 if { ![regexp "$groupname" $wbinfo_output] } {
112 fail $test_desc
113 } else {
114 pass $test_desc
116 } else {
117 verbose "ignoring non-domain group $groupname"
122 # @(#) Test out of order and repeat calls of pwent functions
123 # @(#) Test out of order and repeat calls of grent functions
126 set getent_tests [list \
127 { "out of order pwent operations" "getent_pwent" } \
128 { "out of order grent operations" "getent_grent" } \
131 # Compile and run each test
133 foreach { test } $getent_tests {
134 set test_desc [lindex $test 0]
135 set test_file [lindex $test 1]
137 simple_compile $test_file
138 set output [util_start "$srcdir/$subdir/$test_file" ]
140 if { [regexp "PASS" $output] } {
141 pass $test_desc
142 file delete "$srcdir/$subdir/$test_file" "$srcdir/$subdir/$test_file.o"
143 } else {
144 fail $test_desc
145 puts $output