added isc_sockaddr_eqaddrprefix() tests
This commit is contained in:
@@ -32,7 +32,7 @@ ISCDEPLIBS = ../../lib/isc/libisc.@A@
|
||||
|
||||
LIBS = @LIBS@
|
||||
|
||||
SUBDIRS = db dst master mem names rbt tasks timers
|
||||
SUBDIRS = db dst master mem names rbt sockaddr tasks timers
|
||||
|
||||
# Alphabetically
|
||||
TARGETS = adb_test \
|
||||
|
||||
47
bin/tests/sockaddr/Makefile.in
Normal file
47
bin/tests/sockaddr/Makefile.in
Normal file
@@ -0,0 +1,47 @@
|
||||
# Copyright (C) 1998, 1999 Internet Software Consortium.
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
# ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
# CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
# PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
# SOFTWARE.
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
||||
@BIND9_INCLUDES@
|
||||
|
||||
CINCLUDES = ${TEST_INCLUDES} ${ISC_INCLUDES}
|
||||
|
||||
CDEFINES =
|
||||
CWARNINGS =
|
||||
|
||||
DEPLIBS = ../../../lib/tests/libt_api.@A@ \
|
||||
../../../lib/isc/libisc.@A@
|
||||
|
||||
LIBS = ${DEPLIBS} \
|
||||
@LIBS@
|
||||
|
||||
TARGETS = t_sockaddr
|
||||
|
||||
@BIND9_MAKE_RULES@
|
||||
|
||||
t_sockaddr: t_sockaddr.@O@ ${DEPLIBS}
|
||||
${LIBTOOL} ${CC} -o $@ t_sockaddr.@O@ ${LIBS}
|
||||
|
||||
test:
|
||||
-@./t_sockaddr -b @srcdir@ -a
|
||||
|
||||
testhelp:
|
||||
@./t_sockaddr -h
|
||||
|
||||
clean distclean::
|
||||
rm -f ${TARGETS}
|
||||
79
bin/tests/sockaddr/t_sockaddr.c
Normal file
79
bin/tests/sockaddr/t_sockaddr.c
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 1999 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/sockaddr.h>
|
||||
#include <isc/result.h>
|
||||
#include <tests/t_api.h>
|
||||
|
||||
static int
|
||||
test_isc_sockaddr_eqaddrprefix(void) {
|
||||
struct in_addr ina_a;
|
||||
struct in_addr ina_b;
|
||||
struct in_addr ina_c;
|
||||
isc_sockaddr_t isa_a;
|
||||
isc_sockaddr_t isa_b;
|
||||
isc_sockaddr_t isa_c;
|
||||
|
||||
if (inet_pton(AF_INET, "194.100.32.87", &ina_a) < 0)
|
||||
return T_FAIL;
|
||||
if (inet_pton(AF_INET, "194.100.32.80", &ina_b) < 0)
|
||||
return T_FAIL;
|
||||
if (inet_pton(AF_INET, "194.101.32.87", &ina_c) < 0)
|
||||
return T_FAIL;
|
||||
isc_sockaddr_fromin(&isa_a, &ina_a, 0);
|
||||
isc_sockaddr_fromin(&isa_b, &ina_b, 42);
|
||||
isc_sockaddr_fromin(&isa_c, &ina_c, 0);
|
||||
|
||||
if (isc_sockaddr_eqaddrprefix(&isa_a, &isa_b, 0) != ISC_TRUE)
|
||||
return T_FAIL;
|
||||
if (isc_sockaddr_eqaddrprefix(&isa_a, &isa_b, 29) != ISC_TRUE)
|
||||
return T_FAIL;
|
||||
if (isc_sockaddr_eqaddrprefix(&isa_a, &isa_b, 30) != ISC_FALSE)
|
||||
return T_FAIL;
|
||||
if (isc_sockaddr_eqaddrprefix(&isa_a, &isa_b, 32) != ISC_FALSE)
|
||||
return T_FAIL;
|
||||
if (isc_sockaddr_eqaddrprefix(&isa_a, &isa_c, 8) != ISC_TRUE)
|
||||
return T_FAIL;
|
||||
if (isc_sockaddr_eqaddrprefix(&isa_a, &isa_c, 16) != ISC_FALSE)
|
||||
return T_FAIL;
|
||||
|
||||
return T_PASS;
|
||||
}
|
||||
|
||||
static void
|
||||
t1(void) {
|
||||
int result;
|
||||
t_assert("isc_sockaddr_eqaddrprefix", 1, T_REQUIRED,
|
||||
"IPv4 address prefix comparisions work as expected");
|
||||
result = test_isc_sockaddr_eqaddrprefix();
|
||||
t_result(result);
|
||||
}
|
||||
|
||||
testspec_t T_testlist[] = {
|
||||
{ t1, "isc_sockaddr_eqaddrprefix" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
4
configure
vendored
4
configure
vendored
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
|
||||
# From configure.in Revision: 1.63
|
||||
# From configure.in Revision: 1.64
|
||||
|
||||
|
||||
|
||||
@@ -3154,6 +3154,7 @@ trap 'rm -fr `echo "make/rules
|
||||
bin/tests/timers/Makefile
|
||||
bin/tests/dst/Makefile
|
||||
bin/tests/mem/Makefile
|
||||
bin/tests/sockaddr/Makefile
|
||||
config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
|
||||
EOF
|
||||
cat >> $CONFIG_STATUS <<EOF
|
||||
@@ -3335,6 +3336,7 @@ CONFIG_FILES=\${CONFIG_FILES-"make/rules
|
||||
bin/tests/timers/Makefile
|
||||
bin/tests/dst/Makefile
|
||||
bin/tests/mem/Makefile
|
||||
bin/tests/sockaddr/Makefile
|
||||
"}
|
||||
EOF
|
||||
cat >> $CONFIG_STATUS <<\EOF
|
||||
|
||||
@@ -13,7 +13,7 @@ dnl PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
dnl ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
dnl SOFTWARE.
|
||||
|
||||
AC_REVISION($Revision: 1.64 $)
|
||||
AC_REVISION($Revision: 1.65 $)
|
||||
|
||||
AC_PREREQ(2.13)
|
||||
|
||||
@@ -485,4 +485,5 @@ AC_OUTPUT(
|
||||
bin/tests/timers/Makefile
|
||||
bin/tests/dst/Makefile
|
||||
bin/tests/mem/Makefile
|
||||
bin/tests/sockaddr/Makefile
|
||||
)
|
||||
|
||||
@@ -225,6 +225,9 @@
|
||||
./bin/tests/serial_test.c C 1999
|
||||
./bin/tests/shutdown_test.c C 1998,1999
|
||||
./bin/tests/signer.c C 1999
|
||||
./bin/tests/sockaddr/.cvsignore X 1999
|
||||
./bin/tests/sockaddr/Makefile MAKE 1999
|
||||
./bin/tests/sockaddr/sockaddr/t_sockaddr.c C 1999
|
||||
./bin/tests/sock_test.c C 1998,1999
|
||||
./bin/tests/sym_test.c C 1998,1999
|
||||
./bin/tests/t_api.pl PERL 1999
|
||||
|
||||
Reference in New Issue
Block a user