{
progname = argv[0];
UnityBegin("t-ntp_signd.c");
- RUN_TEST(test_connect_incorrect_socket, 53);
- RUN_TEST(test_connect_correct_socket, 54);
- RUN_TEST(test_write_all, 55);
- RUN_TEST(test_send_packet, 56);
- RUN_TEST(test_recv_packet, 57);
- RUN_TEST(test_send_via_ntp_signd, 58);
+ RUN_TEST(test_connect_incorrect_socket, 67);
+ RUN_TEST(test_connect_correct_socket, 68);
+ RUN_TEST(test_write_all, 69);
+ RUN_TEST(test_send_packet, 70);
+ RUN_TEST(test_recv_packet, 71);
+ RUN_TEST(test_send_via_ntp_signd, 72);
return (UnityEnd());
}
return 1;
}
-//mocked write will only send 4 bytes at a time. This is so write_all can be properly tested
+/*
+** Mocked read() and write() calls.
+**
+** These will only operate 4 bytes at a time.
+**
+** This is so write_all can be properly tested.
+*/
+
+static char rw_buf[4];
+
ssize_t
write(int fd, void const * buf, size_t len)
{
- if (len >= 4) {return 4;}
- else return len;
+ REQUIRE(0 <= len);
+ if (len >= 4) len = 4; /* 4 bytes, max */
+ (void)memcpy(rw_buf, buf, len);
+
+ return len;
}
ssize_t
read(int fd, void * buf, size_t len)
{
- if (len >= 4) {return 4;}
- else return len;
+ REQUIRE(0 <= len);
+ if (len >= 4) len = 4;
+ (void)memcpy(buf, rw_buf, len);
+ return len;
}