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
69b892ed
Commit
69b892ed
authored
Oct 23, 2018
by
Evan Hunt
Browse files
convert time_test
(cherry picked from commit
3bf9a1e5
) (cherry picked from commit
8d039673
)
parent
caac5988
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/isc/tests/Kyuafile
View file @
69b892ed
...
...
@@ -28,5 +28,5 @@ atf_test_program{name='socket_test'}
tap_test_program{name='symtab_test'}
atf_test_program{name='task_test'}
tap_test_program{name='taskpool_test'}
atf
_test_program{name='time_test'}
tap
_test_program{name='time_test'}
atf_test_program{name='timer_test'}
lib/isc/tests/Makefile.in
View file @
69b892ed
...
...
@@ -178,8 +178,9 @@ taskpool_test@EXEEXT@: taskpool_test.@O@ isctest.@O@ ${ISCDEPLIBS}
${ISCLIBS}
${LIBS}
${CMOCKA_LIBS}
time_test@EXEEXT@
:
time_test.@O@ ${ISCDEPLIBS}
${LIBTOOL_MODE_LINK}
${PURIFY}
${CC}
${CFLAGS}
${LDFLAGS}
-o
$@
\
time_test.@O@
${ISCLIBS}
${LIBS}
${LIBTOOL_MODE_LINK}
${PURIFY}
${CC}
${CFLAGS}
${CMOCKA_CFLAGS}
\
${LDFLAGS}
-o
$@
time_test.@O@
\
${ISCLIBS}
${LIBS}
${CMOCKA_LIBS}
timer_test@EXEEXT@
:
timer_test.@O@ isctest.@O@ ${ISCDEPLIBS}
${LIBTOOL_MODE_LINK}
${PURIFY}
${CC}
${CFLAGS}
${LDFLAGS}
-o
$@
\
...
...
lib/isc/tests/time_test.c
View file @
69b892ed
...
...
@@ -10,37 +10,61 @@
*/
#include <config.h>
#if HAVE_CMOCKA
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atf-c.h>
#define UNIT_TESTING
#include <cmocka.h>
#include <isc/
time
.h>
#include <isc/
print
.h>
#include <isc/result.h>
#include <isc/time.h>
#include <isc/util.h>
ATF_TC
(
isc_time_parsehttptimestamp
);
ATF_TC_HEAD
(
isc_time_parsehttptimestamp
,
tc
)
{
atf_tc_set_md_var
(
tc
,
"descr"
,
"parse http time stamp"
);
}
ATF_TC_BODY
(
isc_time_parsehttptimestamp
,
tc
)
{
/* parse http time stamp */
static
void
isc_time_parsehttptimestamp_test
(
void
**
state
)
{
isc_result_t
result
;
isc_time_t
t
,
x
;
char
buf
[
ISC_FORMATHTTPTIMESTAMP_SIZE
];
UNUSED
(
state
);
setenv
(
"TZ"
,
"PST8PDT"
,
1
);
result
=
isc_time_now
(
&
t
);
ATF_REQUIRE_EQ
(
result
,
ISC_R_SUCCESS
);
assert_int_equal
(
result
,
ISC_R_SUCCESS
);
isc_time_formathttptimestamp
(
&
t
,
buf
,
sizeof
(
buf
));
result
=
isc_time_parsehttptimestamp
(
buf
,
&
x
);
ATF_REQUIRE_EQ
(
result
,
ISC_R_SUCCESS
);
ATF_REQUIRE_EQ
(
isc_time_seconds
(
&
t
),
isc_time_seconds
(
&
x
));
assert_int_equal
(
result
,
ISC_R_SUCCESS
);
assert_int_equal
(
isc_time_seconds
(
&
t
),
isc_time_seconds
(
&
x
));
}
/*
* Main
*/
ATF_TP_ADD_TCS
(
tp
)
{
ATF_TP_ADD_TC
(
tp
,
isc_time_parsehttptimestamp
);
return
(
atf_no_error
());
int
main
(
void
)
{
const
struct
CMUnitTest
tests
[]
=
{
cmocka_unit_test
(
isc_time_parsehttptimestamp_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