Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
BIND
Commits
436d9872
Commit
436d9872
authored
Nov 15, 2018
by
Evan Hunt
Browse files
convert isc_ntop_test
(cherry picked from commit
b0309ae7
)
parent
c803e6ee
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/isc/tests/Kyuafile
View file @
436d9872
...
...
@@ -10,7 +10,7 @@ tap_test_program{name='file_test'}
tap_test_program{name='hash_test'}
tap_test_program{name='heap_test'}
tap_test_program{name='ht_test'}
atf
_test_program{name='inet_ntop_test'}
tap
_test_program{name='inet_ntop_test'}
tap_test_program{name='lex_test'}
tap_test_program{name='mem_test'}
tap_test_program{name='netaddr_test'}
...
...
lib/isc/tests/Makefile.in
View file @
436d9872
...
...
@@ -96,8 +96,9 @@ ht_test@EXEEXT@: ht_test.@O@ ${ISCDEPLIBS}
inet_ntop_test.c.@O@
:
${top_srcdir}/lib/isc/ntop_test.c
inet_ntop_test@EXEEXT@
:
inet_ntop_test.@O@ ${ISCDEPLIBS}
${LIBTOOL_MODE_LINK}
${PURIFY}
${CC}
${CFLAGS}
${LDFLAGS}
-o
$@
\
inet_ntop_test.@O@
${ISCLIBS}
${LIBS}
${LIBTOOL_MODE_LINK}
${PURIFY}
${CC}
${CFLAGS}
${CMOCKA_CFLAGS}
\
${LDFLAGS}
-o
$@
inet_ntop_test.@O@
\
${ISCLIBS}
${LIBS}
${CMOCKA_LIBS}
lex_test@EXEEXT@
:
lex_test.@O@ ${ISCDEPLIBS}
${LIBTOOL_MODE_LINK}
${PURIFY}
${CC}
${CFLAGS}
${CMOCKA_CFLAGS}
\
...
...
lib/isc/tests/inet_ntop_test.c
View file @
436d9872
...
...
@@ -11,7 +11,18 @@
#include <config.h>
#include <atf-c.h>
#if HAVE_CMOCKA
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <string.h>
#define UNIT_TESTING
#include <cmocka.h>
#include <isc/print.h>
#include <isc/util.h>
/*
* Force the prototype for isc_net_ntop to be declared.
...
...
@@ -21,11 +32,9 @@
#define ISC_PLATFORM_NEEDNTOP
#include "../inet_ntop.c"
ATF_TC
(
isc_net_ntop
);
ATF_TC_HEAD
(
isc_net_ntop
,
tc
)
{
atf_tc_set_md_var
(
tc
,
"descr"
,
"isc_net_ntop implementation"
);
}
ATF_TC_BODY
(
isc_net_ntop
,
tc
)
{
/* Test isc_net_ntop implementation */
static
void
isc_net_ntop_test
(
void
**
state
)
{
char
buf
[
sizeof
(
"ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"
)];
int
r
;
size_t
i
;
...
...
@@ -45,18 +54,33 @@ ATF_TC_BODY(isc_net_ntop, tc) {
{
AF_INET6
,
"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"
}
};
UNUSED
(
state
);
for
(
i
=
0
;
i
<
sizeof
(
testdata
)
/
sizeof
(
testdata
[
0
]);
i
++
)
{
r
=
inet_pton
(
testdata
[
i
].
family
,
testdata
[
i
].
address
,
abuf
);
ATF_REQUIRE_EQ_MSG
(
r
,
1
,
"%s"
,
testdata
[
i
].
address
);
assert_int_equal
(
r
,
1
);
isc_net_ntop
(
testdata
[
i
].
family
,
abuf
,
buf
,
sizeof
(
buf
));
ATF_CHECK_STREQ
(
buf
,
testdata
[
i
].
address
);
assert_string_equal
(
buf
,
testdata
[
i
].
address
);
}
}
/*
* Main
*/
ATF_TP_ADD_TCS
(
tp
)
{
ATF_TP_ADD_TC
(
tp
,
isc_net_ntop
);
return
(
atf_no_error
());
int
main
(
void
)
{
const
struct
CMUnitTest
tests
[]
=
{
cmocka_unit_test
(
isc_net_ntop_test
),
};
return
(
cmocka_run_group_tests
(
tests
,
NULL
,
NULL
));
}
#else
/* HAVE_CMOCKA */
#include <stdio.h>
int
main
(
void
)
{
printf
(
"1..0 # Skipped: cmocka not available
\n
"
);
return
(
0
);
}
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment