1 # $NetBSD: t_hostent.sh,v 1.2 2013/10/20 17:22:49 christos Exp $
3 # Copyright (c) 2008 The NetBSD Foundation, Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
28 n6
="sixthavenue.astron.com"
29 a6
="2620:106:3003:1f00:2e0:81ff:fe2f:e5d7"
30 ans6
="name=$n6, length=16, addrtype=24, aliases=[] addr_list=[$a6]\n"
32 n4
="sixthavenue.astron.com"
34 ans4
="name=$n4, length=4, addrtype=2, aliases=[] addr_list=[$a4]\n"
38 loc6
="name=$l6, length=16, addrtype=24, aliases=[localhost. localhost.localdomain.] addr_list=[$al6]\n"
42 loc4
="name=$l4, length=4, addrtype=2, aliases=[localhost. localhost.localdomain.] addr_list=[$al4]\n"
44 atf_test_case gethostbyname4
47 atf_set
"descr" "Checks gethostbyname2(3) for AF_INET (auto, as determined by nsswitch.conf(5)"
51 atf_check
-o inline
:"$ans4" -x "$(atf_get_srcdir)/h_hostent -t auto -4 $n4"
54 atf_test_case gethostbyname6
57 atf_set
"descr" "Checks gethostbyname2(3) for AF_INET6 (auto, as determined by nsswitch.conf(5)"
61 atf_check
-o inline
:"$ans6" -x "$(atf_get_srcdir)/h_hostent -t auto -6 $n6"
64 atf_test_case gethostbyaddr4
67 atf_set
"descr" "Checks gethostbyaddr(3) for AF_INET (auto, as determined by nsswitch.conf(5)"
71 atf_check
-o inline
:"$ans4" -x "$(atf_get_srcdir)/h_hostent -t auto -a $a4"
74 atf_test_case gethostbyaddr6
77 atf_set
"descr" "Checks gethostbyaddr(3) for AF_INET6 (auto, as determined by nsswitch.conf(5)"
81 atf_check
-o inline
:"$ans6" -x "$(atf_get_srcdir)/h_hostent -t auto -a $a6"
84 atf_test_case hostsbynamelookup4
85 hostsbynamelookup4_head
()
87 atf_set
"descr" "Checks /etc/hosts name lookup for AF_INET"
89 hostsbynamelookup4_body
()
91 local dir
=$
(atf_get_srcdir
)
92 atf_check
-o inline
:"$loc4" -x "$dir/h_hostent -f $dir/hosts -t file -4 $l4"
95 atf_test_case hostsbynamelookup6
96 hostsbynamelookup6_head
()
98 atf_set
"descr" "Checks /etc/hosts name lookup for AF_INET6"
100 hostsbynamelookup6_body
()
102 local dir
=$
(atf_get_srcdir
)
103 atf_check
-o inline
:"$loc6" -x "$dir/h_hostent -f $dir/hosts -t file -6 $l6"
106 atf_test_case hostsbyaddrlookup4
107 hostsbyaddrlookup4_head
()
109 atf_set
"descr" "Checks /etc/hosts address lookup for AF_INET"
111 hostsbyaddrlookup4_body
()
113 local dir
=$
(atf_get_srcdir
)
114 atf_check
-o inline
:"$loc4" -x "$dir/h_hostent -f $dir/hosts -t file -4 -a $al4"
117 atf_test_case hostsbyaddrlookup6
118 hostsbyaddrlookup6_head
()
120 atf_set
"descr" "Checks /etc/hosts address lookup for AF_INET6"
122 hostsbyaddrlookup6_body
()
124 local dir
=$
(atf_get_srcdir
)
125 atf_check
-o inline
:"$loc6" -x "$dir/h_hostent -f $dir/hosts -t file -6 -a $al6"
128 atf_test_case dnsbynamelookup4
129 dnsbynamelookup4_head
()
131 atf_set
"descr" "Checks DNS name lookup for AF_INET"
133 dnsbynamelookup4_body
()
135 local dir
=$
(atf_get_srcdir
)
136 atf_check
-o inline
:"$ans4" -x "$dir/h_hostent -t dns -4 $n4"
139 atf_test_case dnsbynamelookup6
140 dnsbynamelookup6_head
()
142 atf_set
"descr" "Checks DNS name lookup for AF_INET6"
144 dnsbynamelookup6_body
()
146 local dir
=$
(atf_get_srcdir
)
147 atf_check
-o inline
:"$ans6" -x "$dir/h_hostent -t dns -6 $n6"
150 atf_test_case dnsbyaddrlookup4
151 dnsbyaddrlookup4_head
()
153 atf_set
"descr" "Checks DNS address lookup for AF_INET"
155 dnsbyaddrlookup4_body
()
157 local dir
=$
(atf_get_srcdir
)
158 atf_check
-o inline
:"$ans4" -x "$dir/h_hostent -t dns -4 -a $a4"
161 atf_test_case dnsbyaddrlookup6
162 dnsbyaddrlookup6_head
()
164 atf_set
"descr" "Checks dns address lookup for AF_INET6"
166 dnsbyaddrlookup6_body
()
168 local dir
=$
(atf_get_srcdir
)
169 atf_check
-o inline
:"$ans6" -x "$dir/h_hostent -t dns -6 -a $a6"
172 atf_init_test_cases
()
174 atf_add_test_case gethostbyname4
175 atf_add_test_case gethostbyname6
176 atf_add_test_case gethostbyaddr4
177 atf_add_test_case gethostbyaddr6
179 atf_add_test_case hostsbynamelookup4
180 atf_add_test_case hostsbynamelookup6
181 atf_add_test_case hostsbyaddrlookup4
182 atf_add_test_case hostsbyaddrlookup6
184 atf_add_test_case dnsbynamelookup4
185 atf_add_test_case dnsbynamelookup6
186 atf_add_test_case dnsbyaddrlookup4
187 atf_add_test_case dnsbyaddrlookup6