[ntpsec-main commit] First set of tests running under Unity.

Amar Takhar amar at ntpsec.org
Wed Nov 11 20:34:39 UTC 2015


Module:    ntpsec-main
Branch:    master
Commit:    74904a42c1891aceec5670786e4483e9d72d7b2d
Changeset: http://git.ntpsec.org//commit/?id=74904a42c1891aceec5670786e4483e9d72d7b2d

Author:    Amar Takhar <verm at darkbeer.org>
Date:      Wed Nov 11 15:33:02 2015 -0500

First set of tests running under Unity.

  * This is not hooked up to the build yet you must uncomment the tests recurse
    command in the main wscript.
  * Runner glue needs to be added as there are some interesting quirks
  * C++ files will be removed after a complete or mostly complete conversion.

---

 ntpdig/wscript            | 19 ++++++++++++++++---
 tests/ntpdig/ntpdigtest.h |  1 -
 tests/ntpdig/tests_main.c |  2 ++
 tests/wscript             | 34 ++++++++++++++++++++++++++++++++++
 4 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/ntpdig/wscript b/ntpdig/wscript
index e41857c..8010fc9 100644
--- a/ntpdig/wscript
+++ b/ntpdig/wscript
@@ -2,20 +2,33 @@ def build(ctx):
 	srcnode = ctx.srcnode.abspath()
 	bldnode = ctx.bldnode.abspath()
 
-	ntpdig_source = [
+	ntpdig_obj_source = [
 		"crypto.c",
 		"kod_management.c",
 		"log.c",
 		"main.c",
 		"networking.c",
-		"ntpdig.c",
 		"utilities.c"
 	]
 
 	ctx(
+		target		= "ntpdig_obj",
+		features	= "c bld_include src_include libisc_include",
+		use			= "ntp isc opts M PTHREAD LIBEVENT LIBEVENT_CORE LIBEVENT_PTHREADS RT CRYPTO",
+		source		= ntpdig_obj_source,
+		includes	= [
+						"%s/ntpdig/" % bldnode
+					] + ctx.env.PLATFORM_INCLUDES, # XXX: Hack needs to use libevent_inc or something else.
+	)
+
+	ntpdig_source = [
+		"ntpdig.c",
+	]
+
+	ctx(
 		target		= "ntpdig",
 		features	= "c cprogram bld_include src_include libisc_include ntp_version",
-		use			= "ntp isc opts M PTHREAD ntpdig_obj LIBEVENT LIBEVENT_CORE LIBEVENT_PTHREADS RT CRYPTO",
+		use			= "ntp isc opts ntpdig_obj M PTHREAD ntpdig_obj LIBEVENT LIBEVENT_CORE LIBEVENT_PTHREADS RT CRYPTO",
 		source		= ntpdig_source,
 		includes	= [
 						"%s/ntpdig/" % bldnode
diff --git a/tests/ntpdig/ntpdigtest.h b/tests/ntpdig/ntpdigtest.h
index f6fec81..292d67e 100644
--- a/tests/ntpdig/ntpdigtest.h
+++ b/tests/ntpdig/ntpdigtest.h
@@ -4,7 +4,6 @@
 #include "tests_main.h"
 
 #include "ntp_stdlib.h"
-#include "ntpdig-opts.h"
 
 #if 0
 class ntpdigtest : public ntptest {
diff --git a/tests/ntpdig/tests_main.c b/tests/ntpdig/tests_main.c
index 49cb16d..3930130 100644
--- a/tests/ntpdig/tests_main.c
+++ b/tests/ntpdig/tests_main.c
@@ -5,6 +5,8 @@ const char *progname = "ntpdigtest";
 static const char** args_argv;
 static int args_argc;
 
+/* XXX: This needs to have named arguments and error
+   out if one is not supplied */
 const char* tests_main_args(int arg)
 {
 	int a;
diff --git a/tests/wscript b/tests/wscript
new file mode 100644
index 0000000..1331e5a
--- /dev/null
+++ b/tests/wscript
@@ -0,0 +1,34 @@
+
+def build(ctx):
+	srcnode = ctx.srcnode.abspath()
+
+	unity_source = [
+		"unity/unity.c",
+		"unity/unity_fixture.c"
+	]
+
+	ctx(
+		features    = "c",
+        target      = "unity",
+        source      = unity_source
+	)
+
+
+	test_source = [
+		"ntpdig/fileHandlingTest.c",
+		"ntpdig/keyFile.c",
+		"ntpdig/crypto.c",
+		"ntpdig/tests_main.c"
+	]
+
+
+	ctx(
+		features    = "c cprogram bld_include src_include libisc_include",
+        target      = "ntpdig_crypto",
+		includes	= [
+			"%s/tests/unity/" % srcnode,
+			"%s/ntpdig/" % srcnode
+		],
+		use			= "unity ntpdig_obj ntp isc M",
+        source      = test_source,
+	)



More information about the vc mailing list