]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Makefile.am:
authorDamir Tomic <viperus@ntp.org>
Mon, 17 Aug 2015 11:56:23 +0000 (13:56 +0200)
committerDamir Tomic <viperus@ntp.org>
Mon, 17 Aug 2015 11:56:23 +0000 (13:56 +0200)
  fixed minor typo which caused me a lot of headache
t-ntp_signd.c:
  added a new test
run-t-ntp_signd.c:
  autogen update
Makefile.am:
  removed unnecessary CFLAG
t-ntp_signd.c:
  minor update

bk: 55d1cbe7T5REGmcFI2SJYci979PgoA

tests/ntpd/Makefile.am
tests/ntpd/run-t-ntp_signd.c
tests/ntpd/t-ntp_signd.c

index 1618bcd3310f9a065cc857e04670861442199bd8..55bef305dbef49fd0acdc073327d8f6df383004d 100644 (file)
@@ -118,6 +118,7 @@ $(srcdir)/run-ntp_restrict.c: $(srcdir)/ntp_restrict.c $(std_unity_list)
        $(run_unity) ntp_restrict.c run-ntp_restrict.c
 
 
+
 ###
 test_rc_cmdlength_CFLAGS =             \
        -I$(top_srcdir)/sntp/unity      \
@@ -137,9 +138,6 @@ $(srcdir)/run-rc_cmdlength.c: $(srcdir)/rc_cmdlength.c $(std_unity_list)
        $(run_unity) rc_cmdlength.c run-rc_cmdlength.c
 
 ###
-test_ntp_signd_CFLAGS =                        \
-       -I$(top_srcdir)/sntp/unity      \
-       $(NULL)
 
 test_ntp_signd_LDADD =                 \
        $(unity_tests_LDADD)            \
@@ -154,7 +152,7 @@ test_ntp_signd_SOURCES =            \
        $(srcdir)/../../ntpd/ntp_signd.c        \
        $(NULL)
 
-$(srcdir)/run-ntp_signd.c: $(srcdir)/t-ntp_signd.c $(std_unity_list)
+$(srcdir)/run-t-ntp_signd.c: $(srcdir)/t-ntp_signd.c $(std_unity_list)
        $(run_unity) t-ntp_signd.c run-t-ntp_signd.c
 
 ###
index a3b5bfc809e1c8267dca87b45d1f36949f57c4c5..ff670d6674cbf9aad85fb6b30fc0cb64bb595cf0 100644 (file)
@@ -35,6 +35,9 @@ extern void test_connect_incorrect_socket(void);
 extern void test_connect_correct_socket(void);
 extern void test_write_all(void);
 extern void test_send_packet(void);
+extern void test_recv_packet(void);
+extern void test_send_via_ntp_signd();
+
 
 //=======Test Reset Option=====
 void resetTest(void);
@@ -51,11 +54,13 @@ char *progname;
 int main(int argc, char *argv[])
 {
   progname = argv[0];
-  UnityBegin("ntp_signd.c");
-  RUN_TEST(test_connect_incorrect_socket, 12);
-  RUN_TEST(test_connect_correct_socket, 12);
-  RUN_TEST(test_write_all, 23);
-  RUN_TEST(test_send_packet,25);
+  UnityBegin("t-ntp_signd.c");
+  RUN_TEST(test_connect_incorrect_socket, 49);
+  RUN_TEST(test_connect_correct_socket, 54);
+  RUN_TEST(test_write_all, 74);
+  RUN_TEST(test_send_packet, 84);
+  RUN_TEST(test_recv_packet, 93);
+  RUN_TEST(test_send_via_ntp_signd, 104);
 
   return (UnityEnd());
 }
index 59fc77484405ce4b19ba56c35dbf476991a681e5..45972fb979bad87ee94ce539fc1cb66fd87a7592 100644 (file)
@@ -53,16 +53,8 @@ test_connect_incorrect_socket(void){
 void 
 test_connect_correct_socket(void){
 
-//send_via_ntp_signd(NULL,NULL,NULL,NULL,NULL);        
-       /*
-       send_via_ntp_signd(
-       struct recvbuf *rbufp,  
-       int     xmode,
-       keyid_t xkeyid, 
-       int flags,
-       struct pkt  *xpkt)
-*/
-       
+
+
        int temp = ux_socket_connect("/socket");
 
        //risky, what if something is listening on :123, or localhost isnt 127.0.0.1?
@@ -85,9 +77,6 @@ test_write_all(void){
        char * str = "TEST123";
        int temp = write_all(fd, str,strlen(str));
        TEST_ASSERT_EQUAL(strlen(str),temp);
-
-       
-
 }
 
 
@@ -98,3 +87,30 @@ test_send_packet(void){
        int temp = send_packet(fd, str2, strlen(str2));
        TEST_ASSERT_EQUAL(0,temp);
 }
+
+
+void
+test_recv_packet(void){
+       int fd = ux_socket_connect("/socket");
+       int size = 256; 
+       char str[size];
+
+       int temp = recv_packet(fd, &str, &size);
+       send_packet(fd, str, strlen(str));
+       TEST_ASSERT_EQUAL(0,temp); //0 because nobody sent us anything (yet!)
+}
+
+void 
+test_send_via_ntp_signd(){
+
+       struct recvbuf *rbufp = (struct recvbuf *) malloc(sizeof(struct recvbuf));
+       int     xmode = 1;
+       keyid_t xkeyid = 12345; 
+       int flags =0;
+       struct pkt  *xpkt = (struct pkt *) malloc(sizeof(struct pkt)); //defined in ntp.h
+
+       //send_via_ntp_signd(NULL,NULL,NULL,NULL,NULL); //doesn't work
+       send_via_ntp_signd(rbufp,xmode,xkeyid,flags,xpkt);
+
+
+}