]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
t-ntpq.c:
authorDamir Tomic <viperus@ntp.org>
Thu, 20 Aug 2015 14:35:29 +0000 (16:35 +0200)
committerDamir Tomic <viperus@ntp.org>
Thu, 20 Aug 2015 14:35:29 +0000 (16:35 +0200)
  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

tests/ntpd/ntp_scanner.c
tests/ntpq/Makefile.am
tests/ntpq/run-t-ntpq.c
tests/ntpq/t-ntpq.c

index 3612693468d193ccdbd63e8fb7c7aeed334f97f4..1bbe9fe4c8552d5ac2b1d0bca7f3216bf868a5f0 100644 (file)
@@ -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);
+}
index 1491775cbc6260ab9451b5027a90b3210f1ed0e5..c3183c8ffc987e3ccd23008a8355513447fa7c96 100644 (file)
@@ -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
index 3c9416a9afe59764fe57bfc957ecfbbe0eeeaf92..165b19546f078203ee2a6d3ebcd08fff8110e9fc 100644 (file)
@@ -24,7 +24,6 @@
 #include <stdio.h>
 #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());
 }
index c390ddb63633b37a0798bb57e75a0c3336bfc48b..f4b35c5eb5a6d4837b2fd5986f28e7c2ed620ed6 100644 (file)
@@ -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