[Git][NTPsec/ntpsec][working] 6 commits: Simplify Ubuntu versions used for Gitlab CI to avoid need for future updates
Ian Bruene
gitlab at mg.gitlab.com
Fri Aug 3 20:24:08 UTC 2018
Ian Bruene pushed to branch working at NTPsec / ntpsec
Commits:
9c79e126 by Matt Selsky at 2018-08-01T00:05:19Z
Simplify Ubuntu versions used for Gitlab CI to avoid need for future updates
Instead of:
- 14.04 (LTS release)
- 16.04 (LTS release)
- 17.10 (non-LTS release)
Use:
- latest (latest LTS release)
- rolling (latest release - could be LTS)
- devel (whatever the devel suite points to)
See https://store.docker.com/images/ubuntu for more information
- - - - -
7dfd651f by Eric S. Raymond at 2018-08-01T09:55:20Z
EAGAIN is POSIX.1-2001, and not conditionalized elsewhere.
- - - - -
835d03eb by Eric S. Raymond at 2018-08-02T20:13:11Z
Move recvbuff ring buffer handing from libntp/ to ntpd/.
It doesn't need to be accessible deom anywhere else.
- - - - -
bd2b3fac by Eric S. Raymond at 2018-08-02T20:44:03Z
Fix a name ambiguity.
- - - - -
e01bd969 by Ian Bruene at 2018-08-03T20:23:40Z
Partial test for dolfptoa.c, non-functioning.
- - - - -
a099f11f by Ian Bruene at 2018-08-03T20:23:40Z
Added test for dolfptoa.c, enabled tests for ntp_endian.c.
- - - - -
13 changed files:
- .gitlab-ci.yml
- include/ntp.h
- include/recvbuff.h
- libntp/dolfptoa.c
- libntp/wscript
- ntpd/ntp_io.c
- libntp/recvbuff.c → ntpd/ntp_recvbuff.c
- ntpd/wscript
- tests/common/tests_main.c
- + tests/libntp/dolfptoa.c
- tests/libntp/ntp_endian.c
- tests/libntp/recvbuff.c → tests/ntpd/recvbuff.c
- tests/wscript
Changes:
=====================================
.gitlab-ci.yml
=====================================
@@ -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
=====================================
include/ntp.h
=====================================
@@ -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 */
=====================================
include/recvbuff.h
=====================================
@@ -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 */
=====================================
libntp/dolfptoa.c
=====================================
@@ -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;
}
=====================================
libntp/wscript
=====================================
@@ -17,7 +17,6 @@ def build(ctx):
"ntp_endian.c",
"ntp_dns.c",
"numtoa.c",
- "recvbuff.c",
"refidsmear.c",
"socket.c",
"socktoa.c",
=====================================
ntpd/ntp_io.c
=====================================
@@ -2211,9 +2211,7 @@ read_network_packet(
if (buflen == 0 || (buflen == -1 &&
((EWOULDBLOCK == errno)
-#ifdef EAGAIN
|| (EAGAIN == errno)
-#endif
))) {
freerecvbuf(rb);
return (buflen);
=====================================
libntp/recvbuff.c → ntpd/ntp_recvbuff.c
=====================================
=====================================
ntpd/wscript
=====================================
@@ -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",
]
=====================================
tests/common/tests_main.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
}
=====================================
tests/libntp/dolfptoa.c
=====================================
@@ -0,0 +1,80 @@
+#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);
+}
=====================================
tests/libntp/ntp_endian.c
=====================================
@@ -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) {
=====================================
tests/libntp/recvbuff.c → tests/ntpd/recvbuff.c
=====================================
=====================================
tests/wscript
=====================================
@@ -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(
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/b1a885b15be36a9a7207173542a562a9c9cab5a1...a099f11ff02848a397569af0048f3ae99795f3ed
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/b1a885b15be36a9a7207173542a562a9c9cab5a1...a099f11ff02848a397569af0048f3ae99795f3ed
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20180803/85f85a16/attachment-0001.html>
More information about the vc
mailing list