From: Damir Tomic Date: Thu, 23 Jul 2015 16:37:16 +0000 (+0200) Subject: reduced number of warnings in sntp/tests/ X-Git-Tag: NTP_4_3_64~4^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f82bdaddb48113c16c5119113dbe85ee37f5aa9d;p=thirdparty%2Fntp.git reduced number of warnings in sntp/tests/ bk: 55b1183ccvxlr8Gl_Q74O1Tqr2LprA --- diff --git a/sntp/tests/crypto.c b/sntp/tests/crypto.c index d679fdec7..82d285976 100644 --- a/sntp/tests/crypto.c +++ b/sntp/tests/crypto.c @@ -10,6 +10,12 @@ void test_MakeMd5Mac(void); +void test_MakeSHA1Mac(void); +void test_VerifyCorrectMD5(void); +void test_VerifySHA1(void); +void test_VerifyFailure(void); +void test_PacketSizeNotMultipleOfFourBytes(void); + void test_MakeMd5Mac(void) { diff --git a/sntp/tests/fileHandlingTest.c b/sntp/tests/fileHandlingTest.c index a328f4722..1e0f6a6a7 100644 --- a/sntp/tests/fileHandlingTest.c +++ b/sntp/tests/fileHandlingTest.c @@ -21,7 +21,7 @@ CreatePath(const char* filename, enum DirectoryType argument) { const char srcdir[] = SRCDIR_DEF;//"@abs_srcdir@/data/"; char * path = malloc (sizeof (char) * (strlen(srcdir) + 256)); - char cwd[1024]; + //char cwd[1024]; strcpy(path, srcdir); strcat(path, filename); diff --git a/sntp/tests/keyFile.c b/sntp/tests/keyFile.c index f4d639f1d..77dfee7f0 100644 --- a/sntp/tests/keyFile.c +++ b/sntp/tests/keyFile.c @@ -10,6 +10,10 @@ bool CompareKeys(struct key expected, struct key actual); bool CompareKeysAlternative(int key_id,int key_len,const char* type,const char* key_seq,struct key actual); void test_ReadEmptyKeyFile(void); +void test_ReadASCIIKeys(void); +void test_ReadHexKeys(void); +void test_ReadKeyFileWithComments(void); +void test_ReadKeyFileWithInvalidHex(void); bool diff --git a/sntp/tests/kodDatabase.c b/sntp/tests/kodDatabase.c index a231bbe0d..0c3615d0e 100644 --- a/sntp/tests/kodDatabase.c +++ b/sntp/tests/kodDatabase.c @@ -9,6 +9,12 @@ #include "unity.h" +void setUp(void); +void test_SingleEntryHandling(void); +void test_MultipleEntryHandling(void); +void test_NoMatchInSearch(void); +void test_AddDuplicate(void); +void test_DeleteEntry(void); void diff --git a/sntp/tests/kodFile.c b/sntp/tests/kodFile.c index 69a2376db..6eb0971a9 100644 --- a/sntp/tests/kodFile.c +++ b/sntp/tests/kodFile.c @@ -15,6 +15,14 @@ extern int kod_db_cnt; extern struct kod_entry** kod_db; extern char* kod_db_file; +void setUp(void); +void test_ReadEmptyFile(void); +void test_ReadCorrectFile(void); +void test_ReadFileWithBlankLines(void); +void test_WriteEmptyFile(void); +void test_WriteFileWithSingleEntry(void); +void test_WriteFileWithMultipleEntries(void); + void setUp(void) { diff --git a/sntp/tests/nameresolution.c b/sntp/tests/nameresolution.c index 8f1f6d970..1249c4d9e 100644 --- a/sntp/tests/nameresolution.c +++ b/sntp/tests/nameresolution.c @@ -5,6 +5,9 @@ #include "sntptest.h" #include "networking.h" +void test_ResolveSingleAddress(void); + + int CompareAddrinfo(const char* host, int family, int flags, const struct addrinfo actual) { if (family != actual.ai_family) return FALSE ; diff --git a/sntp/tests/packetHandling.c b/sntp/tests/packetHandling.c index 57b0d9909..1036fc3b8 100644 --- a/sntp/tests/packetHandling.c +++ b/sntp/tests/packetHandling.c @@ -12,6 +12,19 @@ #include "unity.h" +void setUp(void); +int LfpEquality(const l_fp expected, const l_fp actual); +void test_GenerateUnauthenticatedPacket(void); +void test_GenerateAuthenticatedPacket(void); +void test_OffsetCalculationPositiveOffset(void); +void test_OffsetCalculationNegativeOffset(void); +void test_HandleUnusableServer(void); +void test_HandleUnusablePacket(void); +void test_HandleServerAuthenticationFailure(void); +void test_HandleKodDemobilize(void); +void test_HandleKodRate(void); +void test_HandleCorrectPacket(void); + void setUp(void) { diff --git a/sntp/tests/packetProcessing.c b/sntp/tests/packetProcessing.c index 5ec7df3ad..51ec572f1 100644 --- a/sntp/tests/packetProcessing.c +++ b/sntp/tests/packetProcessing.c @@ -12,6 +12,30 @@ extern struct key* key_ptr; extern int key_cnt; +void PrepareAuthenticationTest(int key_id,int key_len,const char* type,const void* key_seq); +void PrepareAuthenticationTestMD5(int key_id,int key_len,const void* key_seq); +void setUp(void); +void tearDown(void); +void test_TooShortLength(void); +void test_LengthNotMultipleOfFour(void); +void test_TooShortExtensionFieldLength(void); +void test_UnauthenticatedPacketReject(void); +void test_CryptoNAKPacketReject(void); +void test_AuthenticatedPacketInvalid(void); +void test_AuthenticatedPacketUnknownKey(void); +void test_ServerVersionTooOld(void); +void test_ServerVersionTooNew(void); +void test_NonWantedMode(void); +void test_KoDRate(void); +void test_KoDDeny(void); +void test_RejectUnsyncedServer(void); +void test_RejectWrongResponseServerMode(void); +void test_AcceptNoSentPacketBroadcastMode(void); +void test_CorrectUnauthenticatedPacket(void); +void test_CorrectAuthenticatedPacketMD5(void); +void test_CorrectAuthenticatedPacketSHA1(void); + + static struct pkt testpkt; static struct pkt testspkt; static sockaddr_u testsock; diff --git a/sntp/tests/run-crypto.c b/sntp/tests/run-crypto.c index 603c6d5d8..d4f811f0e 100644 --- a/sntp/tests/run-crypto.c +++ b/sntp/tests/run-crypto.c @@ -55,11 +55,11 @@ int main(int argc, char *argv[]) progname = argv[0]; UnityBegin("crypto.c"); RUN_TEST(test_MakeMd5Mac, 12); - RUN_TEST(test_MakeSHA1Mac, 38); - RUN_TEST(test_VerifyCorrectMD5, 65); - RUN_TEST(test_VerifySHA1, 85); - RUN_TEST(test_VerifyFailure, 108); - RUN_TEST(test_PacketSizeNotMultipleOfFourBytes, 130); + RUN_TEST(test_MakeSHA1Mac, 13); + RUN_TEST(test_VerifyCorrectMD5, 14); + RUN_TEST(test_VerifySHA1, 15); + RUN_TEST(test_VerifyFailure, 16); + RUN_TEST(test_PacketSizeNotMultipleOfFourBytes, 17); return (UnityEnd()); } diff --git a/sntp/tests/run-keyFile.c b/sntp/tests/run-keyFile.c index e08b614ed..f55c03520 100644 --- a/sntp/tests/run-keyFile.c +++ b/sntp/tests/run-keyFile.c @@ -55,10 +55,10 @@ int main(int argc, char *argv[]) progname = argv[0]; UnityBegin("keyFile.c"); RUN_TEST(test_ReadEmptyKeyFile, 12); - RUN_TEST(test_ReadASCIIKeys, 68); - RUN_TEST(test_ReadHexKeys, 88); - RUN_TEST(test_ReadKeyFileWithComments, 116); - RUN_TEST(test_ReadKeyFileWithInvalidHex, 137); + RUN_TEST(test_ReadASCIIKeys, 13); + RUN_TEST(test_ReadHexKeys, 14); + RUN_TEST(test_ReadKeyFileWithComments, 15); + RUN_TEST(test_ReadKeyFileWithInvalidHex, 16); return (UnityEnd()); } diff --git a/sntp/tests/run-kodDatabase.c b/sntp/tests/run-kodDatabase.c index b10a56d25..6de7bacd0 100644 --- a/sntp/tests/run-kodDatabase.c +++ b/sntp/tests/run-kodDatabase.c @@ -56,11 +56,11 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("kodDatabase.c"); - RUN_TEST(test_SingleEntryHandling, 21); - RUN_TEST(test_MultipleEntryHandling, 36); - RUN_TEST(test_NoMatchInSearch, 69); - RUN_TEST(test_AddDuplicate, 84); - RUN_TEST(test_DeleteEntry, 111); + RUN_TEST(test_SingleEntryHandling, 13); + RUN_TEST(test_MultipleEntryHandling, 14); + RUN_TEST(test_NoMatchInSearch, 15); + RUN_TEST(test_AddDuplicate, 16); + RUN_TEST(test_DeleteEntry, 17); return (UnityEnd()); } diff --git a/sntp/tests/run-kodFile.c b/sntp/tests/run-kodFile.c index 0f29096a0..3c2553c26 100644 --- a/sntp/tests/run-kodFile.c +++ b/sntp/tests/run-kodFile.c @@ -55,12 +55,12 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("kodFile.c"); - RUN_TEST(test_ReadEmptyFile, 27); - RUN_TEST(test_ReadCorrectFile, 35); - RUN_TEST(test_ReadFileWithBlankLines, 55); - RUN_TEST(test_WriteEmptyFile, 80); - RUN_TEST(test_WriteFileWithSingleEntry, 95); - RUN_TEST(test_WriteFileWithMultipleEntries, 120); + RUN_TEST(test_ReadEmptyFile, 19); + RUN_TEST(test_ReadCorrectFile, 20); + RUN_TEST(test_ReadFileWithBlankLines, 21); + RUN_TEST(test_WriteEmptyFile, 22); + RUN_TEST(test_WriteFileWithSingleEntry, 23); + RUN_TEST(test_WriteFileWithMultipleEntries, 24); return (UnityEnd()); } diff --git a/sntp/tests/run-packetHandling.c b/sntp/tests/run-packetHandling.c index f2086e209..3a34590b6 100644 --- a/sntp/tests/run-packetHandling.c +++ b/sntp/tests/run-packetHandling.c @@ -63,16 +63,16 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("packetHandling.c"); - RUN_TEST(test_GenerateUnauthenticatedPacket, 32); - RUN_TEST(test_GenerateAuthenticatedPacket, 57); - RUN_TEST(test_OffsetCalculationPositiveOffset, 98); - RUN_TEST(test_OffsetCalculationNegativeOffset, 144); - RUN_TEST(test_HandleUnusableServer, 189); - RUN_TEST(test_HandleUnusablePacket, 202); - RUN_TEST(test_HandleServerAuthenticationFailure, 215); - RUN_TEST(test_HandleKodDemobilize, 228); - RUN_TEST(test_HandleKodRate, 254); - RUN_TEST(test_HandleCorrectPacket, 267); + RUN_TEST(test_GenerateUnauthenticatedPacket, 17); + RUN_TEST(test_GenerateAuthenticatedPacket, 18); + RUN_TEST(test_OffsetCalculationPositiveOffset, 19); + RUN_TEST(test_OffsetCalculationNegativeOffset, 20); + RUN_TEST(test_HandleUnusableServer, 21); + RUN_TEST(test_HandleUnusablePacket, 22); + RUN_TEST(test_HandleServerAuthenticationFailure, 23); + RUN_TEST(test_HandleKodDemobilize, 24); + RUN_TEST(test_HandleKodRate, 25); + RUN_TEST(test_HandleCorrectPacket, 26); return (UnityEnd()); } diff --git a/sntp/tests/run-packetProcessing.c b/sntp/tests/run-packetProcessing.c index 041d16fcc..b987d4a26 100644 --- a/sntp/tests/run-packetProcessing.c +++ b/sntp/tests/run-packetProcessing.c @@ -66,24 +66,24 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("packetProcessing.c"); - RUN_TEST(test_TooShortLength, 91); - RUN_TEST(test_LengthNotMultipleOfFour, 102); - RUN_TEST(test_TooShortExtensionFieldLength, 113); - RUN_TEST(test_UnauthenticatedPacketReject, 131); - RUN_TEST(test_CryptoNAKPacketReject, 147); - RUN_TEST(test_AuthenticatedPacketInvalid, 161); - RUN_TEST(test_AuthenticatedPacketUnknownKey, 186); - RUN_TEST(test_ServerVersionTooOld, 208); - RUN_TEST(test_ServerVersionTooNew, 225); - RUN_TEST(test_NonWantedMode, 242); - RUN_TEST(test_KoDRate, 259); - RUN_TEST(test_KoDDeny, 272); - RUN_TEST(test_RejectUnsyncedServer, 285); - RUN_TEST(test_RejectWrongResponseServerMode, 299); - RUN_TEST(test_AcceptNoSentPacketBroadcastMode, 318); - RUN_TEST(test_CorrectUnauthenticatedPacket, 332); - RUN_TEST(test_CorrectAuthenticatedPacketMD5, 342); - RUN_TEST(test_CorrectAuthenticatedPacketSHA1, 364); + RUN_TEST(test_TooShortLength, 19); + RUN_TEST(test_LengthNotMultipleOfFour, 20); + RUN_TEST(test_TooShortExtensionFieldLength, 21); + RUN_TEST(test_UnauthenticatedPacketReject, 22); + RUN_TEST(test_CryptoNAKPacketReject, 23); + RUN_TEST(test_AuthenticatedPacketInvalid, 24); + RUN_TEST(test_AuthenticatedPacketUnknownKey, 25); + RUN_TEST(test_ServerVersionTooOld, 26); + RUN_TEST(test_ServerVersionTooNew, 27); + RUN_TEST(test_NonWantedMode, 28); + RUN_TEST(test_KoDRate, 29); + RUN_TEST(test_KoDDeny, 30); + RUN_TEST(test_RejectUnsyncedServer, 31); + RUN_TEST(test_RejectWrongResponseServerMode, 32); + RUN_TEST(test_AcceptNoSentPacketBroadcastMode, 33); + RUN_TEST(test_CorrectUnauthenticatedPacket, 34); + RUN_TEST(test_CorrectAuthenticatedPacketMD5, 35); + RUN_TEST(test_CorrectAuthenticatedPacketSHA1, 36); return (UnityEnd()); } diff --git a/sntp/tests/run-utilities.c b/sntp/tests/run-utilities.c index e196c8a92..0eb0ba90b 100644 --- a/sntp/tests/run-utilities.c +++ b/sntp/tests/run-utilities.c @@ -57,13 +57,13 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("utilities.c"); - RUN_TEST(test_IPv4Address, 74); - RUN_TEST(test_IPv6Address, 86); - RUN_TEST(test_SetLiVnMode1, 108); - RUN_TEST(test_SetLiVnMode2, 123); - RUN_TEST(test_PktOutput, 139); - RUN_TEST(test_LfpOutputBinaryFormat, 161); - RUN_TEST(test_LfpOutputDecimalFormat, 179); + RUN_TEST(test_IPv4Address, 16); + RUN_TEST(test_IPv6Address, 17); + RUN_TEST(test_SetLiVnMode1, 18); + RUN_TEST(test_SetLiVnMode2, 19); + RUN_TEST(test_PktOutput, 20); + RUN_TEST(test_LfpOutputBinaryFormat, 21); + RUN_TEST(test_LfpOutputDecimalFormat, 22); return (UnityEnd()); } diff --git a/sntp/tests/utilities.c b/sntp/tests/utilities.c index b52791f32..39d22d61b 100644 --- a/sntp/tests/utilities.c +++ b/sntp/tests/utilities.c @@ -9,6 +9,18 @@ #include +sockaddr_u CreateSockaddr4(const char* address); +struct addrinfo CreateAddrinfo(sockaddr_u* sock); +void InitDebugTest(const char * filename); +void FinishDebugTest(const char * expected,const char * actual); +void test_IPv4Address(void); +void test_IPv6Address(void); +void test_SetLiVnMode1(void); +void test_SetLiVnMode2(void); +void test_PktOutput(void); +void test_LfpOutputBinaryFormat(void); +void test_LfpOutputDecimalFormat(void); + const char * Version = "stub unit test Version string";