From: Damir Tomic Date: Mon, 27 Jul 2015 17:46:25 +0000 (+0200) Subject: Many files: X-Git-Tag: NTP_4_3_67~2^2~3^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46179cdcdb3ce3281049d2672c86fc80f68cdba4;p=thirdparty%2Fntp.git Many files: 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 --- diff --git a/tests/libntp/lfptest.h b/tests/libntp/lfptest.h index defbf5822..6075f310e 100644 --- a/tests/libntp/lfptest.h +++ b/tests/libntp/lfptest.h @@ -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 diff --git a/tests/libntp/run-decodenetnum.c b/tests/libntp/run-decodenetnum.c index ed7208ee1..70dd294df 100644 --- a/tests/libntp/run-decodenetnum.c +++ b/tests/libntp/run-decodenetnum.c @@ -24,6 +24,7 @@ #include #include "config.h" #include "ntp_stdlib.h" +#include "ntp_calendar.h" #include "sockaddrtest.h" //=======External Functions This Runner Calls===== diff --git a/tests/libntp/run-lfptostr.c b/tests/libntp/run-lfptostr.c index feb402224..c744fba09 100644 --- a/tests/libntp/run-lfptostr.c +++ b/tests/libntp/run-lfptostr.c @@ -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()); } diff --git a/tests/libntp/run-netof.c b/tests/libntp/run-netof.c index 3f27f6759..47fafdd5c 100644 --- a/tests/libntp/run-netof.c +++ b/tests/libntp/run-netof.c @@ -24,7 +24,6 @@ #include #include "config.h" #include "ntp_stdlib.h" -#include "ntp_calendar.h" #include "sockaddrtest.h" //=======External Functions This Runner Calls===== diff --git a/tests/libntp/run-socktoa.c b/tests/libntp/run-socktoa.c index 7bff53c60..3cf17a8b3 100644 --- a/tests/libntp/run-socktoa.c +++ b/tests/libntp/run-socktoa.c @@ -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()); } diff --git a/tests/ntpd/Makefile.am b/tests/ntpd/Makefile.am index 6c224f808..25cfe0665 100644 --- a/tests/ntpd/Makefile.am +++ b/tests/ntpd/Makefile.am @@ -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) diff --git a/tests/ntpd/ntp_scanner.c b/tests/ntpd/ntp_scanner.c index b1f52b0c1..361269346 100644 --- a/tests/ntpd/ntp_scanner.c +++ b/tests/ntpd/ntp_scanner.c @@ -17,13 +17,41 @@ /* 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(); } diff --git a/tests/ntpd/run-leapsec.c b/tests/ntpd/run-leapsec.c index 50d59483e..162dbdab8 100644 --- a/tests/ntpd/run-leapsec.c +++ b/tests/ntpd/run-leapsec.c @@ -22,11 +22,17 @@ #include "unity.h" #include #include +#include "config.h" +#include "ntp.h" +#include "ntp_calendar.h" +#include "ntp_stdlib.h" +#include "ntp_leapsec.h" +#include "test-libntp.h" +#include //=======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); diff --git a/tests/ntpd/run-ntp_scanner.c b/tests/ntpd/run-ntp_scanner.c index 35d2598bd..7731e04fe 100644 --- a/tests/ntpd/run-ntp_scanner.c +++ b/tests/ntpd/run-ntp_scanner.c @@ -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()); } diff --git a/tests/ntpd/run-ntp_signd.c b/tests/ntpd/run-ntp_signd.c index e6e3cef41..55534d78e 100644 --- a/tests/ntpd/run-ntp_signd.c +++ b/tests/ntpd/run-ntp_signd.c @@ -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()); } diff --git a/tests/ntpd/run-rc_cmdlength.c b/tests/ntpd/run-rc_cmdlength.c index 17de146ae..2799b5b3a 100644 --- a/tests/ntpd/run-rc_cmdlength.c +++ b/tests/ntpd/run-rc_cmdlength.c @@ -22,16 +22,22 @@ #include "unity.h" #include #include +#include "config.h" +#include "ntp.h" +#include "ntp_calendar.h" +#include "ntp_stdlib.h" +#include "test-libntp.h" +#include //=======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);