Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Commits on Source (4)
tests: add test for libparse.ieee754io. Just a skeleton.
· 6077bf19
Gary E. Miller
authored
Apr 03, 2017
6077bf19
Add comments to decode dates as magic numbers
· 60b517f7
Hal Murray
authored
Apr 02, 2017
60b517f7
Fix 2x if DEBUG => ifdef DEBUG (in refclocks)
· 2cc696ff
Hal Murray
authored
Apr 04, 2017
2cc696ff
Fixed pep8 issues.
· 6494681a
Ian Bruene
authored
Apr 03, 2017
and
Eric S. Raymond
committed
Apr 04, 2017
6494681a
Hide whitespace changes
Inline
Side-by-side
contrib/make-leap-seconds.py
View file @
6494681a
...
...
@@ -83,7 +83,7 @@ args = sys.argv[1:]
leap
=
time
.
time
()
days
=
int
(
leap
/
86400
)
leap
=
days
*
86400
leap
=
(
days
+
1
)
*
86400
if
len
(
args
)
>
0
:
leapdate
=
datetime
.
datetime
.
strptime
(
args
[
0
],
"
%Y-%m-%d
"
)
...
...
@@ -97,13 +97,16 @@ if len(args) > 0:
expire
=
(
expiredate
-
epoch
).
total_seconds
()
expire
=
int
(
expire
)
args
=
args
[
1
:]
leap_txt
=
time
.
asctime
(
time
.
gmtime
(
leap
))
leap
=
str
(
leap
+
JAN_1970
)
expire_txt
=
time
.
asctime
(
time
.
gmtime
(
expire
))
expire
=
str
(
expire
+
JAN_1970
)
update
=
time
.
time
()
days
=
int
(
update
/
86400
)
update
=
days
*
86400
update
=
int
(
time
.
time
())
update_txt
=
time
.
asctime
(
time
.
gmtime
(
update
))
update
=
str
(
update
+
JAN_1970
)
tai
=
"
40
"
# hardwired
# File format
...
...
@@ -121,13 +124,13 @@ tai = "40" # hardwired
# All dates use NTP epoch of 1900-01-01
sha1
=
sha
.
new
()
print
(
"
%s %s
"
%
(
leap
,
tai
))
print
(
"
%s
%s #
%s
"
%
(
leap
,
tai
,
leap_txt
))
sha1
.
update
(
leap
)
sha1
.
update
(
tai
)
print
(
"
#$ %s
"
%
update
)
sha1
.
update
(
update
)
print
(
"
#@ %s
"
%
expire
)
print
(
"
#@ %s # %s
"
%
(
expire
,
expire_txt
))
sha1
.
update
(
expire
)
print
(
"
#$ %s # %s
"
%
(
update
,
update_txt
))
sha1
.
update
(
update
)
digest
=
sha1
.
hexdigest
()
print
(
"
#h %s %s %s %s %s
"
%
\
(
digest
[
0
:
8
],
digest
[
8
:
16
],
digest
[
16
:
24
],
digest
[
24
:
32
],
digest
[
32
:
40
]))
...
...
ntpd/refclock_jjy.c
View file @
6494681a
...
...
@@ -3492,7 +3492,7 @@ teljjy_conn_data ( struct peer *peer, struct refclockproc *pp, struct jjyunit *u
up
->
iTimestampCount
++
;
if
(
up
->
iTimestampCount
==
6
&&
!
up
->
bLineError
)
{
#if DEBUG
#if
def
DEBUG
printf
(
"refclock_jjy.c : teljjy_conn_data : bLineError=%d iTimestamp=%d, %d, %d
\n
"
,
up
->
bLineError
,
up
->
iTimestamp
[
3
],
up
->
iTimestamp
[
4
],
up
->
iTimestamp
[
5
]
)
;
...
...
ntpd/refclock_jupiter.c
View file @
6494681a
...
...
@@ -589,7 +589,7 @@ jupiter_ppsapi(
}
/* instance->peer->precision = PPS_PRECISION; */
#if DEBUG
#if
def
DEBUG
if
(
debug
)
{
time_pps_getparams
(
instance
->
pps_handle
,
&
instance
->
pps_params
);
jupiter_debug
(
instance
->
peer
,
__func__
,
...
...
tests/common/tests_main.c
View file @
6494681a
...
...
@@ -62,6 +62,10 @@ static void RunAllTests(void)
RUN_TEST_GROUP
(
ymd2yd
);
#endif
#ifdef TEST_LIBPARSE
RUN_TEST_GROUP
(
ieee754io
);
#endif
#ifdef TEST_NTPD
RUN_TEST_GROUP
(
leapsec
);
RUN_TEST_GROUP
(
hackrestrict
);
...
...
tests/libparse/ieee754io.c
0 → 100644
View file @
6494681a
#include
"config.h"
#include
"ntp_stdlib.h"
#include
"ntp_fp.h"
#include
"ieee754io.h"
#include
"timespecops.h"
#include
"unity.h"
#include
"unity_fixture.h"
TEST_GROUP
(
ieee754io
);
TEST_SETUP
(
ieee754io
)
{}
TEST_TEAR_DOWN
(
ieee754io
)
{}
static
offsets_t
native_off
=
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
};
TEST
(
ieee754io
,
test_one
)
{
int
ret
;
unsigned
char
one
[
8
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
unsigned
char
*
bp
=
&
one
[
0
];
l_fp
fp
;
printf
(
"hello
\n
"
);
ret
=
fetch_ieee754
(
&
bp
,
IEEE_DOUBLE
,
&
fp
,
native_off
);
printf
(
"hello
\n
"
);
printf
(
"%ld
\n
"
,
(
long
)
fp
);
TEST_ASSERT
(
IEEE_OK
==
ret
);
TEST_ASSERT_EQUAL_INT64
(
0
,
(
long
)
fp
);
}
TEST_GROUP_RUNNER
(
ieee754io
)
{
RUN_TEST_CASE
(
ieee754io
,
test_one
);
}
tests/pylib/test_util.py
View file @
6494681a
...
...
@@ -68,9 +68,9 @@ class TestPylibUtilMethods(unittest.TestCase):
self
.
assertEqual
(
ntp
.
util
.
scaleforunit
(
-
0.00000042
,
9
),
(
-
420.0
,
-
3
))
self
.
assertEqual
(
ntp
.
util
.
scaleforunit
(
1.0000004
,
6
),
(
1.0
,
0
))
(
1.0
,
0
))
self
.
assertEqual
(
ntp
.
util
.
scaleforunit
(
1.0000005
,
6
),
(
1.000001
,
0
))
(
1.000001
,
0
))
def
test_oomsbetweenunits
(
self
):
self
.
assertEqual
(
ntp
.
util
.
oomsbetweenunits
(
3
,
2
),
...
...
tests/wscript
View file @
6494681a
...
...
@@ -63,6 +63,26 @@ def build(ctx):
source=libntp_source,
)
# libparse/
libparse_source = [
"libparse/ieee754io.c",
] + common_source
ctx.ntp_test(
defines=unity_config + ["TEST_LIBPARSE=1"],
features="c cprogram bld_include src_include test",
includes=["%s/tests/unity/" % srcnode,
"%s/tests/libparse/" % srcnode,
"%s/tests/common/" % srcnode
] + ctx.env.PLATFORM_INCLUDES,
install_path=None,
lib=["parse"],
libpath=["libparse"],
source=libparse_source,
target="test_libparse",
use="unity ntp isc parse M PTHREAD CRYPTO RT SOCKET NSL",
)
ntpd_source = [
# "ntpd/filegen.c",
"ntpd/leapsec.c",
...
...