From: Damir Tomic Date: Wed, 17 Jun 2015 07:35:55 +0000 (+0200) Subject: run-test-networking.c, c_sntptest.h: X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85b3e4763f6ae4a4a3e6468b036db54848c4d7a7;p=thirdparty%2Fntp.git run-test-networking.c, c_sntptest.h: new file networking.c: added c_sntptest.h include Makefile.am: modified so Makefile.am runs unity tests and gtests bk: 5581235bznlwxp9qgGjldrNeZYbRCQ --- diff --git a/sntp/tests/Makefile.am b/sntp/tests/Makefile.am index 804acb19c..4b75e5f99 100644 --- a/sntp/tests/Makefile.am +++ b/sntp/tests/Makefile.am @@ -2,17 +2,22 @@ NULL = BUILT_SOURCES = CLEANFILES = -run_unity = cd $(srcdir) && ruby /unity/auto/generate_test_runner.rb +run_unity = cd $(srcdir) && ruby ../../sntp/unity/auto/generate_test_runner.rb check_PROGRAMS = \ test-networking \ $(NULL) -#maybe an issue where with if GTEST... -if BUILD_SNTP +if GTEST_AVAILABLE check_PROGRAMS += tests +else +EXTRA_PROGRAMS = tests endif +#if BUILD_SNTP +#check_PROGRAMS += tests +#endif + base_SOURCES = \ $(srcdir)/../tests_main.cpp \ $(NULL) @@ -31,6 +36,7 @@ tests_SOURCES = \ noinst_HEADERS = \ sntptest.h \ + c_sntptest.h \ fileHandlingTest.h \ $(NULL) @@ -93,16 +99,16 @@ AM_LDFLAGS = $(LDFLAGS_NTP) test_networking_CFLAGS = \ - -I$(top_srcdir)/sntp/unity \ + -I$(top_srcdir)/unity \ $(NULL) test_networking_LDADD = \ $(LDADD) \ - $(top_builddir)/sntp/unity/libunity.a \ + $(top_builddir)/unity/libunity.a \ $(NULL) BUILT_SOURCES += \ - $(run_unity) networking.c run-test-networking.c \ + $(srcdir)/networking.c run-test-networking.c \ $(NULL) test_networking_SOURCES = \ @@ -116,8 +122,11 @@ $(srcdir)/run-test-networking.c: $(srcdir)/networking.c $(std_unity_list) TESTS = if !NTP_CROSSCOMPILE -TESTS += tests-runner +TESTS += $(check_PROGRAMS) endif +#if !NTP_CROSSCOMPILE +#TESTS += tests-runner +#endif ## ensure ../libsntp.a is built @@ -133,8 +142,8 @@ check-libsntp: ../libsntp.a ## check-libntp.mf - automake fragment ## slightly adapted for deeper directory -BUILT_SOURCES += check-libntp -CLEANFILES += check-libntp +BUILT_SOURCES += check-libntp check-libunity +CLEANFILES += check-libntp check-libunity check-libntp: ../../libntp/libntp.a @echo stamp > $@ @@ -142,5 +151,11 @@ check-libntp: ../../libntp/libntp.a ../../libntp/libntp.a: cd ../../libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a +check-libunity: ../sntp/unity/libunity.a + @echo stamp > $@ + +../sntp/unity/libunity.a: + cd ../unity && $(MAKE) $(AM_MAKEFLAGS) libunity.a + include $(top_srcdir)/depsver.mf include $(top_srcdir)/includes.mf diff --git a/sntp/tests/c_sntptest.h b/sntp/tests/c_sntptest.h new file mode 100644 index 000000000..bb31f068e --- /dev/null +++ b/sntp/tests/c_sntptest.h @@ -0,0 +1,32 @@ +#ifndef SNTPTEST_H +#define SNTPTEST_H + +//#include "tests_main.h" + +#include "ntp_stdlib.h" +#include "sntp-opts.h" + + +sntptest() { + optionSaveState(&sntpOptions); +} +/* +~sntptest() { + optionRestore(&sntpOptions); +} +*/ +void ActivateOption(const char* option, const char* argument) { + const int ARGV_SIZE = 4; + + char* opts[ARGV_SIZE]; + + opts[0] = estrdup("sntpopts"); + opts[1] = estrdup(option); + opts[2] = estrdup(argument); + opts[3] = estrdup("127.0.0.1"); + + optionProcess(&sntpOptions, ARGV_SIZE, opts); +} + + +#endif // SNTPTEST_H diff --git a/sntp/tests/networking.c b/sntp/tests/networking.c index 34df1c15c..b2b5a1307 100644 --- a/sntp/tests/networking.c +++ b/sntp/tests/networking.c @@ -1,4 +1,7 @@ -#include "sntptest.h" +#include "config.h" + +#include "c_sntptest.h" #include "networking.h" +#include "unity.h" diff --git a/sntp/tests/run-test-networking.c b/sntp/tests/run-test-networking.c new file mode 100644 index 000000000..d5e822c71 --- /dev/null +++ b/sntp/tests/run-test-networking.c @@ -0,0 +1,49 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(); \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include +#include + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); + + +//=======Test Reset Option===== +void resetTest() +{ + tearDown(); + setUp(); +} + +char *progname; + + +//=======MAIN===== +int main(int argc, char *argv[]) +{ + progname = argv[0]; + Unity.TestFile = "networking.c"; + UnityBegin("networking.c"); + + return (UnityEnd()); +}