1# $NetBSD: t_hostent.sh,v 1.2 2013/10/20 17:22:49 christos Exp $ 2# 3# Copyright (c) 2008 The NetBSD Foundation, Inc. 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 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. 14# 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. 26# 27 28n6="sixthavenue.astron.com" 29a6="2620:106:3003:1f00:2e0:81ff:fe2f:e5d7" 30ans6="name=$n6, length=16, addrtype=24, aliases=[] addr_list=[$a6]\n" 31 32n4="sixthavenue.astron.com" 33a4="38.117.134.6" 34ans4="name=$n4, length=4, addrtype=2, aliases=[] addr_list=[$a4]\n" 35 36l6="localhost" 37al6="::1" 38loc6="name=$l6, length=16, addrtype=24, aliases=[localhost. localhost.localdomain.] addr_list=[$al6]\n" 39 40l4="localhost" 41al4="127.0.0.1" 42loc4="name=$l4, length=4, addrtype=2, aliases=[localhost. localhost.localdomain.] addr_list=[$al4]\n" 43 44atf_test_case gethostbyname4 45gethostbyname4_head() 46{ 47 atf_set "descr" "Checks gethostbyname2(3) for AF_INET (auto, as determined by nsswitch.conf(5)" 48} 49gethostbyname4_body() 50{ 51 atf_check -o inline:"$ans4" -x "$(atf_get_srcdir)/h_hostent -t auto -4 $n4" 52} 53 54atf_test_case gethostbyname6 55gethostbyname6_head() 56{ 57 atf_set "descr" "Checks gethostbyname2(3) for AF_INET6 (auto, as determined by nsswitch.conf(5)" 58} 59gethostbyname6_body() 60{ 61 atf_check -o inline:"$ans6" -x "$(atf_get_srcdir)/h_hostent -t auto -6 $n6" 62} 63 64atf_test_case gethostbyaddr4 65gethostbyaddr4_head() 66{ 67 atf_set "descr" "Checks gethostbyaddr(3) for AF_INET (auto, as determined by nsswitch.conf(5)" 68} 69gethostbyaddr4_body() 70{ 71 atf_check -o inline:"$ans4" -x "$(atf_get_srcdir)/h_hostent -t auto -a $a4" 72} 73 74atf_test_case gethostbyaddr6 75gethostbyaddr6_head() 76{ 77 atf_set "descr" "Checks gethostbyaddr(3) for AF_INET6 (auto, as determined by nsswitch.conf(5)" 78} 79gethostbyaddr6_body() 80{ 81 atf_check -o inline:"$ans6" -x "$(atf_get_srcdir)/h_hostent -t auto -a $a6" 82} 83 84atf_test_case hostsbynamelookup4 85hostsbynamelookup4_head() 86{ 87 atf_set "descr" "Checks /etc/hosts name lookup for AF_INET" 88} 89hostsbynamelookup4_body() 90{ 91 local dir=$(atf_get_srcdir) 92 atf_check -o inline:"$loc4" -x "$dir/h_hostent -f $dir/hosts -t file -4 $l4" 93} 94 95atf_test_case hostsbynamelookup6 96hostsbynamelookup6_head() 97{ 98 atf_set "descr" "Checks /etc/hosts name lookup for AF_INET6" 99} 100hostsbynamelookup6_body() 101{ 102 local dir=$(atf_get_srcdir) 103 atf_check -o inline:"$loc6" -x "$dir/h_hostent -f $dir/hosts -t file -6 $l6" 104} 105 106atf_test_case hostsbyaddrlookup4 107hostsbyaddrlookup4_head() 108{ 109 atf_set "descr" "Checks /etc/hosts address lookup for AF_INET" 110} 111hostsbyaddrlookup4_body() 112{ 113 local dir=$(atf_get_srcdir) 114 atf_check -o inline:"$loc4" -x "$dir/h_hostent -f $dir/hosts -t file -4 -a $al4" 115} 116 117atf_test_case hostsbyaddrlookup6 118hostsbyaddrlookup6_head() 119{ 120 atf_set "descr" "Checks /etc/hosts address lookup for AF_INET6" 121} 122hostsbyaddrlookup6_body() 123{ 124 local dir=$(atf_get_srcdir) 125 atf_check -o inline:"$loc6" -x "$dir/h_hostent -f $dir/hosts -t file -6 -a $al6" 126} 127 128atf_test_case dnsbynamelookup4 129dnsbynamelookup4_head() 130{ 131 atf_set "descr" "Checks DNS name lookup for AF_INET" 132} 133dnsbynamelookup4_body() 134{ 135 local dir=$(atf_get_srcdir) 136 atf_check -o inline:"$ans4" -x "$dir/h_hostent -t dns -4 $n4" 137} 138 139atf_test_case dnsbynamelookup6 140dnsbynamelookup6_head() 141{ 142 atf_set "descr" "Checks DNS name lookup for AF_INET6" 143} 144dnsbynamelookup6_body() 145{ 146 local dir=$(atf_get_srcdir) 147 atf_check -o inline:"$ans6" -x "$dir/h_hostent -t dns -6 $n6" 148} 149 150atf_test_case dnsbyaddrlookup4 151dnsbyaddrlookup4_head() 152{ 153 atf_set "descr" "Checks DNS address lookup for AF_INET" 154} 155dnsbyaddrlookup4_body() 156{ 157 local dir=$(atf_get_srcdir) 158 atf_check -o inline:"$ans4" -x "$dir/h_hostent -t dns -4 -a $a4" 159} 160 161atf_test_case dnsbyaddrlookup6 162dnsbyaddrlookup6_head() 163{ 164 atf_set "descr" "Checks dns address lookup for AF_INET6" 165} 166dnsbyaddrlookup6_body() 167{ 168 local dir=$(atf_get_srcdir) 169 atf_check -o inline:"$ans6" -x "$dir/h_hostent -t dns -6 -a $a6" 170} 171 172atf_init_test_cases() 173{ 174 atf_add_test_case gethostbyname4 175 atf_add_test_case gethostbyname6 176 atf_add_test_case gethostbyaddr4 177 atf_add_test_case gethostbyaddr6 178 179 atf_add_test_case hostsbynamelookup4 180 atf_add_test_case hostsbynamelookup6 181 atf_add_test_case hostsbyaddrlookup4 182 atf_add_test_case hostsbyaddrlookup6 183 184 atf_add_test_case dnsbynamelookup4 185 atf_add_test_case dnsbynamelookup6 186 atf_add_test_case dnsbyaddrlookup4 187 atf_add_test_case dnsbyaddrlookup6 188} 189