]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Many files:
authorDamir Tomic <viperus@ntp.org>
Mon, 27 Jul 2015 17:46:25 +0000 (19:46 +0200)
committerDamir Tomic <viperus@ntp.org>
Mon, 27 Jul 2015 17:46:25 +0000 (19:46 +0200)
  update

run-leapsec.c:
  minor change
run-ntp_scanner.c, run-decodenetnum.c:
  update
ntp_scanner.c:
  Added more tests
lfptest.h:
  minor move after merge with lokesh
Makefile.am:
  Merge

bk: 55b66e71eg2fOk2FSu9riqhFEJkflQ

tests/libntp/lfptest.h
tests/libntp/run-decodenetnum.c
tests/libntp/run-lfptostr.c
tests/libntp/run-netof.c
tests/libntp/run-socktoa.c
tests/ntpd/Makefile.am
tests/ntpd/ntp_scanner.c
tests/ntpd/run-leapsec.c
tests/ntpd/run-ntp_scanner.c
tests/ntpd/run-ntp_signd.c
tests/ntpd/run-rc_cmdlength.c

index defbf5822a5ff65b8a08523cb0650e232f234835..6075f310e312dde974453b43ac4f12a0bf99b258 100644 (file)
@@ -13,20 +13,4 @@ static const int32 QUARTER_PROMILLE_APPRX = 1073742L;
 
 int IsEqual(const l_fp expected, const l_fp actual);
 
-int IsEqual(const l_fp expected, const l_fp actual) {
-       if (L_ISEQU(&expected, &actual)) {
-               return TRUE;
-       } else {
-               //printf(" expected: ...");
-               /*
-               << " expected: " << lfptoa(&expected, FRACTION_PREC)
-                               << " (" << expected.l_ui << "." << expected.l_uf << ")"
-                               << " but was: " << lfptoa(&actual, FRACTION_PREC)
-                               << " (" << actual.l_ui << "." << actual.l_uf << ")";
-               */
-               return FALSE;
-       }
-
-}
-
 #endif
index ed7208ee133f73596443369da5202da4b844f275..70dd294df72cc28895458f8887daefbb0b4a9050 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdio.h>
 #include "config.h"
 #include "ntp_stdlib.h"
+#include "ntp_calendar.h"
 #include "sockaddrtest.h"
 
 //=======External Functions This Runner Calls=====
index feb402224fbb7032d2daf4851952f7b0a727c19c..c744fba09d45dd04e0fbd2758c28bcee788eead1 100644 (file)
@@ -58,17 +58,17 @@ int main(int argc, char *argv[])
 {
   progname = argv[0];
   UnityBegin("lfptostr.c");
-  RUN_TEST(test_PositiveInteger, 23);
-  RUN_TEST(test_NegativeInteger, 24);
-  RUN_TEST(test_PositiveIntegerWithFraction, 25);
-  RUN_TEST(test_NegativeIntegerWithFraction, 26);
-  RUN_TEST(test_RoundingDownToInteger, 27);
-  RUN_TEST(test_RoundingMiddleToInteger, 28);
-  RUN_TEST(test_RoundingUpToInteger, 29);
-  RUN_TEST(test_SingleDecimal, 30);
-  RUN_TEST(test_MillisecondsRoundingUp, 31);
-  RUN_TEST(test_MillisecondsRoundingDown, 32);
-  RUN_TEST(test_UnsignedInteger, 33);
+  RUN_TEST(test_PositiveInteger, 24);
+  RUN_TEST(test_NegativeInteger, 25);
+  RUN_TEST(test_PositiveIntegerWithFraction, 26);
+  RUN_TEST(test_NegativeIntegerWithFraction, 27);
+  RUN_TEST(test_RoundingDownToInteger, 28);
+  RUN_TEST(test_RoundingMiddleToInteger, 29);
+  RUN_TEST(test_RoundingUpToInteger, 30);
+  RUN_TEST(test_SingleDecimal, 31);
+  RUN_TEST(test_MillisecondsRoundingUp, 32);
+  RUN_TEST(test_MillisecondsRoundingDown, 33);
+  RUN_TEST(test_UnsignedInteger, 34);
 
   return (UnityEnd());
 }
index 3f27f67594c9c597db0fa9335d548fc7d1bd9e54..47fafdd5c933391cc5833bb7c17e458d6a40bb36 100644 (file)
@@ -24,7 +24,6 @@
 #include <stdio.h>
 #include "config.h"
 #include "ntp_stdlib.h"
