]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Unity test cleanup. Harlan Stenn.
authorHarlan Stenn <stenn@ntp.org>
Wed, 25 Nov 2015 12:23:40 +0000 (12:23 +0000)
committerHarlan Stenn <stenn@ntp.org>
Wed, 25 Nov 2015 12:23:40 +0000 (12:23 +0000)
bk: 5655a84c2EcEdGPmoM8TRfzkjAIyww

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

index c0979b05e50e8261cccd1ccabf26184b5e258f5d..5226f7f853120b5e48916938201dbe2f2d36be25 100644 (file)
@@ -55,12 +55,12 @@ int main(int argc, char *argv[])
 {
   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());
 }
index a7c2f82cbdd9350b6a84d17cee828be9723f5217..d9c03f48514c5951b5663a5f8bc260fbe5ecb880 100644 (file)
@@ -25,19 +25,33 @@ connect(int socket, const struct sockaddr *address, socklen_t address_len)
        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;
 }