[Git][NTPsec/ntpsec][ntpc] 4 commits: Import latest fixes from upstream Unity repo
James Browning
gitlab at mg.gitlab.com
Wed Sep 9 15:07:16 UTC 2020
James Browning pushed to branch ntpc at NTPsec / ntpsec
Commits:
30fe9fad by Matt Selsky at 2020-09-07T13:33:52-04:00
Import latest fixes from upstream Unity repo
This imports Unity 2.5.1+ through commit https://github.com/ThrowTheSwitch/Unity/commit/98045925af4409942d43ac348aeab5a0554c9c7f
- - - - -
0a4597a3 by Hal Murray at 2020-09-07T13:25:51-07:00
Restriction cleanup -- when poking holes
- - - - -
99427479 by Richard Laager at 2020-09-07T23:02:52+00:00
Remove unnecessary pylib shebangs
These files are never executed directly.
Requested-by: Hal Murray <hmurray at megapathdsl.net>
- - - - -
ae22209e by James Browning at 2020-09-09T07:51:08-07:00
build, pylib: ntpc... some singing/dancing
- - - - -
15 changed files:
- include/ntpd.h
- + libntp/ntp_c.c
- libntp/wscript
- ntpd/ntp_config.c
- ntpd/ntp_peer.c
- ntpd/ntp_proto.c
- ntpd/ntp_restrict.c
- pylib/agentx.py
- + pylib/ntpc.py
- pylib/poly.py
- pylib/wscript
- tests/unity/unity.c
- tests/unity/unity.h
- tests/unity/unity_internals.h
- wscript
Changes:
=====================================
include/ntpd.h
=====================================
@@ -195,7 +195,8 @@ extern void init_restrict (void);
extern unsigned short restrictions (sockaddr_u *);
extern void hack_restrict (int, sockaddr_u *, sockaddr_u *,
unsigned short, unsigned short);
-extern void restrict_source (sockaddr_u *, bool);
+extern void restrict_source (struct peer *);
+extern void unrestrict_source (struct peer *);
/* ntp_timer.c */
extern void init_timer (void);
=====================================
libntp/ntp_c.c
=====================================
@@ -0,0 +1,119 @@
+/*
+ * Copyright the NTPsec project contributors
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Python binding for selected libntp library functions
+ */
+
+/* This include has to come early or we get warnings from redefining
+ * _POSIX_C_SOURCE and _XOPEN_SOURCE on some systems.
+ */
+#include "config.h"
+
+#include "ntp_machine.h"
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_fp.h"
+#include "ntp_stdlib.h"
+#include "ntp_syslog.h"
+#include "timespecops.h"
+
+#include "ntp_config.h"
+#include "ntp_assert.h"
+
+#include "ntp_control.h"
+
+#include "pymodule-mac.h"
+
+void ntpc_setprogname(char*);
+char *ntpc_prettydate(char*);
+double ntpc_lfptofloat(char*);
+int ntpc_set_tod(int, int);
+bool ntpc_adj_systime(double);
+bool ntpc_step_systime(double);
+
+/* Don't include anything from OpenSSL */
+
+const char *progname = "libntpc";
+int SYS_TYPE = TYPE_SYS;
+int PEER_TYPE = TYPE_PEER;
+int CLOCK_TYPE = TYPE_CLOCK;
+
+/*
+ * Client utility functions
+ */
+
+void
+ntpc_setprogname(char *s)
+{
+ /*
+ * This function is only called from clients. Therefore
+ * log to stderr rather than syslog, and suppress logfile
+ * impediments. If we ever want finer-grained control, that
+ * will be easily implemented with additional arguments.
+ */
+ syslogit = false; /* don't log messages to syslog */
+ termlogit = true; /* duplicate to stdout/err */
+ termlogit_pid = false;
+ msyslog_include_timestamp = false;
+ progname = strdup(s);
+}
+
+char *
+ntpc_prettydate(char *s)
+{
+ l_fp ts;
+
+ if (false == hextolfp(s+2, &ts)) {
+ errno = EINVAL;
+ return strdup("ERROR");
+ }
+ errno = 0;
+ return prettydate(ts);
+}
+
+double
+ntpc_lfptofloat(char *s)
+{
+ l_fp ts;
+ struct timespec tt;
+
+ if (false == hextolfp(s+2, &ts)) {
+ errno = EINVAL;
+ return -0;
+ }
+ errno = 0;
+ tt = lfp_stamp_to_tspec(ts, time(NULL));
+ return tt.tv_sec + (tt.tv_nsec * S_PER_NS);
+}
+
+int
+ntpc_set_tod(int seconds, int fractional)
+{
+ struct timespec ts;
+ ts.tv_sec = seconds;
+ ts.tv_nsec = fractional;
+
+ return ntp_set_tod(&ts);
+}
+
+bool
+ntpc_adj_systime(double adjustment)
+{
+ return adj_systime(adjustment, adjtime) ? 1 : 0;
+}
+
+bool
+ntpc_step_systime(double adjustment)
+{
+ doubletime_t full_adjustment;
+
+ /*
+ * What we really want is for Python to parse a long double.
+ * As this is, it's a potential source of problems in the Python
+ * utilities if and when the time difference between the Unix epoch
+ * and now exceeds the range of a double.
+ */
+ full_adjustment = adjustment;
+ return step_systime(full_adjustment, ntp_set_tod);
+}
=====================================
libntp/wscript
=====================================
@@ -1,3 +1,5 @@
+import os
+
def build(ctx):
libntp_source = [
@@ -47,6 +49,22 @@ def build(ctx):
use="CRYPTO SSL",
)
+ if ctx.env['ntpc'] == 'ffi':
+ # Loadable FFI stub
+ tgt=ctx(
+ features="c cshlib",
+ install_path='${LIBDIR}/ntp',
+ includes=[ctx.bldnode.parent.abspath(), "../include"],
+ source=["ntp_c.c", "pymodule-mac.c"] + libntp_source_sharable,
+ target="../pylib/ntpc", # Put the output in the pylib directory
+ use="M RT CRYPTO",
+ )
+ #_ = tgt.abspath() + '.1.0.0'
+ #os.rename(tgt.abspath(), _)
+ ##os.symlink(_, tgt.abspath())
+ return
+ elif ctx.env['ntpc'] != 'ext':
+ return
# Loadable Python extension
ctx(
features="c cshlib pyext",
=====================================
ntpd/ntp_config.c
=====================================
@@ -2594,6 +2594,7 @@ is_sane_resolved_address(
}
if (IS_IPV6(peeraddr) && !ipv6_works)
+ /* FIXME: error message */
return false;
/* Ok, all tests succeeded, now we can return true */
@@ -2724,10 +2725,10 @@ config_peers(
NULL,
curr_peer->host_mode,
&curr_peer->ctl);
- /*
- * If we have a numeric address, we can safely
- * proceed in the mainline with it.
- */
+ /*
+ * If we have a numeric address, we can safely
+ * proceed in the mainline with it.
+ */
} else if (is_ip_address(curr_peer->addr->address,
curr_peer->addr->type, &peeraddr)) {
@@ -2988,7 +2989,7 @@ config_ntpd(
config_monitor(ptree);
config_auth(ptree);
config_tos(ptree);
- config_access(ptree);
+ config_access(ptree); /* before config_peers */
config_tinker(ptree);
config_nts(ptree);
config_rlimit(ptree);
=====================================
ntpd/ntp_peer.c
=====================================
@@ -420,7 +420,7 @@ unpeer(
)
{
mprintf_event(PEVNT_DEMOBIL, peer, "assoc %u", peer->associd);
- restrict_source(&peer->srcadr, true);
+ unrestrict_source(peer);
set_peerdstadr(peer, NULL);
peer_demobilizations++;
peer_associations--;
@@ -589,9 +589,7 @@ newpeer(
/*
* If a peer is found, this would be a duplicate and we don't
- * allow that. This avoids duplicate ephemeral (broadcast/
- * multicast) and preemptible (manycast and pool) client
- * associations.
+ * allow that.
*/
if (peer != NULL) {
DPRINT(2, ("newpeer(%s) found existing association\n", name));
@@ -689,14 +687,16 @@ newpeer(
/*
* Put the new peer in the hash tables.
*/
- if ((MDF_UCAST & cast_flags) && !(FLAG_LOOKUP & ctl->flags))
+ if ((MDF_UCAST & cast_flags) && !(FLAG_LOOKUP & ctl->flags)) {
+ /* simple server with numeric address */
peer_add_hash(peer);
+ restrict_source(peer);
+ }
hash = peer->associd & NTP_HASH_MASK;
LINK_SLIST(assoc_hash[hash], peer, aid_link);
assoc_hash_count[hash]++;
LINK_SLIST(peer_list, peer, p_link);
- restrict_source(&peer->srcadr, false);
mprintf_event(PEVNT_MOBIL, peer, "assoc %d", peer->associd);
DPRINT(1, ("newpeer: %s->%s mode %u vers %u poll %u %u flags 0x%x 0x%x mode %u key %08x\n",
latoa(peer->dstadr), socktoa(&peer->srcadr), peer->hmode,
=====================================
ntpd/ntp_proto.c
=====================================
@@ -2372,7 +2372,6 @@ dns_take_server(
sockaddr_u *rmtadr
)
{
- int restrict_mask;
struct peer * pp;
if(!(server->cfg.flags & FLAG_LOOKUP))
@@ -2390,17 +2389,11 @@ dns_take_server(
msyslog(LOG_INFO, "DNS: Server taking: %s", socktoa(rmtadr));
else
msyslog(LOG_INFO, "DNS: Server taking: %s", sockporttoa(rmtadr));
- server->cfg.flags &= (unsigned)~FLAG_LOOKUP;
+ server->cfg.flags &= (unsigned)~FLAG_LOOKUP;
server->srcadr = *rmtadr;
peer_add_hash(server);
-
- restrict_mask = restrictions(&server->srcadr);
- if (RES_FLAGS & restrict_mask) {
- msyslog(LOG_INFO, "DNS: Server poking hole in restrictions for: %s",
- socktoa(&server->srcadr));
- restrict_source(&server->srcadr, false);
- }
+ restrict_source(server);
peer_refresh_interface(server);
@@ -2423,7 +2416,6 @@ dns_take_pool(
{
struct peer_ctl pctl;
struct peer * peer;
- int restrict_mask;
endpt * lcladr;
peer = findexistingpeer(rmtadr, NULL, NULL, MODE_CLIENT);
@@ -2450,13 +2442,6 @@ dns_take_pool(
peer->retry = NTP_RETRY;
poll_update(peer, peer->hpoll);
- restrict_mask = restrictions(&peer->srcadr);
- if (RES_FLAGS & restrict_mask) {
- msyslog(LOG_INFO, "DNS: Pool poking hole in restrictions for: %s",
- socktoa(&peer->srcadr));
- restrict_source(&peer->srcadr, false);
- }
-
DPRINT(1, ("dns_take_pool: at %u %s->%s pool\n",
current_time, latoa(lcladr), socktoa(rmtadr)));
}
=====================================
ntpd/ntp_restrict.c
=====================================
@@ -610,31 +610,31 @@ hack_restrict(
}
-/*
- * restrict_source - maintains dynamic "restrict source ..." entries as
- * peers come and go.
+/* restrict_source - poke hole in restrictions if needed
+ * requires "restrict source <flags|NULL>"
+ * Called in 3 cases:
+ * newpeer when allocating a slot with IP Address
+ * dns_check/dns_take_server when DNS assigns an IP Address
+ * nts_check/dns_take_server when NTS assigns an IP Address
+ *
+ * Holes created have RESM_SOURCE in mflags
+ * Restrictions must be initialized before adding servers
*/
void
restrict_source(
- sockaddr_u * addr,
- bool farewell /* false to add, true to remove */
+ struct peer * peer
)
{
+ sockaddr_u * addr = &peer->srcadr;
sockaddr_u onesmask;
restrict_u * res;
- int found_specific;
-
- if (!restrict_source_enabled || SOCK_UNSPEC(addr) || IS_MCAST(addr))
- return;
+ bool found_specific = false;
+ bool need_poke = false;
+ bool auth, nts;
REQUIRE(AF_INET == AF(addr) || AF_INET6 == AF(addr));
SET_HOSTMASK(&onesmask, AF(addr));
- if (farewell) {
- hack_restrict(RESTRICT_REMOVE, addr, &onesmask, 0, 0);
- DPRINT(1, ("restrict_source: %s removed", socktoa(addr)));
- return;
- }
/*
* If there is a specific entry for this address, hands
@@ -650,12 +650,65 @@ restrict_source(
found_specific = ADDR6_EQ(&res->u.v6.mask,
&SOCK_ADDR6(&onesmask));
}
+
+ if (RES_IGNORE & res->flags) {
+ need_poke = true;
+ }
+ auth = (0 != peer->cfg.peerkey);
+ nts = peer->cfg.flags & FLAG_NTS;
+ if (RES_DONTTRUST & res->flags && !auth && !nts) {
+ /* needs authentication, but this slot doesn't have any */
+ need_poke = true;
+ }
+ if (!need_poke) {
+ /* works without a hole */
+ return;
+ }
if (found_specific) {
+ msyslog(LOG_ERR, "RESTRICT: Specific restriction will break %s",
+ socktoa(addr));
return;
}
+ if (!restrict_source_enabled) {
+ msyslog(LOG_ERR, "RESTRICT: Can't poke hole in restrictions for %s - need \"restrict source <flags>\"",
+ socktoa(addr));
+ return;
+ }
+
+ msyslog(LOG_INFO, "RESTRICT: Poking hole in restrictions for %s",
+ socktoa(addr));
hack_restrict(RESTRICT_FLAGS, addr, &onesmask,
restrict_source_mflags, restrict_source_flags);
- DPRINT(1, ("restrict_source: %s host restriction added\n",
- socktoa(addr)));
}
+
+/* unrestrict_source - remove hole poked in restrictions
+ */
+void
+unrestrict_source(
+ struct peer * peer
+ )
+{
+ sockaddr_u * addr = &peer->srcadr;
+ sockaddr_u onesmask;
+ restrict_u * res;
+
+ if (IS_IPV4(addr)) {
+ res = match_restrict4_addr(SRCADR(addr), SRCPORT(addr));
+ } else {
+ res = match_restrict6_addr(&SOCK_ADDR6(addr),
+ SRCPORT(addr));
+ }
+ if (!(res->mflags & RESM_SOURCE)) {
+ return; /* nothing to cleanup */
+ }
+
+ msyslog(LOG_INFO, "RESTRICT: Removing hole in restrictions for %s",
+ socktoa(addr));
+
+ SET_HOSTMASK(&onesmask, AF(addr));
+ hack_restrict(RESTRICT_REMOVE, addr, &onesmask, 0, 0);
+
+}
+
+
=====================================
pylib/agentx.py
=====================================
@@ -1,4 +1,3 @@
-#! /usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, division
=====================================
pylib/ntpc.py
=====================================
@@ -0,0 +1,155 @@
+# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: BSD-2-Clause
+"""Access libntp funtions from Python."""
+from __future__ import absolute_import
+import ctypes
+import ctypes.util
+import errno
+import os
+import os.path
+import ntp.poly
+
+LIB = 'ntpc'
+
+
+def importado():
+ """Load the ntpc library or throw an OSError trying.
+
+ Use find_library() which looks in: LD_LIBRARY_PATH,
+ DYLD_LIBRARY_PATH, $home/lib, /.usr/local/lib,
+ /usr/lib, /lib Returns the library handle.
+ """
+ ntpc_paths = [] # places to look
+
+ j = __file__.split(os.sep)[:-1]
+ for i in ['lib%s.so', 'lib%s.dylib', '%s.dll']:
+ _ = os.sep.join(j + [i % LIB])
+ # print(_)
+ ntpc_paths.append(_)
+
+ ntpc_path = ctypes.util.find_library(LIB)
+ if ntpc_path:
+ ntpc_paths.append(ntpc_path)
+
+ for ntpc_path in ntpc_paths:
+ try:
+ lib = ctypes.CDLL(ntpc_path, use_errno=True)
+ return lib
+ except OSError:
+ pass
+
+ raise OSError("Can't find %s library" % LIB)
+
+
+_ntpc = importado()
+progname = ctypes.c_char_p.in_dll(_ntpc, 'progname')
+# log_sys = ctypes.c_bool.in_dll(_ntpc, 'syslogit')
+# log_term = ctypes.c_bool.in_dll(_ntpc, 'termlogit')
+# log_pid = ctypes.c_bool.in_dll(_ntpc, 'termlogit_pid')
+# log_time = ctypes.c_bool.in_dll(_ntpc, 'msyslog_include_timestamp')
+
+TYPE_SYS = ctypes.c_int.in_dll(_ntpc, 'SYS_TYPE').value
+TYPE_PEER = ctypes.c_int.in_dll(_ntpc, 'PEER_TYPE').value
+TYPE_CLOCK = ctypes.c_int.in_dll(_ntpc, 'CLOCK_TYPE').value
+
+
+def checkname(name):
+ """Check if name is a valid algorithm name."""
+ _ntpc.do_checkname.restype = ctypes.c_int
+ mid_bytes = ntp.poly.polybytes(name)
+ _ntpc.do_checkname.argtypes = [ctypes.c_char_p]
+ return _ntpc.do_checkname(mid_bytes)
+
+
+def mac(data, key, name):
+ """Compute HMAC or CMAC from data, key, and algorithm name."""
+ resultlen = ctypes.c_size_t()
+ result = (ctypes.c_char * 64)()
+ result.value = b'\0' * 64
+ _ntpc.do_mac.restype = None
+ _ntpc.do_mac(ntp.poly.polybytes(name),
+ ntp.poly.polybytes(data), len(data),
+ ntp.poly.polybytes(key), len(key),
+ ctypes.byref(result), ctypes.byref(resultlen))
+ return result.value
+
+
+def setprogname(in_string):
+ """Set program name for logging purposes."""
+ mid_bytes = ntp.poly.polybytes(in_string)
+ _setprogname(mid_bytes)
+
+
+def _lfp_wrap(callback, in_string):
+ """NTP l_fp to other Python-style format."""
+ mid_bytes = ntp.poly.polybytes(in_string)
+ out_value = callback(mid_bytes)
+ err = ctypes.get_errno()
+ if err == errno.EINVAL:
+ raise ValueError('ill-formed hex date')
+ return out_value
+
+
+def statustoa(i_type, i_st):
+ """Convert a time stamp to something readable."""
+ mid_str = _statustoa(i_type, i_st)
+ return ntp.poly.polystr(mid_str)
+
+
+def prettydate(in_string):
+ """Convert a time stamp to something readable."""
+ mid_str = _lfp_wrap(_prettydate, in_string)
+ return ntp.poly.polystr(mid_str)
+
+
+def lfptofloat(in_string):
+ """NTP l_fp to Python-style float time."""
+ return _lfp_wrap(_lfptofloat, in_string)
+
+
+def msyslog(level, in_string):
+ """Log send a message to terminal or output.
+
+ Can actually log to syslog, a file or stdout/arderr.
+ Minimum of of features supported.
+ """
+ mid_bytes = ntp.poly.polybytes(in_string)
+ _msyslog(level, mid_bytes)
+
+
+# Set return type and argument types of hidden ffi handlers
+_msyslog = _ntpc.msyslog
+_msyslog.restype = None
+_msyslog.argtypes = [ctypes.c_int, ctypes.c_char_p]
+
+_setprogname = _ntpc.ntpc_setprogname
+_setprogname.restype = None
+_setprogname.argtypes = [ctypes.c_char_p]
+
+_prettydate = _ntpc.ntpc_prettydate
+_prettydate.restype = ctypes.c_char_p
+_prettydate.argtypes = [ctypes.c_char_p]
+
+_lfptofloat = _ntpc.ntpc_lfptofloat
+_lfptofloat.restype = ctypes.c_double
+_lfptofloat.argtypes = [ctypes.c_char_p]
+
+# Status string display from peer status word.
+_statustoa = _ntpc.statustoa
+_statustoa.restype = ctypes.c_char_p
+_statustoa.argtypes = [ctypes.c_int, ctypes.c_int]
+
+# Set time to nanosecond precision.
+set_tod = _ntpc.ntpc_set_tod
+set_tod.restype = ctypes.c_int
+set_tod.argtypes = [ctypes.c_int, ctypes.c_int]
+
+# Adjust system time by slewing.
+adj_systime = _ntpc.ntpc_adj_systime
+adj_systime.restype = ctypes.c_bool
+adj_systime.argtypes = [ctypes.c_double]
+
+# Adjust system time by stepping.
+step_systime = _ntpc.ntpc_step_systime
+step_systime.restype = ctypes.c_bool
+step_systime.argtypes = [ctypes.c_double]
=====================================
pylib/poly.py
=====================================
@@ -1,4 +1,3 @@
-#! /usr/bin/env python
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: BSD-2-Clause
"""Handle bytes and strings in a polyglot fashion.
=====================================
pylib/wscript
=====================================
@@ -35,8 +35,22 @@ def build(ctx):
bldnode = ctx.bldnode.make_node('pylib')
target1 = bldnode.make_node('control.py')
target2 = bldnode.make_node('magic.py')
+
+ bldnode.mkdir()
- sources = srcnode.ant_glob('*.py')
+ ctx.add_group()
+
+ target3 = bldnode.ant_glob('*ntpc*')
+ for _ in target3:
+ ctx.exec_command("rm -f %s" % _.abspath())
+
+ ctx.add_group()
+
+ sources = []
+ if ctx.env['ntpc'] == 'ext':
+ sources = srcnode.ant_glob("*.py", excl='ntpc.py')
+ elif ctx.env['ntpc'] == 'ffi':
+ sources = srcnode.ant_glob('*.py')
builds = [x.get_bld() for x in sources]
# The rm's here were added to fix a reported (but underdocumented) problem
@@ -52,6 +66,9 @@ def build(ctx):
#ctx.exec_command("rm -f %s" % target1.abspath())
#ctx.exec_command("rm -f %s" % target2.abspath())
+ if ctx.env['ntpc'] is None:
+ return
+
# Make sure Python sees .py as well as .pyc/.pyo
ctx(
features="subst",
=====================================
tests/unity/unity.c
=====================================
@@ -1001,6 +1001,7 @@ void UnityAssertFloatSpecial(const UNITY_FLOAT actual,
is_trait = !isinf(actual) && !isnan(actual);
break;
+ case UNITY_FLOAT_INVALID_TRAIT:
default:
trait_index = 0;
trait_names[0] = UnityStrInvalidFloatTrait;
@@ -1141,6 +1142,7 @@ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual,
is_trait = !isinf(actual) && !isnan(actual);
break;
+ case UNITY_FLOAT_INVALID_TRAIT:
default:
trait_index = 0;
trait_names[0] = UnityStrInvalidFloatTrait;
=====================================
tests/unity/unity.h
=====================================
@@ -150,10 +150,10 @@ void verifyTest(void);
#define TEST_ASSERT_EQUAL_HEX64(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, NULL)
#define TEST_ASSERT_EQUAL_CHAR(expected, actual) UNITY_TEST_ASSERT_EQUAL_CHAR((expected), (actual), __LINE__, NULL)
#define TEST_ASSERT_BITS(mask, expected, actual) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, NULL)
-#define TEST_ASSERT_BITS_HIGH(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(-1), (actual), __LINE__, NULL)
-#define TEST_ASSERT_BITS_LOW(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(0), (actual), __LINE__, NULL)
-#define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, NULL)
-#define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, NULL)
+#define TEST_ASSERT_BITS_HIGH(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT)(-1), (actual), __LINE__, NULL)
+#define TEST_ASSERT_BITS_LOW(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT)(0), (actual), __LINE__, NULL)
+#define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT)1 << (bit)), (UNITY_UINT)(-1), (actual), __LINE__, NULL)
+#define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT)1 << (bit)), (UNITY_UINT)(0), (actual), __LINE__, NULL)
/* Integer Not Equal To (of all sizes) */
#define TEST_ASSERT_NOT_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT((threshold), (actual), __LINE__, NULL)
=====================================
tests/unity/unity_internals.h
=====================================
@@ -40,6 +40,12 @@
#include <limits.h>
#endif
+#if defined __GNUC__
+# define UNITY_FUNCTION_ATTR(a) __attribute__((a))
+#else
+# define UNITY_FUNCTION_ATTR(a) /* ignore */
+#endif
+
/*-------------------------------------------------------
* Guess Widths If Not Specified
*-------------------------------------------------------*/
@@ -611,8 +617,8 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta,
const UNITY_DISPLAY_STYLE_T style,
const UNITY_FLAGS_T flags);
-void UnityFail(const char* message, const UNITY_LINE_TYPE line) __attribute__((noreturn));
-void UnityIgnore(const char* message, const UNITY_LINE_TYPE line) __attribute__((noreturn));
+void UnityFail(const char* message, const UNITY_LINE_TYPE line) UNITY_FUNCTION_ATTR(noreturn);
+void UnityIgnore(const char* message, const UNITY_LINE_TYPE line) UNITY_FUNCTION_ATTR(noreturn);
void UnityMessage(const char* message, const UNITY_LINE_TYPE line);
#ifndef UNITY_EXCLUDE_FLOAT
@@ -701,11 +707,8 @@ extern const char UnityStrErrShorthand[];
#endif
#endif
#ifdef UNITY_SUPPORT_VARIADIC_MACROS
-#define RUN_TEST(...) UnityDefaultTestRun(RUN_TEST_FIRST(__VA_ARGS__), RUN_TEST_SECOND(__VA_ARGS__))
-#define RUN_TEST_FIRST(...) RUN_TEST_FIRST_HELPER(__VA_ARGS__, throwaway)
-#define RUN_TEST_FIRST_HELPER(first, ...) (first), #first
-#define RUN_TEST_SECOND(...) RUN_TEST_SECOND_HELPER(__VA_ARGS__, __LINE__, throwaway)
-#define RUN_TEST_SECOND_HELPER(first, second, ...) (second)
+#define RUN_TEST(...) RUN_TEST_AT_LINE(__VA_ARGS__, __LINE__, throwaway)
+#define RUN_TEST_AT_LINE(func, line, ...) UnityDefaultTestRun(func, #func, line)
#endif
#endif
=====================================
wscript
=====================================
@@ -119,6 +119,8 @@ def configure(ctx):
opt = flag.replace("--", "").upper()
opt_map[opt] = ctx.env.OPT_STORE[flag]
+ ctx.env['ntpc'] = 'ffi'
+
msg("--- Configuring host ---")
ctx.setenv('host', ctx.env.derive())
@@ -1009,6 +1011,7 @@ def build(ctx):
ctx.recurse("ntpd")
return
+ ctx.recurse("pylib")
if ctx.env.REFCLOCK_GENERIC or ctx.env.REFCLOCK_TRIMBLE:
# required by the generic and Trimble refclocks
ctx.recurse("libparse")
@@ -1017,7 +1020,6 @@ def build(ctx):
ctx.recurse("ntpd")
ctx.recurse("ntpfrob")
ctx.recurse("ntptime")
- ctx.recurse("pylib")
ctx.recurse("attic")
ctx.recurse("etc")
ctx.recurse("tests")
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/c5d154e38696f98eaa5c93bca58882aac4a8ac44...ae22209e6da9061bda3b87f9737509c456d28cd5
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/c5d154e38696f98eaa5c93bca58882aac4a8ac44...ae22209e6da9061bda3b87f9737509c456d28cd5
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/20200909/a24e1a19/attachment-0001.htm>
More information about the vc
mailing list