Skip to content
Commits on Source (6)
......@@ -179,29 +179,29 @@ debian-unstable-refclocks:
tags:
- gitlab-org
ubuntu-1404-lts-basic:
ubuntu-latest-basic:
<<: *job_definition
image: ubuntu:14.04
image: ubuntu:latest
script:
- apt-get update
- apt-get install -y bison gcc libssl-dev libcap-dev pps-tools python-dev
- apt-get install -y netbase bison gcc libssl-dev libcap-dev pps-tools python-dev
- python ./waf configure build
tags:
- gitlab-org
ubuntu-1404-lts-refclocks:
ubuntu-latest-refclocks:
<<: *job_definition
image: ubuntu:14.04
image: ubuntu:latest
script:
- apt-get update
- apt-get install -y bison gcc libssl-dev libcap-dev pps-tools python-dev
- apt-get install -y netbase bison gcc libssl-dev libcap-dev pps-tools python-dev
- python ./waf configure --refclock=all build
tags:
- gitlab-org
ubuntu-1604-lts-basic:
ubuntu-rolling-basic:
<<: *job_definition
image: ubuntu:16.04
image: ubuntu:rolling
script:
- apt-get update
- apt-get install -y netbase bison gcc libssl-dev libcap-dev pps-tools python-dev
......@@ -209,9 +209,9 @@ ubuntu-1604-lts-basic:
tags:
- gitlab-org
ubuntu-1604-lts-refclocks:
ubuntu-rolling-refclocks:
<<: *job_definition
image: ubuntu:16.04
image: ubuntu:rolling
script:
- apt-get update
- apt-get install -y netbase bison gcc libssl-dev libcap-dev pps-tools python-dev
......@@ -219,9 +219,10 @@ ubuntu-1604-lts-refclocks:
tags:
- gitlab-org
ubuntu-1710-basic:
ubuntu-devel-basic:
<<: *job_definition
image: ubuntu:17.10
image: ubuntu:devel
allow_failure: true
script:
- apt-get update
- apt-get install -y netbase bison gcc libssl-dev libcap-dev pps-tools python-dev
......@@ -229,9 +230,10 @@ ubuntu-1710-basic:
tags:
- gitlab-org
ubuntu-1710-refclocks:
ubuntu-devel-refclocks:
<<: *job_definition
image: ubuntu:17.10
image: ubuntu:devel
allow_failure: true
script:
- apt-get update
- apt-get install -y netbase bison gcc libssl-dev libcap-dev pps-tools python-dev
......
......@@ -111,12 +111,12 @@ extern uint64_t ntp_random64 (void);
/*
* The endpt structure is used to hold the addresses and socket
* The netendpt structure is used to hold the addresses and socket
* numbers of each of the local network addresses we are using.
* endpt is unrelated to the select algorithm's struct endpoint.
*/
typedef struct __endpt {
struct __endpt *elink; /* endpt list link */
typedef struct netendpt {
struct netendpt *elink; /* endpt list link */
SOCKET fd; /* socket descriptor */
uint32_t ifnum; /* endpt instance count */
sockaddr_u sin; /* unicast address */
......
......@@ -36,7 +36,7 @@ struct recvbuf {
recvbuf_t * link; /* next in list */
sockaddr_u recv_srcadr;
sockaddr_u srcadr; /* where packet came from */
endpt * dstadr; /* address pkt arrived on */
struct netendpt * dstadr; /* address pkt arrived on */
SOCKET fd; /* fd on which it was received */
l_fp recv_time; /* time of arrival */
void (*receiver)(struct recvbuf *); /* callback */
......
......@@ -52,6 +52,10 @@ dolfptoa(
digit = fpi;
fpi /= 10U;
/*
* This should be able to be replaced by [digit -= fpi * 10].
* It is being left as is at the moment for subtle bug avoidance.
*/
digit -= (fpi << 3) + (fpi << 1); /* i*10 */
*--cp = (uint8_t)digit;
}
......
......@@ -17,7 +17,6 @@ def build(ctx):
"ntp_endian.c",
"ntp_dns.c",
"numtoa.c",
"recvbuff.c",
"refidsmear.c",
"socket.c",
"socktoa.c",
......
......@@ -2211,9 +2211,7 @@ read_network_packet(
if (buflen == 0 || (buflen == -1 &&
((EWOULDBLOCK == errno)
#ifdef EAGAIN
|| (EAGAIN == errno)
#endif
))) {
freerecvbuf(rb);
return (buflen);
......
......@@ -53,6 +53,7 @@ def build(ctx):
"ntp_filegen.c",
"ntp_leapsec.c",
"ntp_monitor.c", # Needed by the restrict code
"ntp_recvbuff.c",
"ntp_restrict.c",
"ntp_util.c",
]
......
......@@ -42,7 +42,9 @@ static void RunAllTests(void)
RUN_TEST_GROUP(authkeys);
RUN_TEST_GROUP(calendar);
RUN_TEST_GROUP(clocktime);
RUN_TEST_GROUP(endian);
RUN_TEST_GROUP(decodenetnum);
RUN_TEST_GROUP(dolfptoa);
RUN_TEST_GROUP(hextolfp);
RUN_TEST_GROUP(lfpfunc);
RUN_TEST_GROUP(lfptostr);
......@@ -52,7 +54,6 @@ static void RunAllTests(void)
RUN_TEST_GROUP(numtoa);
RUN_TEST_GROUP(prettydate);
RUN_TEST_GROUP(random);
RUN_TEST_GROUP(recvbuff);
RUN_TEST_GROUP(refidsmear);
RUN_TEST_GROUP(socktoa);
RUN_TEST_GROUP(statestr);
......@@ -71,6 +72,7 @@ static void RunAllTests(void)
#ifdef TEST_NTPD
RUN_TEST_GROUP(leapsec);
RUN_TEST_GROUP(hackrestrict);
RUN_TEST_GROUP(recvbuff);
#endif
}
......
#include "config.h"
#include "ntp_stdlib.h"
#include "ntp_fp.h"
#include "unity.h"
#include "unity_fixture.h"
TEST_GROUP(dolfptoa);
TEST_SETUP(dolfptoa) {}
TEST_TEAR_DOWN(dolfptoa) {}
TEST(dolfptoa, DoLfpToA) {
l_fp in;
// Nothingness
in = lfpinit(0, 0);
TEST_ASSERT_EQUAL_STRING("0", dolfptoa(in, false, 0, false));
TEST_ASSERT_EQUAL_STRING("-0", dolfptoa(in, true, 0, false));
TEST_ASSERT_EQUAL_STRING("0", dolfptoa(in, false, 0, true));
TEST_ASSERT_EQUAL_STRING("-0", dolfptoa(in, true, 0, true));
// Somthingness
in = lfpinit(42, 0x80000000);
TEST_ASSERT_EQUAL_STRING("42.500", dolfptoa(in, false, 3, false));
TEST_ASSERT_EQUAL_STRING("-42.500", dolfptoa(in, true, 3, false));
TEST_ASSERT_EQUAL_STRING("42500.000", dolfptoa(in, false, 3, true));
TEST_ASSERT_EQUAL_STRING("-42500.000", dolfptoa(in, true, 3, true));
// Rounded up decimals
in = lfpinit(0xFFFFFFFF, 0xFFFFFF);
TEST_ASSERT_EQUAL_STRING("4294967295.004", dolfptoa(in, false, 3, false));
TEST_ASSERT_EQUAL_STRING("-4294967295.004", dolfptoa(in, true, 3, false));
TEST_ASSERT_EQUAL_STRING("4294967295003.906", dolfptoa(in, false, 3, true));
TEST_ASSERT_EQUAL_STRING("-4294967295003.906", dolfptoa(in, true, 3, true));
// Rounded down decimals
in = lfpinit(0xFFFFFFFF, 0xFF000000);
TEST_ASSERT_EQUAL_STRING("4294967295.99609",
dolfptoa(in, false, 5, false));
TEST_ASSERT_EQUAL_STRING("-4294967295.99609",
dolfptoa(in, true, 5, false));
TEST_ASSERT_EQUAL_STRING("4294967295996.09375",
dolfptoa(in, false, 5, true));
TEST_ASSERT_EQUAL_STRING("-4294967295996.09375",
dolfptoa(in, true, 5, true));
// Extended decimals
in = lfpinit(0xFFFFFFFF, 0xFF000000);
TEST_ASSERT_EQUAL_STRING("4294967295.99609375000000",
dolfptoa(in, false, 15, false));
TEST_ASSERT_EQUAL_STRING("-4294967295.99609375000000",
dolfptoa(in, true, 15, false));
TEST_ASSERT_EQUAL_STRING("4294967295996.09375000000",
dolfptoa(in, false, 15, true));
TEST_ASSERT_EQUAL_STRING("-4294967295996.09375000000",
dolfptoa(in, true, 15, true));
}
TEST(dolfptoa, MfpToA) {
l_fp in;
in = lfpinit(42, 0);
TEST_ASSERT_EQUAL_STRING("42.000", mfptoa(in, 3));
in = lfpinit(-42, 0);
TEST_ASSERT_EQUAL_STRING("-42.000", mfptoa(in, 3));
}
TEST(dolfptoa, MfpToMs) {
l_fp in;
in = lfpinit(42, 0);
TEST_ASSERT_EQUAL_STRING("42000.000", mfptoms(in, 3));
in = lfpinit(-42, 0);
TEST_ASSERT_EQUAL_STRING("-42000.000", mfptoms(in, 3));
}
TEST_GROUP_RUNNER(dolfptoa) {
RUN_TEST_CASE(dolfptoa, DoLfpToA);
RUN_TEST_CASE(dolfptoa, MfpToA);
RUN_TEST_CASE(dolfptoa, MfpToMs);
}
......@@ -14,19 +14,19 @@ TEST_TEAR_DOWN(endian) {}
TEST(endian, Bit16) {
uint8_t buffer[2] = {0x22, 0x11};
TEST_ASSERT_EQUAL(0x1122, ntp_be16dec((void *)buffer));
TEST_ASSERT_EQUAL(0x2211, ntp_be16dec((void *)buffer));
}
TEST(endian, Bit32) {
uint8_t buffer[4] = {0x44, 0x33, 0x22, 0x11};
TEST_ASSERT_EQUAL(0x11223344, ntp_be32dec((void *)buffer));
TEST_ASSERT_EQUAL(0x44332211, ntp_be32dec((void *)buffer));
}
TEST(endian, Bit64) {
uint8_t buffer[8] = {0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11};
TEST_ASSERT_EQUAL(0x1122334455667788, ntp_be64dec((void *)buffer));
TEST_ASSERT_EQUAL(0x8877665544332211, ntp_be64dec((void *)buffer));
}
TEST_GROUP_RUNNER(endian) {
......
......@@ -39,6 +39,7 @@ def build(ctx):
"libntp/ntp_random.c",
"libntp/clocktime.c",
"libntp/decodenetnum.c",
"libntp/dolfptoa.c",
"libntp/hextolfp.c",
"libntp/lfpfunc.c",
"libntp/lfptostr.c",
......@@ -47,7 +48,6 @@ def build(ctx):
"libntp/netof.c",
"libntp/numtoa.c",
"libntp/prettydate.c",
"libntp/recvbuff.c",
"libntp/refidsmear.c",
"libntp/socktoa.c",
"libntp/statestr.c",
......@@ -100,6 +100,7 @@ def build(ctx):
# "ntpd/filegen.c",
"ntpd/leapsec.c",
"ntpd/restrict.c",
"ntpd/recvbuff.c",
] + common_source
ctx.ntp_test(
......