1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
import os
from waflib import Utils # pylint: disable=import-error
def build(ctx):
testsrc = ctx.srcnode.make_node('tests')
pylib = ctx.srcnode.make_node('pylib')
testpylib = testsrc.make_node('pylib')
testpysrc = testpylib.ant_glob('*.py')
# Unity source
unity_source = [
"unity/unity.c",
"unity/unity_fixture.c",
"unity/unity_memory.c",
]
unity_config = ["UNITY_INCLUDE_DOUBLE", "UNITY_SUPPORT_64"]
ctx(
defines=unity_config,
features="c",
target="unity",
source=unity_source
)
# Test main.
common_source = [
"common/tests_main.c",
"common/caltime.c",
"common/sockaddrtest.c",
]
# libntp/
libntp_source = [
"libntp/authkeys.c",
"libntp/ntp_calendar.c",
"libntp/ntp_endian.c",
"libntp/ntp_random.c",
"libntp/clocktime.c",
"libntp/decodenetnum.c",
"libntp/dolfptoa.c",
"libntp/hextolfp.c",
"libntp/lfpfunc.c",
"libntp/lfptostr.c",
"libntp/macencrypt.c",
"libntp/numtoa.c",
"libntp/prettydate.c",
"libntp/refidsmear.c",
"libntp/socktoa.c",
"libntp/statestr.c",
"libntp/strtolfp.c",
"libntp/timespecops.c",
"libntp/vi64ops.c",
"libntp/ymd2yd.c"
] + common_source
ctx.ntp_test(
features="c cprogram test",
target="test_libntp",
install_path=None,
defines=unity_config + ["TEST_LIBNTP=1"],
includes=[ctx.bldnode.parent.abspath(), "../include", "unity", "common"],
use="unity ntp parse M PTHREAD CRYPTO RT SOCKET NSL",
source=libntp_source,
)
if ctx.env.REFCLOCK_GENERIC or ctx.env.REFCLOCK_TRIMBLE:
# libparse available/required with generic and Trimble refclocks
# libparse/
libparse_source = [
"libparse/binio.c",
"libparse/gpstolfp.c",
"libparse/ieee754io.c",
] + common_source
ctx.ntp_test(
defines=unity_config + ["TEST_LIBPARSE=1"],
features="c cprogram test",
includes=[ctx.bldnode.parent.abspath(), "../include", "unity"],
install_path=None,
lib=["parse"],
libpath=["libparse"],
source=libparse_source,
target="test_libparse",
use="unity ntp parse M PTHREAD RT SOCKET NSL",
)
ntpd_source = [
# "ntpd/filegen.c",
"ntpd/leapsec.c",
"ntpd/restrict.c",
"ntpd/recvbuff.c",
] + common_source
if not ctx.env.DISABLE_NTS:
ntpd_source += [
"ntpd/nts.c",
"ntpd/nts_client.c",
"ntpd/nts_server.c",
"ntpd/nts_cookie.c",
"ntpd/nts_extens.c",
]
ctx.ntp_test(
defines=unity_config + ["TEST_NTPD=1"],
features="c cprogram test",
includes=[ctx.bldnode.parent.abspath(), "../include", "unity", "../ntpd", "common", "../libaes_siv"],
install_path=None,
source=ntpd_source,
target="test_ntpd",
use="ntpd_lib libntpd_obj unity ntp aes_siv "
"M PTHREAD CRYPTO RT SOCKET NSL",
)
testpylib.get_bld().mkdir()
pypath = pylib.get_bld()
targdir = "tests/pylib"
linkpath = ctx.bldnode.make_node(targdir + "/ntp").abspath()
relpath = ("../" * (targdir.count("/")+1)) + pypath.path_from(ctx.bldnode)
if (not os.path.exists(linkpath)) or os.readlink(linkpath) != relpath:
try:
os.remove(linkpath)
except OSError:
pass
os.symlink(relpath, linkpath)
pytests = ["pylib/test_util.py",
"pylib/test_agentx.py",
"pylib/test_agentx_packet.py",
"pylib/test_ntpc.py",
"pylib/test_packet.py",
"pylib/test_statfiles.py"]
ctx(
features="subst",
source=testpysrc,
target=[x.get_bld() for x in testpysrc],
chmod=Utils.O755,
)
for path in pytests:
ctx(
features="py test_scripts",
test_scripts_source=path,
test_scripts_template="${PYTHON} ${SRC}",
)
|