Home | History | Annotate | Line # | Download | only in net
t_hostent.sh revision 1.1
      1 # $NetBSD: t_hostent.sh,v 1.1 2013/08/16 15:29:45 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 
     28 n6="sixthavenue.astron.com"
     29 a6="2620:106:3000:100:2e0:81ff:fe2f:e5d6"
     30 ans6="name=$n6, length=16, addrtype=24, aliases=[] addr_list=[$a6]\n"
     31 
     32 n4="sixthavenue.astron.com"
     33 a4="208.77.212.99"
     34 ans4="name=$n4, length=4, addrtype=2, aliases=[] addr_list=[$a4]\n"
     35 
     36 l6="localhost"
     37 al6="::1"
     38 loc6="name=$l6, length=16, addrtype=24, aliases=[localhost. localhost.localdomain.] addr_list=[$al6]\n"
     39 
     40 l4="localhost"
     41 al4="127.0.0.1"
     42 loc4="name=$l4, length=4, addrtype=2, aliases=[localhost. localhost.localdomain.] addr_list=[$al4]\n"
     43 
     44 atf_test_case gethostbyname4
     45 gethostbyname4_head()
     46 {
     47 	atf_set "descr" "Checks gethostbyname2(3) for AF_INET (auto, as determined by nsswitch.conf(5)"
     48 }
     49 gethostbyname4_body()
     50 {
     51 	atf_check -o inline:"$ans4" -x "$(atf_get_srcdir)/h_hostent -t auto -4 $n4"
     52 }
     53 
     54 atf_test_case gethostbyname6
     55 gethostbyname6_head()
     56 {
     57 	atf_set "descr" "Checks gethostbyname2(3) for AF_INET6 (auto, as determined by nsswitch.conf(5)"
     58 }
     59 gethostbyname6_body()
     60 {
     61 	atf_check -o inline:"$ans6" -x "$(atf_get_srcdir)/h_hostent -t auto -6 $n6"
     62 }
     63 
     64 atf_test_case gethostbyaddr4
     65 gethostbyaddr4_head()
     66 {
     67 	atf_set "descr" "Checks gethostbyaddr(3) for AF_INET (auto, as determined by nsswitch.conf(5)"
     68 }
     69 gethostbyaddr4_body()
     70 {
     71 	atf_check -o inline:"$ans4" -x "$(atf_get_srcdir)/h_hostent -t auto -a $a4"
     72 }
     73 
     74 atf_test_case gethostbyaddr6
     75 gethostbyaddr6_head()
     76 {
     77 	atf_set "descr" "Checks gethostbyaddr(3) for AF_INET6 (auto, as determined by nsswitch.conf(5)"
     78 }
     79 gethostbyaddr6_body()
     80 {
     81 	atf_check -o inline:"$ans6" -x "$(atf_get_srcdir)/h_hostent -t auto -a $a6"
     82 }
     83 
     84 atf_test_case hostsbynamelookup4
     85 hostsbynamelookup4_head()
     86 {
     87 	atf_set "descr" "Checks /etc/hosts name lookup for AF_INET"
     88 }
     89 hostsbynamelookup4_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 
     95 atf_test_case hostsbynamelookup6
     96 hostsbynamelookup6_head()
     97 {
     98 	atf_set "descr" "Checks /etc/hosts name lookup for AF_INET6"
     99 }
    100 hostsbynamelookup6_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 
    106 atf_test_case hostsbyaddrlookup4
    107 hostsbyaddrlookup4_head()
    108 {
    109 	atf_set "descr" "Checks /etc/hosts address lookup for AF_INET"
    110 }
    111 hostsbyaddrlookup4_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 
    117 atf_test_case hostsbyaddrlookup6
    118 hostsbyaddrlookup6_head()
    119 {
    120 	atf_set "descr" "Checks /etc/hosts address lookup for AF_INET6"
    121 }
    122 hostsbyaddrlookup6_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 
    128 atf_test_case dnsbynamelookup4
    129 dnsbynamelookup4_head()
    130 {
    131 	atf_set "descr" "Checks DNS name lookup for AF_INET"
    132 }
    133 dnsbynamelookup4_body()
    134 {
    135 	local dir=$(atf_get_srcdir)
    136 	atf_check -o inline:"$ans4" -x "$dir/h_hostent -t dns -4 $n4"
    137 }
    138 
    139 atf_test_case dnsbynamelookup6
    140 dnsbynamelookup6_head()
    141 {
    142 	atf_set "descr" "Checks DNS name lookup for AF_INET6"
    143 }
    144 dnsbynamelookup6_body()
    145 {
    146 	local dir=$(atf_get_srcdir)
    147 	atf_check -o inline:"$ans6" -x "$dir/h_hostent -t dns -6 $n6"
    148 }
    149 
    150 atf_test_case dnsbyaddrlookup4
    151 dnsbyaddrlookup4_head()
    152 {
    153 	atf_set "descr" "Checks DNS address lookup for AF_INET"
    154 }
    155 dnsbyaddrlookup4_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 
    161 atf_test_case dnsbyaddrlookup6
    162 dnsbyaddrlookup6_head()
    163 {
    164 	atf_set "descr" "Checks dns address lookup for AF_INET6"
    165 }
    166 dnsbyaddrlookup6_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 
    172 atf_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