From: Damir Tomic Date: Thu, 20 Aug 2015 14:35:29 +0000 (+0200) Subject: t-ntpq.c: X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5bb283cab7ea7b6d38d5648b50529038b79feaf6;p=thirdparty%2Fntp.git t-ntpq.c: disabled for now, very trick to test static functions. run-t-ntpq.c: update ntp_scanner.c: added new test Makefile.am: added more include dirs bk: 55d5e5b1Gj-SA6whoaZsjQFewTRQgQ --- diff --git a/tests/ntpd/ntp_scanner.c b/tests/ntpd/ntp_scanner.c index 361269346..1bbe9fe4c 100644 --- a/tests/ntpd/ntp_scanner.c +++ b/tests/ntpd/ntp_scanner.c @@ -14,6 +14,7 @@ #include "ntp_scanner.h" //#include "ntp_parser.h" + /* ntp_keyword.h declares finite state machine and token text */ //#include "ntp_keyword.h" @@ -49,9 +50,16 @@ void test_IncorrectlyInitializeLexStack(void){ void test_InitializeLexStack(void){ //Some sort of server is required for this to work. - //sockaddr_u * remote_addr - //char origin[128]; + sockaddr_u * remote_addr; + char origin[128] ={ "" } ; + strcat(origin,"127.0.0.1"); //snprintf(origin, sizeof(origin), "remote config from %s", stoa(remote_addr)); - //TEST_ASSERT_TRUE(lex_init_stack(origin,NULL)); //path, mode -> NULL is ok! + TEST_ASSERT_TRUE(lex_init_stack(origin,NULL)); //path, mode -> NULL is ok! lex_drop_stack(); } + +void test_PopEmptyStack(void){ + int temp = lex_pop_file(); + + TEST_ASSERT_FALSE(temp); +} diff --git a/tests/ntpq/Makefile.am b/tests/ntpq/Makefile.am index 1491775cb..c3183c8ff 100644 --- a/tests/ntpq/Makefile.am +++ b/tests/ntpq/Makefile.am @@ -33,9 +33,8 @@ AM_CFLAGS = $(CFLAGS_NTP) AM_CPPFLAGS = $(NTP_INCS) AM_CPPFLAGS += -I$(top_srcdir)/ntpq -#AM_CPPFLAGS += -I$(top_srcdir)/sntp -#AM_CPPFLAGS += -I$(top_srcdir)/ntpd -#AM_CPPFLAGS += -I$(top_srcdir)/tests/libntp +AM_CPPFLAGS += -I$(top_srcdir)/sntp +AM_CPPFLAGS += -I$(top_srcdir)/sntp/libopts AM_CPPFLAGS += $(CPPFLAGS_NTP) AM_CPPFLAGS += -DUNITY_INCLUDE_CONFIG_H AM_CPPFLAGS += -I$(top_srcdir)/sntp/unity diff --git a/tests/ntpq/run-t-ntpq.c b/tests/ntpq/run-t-ntpq.c index 3c9416a9a..165b19546 100644 --- a/tests/ntpq/run-t-ntpq.c +++ b/tests/ntpq/run-t-ntpq.c @@ -24,7 +24,6 @@ #include #include "config.h" #include "ntp.h" -#include "ntp_stdlib.h" #include "ntpq.h" //=======External Functions This Runner Calls===== @@ -49,7 +48,7 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("t-ntpq.c"); - RUN_TEST(testPrimary, 9); + RUN_TEST(testPrimary, 20); return (UnityEnd()); } diff --git a/tests/ntpq/t-ntpq.c b/tests/ntpq/t-ntpq.c index c390ddb63..f4b35c5eb 100644 --- a/tests/ntpq/t-ntpq.c +++ b/tests/ntpq/t-ntpq.c @@ -1,14 +1,37 @@ #include "config.h" #include "ntp.h" -#include "ntp_stdlib.h" +//#include "ntp_stdlib.h" + + +//#include "ntp_calendar.h" #include "unity.h" #include "ntpq.h" +//very tricky to test static functions. It might be a good idea to use cmock here +//#define HAVE_NTPQ +//#include "ntpq.c" + + + +//extern int main(int argc, char *argv[]); + void testPrimary(void); void testPrimary(void){ + //main(NULL,NULL); +/* + char ** tokens; + int * num = 0; + tokenize("a bc de1 234",tokens, num); +*/ +} -} + + + + + +#define HAVE_NTP_SIGND