-#include "ntp_calendar.h"
 #include "sockaddrtest.h"
 
 //=======External Functions This Runner Calls=====
index 7bff53c605fce958cd334c0ec2e38bebeb3c38fc..3cf17a8b308e7ce12b6c0482a0d2ceb2de0d851e 100644 (file)
@@ -54,12 +54,12 @@ int main(int argc, char *argv[])
 {
   progname = argv[0];
   UnityBegin("socktoa.c");
-  RUN_TEST(test_IPv4AddressWithPort, 10);
-  RUN_TEST(test_IPv6AddressWithPort, 11);
-  RUN_TEST(test_ScopedIPv6AddressWithPort, 12);
-  RUN_TEST(test_HashEqual, 13);
-  RUN_TEST(test_HashNotEqual, 14);
-  RUN_TEST(test_IgnoreIPv6Fields, 15);
+  RUN_TEST(test_IPv4AddressWithPort, 9);
+  RUN_TEST(test_IPv6AddressWithPort, 10);
+  RUN_TEST(test_ScopedIPv6AddressWithPort, 11);
+  RUN_TEST(test_HashEqual, 12);
+  RUN_TEST(test_HashNotEqual, 13);
+  RUN_TEST(test_IgnoreIPv6Fields, 14);
 
   return (UnityEnd());
 }
index 6c224f808fac5604aab89804c3ea371276d04752..25cfe066559f822dbe7d53fbf54168c539b3788e 100644 (file)
@@ -10,10 +10,12 @@ run_unity = cd $(srcdir) && ruby ../../sntp/unity/auto/generate_test_runner.rb
 
 check_PROGRAMS =               \
        test-leapsec            \
-       test-rc_cmdlength   \
+       test-rc_cmdlength       \
        test-ntp_scanner        \
        $(NULL)
 
+#      test-ntp_signd          \ #doesn't work, can't link it because you can't link static function
+
 if GTEST_AVAILABLE
 check_PROGRAMS += tests
 else
@@ -111,7 +113,9 @@ test_ntp_signd_CFLAGS =                     \
        $(NULL)
 
 test_ntp_signd_LDADD =                 \
+       $(unity_tests_LDADD)            \
        $(top_builddir)/ntpd/libntpd.a  \
+       $(top_builddir)/ntpd/ntp_signd.o        \
        $(unity_tests_LDADD)            \
        $(NULL)
 
@@ -131,12 +135,13 @@ test_ntp_scanner_CFLAGS =                 \
 
 test_ntp_scanner_LDADD =                       \
        $(unity_tests_LDADD)            \
+       $(top_builddir)/ntpd/ntp_scanner.o              \
        $(NULL)
 
 test_ntp_scanner_SOURCES =                     \
-       ntp_scanner.c                   \
+       ntp_scanner.c                           \
        run-ntp_scanner.c                       \
-       $(srcdir)/../libntp/test-libntp.c               \
+       $(srcdir)/../libntp/test-libntp.c       \
        $(NULL)
 
 $(srcdir)/run-ntp_scanner.c: $(srcdir)/ntp_scanner.c $(std_unity_list)
index b1f52b0c1afbc06d9efcf1eded7bebf379cb13cb..3612693468d193ccdbd63e8fb7c7aeed334f97f4 100644 (file)
 /* ntp_keyword.h declares finite state machine and token text */
 //#include "ntp_keyword.h"
 
+void test_keywordIncorrectToken(void);
+void test_keywordServerToken(void);
+void test_DropUninitializedStack(void);
+void test_IncorrectlyInitializeLexStack(void);
+void test_InitializeLexStack(void);
+
+
 void test_keywordIncorrectToken(void){
        char * temp = keyword(999);
-       printf("%s",temp);
+       //printf("%s\n",temp);
+       TEST_ASSERT_EQUAL_STRING("(keyword not found)",temp);
 }
 
 void test_keywordServerToken(void){
        char * temp = keyword(401);
-       printf("%s",temp); //143 or 401 ?
+       //printf("%s",temp); //143 or 401 ?
+       TEST_ASSERT_EQUAL_STRING("server",temp);
+}
+
+void test_DropUninitializedStack(void){
+       lex_drop_stack();
+}
+
+void test_IncorrectlyInitializeLexStack(void){
+
+       TEST_ASSERT_FALSE(lex_init_stack(NULL,NULL));
+       lex_drop_stack();
+}
 
