]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
packetProcessing.c:
authorDamir Tomic <viperus@ntp.org>
Thu, 25 Jun 2015 14:34:19 +0000 (16:34 +0200)
committerDamir Tomic <viperus@ntp.org>
Thu, 25 Jun 2015 14:34:19 +0000 (16:34 +0200)
  fixed SetUp() -> setUp() and TearDown() -> tearDown() which seemed to work because of extern functions

bk: 558c116b-voNJrcEWcMo1XSIoHrZmA

sntp/tests/packetProcessing.c
sntp/tests/run-packetProcessing.c

index 34ac79007b5b55fc7ac5457cce21fa53c96920bf..27ab72e4d4336a96fcf5c2c1af2cc9df2e6b4b8f 100644 (file)
@@ -43,7 +43,9 @@ void PrepareAuthenticationTestMD5(int key_id,
        PrepareAuthenticationTest(key_id, key_len, "MD5", key_seq);
 }
 
-void SetUp() {
+void setUp() {
+
+       sntptest();
        restoreKeyDb = false;
 
        /* Initialize the test packet and socket,
@@ -64,7 +66,7 @@ void SetUp() {
 
 }
 
-void TearDown() {
+void tearDown() {
        
        if (restoreKeyDb) {
                key_cnt = 0;
@@ -72,7 +74,7 @@ void TearDown() {
                key_ptr = NULL;
        }
 
-       //sntptest_destroy(); //only on the final test!! if counter == 0 etc...
+       sntptest_destroy(); //only on the final test!! if counter == 0 etc...
 
 }
 
@@ -113,7 +115,7 @@ void test_TooShortExtensionFieldLength(void) {
 }
 
 void test_UnauthenticatedPacketReject(void) {
-       sntptest();
+       //sntptest();
        // Activate authentication option
        ActivateOption("-a", "123");
        TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
@@ -127,7 +129,6 @@ void test_UnauthenticatedPacketReject(void) {
 }
 
 void test_CryptoNAKPacketReject(void) {
-sntptest_destroy();
        // Activate authentication option
        ActivateOption("-a", "123");
        TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
@@ -140,7 +141,6 @@ sntptest_destroy();
 }
 
 void test_AuthenticatedPacketInvalid(void) {
-sntptest_destroy();
        // Activate authentication option
        PrepareAuthenticationTestMD5(50, 9, "123456789");
        TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
@@ -163,7 +163,7 @@ sntptest_destroy();
                                                  MODE_SERVER, &testspkt, "UnitTest"));
 }
 
-void test_AuthenticatedPacketUnknownKey(void) {sntptest_destroy();
+void test_AuthenticatedPacketUnknownKey(void) {
        // Activate authentication option
        PrepareAuthenticationTestMD5(30, 9, "123456789");
        TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
@@ -279,7 +279,7 @@ void test_RejectWrongResponseServerMode(void) {
                                                  MODE_SERVER, &testspkt, "UnitTest"));
 }
 
-void test_AcceptNoSentPacketBroadcastMode(void) { sntptest_destroy();
+void test_AcceptNoSentPacketBroadcastMode(void) {
        TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
 
        testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
@@ -291,7 +291,7 @@ void test_AcceptNoSentPacketBroadcastMode(void) { sntptest_destroy();
                              MODE_BROADCAST, NULL, "UnitTest"));
 }
 
-void test_CorrectUnauthenticatedPacket(void) { sntptest_destroy();
+void test_CorrectUnauthenticatedPacket(void) {
        TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
 
        TEST_ASSERT_EQUAL(LEN_PKT_NOMAC,
@@ -299,7 +299,7 @@ void test_CorrectUnauthenticatedPacket(void) { sntptest_destroy();
                                                  MODE_SERVER, &testspkt, "UnitTest"));
 }
 
-void test_CorrectAuthenticatedPacketMD5(void) { sntptest_destroy();
+void test_CorrectAuthenticatedPacketMD5(void) {
        PrepareAuthenticationTestMD5(10, 15, "123456789abcdef");
        TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
 
@@ -319,7 +319,7 @@ void test_CorrectAuthenticatedPacketMD5(void) { sntptest_destroy();
 
 }
 
-void test_CorrectAuthenticatedPacketSHA1(void) { sntptest_destroy();
+void test_CorrectAuthenticatedPacketSHA1(void) {
        PrepareAuthenticationTest(20, 15, "SHA1", "abcdefghijklmno");
        TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
 
index b222d6eda267b8a71e3b95fe55d8b32d35074aa3..f41d5c7eb2f0c3fe341571ac61f30f0f7c5cf4ad 100644 (file)
@@ -63,12 +63,12 @@ int main(int argc, char *argv[])
   progname = argv[0];
   Unity.TestFile = "packetProcessing.c";
   UnityBegin("packetProcessing.c");
-  RUN_TEST(test_TooShortLength, 81);
-  RUN_TEST(test_LengthNotMultipleOfFour, 90);
-  RUN_TEST(test_TooShortExtensionFieldLength, 99);
-  RUN_TEST(test_UnauthenticatedPacketReject, 115);
-  RUN_TEST(test_CryptoNAKPacketReject, 129);
-  RUN_TEST(test_AuthenticatedPacketInvalid, 142);
+  RUN_TEST(test_TooShortLength, 83);
+  RUN_TEST(test_LengthNotMultipleOfFour, 92);
+  RUN_TEST(test_TooShortExtensionFieldLength, 101);
+  RUN_TEST(test_UnauthenticatedPacketReject, 117);
+  RUN_TEST(test_CryptoNAKPacketReject, 131);
+  RUN_TEST(test_AuthenticatedPacketInvalid, 143);
   RUN_TEST(test_AuthenticatedPacketUnknownKey, 166);
   RUN_TEST(test_ServerVersionTooOld, 186);
   RUN_TEST(test_ServerVersionTooNew, 201);