$(run_unity) ntp_restrict.c run-ntp_restrict.c
+
###
test_rc_cmdlength_CFLAGS = \
-I$(top_srcdir)/sntp/unity \
$(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) \
$(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
###
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);
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());
}
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?
char * str = "TEST123";
int temp = write_all(fd, str,strlen(str));
TEST_ASSERT_EQUAL(strlen(str),temp);
-
-
-
}
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);
+
+
+}