+void test_InitializeLexStack(void){
+       
+       //Some sort of server is required for this to work.
+       //sockaddr_u *  remote_addr
+       //char origin[128];
+       //snprintf(origin, sizeof(origin), "remote config from %s", stoa(remote_addr));
+       //TEST_ASSERT_TRUE(lex_init_stack(origin,NULL)); //path, mode -> NULL is ok!
+       lex_drop_stack();
 }
index 50d59483ee7807df33803e9f0830ef5b4877408e..162dbdab82cc5c85f44ce9259fcafb91fc40b1b5 100644 (file)
 #include "unity.h"
 #include <setjmp.h>
 #include <stdio.h>
+#include "config.h"
+#include "ntp.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+#include "ntp_leapsec.h"
+#include "test-libntp.h"
+#include <string.h>
 
 //=======External Functions This Runner Calls=====
 extern void setUp(void);
 extern void tearDown(void);
-void resetTest(void);
 extern void test_ValidateGood(void);
 extern void test_ValidateNoHash(void);
 extern void test_ValidateBad(void);
@@ -63,7 +69,8 @@ extern void test_lsEmptyTableElectric(void);
 
 
 //=======Test Reset Option=====
-void resetTest()
+void resetTest(void);
+void resetTest(void)
 {
   tearDown();
   setUp();
@@ -76,7 +83,6 @@ char *progname;
 int main(int argc, char *argv[])
 {
   progname = argv[0];
-  Unity.TestFile = "leapsec.c";
   UnityBegin("leapsec.c");
   RUN_TEST(test_ValidateGood, 331);
   RUN_TEST(test_ValidateNoHash, 338);
index 35d2598bd2f318b2766df758ef7c6423cdf287a3..7731e04feb0f7d701ab5331e6b1ac389b8c8e5d2 100644 (file)
@@ -30,6 +30,9 @@ extern void setUp(void);
 extern void tearDown(void);
 extern void test_keywordIncorrectToken(void);
 extern void test_keywordServerToken(void);
+extern void test_DropUninitializedStack(void);
+extern void test_IncorrectlyInitializeLexStack(void);
+extern void test_InitializeLexStack(void);
 
 
 //=======Test Reset Option=====
@@ -49,7 +52,10 @@ int main(int argc, char *argv[])
   progname = argv[0];
   UnityBegin("ntp_scanner.c");
   RUN_TEST(test_keywordIncorrectToken, 20);
-  RUN_TEST(test_keywordServerToken, 25);
+  RUN_TEST(test_keywordServerToken, 21);
+  RUN_TEST(test_DropUninitializedStack, 22);
+  RUN_TEST(test_IncorrectlyInitializeLexStack, 23);
+  RUN_TEST(test_InitializeLexStack, 24);
 
   return (UnityEnd());
 }
index e6e3cef41eadd66be4e39a1f748f7f570baaa4d5..55534d78e63da4766e7ecf9ea9639b17f3e881b6 100644 (file)
@@ -51,8 +51,8 @@ int main(int argc, char *argv[])
 {
   progname = argv[0];
   UnityBegin("ntp_signd.c");
-  RUN_TEST(test_ux_socket_connect, 13);
-  RUN_TEST(test_write_all, 24);
+  RUN_TEST(test_ux_socket_connect, 12);
+  RUN_TEST(test_write_all, 23);
 
   return (UnityEnd());
 }
index 17de146ae30031b4d26d5cdedbeddaf63d840502..2799b5b3a541e3f79c49034e6dff91656a604ae8 100644 (file)
 #include "unity.h"
 #include <setjmp.h>
 #include <stdio.h>
+#include "config.h"
+#include "ntp.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+#include "test-libntp.h"
+#include <string.h>
 
 //=======External Functions This Runner Calls=====
 extern void setUp(void);
 extern void tearDown(void);
-void resetTest(void);
 extern void test_EvaluateCommandLength(void);
 
 
 //=======Test Reset Option=====
-void resetTest()
+void resetTest(void);
+void resetTest(void)
 {
   tearDown();
   setUp();
@@ -44,7 +50,6 @@ char *progname;
 int main(int argc, char *argv[])
 {
   progname = argv[0];
-  Unity.TestFile = "rc_cmdlength.c";
   UnityBegin("rc_cmdlength.c");
   RUN_TEST(test_EvaluateCommandLength, 15);