Skip to content
Commits on Source (4)
......@@ -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]))
......
......@@ -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
#ifdef 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] ) ;
......
......@@ -589,7 +589,7 @@ jupiter_ppsapi(
}
/* instance->peer->precision = PPS_PRECISION; */
#if DEBUG
#ifdef DEBUG
if (debug) {
time_pps_getparams(instance->pps_handle, &instance->pps_params);
jupiter_debug(instance->peer, __func__,
......
......@@ -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);
......
#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);
}
......@@ -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),
......
......@@ -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",
......