From: Damir Tomic Date: Mon, 17 Aug 2015 11:56:23 +0000 (+0200) Subject: Makefile.am: X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b81b7ce77baf4f25fd25a15194f018803a2d1a74;p=thirdparty%2Fntp.git Makefile.am: 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 --- diff --git a/tests/ntpd/Makefile.am b/tests/ntpd/Makefile.am index 1618bcd33..55bef305d 100644 --- a/tests/ntpd/Makefile.am +++ b/tests/ntpd/Makefile.am @@ -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 ### diff --git a/tests/ntpd/run-t-ntp_signd.c b/tests/ntpd/run-t-ntp_signd.c index a3b5bfc80..ff670d667 100644 --- a/tests/ntpd/run-t-ntp_signd.c +++ b/tests/ntpd/run-t-ntp_signd.c @@ -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()); } diff --git a/tests/ntpd/t-ntp_signd.c b/tests/ntpd/t-ntp_signd.c index 59fc77484..45972fb97 100644 --- a/tests/ntpd/t-ntp_signd.c +++ b/tests/ntpd/t-ntp_signd.c @@ -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); + + +}