]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
lfptest.h:
authorTomek Mrugalski <tomasz@isc.org>
Thu, 9 Jul 2015 02:25:01 +0000 (04:25 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Thu, 9 Jul 2015 02:25:01 +0000 (04:25 +0200)
  now it uses NTP's conventions
ChangeLog:
  add info about lfptest.h
test-libntp.c:
  fixed formatting
sockaddrtest.h:
  formatting fix
kodDatabase.c:
  formatting, adding const, adding a missing library
ChangeLog:
  added info about timespecops.c
kodFile.c:
  formatting, changes to usage of unity macros to get better print messages, cleanup
crypto.c, lfptest.h:
  cleanup
ChangeLog:
  add info about test-libntp.c
timespecops.c:
  further formatting changes
ChangeLog:
  added info about timevalops.c
fileHandlingTest.h.in:
  fixed buffer overflow problem and fixed one function that previously did nothing
timevalops.c:
  fixed the order of includes, deleted unnecessary
packetProcessing.c:
  formatting, sprintf->snprintf
packetHandling.c:
  formatting, using better unity functions, using proper unity functions, deleting unused variable
keyFile.c:
  formatting, using proper unity's macros
ChangeLog:
  fileHandlingTest.h info
  updating with info about sockaddrtest.h
timespecops.c:
  forgot to delete one comment
ChangeLog:
  added info about my code review changes in sntp/tests/
kodDatabase.c:
  missed something in formatting
sntptest.h:
  formatting
Many files:
  autogenerated
kodDatabase.c:
  added a header. now it's windows compliant too!
fileHandlingTest.h.in:
  formatting, deleted unnecessary prints
timespecops.c:
  fixed formatting, fixed the order of includes,
    removed unnecessary comments, cleanup
utilities.c:
  the order of includes, formatting, removing unnecessary comments, using proper unity assertions

bk: 559ddb7dz0V3PG7iNtSlO43ESbra7Q

24 files changed:
ChangeLog
sntp/tests/crypto.c
sntp/tests/fileHandlingTest.h.in
sntp/tests/keyFile.c
sntp/tests/kodDatabase.c
sntp/tests/kodFile.c
sntp/tests/packetHandling.c
sntp/tests/packetProcessing.c
sntp/tests/run-crypto.c
sntp/tests/run-keyFile.c
sntp/tests/run-kodDatabase.c
sntp/tests/run-kodFile.c
sntp/tests/run-packetHandling.c
sntp/tests/run-packetProcessing.c
sntp/tests/run-utilities.c
sntp/tests/sntptest.h
sntp/tests/utilities.c
tests/libntp/lfptest.h
tests/libntp/run-timespecops.c
tests/libntp/run-timevalops.c
tests/libntp/sockaddrtest.h
tests/libntp/test-libntp.c
tests/libntp/timespecops.c
tests/libntp/timevalops.c

index 92886c21b47dae14438591cf29ad37873e0d9f67..ab9613f9f304949813189ef81916fa86b7c6591e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,7 +16,7 @@
 * tests/ntpd/ function parameter list cleanup.  Damir Tomić.
 * sntp/unity/unity_config.h: handle stdint.h.  Harlan Stenn.
 * sntp/unity/unity_internals.h: handle *INTPTR_MAX on old Solaris.  H.Stenn.
-* tests/libntp/timevalops.c and timespecops.c fixd error printing.  D.Tomić.
+* tests/libntp/timevalops.c and timespecops.c fixed error printing.  D.Tomić.
 * tests/libntp/ improvements in code and fixed error printing.  Damir Tomić.
 * tests/libntp: a_md5encrypt.c, authkeys.c, buftvtots.c, calendar.c, caljulian.c,
   caltontp.c, clocktime.c, humandate.c, hextolfp.c, decodenetnum.c - fixed
 * tests/libntp/vi64ops.c removed an unnecessary comment, fixed formatting.
 * tests/libntp/ymd3yd.c removed an empty function and an unnecessary include,
 fixed formatting. Tomasz Flendrich
+* tests/libntp/timespecops.c fixed formatting, fixed the order of includes,
+  removed unnecessary comments, cleanup. Tomasz Flendrich
+* tests/libntp/timevalops.c fixed the order of includes, deleted unnecessary
+  comments, cleanup. Tomasz Flendrich
+* tests/libntp/sockaddrtest.h making it agree to NTP's conventions of formatting.
+  Tomasz Flendrich
+* tests/libntp/lfptest.h cleanup. Tomasz Flendrich
+* tests/libntp/test-libntp.c fix formatting. Tomasz Flendrich
+* sntp/tests/crypto.c is now using proper Unity's assertions, fixed formatting.
+  Tomasz Flendrich
+* sntp/tests/kodDatabase.c added consts, deleted empty function,
+  fixed formatting. Tomasz Flendrich
+* sntp/tests/kodFile.c cleanup, fixed formatting. Tomasz Flendrich
+* sntp/tests/packetHandling.c is now using proper Unity's assertions,
+  fixed formatting, deleted unused variable. Tomasz Flendrich
+* sntp/tests/keyFile.c is now using proper Unity's assertions, fixed formatting.
+  Tomasz Flendrich
+* sntp/tests/packetProcessing.c changed from sprintf to snprintf,
+  fixed formatting. Tomasz Flendrich
+* sntp/tests/utilities.c is now using proper Unity's assertions, changed
+  the order of includes, fixed formatting, removed unnecessary comments.
+  Tomasz Flendrich
+* sntp/tests/sntptest.h fixed formatting. Tomasz Flendrich
+* sntp/tests/fileHandlingTest.h.in fixed a possible buffer overflow problem,
+  made one function do its job, deleted unnecessary prints, fixed formatting.
+  Tomasz Flendrich
 * sntp/unity/Makefile.am added a missing header. Tomasz Flendrich
 * sntp/unity/unity_config.h: Distribute it.  Harlan Stenn.
 * sntp/libevent/evconfig-private.h: remove generated filefrom SCM.  H.Stenn.
index c9a1cedbf37513d67485378cb090b7e057aad0b0..7781b81b8c5ec822939aac7f0728ad84104b1299 100644 (file)
@@ -9,7 +9,8 @@
 #define SHA1_LENGTH 20
 
 
-void test_MakeMd5Mac(void) {
+void
+test_MakeMd5Mac(void) {
 
        const char* PKT_DATA = "abcdefgh0123";
        const int PKT_LEN = strlen(PKT_DATA);
@@ -31,7 +32,8 @@ void test_MakeMd5Mac(void) {
 }
 
 
-void test_MakeSHA1Mac(void) {
+void
+test_MakeSHA1Mac(void) {
 #ifdef OPENSSL
        const char* PKT_DATA = "abcdefgh0123";
        const int PKT_LEN = strlen(PKT_DATA);
@@ -50,14 +52,15 @@ void test_MakeSHA1Mac(void) {
        TEST_ASSERT_EQUAL(SHA1_LENGTH,
                          make_mac((char*)PKT_DATA, PKT_LEN, SHA1_LENGTH, &sha1, actual));
 
-       TEST_ASSERT_TRUE(memcmp(EXPECTED_DIGEST, actual, SHA1_LENGTH) == 0);
+       TEST_ASSERT_EQUAL_MEMORY(EXPECTED_DIGEST, actual, SHA1_LENGTH);
 #else
        TEST_IGNORE_MESSAGE("OpenSSL not found, skipping...");
 #endif /* OPENSSL */
 }
 
 
-void test_VerifyCorrectMD5(void) {
+void
+test_VerifyCorrectMD5(void) {
        const char* PKT_DATA =
                "sometestdata"          // Data
                "\0\0\0\0"                      // Key-ID (unused)
@@ -76,7 +79,8 @@ void test_VerifyCorrectMD5(void) {
 }
 
 
-void test_VerifySHA1(void) {
+void
+test_VerifySHA1(void) {
 #ifdef OPENSSL
        const char* PKT_DATA =
                "sometestdata"          // Data
@@ -98,7 +102,8 @@ void test_VerifySHA1(void) {
 #endif /* OPENSSL */
 }
 
-void test_VerifyFailure(void) {
+void
+test_VerifyFailure(void) {
        /* We use a copy of the MD5 verification code, but modify
         * the last bit to make sure verification fails. */
        const char* PKT_DATA =
@@ -118,7 +123,9 @@ void test_VerifyFailure(void) {
        TEST_ASSERT_FALSE(auth_md5((char*)PKT_DATA, PKT_LEN, MD5_LENGTH, &md5));
 }
 
-void test_PacketSizeNotMultipleOfFourBytes(void) {
+
+void
+test_PacketSizeNotMultipleOfFourBytes(void) {
        const char* PKT_DATA = "123456";
        const int PKT_LEN = 6;
        char actual[MD5_LENGTH];
@@ -132,4 +139,3 @@ void test_PacketSizeNotMultipleOfFourBytes(void) {
 
        TEST_ASSERT_EQUAL(0, make_mac((char*)PKT_DATA, PKT_LEN, MD5_LENGTH, &md5, actual));
 }
-
index 8ff9d34ec3b70626595e1500ecf0001868b99520..5e37c326eaeec08f8e2e70eec8c31bf2e56a95cc 100644 (file)
@@ -13,54 +13,33 @@ enum DirectoryType {
        OUTPUT_DIR = 1
 };
 
-const char * CreatePath(const char* filename, enum DirectoryType argument) {
-       
-        char * path = malloc (sizeof (char) * 256);
-
-       /*
-       if (m_params.size() >= argument + 1) {
-               path = m_params[argument];
-       }
 
-       if (path[path.size()-1] != DIR_SEP && !path.empty()) {
-               path.append(1, DIR_SEP);
-       }
-       */
-       //strcpy(path,filename);
-       //path.append(filename);
-
-       //return path;
+const char *
+CreatePath(const char* filename, enum DirectoryType argument) {
+       const char srcdir[] = "@abs_srcdir@/data/";
+       char * path = malloc (sizeof (char) * (strlen(srcdir) + 256));
 
        char cwd[1024];
-       if (getcwd(cwd, sizeof(cwd)) != NULL)
-               printf("Current working dir: %s\n", cwd);
-       
-       printf("builddir is   <@builddir@>\n");
-       printf("abs_srcdir is <@abs_srcdir@>\n");
-       strcpy(path,"@abs_srcdir@/data/");
 
-       //strcpy(path,"");
-       strcat(path,filename);
-       printf("PATH IS : %s\n",path);
+       strcpy(path, srcdir);
+       strcat(path, filename);
+
        return path;
 }
 
-int GetFileSize(FILE *file) {
 
+int
+GetFileSize(FILE *file) {
        fseek(file, 0L, SEEK_END);
        int length = ftell(file);
        fseek(file, 0L, SEEK_SET);
-       
-       //int initial = file.tellg();
-
-       //file.seekg(0, ios::end);
-       //int length = file.tellg();
-       //file.seekg(initial);
 
        return length;
 }
 
-bool CompareFileContent(FILE* expected, FILE* actual) {
+
+bool
+CompareFileContent(FILE* expected, FILE* actual) {
        int currentLine = 1;
 
        char actualLine[1024];
@@ -72,28 +51,23 @@ bool CompareFileContent(FILE* expected, FILE* actual) {
              && ( (fgets(expectedLine, lenExp, expected)) != NULL )
              ) {
 
-               //printf("%s",actualLine);
-               //printf("%s",expectedLine);
        
                if( strcmp(actualLine,expectedLine) !=0 ){
                        printf("Comparision failed on line %d",currentLine);
                        return FALSE;
                }
 
-               //I removed this and modified the test kodFile.c, because there shouldn't be any ASSERTs in .h files!
-               //TEST_ASSERT_EQUAL_STRING(actualLine,expectedLine);//EXPECT_EQ(expectedLine, actualLine) << "Comparision failed on line " << currentLine;
                currentLine++;
        }
 
        return TRUE;
 }
 
-void ClearFile(const char * filename) {
-       FILE * clear = fopen(filename, "w");//ios::trunc); //similar to truncate, I GUESS???!
-       
-       //I removed this because there shouldn't be any ASSERTs in .h files!
-       //TEST_ASSERT_TRUE(clear != NULL);
-       fclose(clear);
+
+void
+ClearFile(const char * filename) {
+       if (!truncate(filename, 0))
+               exit(1);
 }
 
 
index 10a68fb02480215b10bbe7f261fb82359d2ea597..d7b290ec6465b37f377745f51a87ce1006432d96 100644 (file)
@@ -7,10 +7,9 @@
 
 #include "unity.h"
 
-//typedef int bool;
 
-
-bool CompareKeys(struct key expected, struct key actual) {
+bool
+CompareKeys(struct key expected, struct key actual) {
        if (expected.key_id != actual.key_id){
                printf("Expected key_id: %d", expected.key_id);
                printf(" but was: %d\n", actual.key_id);
@@ -34,7 +33,9 @@ bool CompareKeys(struct key expected, struct key actual) {
        return TRUE;
 }
 
-bool CompareKeysAlternative(int key_id,
+
+bool
+CompareKeysAlternative(int key_id,
               int key_len,
               const char* type,
               const char* key_seq,
@@ -50,91 +51,99 @@ bool CompareKeysAlternative(int key_id,
 }
 
 
-void test_ReadEmptyKeyFile(void) {
+void
+test_ReadEmptyKeyFile(void) {
        struct key* keys = NULL;
 
        TEST_ASSERT_EQUAL(0, auth_init(CreatePath("key-test-empty", INPUT_DIR), &keys));
-
-       TEST_ASSERT_TRUE(keys == NULL);
+       TEST_ASSERT_NULL(keys);
 }
 
-void test_ReadASCIIKeys(void) {
+
+void
+test_ReadASCIIKeys(void) {
        struct key* keys = NULL;
 
        TEST_ASSERT_EQUAL(2, auth_init(CreatePath("key-test-ascii", INPUT_DIR), &keys));
 
-       TEST_ASSERT_TRUE(keys != NULL);
+       TEST_ASSERT_NOT_NULL(keys);
 
        struct key* result = NULL;
        get_key(40, &result);
-       TEST_ASSERT_TRUE(result != NULL);
+       TEST_ASSERT_NOT_NULL(result);
        TEST_ASSERT_TRUE(CompareKeysAlternative(40, 11, "MD5", "asciikeyTwo", *result));
 
        result = NULL;
        get_key(50, &result);
-       TEST_ASSERT_TRUE(result != NULL);
+       TEST_ASSERT_NOT_NULL(result);
        TEST_ASSERT_TRUE(CompareKeysAlternative(50, 11, "MD5", "asciikeyOne", *result));
 }
 
-void test_ReadHexKeys(void) {
+
+void
+test_ReadHexKeys(void) {
        struct key* keys = NULL;
 
        TEST_ASSERT_EQUAL(3, auth_init(CreatePath("key-test-hex", INPUT_DIR), &keys));
 
-       TEST_ASSERT_TRUE(keys != NULL);
+       TEST_ASSERT_NOT_NULL(keys);
 
        struct key* result = NULL;
        get_key(10, &result);
-       TEST_ASSERT_TRUE(result != NULL);
+       TEST_ASSERT_NOT_NULL(result);
        TEST_ASSERT_TRUE(CompareKeysAlternative(10, 13, "MD5",
                 "\x01\x23\x45\x67\x89\xab\xcd\xef\x01\x23\x45\x67\x89", *result));
 
        result = NULL;
        get_key(20, &result);
-       TEST_ASSERT_TRUE(result != NULL);
+       TEST_ASSERT_NOT_NULL(result);
        char data1[15]; memset(data1, 0x11, 15);
        TEST_ASSERT_TRUE(CompareKeysAlternative(20, 15, "MD5", data1, *result));
 
        result = NULL;
        get_key(30, &result);
-       TEST_ASSERT_TRUE(result != NULL);
+       TEST_ASSERT_NOT_NULL(result);
        char data2[13]; memset(data2, 0x01, 13);
        TEST_ASSERT_TRUE(CompareKeysAlternative(30, 13, "MD5", data2, *result));
 }
 
-void test_ReadKeyFileWithComments(void) {
+
+void
+test_ReadKeyFileWithComments(void) {
        struct key* keys = NULL;
 
        TEST_ASSERT_EQUAL(2, auth_init(CreatePath("key-test-comments", INPUT_DIR), &keys));
        
-       TEST_ASSERT_TRUE(keys != NULL);
+       TEST_ASSERT_NOT_NULL(keys);
 
        struct key* result = NULL;
        get_key(10, &result);
-       TEST_ASSERT_TRUE(result != NULL);
+       TEST_ASSERT_NOT_NULL(result);
        char data[15]; memset(data, 0x01, 15);
        TEST_ASSERT_TRUE(CompareKeysAlternative(10, 15, "MD5", data, *result));
 
        result = NULL;
        get_key(34, &result);
-       TEST_ASSERT_TRUE(result != NULL);
+       TEST_ASSERT_NOT_NULL(result);
        TEST_ASSERT_TRUE(CompareKeysAlternative(34, 3, "MD5", "xyz", *result));
 }
 
-void test_ReadKeyFileWithInvalidHex(void) {
+
+void
+test_ReadKeyFileWithInvalidHex(void) {
        struct key* keys = NULL;
 
        TEST_ASSERT_EQUAL(1, auth_init(CreatePath("key-test-invalid-hex", INPUT_DIR), &keys));
 
-       TEST_ASSERT_TRUE(keys != NULL);
+       TEST_ASSERT_NOT_NULL(keys);
 
        struct key* result = NULL;
        get_key(10, &result);
-       TEST_ASSERT_TRUE(result != NULL);
+       TEST_ASSERT_NOT_NULL(result);
        char data[15]; memset(data, 0x01, 15);
        TEST_ASSERT_TRUE(CompareKeysAlternative(10, 15, "MD5", data, *result));
 
        result = NULL;
        get_key(30, &result); // Should not exist, and result should remain NULL.
-       TEST_ASSERT_TRUE(result == NULL);
+       TEST_ASSERT_NULL(result);
 }
index f64dc73e133ae912a6bed0841c4ef27a39ac9aef..a231bbe0d090a4e0dda6f4655c014e59b3c49058 100644 (file)
@@ -4,24 +4,23 @@
 #include "sntptest.h"
 #include "ntp_stdlib.h"
 #include "sntp-opts.h"
-
 #include "kod_management.h"
+#include "ntp_io.h"
 
 #include "unity.h"
 
-void setUp(void)
-{
-       kod_init_kod_db("/dev/null", TRUE);
-}
 
-void tearDown(void)
-{
+
+void
+setUp(void) {
+       kod_init_kod_db("/dev/null", TRUE);
 }
 
 
-void test_SingleEntryHandling(void) {
-       char HOST[] = "192.0.2.5";
-       char REASON[] = "DENY";
+void
+test_SingleEntryHandling(void) {
+       const char HOST[] = "192.0.2.5";
+       const char REASON[] = "DENY";
 
        add_entry(HOST, REASON);
 
@@ -32,15 +31,17 @@ void test_SingleEntryHandling(void) {
        TEST_ASSERT_EQUAL_STRING(REASON, result->type);
 }
 
-void test_MultipleEntryHandling(void) {
-       char HOST1[] = "192.0.2.3";
-       char REASON1[] = "DENY";
 
-       char HOST2[] = "192.0.5.5";
-       char REASON2[] = "RATE";
+void
+test_MultipleEntryHandling(void) {
+       const char HOST1[] = "192.0.2.3";
+       const char REASON1[] = "DENY";
 
-       char HOST3[] = "192.0.10.1";
-       char REASON3[] = "DENY";
+       const char HOST2[] = "192.0.5.5";
+       const char REASON2[] = "RATE";
+
+       const char HOST3[] = "192.0.10.1";
+       const char REASON3[] = "DENY";
 
        add_entry(HOST1, REASON1);
        add_entry(HOST2, REASON2);
@@ -63,10 +64,12 @@ void test_MultipleEntryHandling(void) {
        free(result);
 }
 
-void test_NoMatchInSearch(void) {
-       char HOST_ADD[] = "192.0.2.6";
-       char HOST_NOTADD[] = "192.0.6.1";
-       char REASON[] = "DENY";
+
+void
+test_NoMatchInSearch(void) {
+       const char HOST_ADD[] = "192.0.2.6";
+       const char HOST_NOTADD[] = "192.0.6.1";
+       const char REASON[] = "DENY";
 
        add_entry(HOST_ADD, REASON);
 
@@ -76,10 +79,12 @@ void test_NoMatchInSearch(void) {
        TEST_ASSERT_TRUE(result == NULL);
 }
 
-void test_AddDuplicate(void) {
-       char HOST[] = "192.0.2.3";
-       char REASON1[] = "RATE";
-       char REASON2[] = "DENY";
+
+void
+test_AddDuplicate(void) {
+       const char HOST[] = "192.0.2.3";
+       const char REASON1[] = "RATE";
+       const char REASON2[] = "DENY";
 
        add_entry(HOST, REASON1);
        struct kod_entry* result1;
@@ -101,11 +106,13 @@ void test_AddDuplicate(void) {
        free(result2);
 }
 
-void test_DeleteEntry(void) {
-       char HOST1[] = "192.0.2.1";
-       char HOST2[] = "192.0.2.2";
-       char HOST3[] = "192.0.2.3";
-       char REASON[] = "DENY";
+
+void
+test_DeleteEntry(void) {
+       const char HOST1[] = "192.0.2.1";
+       const char HOST2[] = "192.0.2.2";
+       const char HOST3[] = "192.0.2.3";
+       const char REASON[] = "DENY";
 
        add_entry(HOST1, REASON);
        add_entry(HOST2, REASON);
index b76d1b117eea5625b20bf86b93d19ed579540ea0..69a2376db5e174bcce96aa5d866b4c35b00b95fb 100644 (file)
@@ -1,10 +1,8 @@
 #include "config.h"
+
 #include "ntp_types.h"
 #include "ntp_stdlib.h" // For estrdup()
-
-
 #include "fileHandlingTest.h"
-
 #include "kod_management.h"
 
 #include "unity.h"
@@ -17,22 +15,24 @@ extern int kod_db_cnt;
 extern struct kod_entry** kod_db;
 extern char* kod_db_file;
 
-void setUp(void) {
-               kod_db_cnt = 0;
-               kod_db = NULL;
-}
 
-void tearDown(void) {
+void
+setUp(void) {
+       kod_db_cnt = 0;
+       kod_db = NULL;
 }
 
 
-void test_ReadEmptyFile(void) {
+void
+test_ReadEmptyFile(void) {
        kod_init_kod_db(CreatePath("kod-test-empty", INPUT_DIR), TRUE);
 
        TEST_ASSERT_EQUAL(0, kod_db_cnt);
 }
 
-void test_ReadCorrectFile(void) {
+
+void
+test_ReadCorrectFile(void) {
        kod_init_kod_db(CreatePath("kod-test-correct", INPUT_DIR), TRUE);
        
        TEST_ASSERT_EQUAL(2, kod_db_cnt);
@@ -50,7 +50,9 @@ void test_ReadCorrectFile(void) {
        TEST_ASSERT_EQUAL(0xfff, res->timestamp);
 }
 
-void test_ReadFileWithBlankLines(void) {
+
+void
+test_ReadFileWithBlankLines(void) {
        kod_init_kod_db(CreatePath("kod-test-blanks", INPUT_DIR), TRUE);
 
        TEST_ASSERT_EQUAL(3, kod_db_cnt);
@@ -73,31 +75,30 @@ void test_ReadFileWithBlankLines(void) {
        TEST_ASSERT_EQUAL(0xabcd, res->timestamp);
 }
 
-void test_WriteEmptyFile(void) {
-       //kod_db_file = estrdup(CreatePath("kod-output-blank", OUTPUT_DIR)); //causing issues on psp-at1, replaced
+
+void
+test_WriteEmptyFile(void) {
        kod_db_file = estrdup("kod-output-blank");
-       //printf("kod PATH: %s\n",kod_db_file);
        write_kod_db();
 
        // Open file and ensure that the filesize is 0 bytes.
-       FILE * is;
-       is = fopen(kod_db_file, "rb");//std::ios::binary);
-       TEST_ASSERT_FALSE(is == NULL );//is.fail());
-       
+       FILE * is = fopen(kod_db_file, "rb");
+       TEST_ASSERT_NOT_NULL(is);
+
        TEST_ASSERT_EQUAL(0, GetFileSize(is));
 
        fclose(is);
 }
 
-void test_WriteFileWithSingleEntry(void) {
-       //kod_db_file = estrdup(CreatePath("kod-output-single", OUTPUT_DIR)); //causing issues on psp-at1, replaced
+
+void
+test_WriteFileWithSingleEntry(void) {
        kod_db_file = estrdup("kod-output-single"); 
-       //printf("kod PATH: %s\n",kod_db_file);
        add_entry("host1", "DENY");
 
        // Here we must manipulate the timestamps, so they match the one in
        // the expected file.
-       //
+
        kod_db[0]->timestamp = 1;
 
        write_kod_db();
@@ -105,18 +106,19 @@ void test_WriteFileWithSingleEntry(void) {
        // Open file and compare sizes.
        FILE * actual = fopen(kod_db_file, "rb");
        FILE * expected = fopen(CreatePath("kod-expected-single", INPUT_DIR),"rb");
-       TEST_ASSERT_TRUE(actual !=NULL);//TEST_ASSERT_TRUE(actual.good());
-       TEST_ASSERT_TRUE(expected !=NULL);//TEST_ASSERT_TRUE(expected.good());
 
-       TEST_ASSERT_EQUAL(GetFileSize(expected), GetFileSize(actual));
+       TEST_ASSERT_NOT_NULL(actual);
+       TEST_ASSERT_NOT_NULL(expected);
 
+       TEST_ASSERT_EQUAL(GetFileSize(expected), GetFileSize(actual));
+       
        TEST_ASSERT_TRUE(CompareFileContent(expected, actual));
 }
 
-void test_WriteFileWithMultipleEntries(void) {
-       //kod_db_file = estrdup(CreatePath("kod-output-multiple", OUTPUT_DIR)); //causing issues on psp-at1, replaced
+
+void
+test_WriteFileWithMultipleEntries(void) {
        kod_db_file = estrdup("kod-output-multiple");
-       //printf("kod PATH: %s\n",kod_db_file);
        add_entry("example.com", "RATE");
        add_entry("192.0.2.1", "DENY");
        add_entry("192.0.2.5", "RSTR");
@@ -134,12 +136,12 @@ void test_WriteFileWithMultipleEntries(void) {
        // Open file and compare sizes and content.
        FILE * actual = fopen(kod_db_file, "rb");
        FILE * expected = fopen(CreatePath("kod-expected-multiple", INPUT_DIR),"rb");
-       TEST_ASSERT_TRUE(actual !=NULL);//TEST_ASSERT_TRUE(actual.good());
-       TEST_ASSERT_TRUE(expected !=NULL);//TEST_ASSERT_TRUE(expected.good());
 
-       
+       TEST_ASSERT_NOT_NULL(actual);
+       TEST_ASSERT_NOT_NULL(expected);
+
+
        TEST_ASSERT_EQUAL(GetFileSize(expected), GetFileSize(actual));
 
        TEST_ASSERT_TRUE(CompareFileContent(expected, actual));
 }
-
index 4cb5a91c9308eac0c3a68a7e556193fe1348ba39..57b0d9909f08cbd7f31630db2e8b2ca9cca936a4 100644 (file)
 #include "unity.h"
 
 
-int counter = 0;
-
-
-// old code from google test framework, moved to SetUp() for unity
-void setUp(void)
-{ 
+void
+setUp(void) { 
        init_lib(); 
 }
 
 
-
-int LfpEquality(const l_fp expected, const l_fp actual) {
-               if (L_ISEQU(&expected, &actual)) {
-                       return TRUE; 
-               } else {
-                       return FALSE;
-               }
+int
+LfpEquality(const l_fp expected, const l_fp actual) {
+       if (L_ISEQU(&expected, &actual))
+               return TRUE; 
+       else
+               return FALSE;
 }
 
-void test_GenerateUnauthenticatedPacket(void) {
+
+void
+test_GenerateUnauthenticatedPacket(void) {
        struct pkt testpkt;
 
        struct timeval xmt;
@@ -55,7 +52,9 @@ void test_GenerateUnauthenticatedPacket(void) {
        TEST_ASSERT_TRUE(LfpEquality(expected_xmt, actual_xmt));
 }
 
-void test_GenerateAuthenticatedPacket(void) {
+
+void
+test_GenerateAuthenticatedPacket(void) {
        struct key testkey;
        testkey.next = NULL;
        testkey.key_id = 30;
@@ -91,10 +90,12 @@ void test_GenerateAuthenticatedPacket(void) {
        char expected_mac[MAX_MD5_LEN];
        TEST_ASSERT_EQUAL(MAX_MD5_LEN - 4, // Remove the key_id, only keep the mac.
                          make_mac((char*)&testpkt, LEN_PKT_NOMAC, MAX_MD5_LEN, &testkey, expected_mac));
-       TEST_ASSERT_TRUE(memcmp(expected_mac, (char*)&testpkt.exten[1], MAX_MD5_LEN -4) == 0);
+       TEST_ASSERT_EQUAL_MEMORY(expected_mac, (char*)&testpkt.exten[1], MAX_MD5_LEN -4);
 }
 
-void test_OffsetCalculationPositiveOffset(void) {
+
+void
+test_OffsetCalculationPositiveOffset(void) {
        struct pkt rpkt;
 
        rpkt.precision = -16; // 0,000015259
@@ -132,13 +133,15 @@ void test_OffsetCalculationPositiveOffset(void) {
        double offset, precision, synch_distance;
        offset_calculation(&rpkt, LEN_PKT_NOMAC, &dst, &offset, &precision, &synch_distance);
 
-       TEST_ASSERT_EQUAL_FLOAT(1.25, offset);
-       TEST_ASSERT_EQUAL_FLOAT(1. / ULOGTOD(16), precision);
+       TEST_ASSERT_EQUAL_DOUBLE(1.25, offset);
+       TEST_ASSERT_EQUAL_DOUBLE(1. / ULOGTOD(16), precision);
        // 1.1250150000000001 ?
-       TEST_ASSERT_EQUAL_FLOAT(1.125015, synch_distance);
+       TEST_ASSERT_EQUAL_DOUBLE(1.125015, synch_distance);
 }
 
-void test_OffsetCalculationNegativeOffset(void) {
+
+void
+test_OffsetCalculationNegativeOffset(void) {
        struct pkt rpkt;
 
        rpkt.precision = -1;
@@ -176,12 +179,14 @@ void test_OffsetCalculationNegativeOffset(void) {
        double offset, precision, synch_distance;
        offset_calculation(&rpkt, LEN_PKT_NOMAC, &dst, &offset, &precision, &synch_distance);
 
-       TEST_ASSERT_EQUAL_FLOAT(-1, offset);
-       TEST_ASSERT_EQUAL_FLOAT(1. / ULOGTOD(1), precision);
-       TEST_ASSERT_EQUAL_FLOAT(1.3333483333333334, synch_distance);
+       TEST_ASSERT_EQUAL_DOUBLE(-1, offset);
+       TEST_ASSERT_EQUAL_DOUBLE(1. / ULOGTOD(1), precision);
+       TEST_ASSERT_EQUAL_DOUBLE(1.3333483333333334, synch_distance);
 }
 
-void test_HandleUnusableServer(void) {
+
+void
+test_HandleUnusableServer(void) {
        struct pkt              rpkt;
        sockaddr_u      host;
        int             rpktl;
@@ -192,7 +197,9 @@ void test_HandleUnusableServer(void) {
        TEST_ASSERT_EQUAL(-1, handle_pkt(rpktl, &rpkt, &host, ""));
 }
 
-void test_HandleUnusablePacket(void) {
+
+void
+test_HandleUnusablePacket(void) {
        struct pkt              rpkt;
        sockaddr_u      host;
        int             rpktl;
@@ -203,7 +210,9 @@ void test_HandleUnusablePacket(void) {
        TEST_ASSERT_EQUAL(1, handle_pkt(rpktl, &rpkt, &host, ""));
 }
 
-void test_HandleServerAuthenticationFailure(void) {
+
+void
+test_HandleServerAuthenticationFailure(void) {
        struct pkt              rpkt;
        sockaddr_u      host;
        int             rpktl;
@@ -214,7 +223,9 @@ void test_HandleServerAuthenticationFailure(void) {
        TEST_ASSERT_EQUAL(1, handle_pkt(rpktl, &rpkt, &host, ""));
 }
 
-void test_HandleKodDemobilize(void) {
+
+void
+test_HandleKodDemobilize(void) {
        const char *    HOSTNAME = "192.0.2.1";
        const char *    REASON = "DENY";
        struct pkt              rpkt;
@@ -235,10 +246,12 @@ void test_HandleKodDemobilize(void) {
        TEST_ASSERT_EQUAL(1, handle_pkt(rpktl, &rpkt, &host, HOSTNAME));
 
        TEST_ASSERT_EQUAL(1, search_entry(HOSTNAME, &entry));
-       TEST_ASSERT_TRUE(memcmp(REASON, entry->type, 4) == 0);
+       TEST_ASSERT_EQUAL_MEMORY(REASON, entry->type, 4);
 }
 
-void test_HandleKodRate(void) {
+
+void
+test_HandleKodRate(void) {
        struct  pkt             rpkt;
        sockaddr_u      host;
        int             rpktl;
@@ -249,7 +262,9 @@ void test_HandleKodRate(void) {
        TEST_ASSERT_EQUAL(1, handle_pkt(rpktl, &rpkt, &host, ""));
 }
 
-void test_HandleCorrectPacket(void) {
+
+void
+test_HandleCorrectPacket(void) {
        struct pkt              rpkt;
        sockaddr_u      host;
        int             rpktl;
index 07bfc30f61e0eba3ec88817a8c44eac7eedded91..5ec7df3ad7818c97d60a8b6fae2f9d6d893ce2df 100644 (file)
@@ -4,6 +4,7 @@
 #include "ntp_stdlib.h"
 #include "unity.h"
 
+
 const char * Version = "stub unit test Version string";
 
 // Hacks into the key database.
@@ -16,12 +17,14 @@ static struct pkt testspkt;
 static sockaddr_u testsock;
 bool restoreKeyDb;
 
-void PrepareAuthenticationTest(int key_id,
+
+void
+PrepareAuthenticationTest(int key_id,
                                                           int key_len,
                                                           const char* type,
                                                           const void* key_seq) {
        char str[25];
-       sprintf(str, "%d", key_id);
+       snprintf(str, 25, "%d", key_id);
        ActivateOption("-a", str);
 
        key_cnt = 1;
@@ -37,13 +40,17 @@ void PrepareAuthenticationTest(int key_id,
        restoreKeyDb = true;
 }
 
-void PrepareAuthenticationTestMD5(int key_id,
+
+void
+PrepareAuthenticationTestMD5(int key_id,
                                                           int key_len,
                                                           const void* key_seq) {
        PrepareAuthenticationTest(key_id, key_len, "MD5", key_seq);
 }
 
-void setUp(void) {
+
+void
+setUp(void) {
 
        sntptest();
        restoreKeyDb = false;
@@ -63,10 +70,11 @@ void setUp(void) {
 
        HTONL_FP(&tmp, &testpkt.org);
        HTONL_FP(&tmp, &testspkt.xmt);
-
 }
 
-void tearDown(void) {
+
+void
+tearDown(void) {
        
        if (restoreKeyDb) {
                key_cnt = 0;
@@ -75,12 +83,12 @@ void tearDown(void) {
        }
 
        sntptest_destroy(); //only on the final test!! if counter == 0 etc...
-
 }
 
 
 
-void test_TooShortLength(void) {
+void
+test_TooShortLength(void) {
        TEST_ASSERT_EQUAL(PACKET_UNUSEABLE,
                          process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC - 1,
                                                  MODE_SERVER, &testspkt, "UnitTest"));
@@ -89,7 +97,9 @@ void test_TooShortLength(void) {
                                                  MODE_BROADCAST, &testspkt, "UnitTest"));
 }
 
-void test_LengthNotMultipleOfFour(void) {
+
+void
+test_LengthNotMultipleOfFour(void) {
        TEST_ASSERT_EQUAL(PACKET_UNUSEABLE,
                          process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC + 6,
                                                  MODE_SERVER, &testspkt, "UnitTest"));
@@ -98,7 +108,9 @@ void test_LengthNotMultipleOfFour(void) {
                                                  MODE_BROADCAST, &testspkt, "UnitTest"));
 }
 
-void test_TooShortExtensionFieldLength(void) {
+
+void
+test_TooShortExtensionFieldLength(void) {
        /* The lower 16-bits are the length of the extension field.
         * This lengths must be multiples of 4 bytes, which gives
         * a minimum of 4 byte extension field length. */
@@ -114,7 +126,9 @@ void test_TooShortExtensionFieldLength(void) {
                                                  MODE_SERVER, &testspkt, "UnitTest"));
 }
 
-void test_UnauthenticatedPacketReject(void) {
+
+void
+test_UnauthenticatedPacketReject(void) {
        //sntptest();
        // Activate authentication option
        ActivateOption("-a", "123");
@@ -128,7 +142,9 @@ void test_UnauthenticatedPacketReject(void) {
                                                  MODE_SERVER, &testspkt, "UnitTest"));
 }
 
-void test_CryptoNAKPacketReject(void) {
+
+void
+test_CryptoNAKPacketReject(void) {
        // Activate authentication option
        ActivateOption("-a", "123");
        TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
@@ -140,7 +156,9 @@ void test_CryptoNAKPacketReject(void) {
                                                  MODE_SERVER, &testspkt, "UnitTest"));
 }
 
-void test_AuthenticatedPacketInvalid(void) {
+
+void
+test_AuthenticatedPacketInvalid(void) {
        // Activate authentication option
        PrepareAuthenticationTestMD5(50, 9, "123456789");
        TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
@@ -163,7 +181,9 @@ void test_AuthenticatedPacketInvalid(void) {
                                                  MODE_SERVER, &testspkt, "UnitTest"));
 }
 
-void test_AuthenticatedPacketUnknownKey(void) {
+
+void
+test_AuthenticatedPacketUnknownKey(void) {
        // Activate authentication option
        PrepareAuthenticationTestMD5(30, 9, "123456789");
        TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
@@ -183,7 +203,9 @@ void test_AuthenticatedPacketUnknownKey(void) {
                                                  MODE_SERVER, &testspkt, "UnitTest"));
 }
 
-void test_ServerVersionTooOld(void) {
+
+void
+test_ServerVersionTooOld(void) {
        TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
 
        testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
@@ -198,7 +220,9 @@ void test_ServerVersionTooOld(void) {
                                                  MODE_SERVER, &testspkt, "UnitTest"));
 }
 
-void test_ServerVersionTooNew(void) {
+
+void
+test_ServerVersionTooNew(void) {
        TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
 
        testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
@@ -213,7 +237,9 @@ void test_ServerVersionTooNew(void) {
                                                  MODE_SERVER, &testspkt, "UnitTest"));
 }
 
-void test_NonWantedMode(void) {
+
+void
+test_NonWantedMode(void) {
        TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
 
        testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
@@ -227,8 +253,10 @@ void test_NonWantedMode(void) {
                                                  MODE_SERVER, &testspkt, "UnitTest"));
 }
 
+
 /* Tests bug 1597 */
-void test_KoDRate(void) {
+void
+test_KoDRate(void) {
        TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
 
        testpkt.stratum = STRATUM_PKT_UNSPEC;
@@ -239,7 +267,9 @@ void test_KoDRate(void) {
                                                  MODE_SERVER, &testspkt, "UnitTest"));
 }
 
-void test_KoDDeny(void) {
+
+void
+test_KoDDeny(void) {
        TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
 
        testpkt.stratum = STRATUM_PKT_UNSPEC;
@@ -250,7 +280,9 @@ void test_KoDDeny(void) {
                                                  MODE_SERVER, &testspkt, "UnitTest"));
 }
 
-void test_RejectUnsyncedServer(void) {
+
+void
+test_RejectUnsyncedServer(void) {
        TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
 
        testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOTINSYNC,
@@ -262,7 +294,9 @@ void test_RejectUnsyncedServer(void) {
                                                  MODE_SERVER, &testspkt, "UnitTest"));
 }
 
-void test_RejectWrongResponseServerMode(void) {
+
+void
+test_RejectWrongResponseServerMode(void) {
        TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
 
        l_fp tmp;
@@ -279,7 +313,9 @@ void test_RejectWrongResponseServerMode(void) {
                                                  MODE_SERVER, &testspkt, "UnitTest"));
 }
 
-void test_AcceptNoSentPacketBroadcastMode(void) {
+
+void
+test_AcceptNoSentPacketBroadcastMode(void) {
        TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
 
        testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
@@ -291,7 +327,9 @@ void test_AcceptNoSentPacketBroadcastMode(void) {
                              MODE_BROADCAST, NULL, "UnitTest"));
 }
 
-void test_CorrectUnauthenticatedPacket(void) {
+
+void
+test_CorrectUnauthenticatedPacket(void) {
        TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
 
        TEST_ASSERT_EQUAL(LEN_PKT_NOMAC,
@@ -299,7 +337,9 @@ void test_CorrectUnauthenticatedPacket(void) {
                                                  MODE_SERVER, &testspkt, "UnitTest"));
 }
 
-void test_CorrectAuthenticatedPacketMD5(void) {
+
+void
+test_CorrectAuthenticatedPacketMD5(void) {
        PrepareAuthenticationTestMD5(10, 15, "123456789abcdef");
        TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
 
@@ -319,7 +359,9 @@ void test_CorrectAuthenticatedPacketMD5(void) {
 
 }
 
-void test_CorrectAuthenticatedPacketSHA1(void) {
+
+void
+test_CorrectAuthenticatedPacketSHA1(void) {
        PrepareAuthenticationTest(20, 15, "SHA1", "abcdefghijklmno");
        TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
 
index e4325268985e9abd1cfef5e7c4c5d37c9377f386..ed9114bc87afb61a108ac24ce68f04e6ff1ddaa1 100644 (file)
@@ -51,12 +51,12 @@ int main(int argc, char *argv[])
   progname = argv[0];
   Unity.TestFile = "crypto.c";
   UnityBegin("crypto.c");
-  RUN_TEST(test_MakeMd5Mac, 12);
-  RUN_TEST(test_MakeSHA1Mac, 34);
-  RUN_TEST(test_VerifyCorrectMD5, 60);
-  RUN_TEST(test_VerifySHA1, 79);
-  RUN_TEST(test_VerifyFailure, 101);
-  RUN_TEST(test_PacketSizeNotMultipleOfFourBytes, 121);
+  RUN_TEST(test_MakeMd5Mac, 13);
+  RUN_TEST(test_MakeSHA1Mac, 36);
+  RUN_TEST(test_VerifyCorrectMD5, 63);
+  RUN_TEST(test_VerifySHA1, 83);
+  RUN_TEST(test_VerifyFailure, 106);
+  RUN_TEST(test_PacketSizeNotMultipleOfFourBytes, 128);
 
   return (UnityEnd());
 }
index decf612c791c73b68d21b9de07cda1bb32874bf4..f908d5930ecb0b3c46c937fc04ad02b890224db4 100644 (file)
@@ -50,11 +50,11 @@ int main(int argc, char *argv[])
   progname = argv[0];
   Unity.TestFile = "keyFile.c";
   UnityBegin("keyFile.c");
-  RUN_TEST(test_ReadEmptyKeyFile, 53);
-  RUN_TEST(test_ReadASCIIKeys, 61);
-  RUN_TEST(test_ReadHexKeys, 79);
-  RUN_TEST(test_ReadKeyFileWithComments, 105);
-  RUN_TEST(test_ReadKeyFileWithInvalidHex, 124);
+  RUN_TEST(test_ReadEmptyKeyFile, 55);
+  RUN_TEST(test_ReadASCIIKeys, 64);
+  RUN_TEST(test_ReadHexKeys, 84);
+  RUN_TEST(test_ReadKeyFileWithComments, 112);
+  RUN_TEST(test_ReadKeyFileWithInvalidHex, 133);
 
   return (UnityEnd());
 }
index db7addcd21050aca20148a213d618ebb073e7cbf..faa32f74c8a340bf749dabd4996541bff81323f9 100644 (file)
@@ -50,11 +50,11 @@ int main(int argc, char *argv[])
   progname = argv[0];
   Unity.TestFile = "kodDatabase.c";
   UnityBegin("kodDatabase.c");
-  RUN_TEST(test_SingleEntryHandling, 22);
-  RUN_TEST(test_MultipleEntryHandling, 35);
-  RUN_TEST(test_NoMatchInSearch, 66);
-  RUN_TEST(test_AddDuplicate, 79);
-  RUN_TEST(test_DeleteEntry, 104);
+  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);
 
   return (UnityEnd());
 }
index 7e8490bd2bb03dbe9303af794960d92e7f450ab5..da4835a4406a76332a1e0fe8b68cd95c65ef584b 100644 (file)
@@ -51,12 +51,12 @@ int main(int argc, char *argv[])
   progname = argv[0];
   Unity.TestFile = "kodFile.c";
   UnityBegin("kodFile.c");
-  RUN_TEST(test_ReadEmptyFile, 29);
+  RUN_TEST(test_ReadEmptyFile, 27);
   RUN_TEST(test_ReadCorrectFile, 35);
-  RUN_TEST(test_ReadFileWithBlankLines, 53);
-  RUN_TEST(test_WriteEmptyFile, 76);
-  RUN_TEST(test_WriteFileWithSingleEntry, 92);
-  RUN_TEST(test_WriteFileWithMultipleEntries, 116);
+  RUN_TEST(test_ReadFileWithBlankLines, 55);
+  RUN_TEST(test_WriteEmptyFile, 80);
+  RUN_TEST(test_WriteFileWithSingleEntry, 95);
+  RUN_TEST(test_WriteFileWithMultipleEntries, 120);
 
   return (UnityEnd());
 }
index 69e958e4c15c76c16c4da34d1d5c9f0f96048534..e8ae331af6f52d5fd5c9ea4a7bef560aa6132c05 100644 (file)
@@ -55,16 +55,16 @@ int main(int argc, char *argv[])
   progname = argv[0];
   Unity.TestFile = "packetHandling.c";
   UnityBegin("packetHandling.c");
-  RUN_TEST(test_GenerateUnauthenticatedPacket, 35);
-  RUN_TEST(test_GenerateAuthenticatedPacket, 58);
-  RUN_TEST(test_OffsetCalculationPositiveOffset, 97);
-  RUN_TEST(test_OffsetCalculationNegativeOffset, 141);
-  RUN_TEST(test_HandleUnusableServer, 184);
-  RUN_TEST(test_HandleUnusablePacket, 195);
-  RUN_TEST(test_HandleServerAuthenticationFailure, 206);
-  RUN_TEST(test_HandleKodDemobilize, 217);
-  RUN_TEST(test_HandleKodRate, 241);
-  RUN_TEST(test_HandleCorrectPacket, 252);
+  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);
 
   return (UnityEnd());
 }
index f41d5c7eb2f0c3fe341571ac61f30f0f7c5cf4ad..c8fcd21aef129d395667f3bf664664e9e0aa866b 100644 (file)
@@ -63,24 +63,24 @@ int main(int argc, char *argv[])
   progname = argv[0];
   Unity.TestFile = "packetProcessing.c";
   UnityBegin("packetProcessing.c");
-  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);
-  RUN_TEST(test_NonWantedMode, 216);
-  RUN_TEST(test_KoDRate, 231);
-  RUN_TEST(test_KoDDeny, 242);
-  RUN_TEST(test_RejectUnsyncedServer, 253);
-  RUN_TEST(test_RejectWrongResponseServerMode, 265);
-  RUN_TEST(test_AcceptNoSentPacketBroadcastMode, 282);
-  RUN_TEST(test_CorrectUnauthenticatedPacket, 294);
-  RUN_TEST(test_CorrectAuthenticatedPacketMD5, 302);
-  RUN_TEST(test_CorrectAuthenticatedPacketSHA1, 322);
+  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);
 
   return (UnityEnd());
 }
index 8b6448d40d25895b5d9ba921ee5df973e6c980c0..89cb9649318b97410eaccfdd55d50ad1d9f3a3d1 100644 (file)
@@ -52,13 +52,13 @@ int main(int argc, char *argv[])
   progname = argv[0];
   Unity.TestFile = "utilities.c";
   UnityBegin("utilities.c");
-  RUN_TEST(test_IPv4Address, 66);
-  RUN_TEST(test_IPv6Address, 76);
-  RUN_TEST(test_SetLiVnMode1, 96);
-  RUN_TEST(test_SetLiVnMode2, 109);
-  RUN_TEST(test_PktOutput, 124);
-  RUN_TEST(test_LfpOutputBinaryFormat, 144);
-  RUN_TEST(test_LfpOutputDecimalFormat, 160);
+  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);
 
   return (UnityEnd());
 }
index 277361c5b5dfb89f6066e51dfb5ea921da89fcf3..2559d2cf680cd2536a38edbf4a2bbc3ccfe64f88 100644 (file)
@@ -8,15 +8,21 @@ void sntptest(void);
 void sntptest_destroy(void);
 void ActivateOption(const char* option, const char* argument);
 
-void sntptest(void) {
+
+void
+sntptest(void) {
        optionSaveState(&sntpOptions);
 }
 
-void sntptest_destroy(void) {
+
+void
+sntptest_destroy(void) {
        optionRestore(&sntpOptions);
 }
 
-void ActivateOption(const char* option, const char* argument) {
+
+void
+ActivateOption(const char* option, const char* argument) {
 
        const int ARGV_SIZE = 4;
 
index 29405255926c73e80daad809fc15da7c7d1cf30c..b52791f32d74a6e15f537763add404742ab115ab 100644 (file)
@@ -2,18 +2,19 @@
 
 #include "sntptest.h"
 #include "fileHandlingTest.h"
-
 #include "main.h"
 #include "utilities.h"
-#include "math.h"
 
 #include "unity.h"
 
-const char * Version = "stub unit test Version string";
+#include <math.h>
 
 
+const char * Version = "stub unit test Version string";
+
 
-sockaddr_u CreateSockaddr4(const char* address) {
+sockaddr_u
+CreateSockaddr4(const char* address) {
        sockaddr_u s;
        s.sa4.sin_family = AF_INET;
        s.sa4.sin_addr.s_addr = inet_addr(address);
@@ -22,7 +23,9 @@ sockaddr_u CreateSockaddr4(const char* address) {
        return s;
 }
 
-struct addrinfo CreateAddrinfo( sockaddr_u* sock) {
+
+struct addrinfo
+CreateAddrinfo(sockaddr_u* sock) {
        struct addrinfo a;
        a.ai_family = sock->sa.sa_family;
        a.ai_addrlen = SIZEOF_SOCKADDR(a.ai_family);
@@ -34,24 +37,28 @@ struct addrinfo CreateAddrinfo( sockaddr_u* sock) {
 bool outputFileOpened;
 FILE* outputFile;
 
-void InitDebugTest(const char * filename) {
+
+void
+InitDebugTest(const char * filename) {
        // Clear the contents of the current file.
        // Open the output file
        outputFile = fopen(filename, "w+");
-       TEST_ASSERT_TRUE(outputFile != NULL);
+       TEST_ASSERT_NOT_NULL(outputFile);
        outputFileOpened = true;
 }
 
+
 // Closes outputFile, and compare contents.
-void FinishDebugTest(const char * expected,
+void
+FinishDebugTest(const char * expected,
                     const char * actual) {
        if (outputFileOpened)
                fclose(outputFile);
 
        FILE * e = fopen(expected,"rb");
        FILE * a = fopen(actual,"rb");
-       TEST_ASSERT_TRUE(e != NULL);
-       TEST_ASSERT_TRUE(a != NULL);
+       TEST_ASSERT_NOT_NULL(e);
+       TEST_ASSERT_NOT_NULL(a);
 
        CompareFileContent(e, a);
 }
@@ -63,7 +70,8 @@ void FinishDebugTest(const char * expected,
  * tests can be removed.
  */
 
-void test_IPv4Address(void) {
+void
+test_IPv4Address(void) {
        const char* ADDR = "192.0.2.10";
 
        sockaddr_u input = CreateSockaddr4(ADDR);
@@ -73,7 +81,9 @@ void test_IPv4Address(void) {
        TEST_ASSERT_EQUAL_STRING(ADDR, addrinfo_to_str(&inputA));
 }
 
-void test_IPv6Address(void) {
+
+void
+test_IPv6Address(void) {
        const struct in6_addr address = {
                                                0x20, 0x01, 0x0d, 0xb8,
                                                0x85, 0xa3, 0x08, 0xd3, 
@@ -93,7 +103,9 @@ void test_IPv6Address(void) {
        TEST_ASSERT_EQUAL_STRING(expected, addrinfo_to_str(&inputA));
 }
 
-void test_SetLiVnMode1(void) {
+
+void
+test_SetLiVnMode1(void) {
        struct pkt expected;
        expected.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
                                             NTP_VERSION,
@@ -106,7 +118,9 @@ void test_SetLiVnMode1(void) {
        TEST_ASSERT_EQUAL(expected.li_vn_mode, actual.li_vn_mode);
 }
 
-void test_SetLiVnMode2(void) {
+
+void
+test_SetLiVnMode2(void) {
        struct pkt expected;
        expected.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOTINSYNC,
                                             NTP_OLDVERSION,
@@ -121,8 +135,9 @@ void test_SetLiVnMode2(void) {
 
 /* Debug utilities tests */
 
-void test_PktOutput(void) {
-       char * filename = "debug-output-pkt";//CreatePath("debug-output-pkt", OUTPUT_DIR);
+void
+test_PktOutput(void) {
+       char * filename = "debug-output-pkt";
        InitDebugTest(filename);
 
        struct pkt testpkt;
@@ -141,7 +156,9 @@ void test_PktOutput(void) {
        FinishDebugTest(CreatePath("debug-input-pkt", INPUT_DIR), filename);
 }
 
-void test_LfpOutputBinaryFormat(void) {
+
+void
+test_LfpOutputBinaryFormat(void) {
        char * filename = "debug-output-lfp-bin";//CreatePath("debug-output-lfp-bin", OUTPUT_DIR);
        InitDebugTest(filename);
 
@@ -157,8 +174,10 @@ void test_LfpOutputBinaryFormat(void) {
        FinishDebugTest(CreatePath("debug-input-lfp-bin", INPUT_DIR), filename);
 }
 
-void test_LfpOutputDecimalFormat(void) {
-       char * filename = "debug-output-lfp-dec"; //CreatePath("debug-output-lfp-dec", OUTPUT_DIR);
+
+void
+test_LfpOutputDecimalFormat(void) {
+       char * filename = "debug-output-lfp-dec";
        InitDebugTest(filename);
 
        l_fp test;
@@ -172,4 +191,3 @@ void test_LfpOutputDecimalFormat(void) {
 
        FinishDebugTest(CreatePath("debug-input-lfp-dec", INPUT_DIR), filename);
 }
-
index a830b37a4cece0aa7e37c853fe0a8b4d1d12c88a..46c87385378e68590a39b4b0ea0d1323622c68f0 100644 (file)
@@ -3,30 +3,20 @@
 
 #include "ntp_fp.h"
 
-int IsEqual(const l_fp expected, const l_fp actual);
 
-int IsEqual(const l_fp expected, const l_fp actual) {
+static const int32 HALF = -2147483647L - 1L;
+static const int32 HALF_PROMILLE_UP = 2147484; // slightly more than 0.0005
+static const int32 HALF_PROMILLE_DOWN = 2147483; // slightly less than 0.0005
+static const int32 QUARTER = 1073741824L;
+static const int32 QUARTER_PROMILLE_APPRX = 1073742L;
+
+int
+IsEqual(const l_fp expected, const l_fp actual) {
        if (L_ISEQU(&expected, &actual)) {
                return TRUE;
        } else {
-               //printf(" expected: ...");
-               /*
-               << " expected: " << lfptoa(&expected, FRACTION_PREC)
-                               << " (" << expected.l_ui << "." << expected.l_uf << ")"
-                               << " but was: " << lfptoa(&actual, FRACTION_PREC)
-                               << " (" << actual.l_ui << "." << actual.l_uf << ")";
-               */
                return FALSE;
        }
-
 }
 
-static const int32 HALF = -2147483647L - 1L;
-static const int32 HALF_PROMILLE_UP = 2147484; // slightly more than 0.0005
-static const int32 HALF_PROMILLE_DOWN = 2147483; // slightly less than 0.0005
-static const int32 QUARTER = 1073741824L;
-static const int32 QUARTER_PROMILLE_APPRX = 1073742L;
-
 #endif
-
-
index 48a9a51fdabb32af6edb51ac095b8bcb5bc0aff8..e10a28b4516432f9db8acd4ff53f3184724d0e06 100644 (file)
@@ -73,34 +73,34 @@ int main(int argc, char *argv[])
   progname = argv[0];
   Unity.TestFile = "timespecops.c";
   UnityBegin("timespecops.c");
-  RUN_TEST(test_Helpers1, 149);
-  RUN_TEST(test_Normalise, 169);
-  RUN_TEST(test_SignNoFrac, 183);
-  RUN_TEST(test_SignWithFrac, 195);
-  RUN_TEST(test_CmpFracEQ, 209);
-  RUN_TEST(test_CmpFracGT, 222);
-  RUN_TEST(test_CmpFracLT, 235);
-  RUN_TEST(test_AddFullNorm, 252);
-  RUN_TEST(test_AddFullOflow1, 266);
-  RUN_TEST(test_AddNsecNorm, 280);
-  RUN_TEST(test_AddNsecOflow1, 292);
-  RUN_TEST(test_SubFullNorm, 308);
-  RUN_TEST(test_SubFullOflow, 322);
-  RUN_TEST(test_SubNsecNorm, 336);
-  RUN_TEST(test_SubNsecOflow, 348);
-  RUN_TEST(test_Neg, 364);
-  RUN_TEST(test_AbsNoFrac, 381);
-  RUN_TEST(test_AbsWithFrac, 392);
-  RUN_TEST(test_Helpers2, 407);
-  RUN_TEST(test_ToLFPbittest, 439);
-  RUN_TEST(test_ToLFPrelPos, 452);
-  RUN_TEST(test_ToLFPrelNeg, 464);
-  RUN_TEST(test_ToLFPabs, 476);
-  RUN_TEST(test_FromLFPbittest, 491);
-  RUN_TEST(test_FromLFPrelPos, 510);
-  RUN_TEST(test_FromLFPrelNeg, 523);
-  RUN_TEST(test_LFProundtrip, 538);
-  RUN_TEST(test_ToString, 557);
+  RUN_TEST(test_Helpers1, 153);
+  RUN_TEST(test_Normalise, 174);
+  RUN_TEST(test_SignNoFrac, 189);
+  RUN_TEST(test_SignWithFrac, 203);
+  RUN_TEST(test_CmpFracEQ, 218);
+  RUN_TEST(test_CmpFracGT, 233);
+  RUN_TEST(test_CmpFracLT, 248);
+  RUN_TEST(test_AddFullNorm, 266);
+  RUN_TEST(test_AddFullOflow1, 282);
+  RUN_TEST(test_AddNsecNorm, 298);
+  RUN_TEST(test_AddNsecOflow1, 312);
+  RUN_TEST(test_SubFullNorm, 329);
+  RUN_TEST(test_SubFullOflow, 345);
+  RUN_TEST(test_SubNsecNorm, 361);
+  RUN_TEST(test_SubNsecOflow, 375);
+  RUN_TEST(test_Neg, 393);
+  RUN_TEST(test_AbsNoFrac, 411);
+  RUN_TEST(test_AbsWithFrac, 424);
+  RUN_TEST(test_Helpers2, 440);
+  RUN_TEST(test_ToLFPbittest, 469);
+  RUN_TEST(test_ToLFPrelPos, 484);
+  RUN_TEST(test_ToLFPrelNeg, 498);
+  RUN_TEST(test_ToLFPabs, 512);
+  RUN_TEST(test_FromLFPbittest, 529);
+  RUN_TEST(test_FromLFPrelPos, 550);
+  RUN_TEST(test_FromLFPrelNeg, 565);
+  RUN_TEST(test_LFProundtrip, 581);
+  RUN_TEST(test_ToString, 601);
 
   return (UnityEnd());
 }
index 0a2616ef25a946f548b1db5d78a8c0fac58db8cf..c0089bbb0bce0e253356acb089ee92e5b47b256d 100644 (file)
@@ -73,34 +73,34 @@ int main(int argc, char *argv[])
   progname = argv[0];
   Unity.TestFile = "timevalops.c";
   UnityBegin("timevalops.c");
-  RUN_TEST(test_Helpers1, 149);
-  RUN_TEST(test_Normalise, 169);
-  RUN_TEST(test_SignNoFrac, 183);
-  RUN_TEST(test_SignWithFrac, 195);
-  RUN_TEST(test_CmpFracEQ, 210);
-  RUN_TEST(test_CmpFracGT, 224);
-  RUN_TEST(test_CmpFracLT, 238);
-  RUN_TEST(test_AddFullNorm, 256);
-  RUN_TEST(test_AddFullOflow1, 270);
-  RUN_TEST(test_AddUsecNorm, 284);
-  RUN_TEST(test_AddUsecOflow1, 296);
-  RUN_TEST(test_SubFullNorm, 312);
-  RUN_TEST(test_SubFullOflow, 326);
-  RUN_TEST(test_SubUsecNorm, 340);
-  RUN_TEST(test_SubUsecOflow, 352);
-  RUN_TEST(test_Neg, 368);
-  RUN_TEST(test_AbsNoFrac, 385);
-  RUN_TEST(test_AbsWithFrac, 396);
-  RUN_TEST(test_Helpers2, 412);
-  RUN_TEST(test_ToLFPbittest, 445);
-  RUN_TEST(test_ToLFPrelPos, 460);
-  RUN_TEST(test_ToLFPrelNeg, 474);
-  RUN_TEST(test_ToLFPabs, 487);
-  RUN_TEST(test_FromLFPbittest, 505);
-  RUN_TEST(test_FromLFPrelPos, 523);
-  RUN_TEST(test_FromLFPrelNeg, 536);
-  RUN_TEST(test_LFProundtrip, 550);
-  RUN_TEST(test_ToString, 569);
+  RUN_TEST(test_Helpers1, 157);
+  RUN_TEST(test_Normalise, 178);
+  RUN_TEST(test_SignNoFrac, 193);
+  RUN_TEST(test_SignWithFrac, 207);
+  RUN_TEST(test_CmpFracEQ, 223);
+  RUN_TEST(test_CmpFracGT, 239);
+  RUN_TEST(test_CmpFracLT, 255);
+  RUN_TEST(test_AddFullNorm, 274);
+  RUN_TEST(test_AddFullOflow1, 290);
+  RUN_TEST(test_AddUsecNorm, 306);
+  RUN_TEST(test_AddUsecOflow1, 320);
+  RUN_TEST(test_SubFullNorm, 337);
+  RUN_TEST(test_SubFullOflow, 353);
+  RUN_TEST(test_SubUsecNorm, 369);
+  RUN_TEST(test_SubUsecOflow, 383);
+  RUN_TEST(test_Neg, 400);
+  RUN_TEST(test_AbsNoFrac, 418);
+  RUN_TEST(test_AbsWithFrac, 431);
+  RUN_TEST(test_Helpers2, 448);
+  RUN_TEST(test_ToLFPbittest, 482);
+  RUN_TEST(test_ToLFPrelPos, 498);
+  RUN_TEST(test_ToLFPrelNeg, 514);
+  RUN_TEST(test_ToLFPabs, 529);
+  RUN_TEST(test_FromLFPbittest, 548);
+  RUN_TEST(test_FromLFPrelPos, 568);
+  RUN_TEST(test_FromLFPrelNeg, 583);
+  RUN_TEST(test_LFProundtrip, 599);
+  RUN_TEST(test_ToString, 619);
 
   return (UnityEnd());
 }
index eb1a3b5093162bd7aaeb61487902cb065dd35f4d..14d880d0e78a80e8473dfed57e1d6eecc2f7198b 100644 (file)
@@ -4,7 +4,9 @@
 #include "ntp.h"
 #include "ntp_stdlib.h"
 
-sockaddr_u CreateSockaddr4(const char* address, unsigned int port) {
+
+sockaddr_u
+CreateSockaddr4(const char* address, unsigned int port) {
        sockaddr_u s;
        s.sa4.sin_family = AF_INET;
        s.sa4.sin_addr.s_addr = inet_addr(address);
@@ -13,7 +15,9 @@ sockaddr_u CreateSockaddr4(const char* address, unsigned int port) {
        return s;
 }
 
-int IsEqual(const sockaddr_u expected, const sockaddr_u actual) {
+
+int
+IsEqual(const sockaddr_u expected, const sockaddr_u actual) {
        struct in_addr in;
        struct in6_addr in6;
 
@@ -48,6 +52,3 @@ int IsEqual(const sockaddr_u expected, const sockaddr_u actual) {
 
 
 #endif // TESTS_SOCKADDRTEST_H
-
-
-
index e489f673fc7654391e9a7c710f9c1b4f5319378f..4d9b8406775d733ea925ef688acd2b1f215ebac2 100644 (file)
@@ -5,28 +5,23 @@
 
 #include "test-libntp.h"
 
-//const char *progname = "test-libntp";
-
-// current_time is needed by authkeys. Used only in to calculate lifetime.
-//u_long current_time = 4;
-
 
 time_t nowtime = 0;
 
-time_t timefunc(time_t *ptr)
-{
+
+time_t
+timefunc(time_t *ptr) {
     if (ptr)
        *ptr = nowtime;
     return nowtime;
 }
 
-void settime(int y, int m, int d, int H, int M, int S)
-{
+
+void
+settime(int y, int m, int d, int H, int M, int S) {
 
     time_t days = ntpcal_edate_to_eradays(y-1, m-1, d-1) + 1 - DAY_UNIX_STARTS;
     time_t secs = ntpcal_etime_to_seconds(H, M, S);
 
     nowtime = days * SECSPERDAY + secs;
 }
-
-
index ac7a45d6c391c1673a17e9c2e3359f7d4b5e013a..b66a8537f5289951a1da85536fbd3f8e7daa32f4 100644 (file)
@@ -2,32 +2,30 @@
 
 #include "ntp_types.h"
 #include "ntp_fp.h"
-
-#include <math.h>
 #include "timespecops.h"
 
 #include "unity.h"
 
-
+#include <math.h>
 #include <string.h>
 
-//in unity_helper.h :
+
 #define TEST_ASSERT_EQUAL_timespec(a, b) { \
     TEST_ASSERT_EQUAL_MESSAGE(a.tv_sec, b.tv_sec, "Field tv_sec"); \
     TEST_ASSERT_EQUAL_MESSAGE(a.tv_nsec, b.tv_nsec, "Field tv_nsec");  \
 }
 
-//what about l_fp.l_ui  ??? it's a union so it's either l_fp.l_ui or l_fp.l_i?
+
 #define TEST_ASSERT_EQUAL_l_fp(a, b) { \
     TEST_ASSERT_EQUAL_MESSAGE(a.l_i, b.l_i, "Field l_i"); \
     TEST_ASSERT_EQUAL_UINT_MESSAGE(a.l_uf, b.l_uf, "Field l_uf");      \
 }
 
-//timespec has time_t, long, and time_t is basically long uint, 4 or 8 bytes size, depending on 32/64bit
 
 static u_int32 my_tick_to_tsf(u_int32 ticks);
 static u_int32 my_tsf_to_tick(u_int32 tsf);
 
+
 // that's it...
 struct lfpfracdata {
        long    nsec;
@@ -36,21 +34,25 @@ struct lfpfracdata {
 
 //******************************************MY CUSTOM FUNCTIONS*******************************
 
-typedef int bool; //TRUE and FALSE are already defined somewhere, so I can't do typedef enum { FALSE, TRUE } boolean;
+typedef int bool;
+
+const bool
+timespec_isValid(struct timespec V) {
+       return V.tv_nsec >= 0 && V.tv_nsec < 1000000000;
+}
 
-const bool timespec_isValid(struct timespec V)
-               { return V.tv_nsec >= 0 && V.tv_nsec < 1000000000; }
 
-struct timespec timespec_init(time_t hi, long lo){
+struct timespec
+timespec_init(time_t hi, long lo) {
        struct timespec V;      
        V.tv_sec = hi;
        V.tv_nsec = lo;
        return V;
 }
 
-//taken from lfpfunc.c -> maybe remove this from timevalops.c and lfpfunc. and put in c_timstructs.h ????!!!!!
-l_fp l_fp_init(int32 i, u_int32 f)
-{
+
+l_fp
+l_fp_init(int32 i, u_int32 f) {
        l_fp temp;
        temp.l_i  = i;
        temp.l_uf = f;
@@ -58,9 +60,9 @@ l_fp l_fp_init(int32 i, u_int32 f)
        return temp;
 }
 
-//also in timelalops.c!!!!!!
-bool AssertFpClose(const l_fp m,const l_fp n, const l_fp limit)
-{
+
+bool
+AssertFpClose(const l_fp m, const l_fp n, const l_fp limit) {
        l_fp diff;
 
        if (L_ISGEQ(&m, &n)) {
@@ -74,14 +76,14 @@ bool AssertFpClose(const l_fp m,const l_fp n, const l_fp limit)
                return TRUE;
        }
        else {
-               printf("m_expr which is %s \nand\nn_expr which is %s\nare not close; diff=%susec\n",lfptoa(&m,10),lfptoa(&n,10),lfptoa(&diff,10)); 
+               printf("m_expr which is %s \nand\nn_expr which is %s\nare not close; diff=%susec\n", lfptoa(&m, 10), lfptoa(&n, 10), lfptoa(&diff, 10)); 
                return FALSE;
        }
 }
 
 
-bool AssertTimespecClose(const struct timespec m,const struct timespec n, const struct timespec limit)
-{
+bool
+AssertTimespecClose(const struct timespec m, const struct timespec n, const struct timespec limit) {
        struct timespec diff;
 
        diff = abs_tspec(sub_tspec(m, n));
@@ -89,7 +91,7 @@ bool AssertTimespecClose(const struct timespec m,const struct timespec n, const
                return TRUE;
        else
        {
-               printf("m_expr which is %ld.%lu \nand\nn_expr which is %ld.%lu\nare not close; diff=%ld.%lunsec\n",m.tv_sec,m.tv_nsec,n.tv_sec,n.tv_nsec,diff.tv_sec,diff.tv_nsec); 
+               printf("m_expr which is %ld.%lu \nand\nn_expr which is %ld.%lu\nare not close; diff=%ld.%lunsec\n", m.tv_sec, m.tv_nsec, n.tv_sec, n.tv_nsec, diff.tv_sec, diff.tv_nsec); 
                return FALSE;
        }
 }
@@ -114,8 +116,8 @@ static const struct lfpfracdata fdata[] = {
        };
 
 
-u_int32 my_tick_to_tsf(u_int32 ticks)
-{
+u_int32
+my_tick_to_tsf(u_int32 ticks) {
        // convert nanoseconds to l_fp fractional units, using double
        // precision float calculations or, if available, 64bit integer
        // arithmetic. This should give the precise fraction, rounded to
@@ -129,8 +131,9 @@ u_int32 my_tick_to_tsf(u_int32 ticks)
        // truncated nonsense, so don't use it out-of-bounds.
 }
 
-u_int32 my_tsf_to_tick(u_int32 tsf)
-{
+
+u_int32
+my_tsf_to_tick(u_int32 tsf) {
        // Inverse operation: converts fraction to microseconds.
 #ifdef HAVE_U_INT64
        return (u_int32)(( ((u_int64)(tsf)) * 1000000000 + 0x80000000) >> 32);
@@ -146,7 +149,8 @@ u_int32 my_tsf_to_tick(u_int32 tsf)
 // test support stuff -- part 1
 // ---------------------------------------------------------------------
 
-void test_Helpers1(void) {
+void
+test_Helpers1(void) {
        struct timespec x;
 
        for (x.tv_sec = -2; x.tv_sec < 3; x.tv_sec++) {
@@ -166,7 +170,8 @@ void test_Helpers1(void) {
 // test normalisation
 //----------------------------------------------------------------------
 
-void test_Normalise(void) {
+void
+test_Normalise(void) {
        long ns;
        for ( ns = -2000000000; ns <= 2000000000; ns += 10000000) {
                struct timespec x = timespec_init(0, ns);
@@ -180,7 +185,8 @@ void test_Normalise(void) {
 // test classification
 //----------------------------------------------------------------------
 
-void test_SignNoFrac(void) {
+void
+test_SignNoFrac(void) {
        // sign test, no fraction
        int i;
        for (i = -4; i <= 4; ++i) {
@@ -192,7 +198,9 @@ void test_SignNoFrac(void) {
        }
 }
 
-void test_SignWithFrac(void) {
+
+void
+test_SignWithFrac(void) {
        // sign test, with fraction
        int i;
        for (i = -4; i <= 4; ++i) {
@@ -206,9 +214,10 @@ void test_SignWithFrac(void) {
 //----------------------------------------------------------------------
 // test compare
 //----------------------------------------------------------------------
-void test_CmpFracEQ(void) {
+void
+test_CmpFracEQ(void) {
        // fractions are equal
-       int i,j;
+       int i, j;
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timespec a = timespec_init( i , 200);
@@ -219,9 +228,11 @@ void test_CmpFracEQ(void) {
                }
 }
 
-void test_CmpFracGT(void) {
+
+void
+test_CmpFracGT(void) {
        // fraction a bigger fraction b
-       int i,j;
+       int i, j;
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timespec a = timespec_init(i, 999999800);
@@ -232,9 +243,11 @@ void test_CmpFracGT(void) {
                }
 }
 
-void test_CmpFracLT(void) {
+
+void
+test_CmpFracLT(void) {
        // fraction a less fraction b
-       int i,j;
+       int i, j;
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timespec a = timespec_init(i, 200);
@@ -249,8 +262,9 @@ void test_CmpFracLT(void) {
 // Test addition (sum)
 //----------------------------------------------------------------------
 
-void test_AddFullNorm(void) {
-       int i,j;
+void
+test_AddFullNorm(void) {
+       int i, j;
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timespec a = timespec_init(i, 200);
@@ -263,8 +277,10 @@ void test_AddFullNorm(void) {
                }
 }
 
-void test_AddFullOflow1(void) {
-       int i,j;
+
+void
+test_AddFullOflow1(void) {
+       int i, j;
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timespec a = timespec_init(i, 200);
@@ -277,7 +293,9 @@ void test_AddFullOflow1(void) {
                }
 }
 
-void test_AddNsecNorm(void) {
+
+void
+test_AddNsecNorm(void) {
        int i;
        for (i = -4; i <= 4; ++i) {
                struct timespec a = timespec_init(i, 200);
@@ -289,7 +307,9 @@ void test_AddNsecNorm(void) {
        }
 }
 
-void test_AddNsecOflow1(void) {
+
+void
+test_AddNsecOflow1(void) {
        int i;
        for (i = -4; i <= 4; ++i) {
                struct timespec a = timespec_init(i, 200);
@@ -305,8 +325,9 @@ void test_AddNsecOflow1(void) {
 // test subtraction (difference)
 //----------------------------------------------------------------------
 
-void test_SubFullNorm(void) {
-       int i,j;
+void
+test_SubFullNorm(void) {
+       int i, j;
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timespec a = timespec_init( i , 600);
@@ -319,13 +340,15 @@ void test_SubFullNorm(void) {
                }
 }
 
-void test_SubFullOflow(void) {
-       int i,j;
+
+void
+test_SubFullOflow(void) {
+       int i, j;
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
-                       struct timespec a = timespec_init(  i  , 100);
-                       struct timespec b = timespec_init(  j  , 999999900);
-                       struct timespec E = timespec_init(i-j-1, 200);
+                       struct timespec a = timespec_init(i, 100);
+                       struct timespec b = timespec_init(j, 999999900);
+                       struct timespec E = timespec_init(i - j - 1, 200);
                        struct timespec c;
 
                        c = sub_tspec(a, b);
@@ -333,7 +356,9 @@ void test_SubFullOflow(void) {
                }
 }
 
-void test_SubNsecNorm(void) {
+
+void
+test_SubNsecNorm(void) {
        int i;
        for (i = -4; i <= 4; ++i) {
                struct timespec a = timespec_init(i, 600);
@@ -345,7 +370,9 @@ void test_SubNsecNorm(void) {
        }
 }
 
-void test_SubNsecOflow(void) {
+
+void
+test_SubNsecOflow(void) {
        int i;
        for (i = -4; i <= 4; ++i) {
                struct timespec a = timespec_init( i , 100);
@@ -361,7 +388,9 @@ void test_SubNsecOflow(void) {
 // test negation
 //----------------------------------------------------------------------
 
-void test_Neg(void) {
+
+void
+test_Neg(void) {
        int i;
        for (i = -4; i <= 4; ++i) {
                struct timespec a = timespec_init(i, 100);
@@ -378,7 +407,8 @@ void test_Neg(void) {
 // test abs value
 //----------------------------------------------------------------------
 
-void test_AbsNoFrac(void) {
+void
+test_AbsNoFrac(void) {
        int i;
        for (i = -4; i <= 4; ++i) {
                struct timespec a = timespec_init(i , 0);
@@ -389,7 +419,9 @@ void test_AbsNoFrac(void) {
        }
 }
 
-void test_AbsWithFrac(void) {
+
+void
+test_AbsWithFrac(void) {
        int i;
        for (i = -4; i <= 4; ++i) {
                struct timespec a = timespec_init(i, 100);
@@ -404,8 +436,9 @@ void test_AbsWithFrac(void) {
 // test support stuff -- part 2
 // ---------------------------------------------------------------------
 
-void test_Helpers2(void) {
-       struct timespec limit = timespec_init(0,2);
+void
+test_Helpers2(void) {
+       struct timespec limit = timespec_init(0, 2);
        
        struct timespec x, y;
        long i;
@@ -414,30 +447,27 @@ void test_Helpers2(void) {
                for (x.tv_nsec = 1;
                     x.tv_nsec < 1000000000;
                     x.tv_nsec += 499999999) {
-                       for (i = -4; i < 5; i++) {
+                       for (i = -4; i < 5; ++i) {
                                y = x;
                                y.tv_nsec += i;
                                if (i >= -2 && i <= 2){
-                                       TEST_ASSERT_TRUE(AssertTimespecClose(x,y,limit));//ASSERT_PRED_FORMAT2(isClose, x, y);
+                                       TEST_ASSERT_TRUE(AssertTimespecClose(x, y, limit));
                                }
                                else
                                {
-                                       TEST_ASSERT_FALSE(AssertTimespecClose(x,y,limit));
+                                       TEST_ASSERT_FALSE(AssertTimespecClose(x, y, limit));
                                }
                        }
                }
 }
 
-// global predicate instances we're using here
-//static l_fp lfpClose =  l_fp_init(0,1); //static AssertFpClose FpClose(0, 1);
-//static struct timespec limit = timespec_init(0,2); //static AssertTimespecClose TimespecClose(0, 2);
-
 //----------------------------------------------------------------------
 // conversion to l_fp
 //----------------------------------------------------------------------
 
-void test_ToLFPbittest(void) {
-       l_fp lfpClose =  l_fp_init(0,1);
+void
+test_ToLFPbittest(void) {
+       l_fp lfpClose =  l_fp_init(0, 1);
        u_int32 i;
        for (i = 0; i < 1000000000; i+=1000) {
                struct timespec a = timespec_init(1, i);
@@ -445,13 +475,15 @@ void test_ToLFPbittest(void) {
                l_fp r;
 
                r = tspec_intv_to_lfp(a);
-               TEST_ASSERT_TRUE(AssertFpClose(E,r,lfpClose));
+               TEST_ASSERT_TRUE(AssertFpClose(E, r, lfpClose));
        }
 }
 
-void test_ToLFPrelPos(void) {
+
+void
+test_ToLFPrelPos(void) {
        int i;
-       for (i = 0; i < COUNTOF(fdata); i++) {
+       for (i = 0; i < COUNTOF(fdata); ++i) {
                struct timespec a = timespec_init(1, fdata[i].nsec);
                l_fp E = l_fp_init(1, fdata[i].frac);
                l_fp r;
@@ -461,9 +493,11 @@ void test_ToLFPrelPos(void) {
        }
 }
 
-void test_ToLFPrelNeg(void) {
+
+void
+test_ToLFPrelNeg(void) {
        int i;
-       for (i = 0; i < COUNTOF(fdata); i++) {
+       for (i = 0; i < COUNTOF(fdata); ++i) {
                struct timespec a = timespec_init(-1, fdata[i].nsec);
                l_fp E = l_fp_init(~0, fdata[i].frac);
                l_fp r;
@@ -473,9 +507,11 @@ void test_ToLFPrelNeg(void) {
        }
 }
 
-void test_ToLFPabs(void) {
+
+void
+test_ToLFPabs(void) {
        int i;
-       for (i = 0; i < COUNTOF(fdata); i++) {
+       for (i = 0; i < COUNTOF(fdata); ++i) {
                struct timespec a = timespec_init(1, fdata[i].nsec);
                l_fp E = l_fp_init(1 + JAN_1970, fdata[i].frac);
                l_fp r;
@@ -488,8 +524,10 @@ void test_ToLFPabs(void) {
 //----------------------------------------------------------------------
 // conversion from l_fp
 //----------------------------------------------------------------------
-void test_FromLFPbittest(void) {
-       struct timespec limit = timespec_init(0,2);
+
+void
+test_FromLFPbittest(void) {
+       struct timespec limit = timespec_init(0, 2);
 
        // Not *exactly* a bittest, because 2**32 tests would take a
        // really long time even on very fast machines! So we do test
@@ -503,43 +541,48 @@ void test_FromLFPbittest(void) {
                r = lfp_intv_to_tspec(a);
                // The conversion might be off by one nanosecond when
                // comparing to calculated value.
-               TEST_ASSERT_TRUE(AssertTimespecClose(E,r,limit));
+               TEST_ASSERT_TRUE(AssertTimespecClose(E, r, limit));
        }
 }
 
-void test_FromLFPrelPos(void) {
-       struct timespec limit = timespec_init(0,2);
+
+void
+test_FromLFPrelPos(void) {
+       struct timespec limit = timespec_init(0, 2);
        int i;
-       for (i = 0; i < COUNTOF(fdata); i++) {
+       for (i = 0; i < COUNTOF(fdata); ++i) {
                l_fp a = l_fp_init(1, fdata[i].frac);
                struct timespec E = timespec_init(1, fdata[i].nsec);
                struct timespec r;
 
                r = lfp_intv_to_tspec(a);
-               TEST_ASSERT_TRUE(AssertTimespecClose(E,r,limit));
+               TEST_ASSERT_TRUE(AssertTimespecClose(E, r, limit));
        }
 }
 
-void test_FromLFPrelNeg(void) {
-       struct timespec limit = timespec_init(0,2);
+
+void
+test_FromLFPrelNeg(void) {
+       struct timespec limit = timespec_init(0, 2);
        int i;
-       for (i = 0; i < COUNTOF(fdata); i++) {
+       for (i = 0; i < COUNTOF(fdata); ++i) {
                l_fp a = l_fp_init(~0, fdata[i].frac);
                struct timespec E = timespec_init(-1, fdata[i].nsec);
                struct timespec r;
 
                r = lfp_intv_to_tspec(a);
-               TEST_ASSERT_TRUE(AssertTimespecClose(E,r,limit));
+               TEST_ASSERT_TRUE(AssertTimespecClose(E, r, limit));
        }
 }
 
 
 // nsec -> frac -> nsec roundtrip, using a prime start and increment
-void test_LFProundtrip(void) {
+void
+test_LFProundtrip(void) {
        int32_t t;
        u_int32 i;
        for (t = -1; t < 2; ++t)
-               for (i = 4999; i < 1000000000; i+=10007) {
+               for (i = 4999; i < 1000000000; i += 10007) {
                        struct timespec E = timespec_init(t, i);
                        l_fp a;
                        struct timespec r;
@@ -554,7 +597,8 @@ void test_LFProundtrip(void) {
 // string formatting
 //----------------------------------------------------------------------
 
-void test_ToString(void) {
+void
+test_ToString(void) {
        static const struct {
                time_t          sec;
                long            nsec;
@@ -570,7 +614,7 @@ void test_ToString(void) {
                {-1,-1, "-1.000000001" },
        };
        int i;
-       for (i = 0; i < COUNTOF(data); i++) {
+       for (i = 0; i < COUNTOF(data); ++i) {
                struct timespec a = timespec_init(data[i].sec, data[i].nsec);
                const char * E = data[i].repr;
                const char * r = tspectoa(a);
index 9d832673d6c51058aa72d65cb2acfad0ea0ab032..c3077f9d714c3c07edc480fd10b5fb90b86befcd 100644 (file)
@@ -5,23 +5,22 @@
 #include "ntp_types.h"
 #include "ntp_fp.h"
 
-#include <math.h>
 #include "timevalops.h"
 
+#include <math.h>
 #include "unity.h"
 
 
-//in unity_helper.h :
 #define TEST_ASSERT_EQUAL_timeval(a, b) { \
     TEST_ASSERT_EQUAL_MESSAGE(a.tv_sec, b.tv_sec, "Field tv_sec"); \
     TEST_ASSERT_EQUAL_MESSAGE(a.tv_usec, b.tv_usec, "Field tv_usec");  \
 }
 
-//timeval has time_t, long, and time_t is basically uint
 
 static u_int32 my_tick_to_tsf(u_int32 ticks);
 static u_int32 my_tsf_to_tick(u_int32 tsf);
 
+
 // that's it...
 typedef struct {
        long    usec;
@@ -31,21 +30,26 @@ typedef struct {
 
 //******************************************MY CUSTOM FUNCTIONS*******************************
 
-typedef int bool; //TRUE and FALSE are already defined somewhere, so I can't do typedef enum { FALSE, TRUE } boolean;
+typedef int bool;
+
 
-struct timeval timeval_init( time_t hi, long lo){
+struct timeval
+timeval_init( time_t hi, long lo){
        struct timeval V; 
        V.tv_sec = hi; 
        V.tv_usec = lo;
        return V;
 }
 
-const bool timeval_isValid(struct timeval V)
-       { return V.tv_usec >= 0 && V.tv_usec < 1000000; }
 
-//taken from lfpfunc.c -> maybe remove this from timevalops.c and lfpfunc. and put in c_timstructs.h ????!!!!!
-l_fp l_fp_init(int32 i, u_int32 f)
-{
+const bool
+timeval_isValid(struct timeval V) {
+       return V.tv_usec >= 0 && V.tv_usec < 1000000;
+}
+
+
+l_fp
+l_fp_init(int32 i, u_int32 f) {
        l_fp temp;
        temp.l_i  = i;
        temp.l_uf = f;
@@ -53,8 +57,9 @@ l_fp l_fp_init(int32 i, u_int32 f)
        return temp;
 }
 
-bool AssertTimevalClose(const struct timeval m, const struct timeval n, const struct timeval limit)
-{
+
+bool
+AssertTimevalClose(const struct timeval m, const struct timeval n, const struct timeval limit) {
        struct timeval diff;
 
        diff = abs_tval(sub_tval(m, n));
@@ -63,15 +68,16 @@ bool AssertTimevalClose(const struct timeval m, const struct timeval n, const st
        
        else 
        {
-               printf("m_expr which is %ld.%lu \nand\nn_expr which is %ld.%lu\nare not close; diff=%ld.%luusec\n",m.tv_sec,m.tv_usec,n.tv_sec,n.tv_usec,diff.tv_sec,diff.tv_usec); 
+               printf("m_expr which is %ld.%lu \nand\nn_expr which is %ld.%lu\nare not close; diff=%ld.%luusec\n", m.tv_sec, m.tv_usec, n.tv_sec, n.tv_usec, diff.tv_sec, diff.tv_usec); 
                //I don't have variables m_expr and n_expr in unity, those are command line arguments which only getst has!!!
                
                return FALSE;
        }
 }
 
-bool AssertFpClose(const l_fp m,const l_fp n, const l_fp limit)
-{
+
+bool
+AssertFpClose(const l_fp m, const l_fp n, const l_fp limit) {
        l_fp diff;
 
        if (L_ISGEQ(&m, &n)) {
@@ -85,8 +91,8 @@ bool AssertFpClose(const l_fp m,const l_fp n, const l_fp limit)
                return TRUE;
        }
        else {
-               printf("m_expr which is %s \nand\nn_expr which is %s\nare not close; diff=%susec\n",lfptoa(&m,10),lfptoa(&n,10),lfptoa(&diff,10)); 
-               //printf("m_expr which is %d.%d \nand\nn_expr which is %d.%d\nare not close; diff=%d.%dusec\n",m.l_uf,m.Ul_i,n.l_uf,n.Ul_i,diff.l_uf,diff.Ul_i); 
+               printf("m_expr which is %s \nand\nn_expr which is %s\nare not close; diff=%susec\n", lfptoa(&m, 10), lfptoa(&n, 10), lfptoa(&diff, 10)); 
+               //printf("m_expr which is %d.%d \nand\nn_expr which is %d.%d\nare not close; diff=%d.%dusec\n", m.l_uf, m.Ul_i, n.l_uf, n.Ul_i, diff.l_uf, diff.Ul_i); 
                return FALSE;
        }
 }
@@ -112,8 +118,8 @@ static const lfpfracdata fdata[] = {
 };
 
 
-u_int32 my_tick_to_tsf(u_int32 ticks)
-{
+u_int32
+my_tick_to_tsf(u_int32 ticks) {
        // convert microseconds to l_fp fractional units, using double
        // precision float calculations or, if available, 64bit integer
        // arithmetic. This should give the precise fraction, rounded to
@@ -127,8 +133,9 @@ u_int32 my_tick_to_tsf(u_int32 ticks)
        // truncated nonsense, so don't use it out-of-bounds.
 }
 
-u_int32 my_tsf_to_tick(u_int32 tsf)
-{
+
+u_int32
+my_tsf_to_tick(u_int32 tsf) {
        // Inverse operation: converts fraction to microseconds.
 #ifdef HAVE_U_INT64
        return (u_int32)( ((u_int64)(tsf) * 1000000 + 0x80000000) >> 32); //CHECK ME!!!
@@ -146,7 +153,8 @@ u_int32 my_tsf_to_tick(u_int32 tsf)
 // test support stuff - part1
 // ---------------------------------------------------------------------
 
-void test_Helpers1(void) {
+void
+test_Helpers1(void) {
        struct timeval x;
 
        for (x.tv_sec = -2; x.tv_sec < 3; x.tv_sec++) {
@@ -166,7 +174,8 @@ void test_Helpers1(void) {
 // test normalisation
 //----------------------------------------------------------------------
 
-void test_Normalise(void) {
+void
+test_Normalise(void) {
        long ns;
        for (ns = -2000000000; ns <= 2000000000; ns += 10000000) {
                struct timeval x = timeval_init(0, ns);
@@ -180,7 +189,8 @@ void test_Normalise(void) {
 // test classification
 //----------------------------------------------------------------------
 
-void test_SignNoFrac(void) {
+void
+test_SignNoFrac(void) {
        int i;
        // sign test, no fraction
        for (i = -4; i <= 4; ++i) {
@@ -192,7 +202,9 @@ void test_SignNoFrac(void) {
        }
 }
 
-void test_SignWithFrac(void) {
+
+void
+test_SignWithFrac(void) {
        // sign test, with fraction
        int i;
        for (i = -4; i <= 4; ++i) {
@@ -207,8 +219,9 @@ void test_SignWithFrac(void) {
 //----------------------------------------------------------------------
 // test compare
 //----------------------------------------------------------------------
-void test_CmpFracEQ(void) {
-       int i,j;
+void
+test_CmpFracEQ(void) {
+       int i, j;
        // fractions are equal
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
@@ -221,9 +234,11 @@ void test_CmpFracEQ(void) {
                }
 }
 
-void test_CmpFracGT(void) {
+
+void
+test_CmpFracGT(void) {
        // fraction a bigger fraction b
-       int i,j;
+       int i, j;
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timeval a = timeval_init( i , 999800);
@@ -235,9 +250,11 @@ void test_CmpFracGT(void) {
                }
 }
 
-void test_CmpFracLT(void) {
+
+void
+test_CmpFracLT(void) {
        // fraction a less fraction b
-       int i,j;
+       int i, j;
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timeval a = timeval_init(i, 200);
@@ -253,8 +270,9 @@ void test_CmpFracLT(void) {
 // Test addition (sum)
 //----------------------------------------------------------------------
 
-void test_AddFullNorm(void) {
-       int i,j;
+void
+test_AddFullNorm(void) {
+       int i, j;
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timeval a = timeval_init(i, 200);
@@ -267,8 +285,10 @@ void test_AddFullNorm(void) {
                }
 }
 
-void test_AddFullOflow1(void) {
-       int i,j;
+
+void
+test_AddFullOflow1(void) {
+       int i, j;
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timeval a = timeval_init(i, 200);
@@ -281,7 +301,9 @@ void test_AddFullOflow1(void) {
                }
 }
 
-void test_AddUsecNorm(void) {
+
+void
+test_AddUsecNorm(void) {
        int i;
        for (i = -4; i <= 4; ++i) {
                struct timeval a = timeval_init(i, 200);
@@ -293,7 +315,9 @@ void test_AddUsecNorm(void) {
        }
 }
 
-void test_AddUsecOflow1(void) {
+
+void
+test_AddUsecOflow1(void) {
        int i;
        for (i = -4; i <= 4; ++i) {
                struct timeval a = timeval_init(i, 200);
@@ -309,8 +333,9 @@ void test_AddUsecOflow1(void) {
 // test subtraction (difference)
 //----------------------------------------------------------------------
 
-void test_SubFullNorm(void) {
-       int i,j;
+void
+test_SubFullNorm(void) {
+       int i, j;
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timeval a = timeval_init(i, 600);
@@ -323,8 +348,10 @@ void test_SubFullNorm(void) {
                }
 }
 
-void test_SubFullOflow(void) {
-       int i,j;
+
+void
+test_SubFullOflow(void) {
+       int i, j;
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timeval a = timeval_init(i, 100);
@@ -337,7 +364,9 @@ void test_SubFullOflow(void) {
                }
 }
 
-void test_SubUsecNorm(void) {
+
+void
+test_SubUsecNorm(void) {
        int i = -4;
        for (i = -4; i <= 4; ++i) {
                struct timeval a = timeval_init(i, 600);
@@ -349,7 +378,9 @@ void test_SubUsecNorm(void) {
        }
 }
 
-void test_SubUsecOflow(void) {
+
+void
+test_SubUsecOflow(void) {
        int i = -4;
        for (i = -4; i <= 4; ++i) {
                struct timeval a = timeval_init(i, 100);
@@ -365,7 +396,8 @@ void test_SubUsecOflow(void) {
 // test negation
 //----------------------------------------------------------------------
 
-void test_Neg(void) {
+void
+test_Neg(void) {
        int i = -4;
        for (i = -4; i <= 4; ++i) {
                struct timeval a = timeval_init(i, 100);
@@ -382,7 +414,8 @@ void test_Neg(void) {
 // test abs value
 //----------------------------------------------------------------------
 
-void test_AbsNoFrac(void) {
+void
+test_AbsNoFrac(void) {
        int i = -4;
        for (i = -4; i <= 4; ++i) {
                struct timeval a = timeval_init(i, 0);
@@ -393,7 +426,9 @@ void test_AbsNoFrac(void) {
        }
 }
 
-void test_AbsWithFrac(void) {
+
+void
+test_AbsWithFrac(void) {
        int i = -4;
        for (i = -4; i <= 4; ++i) {
                struct timeval a = timeval_init(i, 100);
@@ -409,7 +444,8 @@ void test_AbsWithFrac(void) {
 // ---------------------------------------------------------------------
 
 
-void test_Helpers2(void) {
+void
+test_Helpers2(void) {
 
        struct timeval limit = timeval_init(0, 2);
        struct timeval x, y;
@@ -419,14 +455,14 @@ void test_Helpers2(void) {
                for (x.tv_usec = 1;
                     x.tv_usec < 1000000;
                     x.tv_usec += 499999) {
-                       for (i = -4; i < 5; i++) {
+                       for (i = -4; i < 5; ++i) {
                                y = x;
                                y.tv_usec += i;
                                if (i >= -2 && i <= 2){
-                                       TEST_ASSERT_TRUE(AssertTimevalClose(x,y,limit));//ASSERT_PRED_FORMAT2(isClose, x, y);
+                                       TEST_ASSERT_TRUE(AssertTimevalClose(x, y, limit));//ASSERT_PRED_FORMAT2(isClose, x, y);
                                }
                                else {
-                                       TEST_ASSERT_FALSE(AssertTimevalClose(x,y,limit));
+                                       TEST_ASSERT_FALSE(AssertTimevalClose(x, y, limit));
                                }
                        }
                }
@@ -435,66 +471,72 @@ void test_Helpers2(void) {
 
 // and the global predicate instances we're using here
 
-//static l_fp lfpClose =  l_fp_init(0,1); //static AssertFpClose FpClose(0, 1);
-//static struct timeval timevalClose = timeval_init(0,1); //static AssertTimevalClose TimevalClose(0, 1);
+//static l_fp lfpClose =  l_fp_init(0, 1); //static AssertFpClose FpClose(0, 1);
+//static struct timeval timevalClose = timeval_init(0, 1); //static AssertTimevalClose TimevalClose(0, 1);
 
 //----------------------------------------------------------------------
 // conversion to l_fp
 //----------------------------------------------------------------------
 
-void test_ToLFPbittest(void) {
-       l_fp lfpClose =  l_fp_init(0,1);        
+void
+test_ToLFPbittest(void) {
+       l_fp lfpClose =  l_fp_init(0, 1);       
 
        u_int32 i = 0;
-       for (i = 0; i < 1000000; i++) {
+       for (i = 0; i < 1000000; ++i) {
                struct timeval a = timeval_init(1, i);
-               l_fp E = l_fp_init(1,my_tick_to_tsf(i));
+               l_fp E = l_fp_init(1, my_tick_to_tsf(i));
                l_fp r;
 
                r = tval_intv_to_lfp(a);
-               TEST_ASSERT_TRUE(AssertFpClose(E,r,lfpClose));  //ASSERT_PRED_FORMAT2(FpClose, E, r);
+               TEST_ASSERT_TRUE(AssertFpClose(E, r, lfpClose));        //ASSERT_PRED_FORMAT2(FpClose, E, r);
        }
 }
 
 
-void test_ToLFPrelPos(void) {
-       l_fp lfpClose =  l_fp_init(0,1);
+void
+test_ToLFPrelPos(void) {
+       l_fp lfpClose =  l_fp_init(0, 1);
 
        int i = 0;
-       for (i = 0; i < COUNTOF(fdata); i++) {
+       for (i = 0; i < COUNTOF(fdata); ++i) {
                struct timeval a = timeval_init(1, fdata[i].usec);
                l_fp E = l_fp_init(1, fdata[i].frac);
                l_fp r;
 
                r = tval_intv_to_lfp(a);
-               TEST_ASSERT_TRUE(AssertFpClose(E,r,lfpClose));
+               TEST_ASSERT_TRUE(AssertFpClose(E, r, lfpClose));
        }
 }
 
-void test_ToLFPrelNeg(void) {
-       l_fp lfpClose =  l_fp_init(0,1);
+
+void
+test_ToLFPrelNeg(void) {
+       l_fp lfpClose =  l_fp_init(0, 1);
        int i = 0;
-       for (i = 0; i < COUNTOF(fdata); i++) {
+       for (i = 0; i < COUNTOF(fdata); ++i) {
                struct timeval a = timeval_init(-1, fdata[i].usec);
                l_fp E = l_fp_init(~0, fdata[i].frac);
                l_fp    r;
 
                r = tval_intv_to_lfp(a);
-               TEST_ASSERT_TRUE(AssertFpClose(E,r,lfpClose));
+               TEST_ASSERT_TRUE(AssertFpClose(E, r, lfpClose));
        }
 }
 
-void test_ToLFPabs(void) {
-       l_fp lfpClose =  l_fp_init(0,1);
+
+void
+test_ToLFPabs(void) {
+       l_fp lfpClose =  l_fp_init(0, 1);
 
        int i = 0;
-       for (i = 0; i < COUNTOF(fdata); i++) {
+       for (i = 0; i < COUNTOF(fdata); ++i) {
                struct timeval a = timeval_init(1, fdata[i].usec);
                l_fp E = l_fp_init(1 + JAN_1970, fdata[i].frac);
                l_fp    r;
 
                r = tval_stamp_to_lfp(a);
-               TEST_ASSERT_TRUE(AssertFpClose(E,r,lfpClose));
+               TEST_ASSERT_TRUE(AssertFpClose(E, r, lfpClose));
        }
 }
 
@@ -502,8 +544,9 @@ void test_ToLFPabs(void) {
 // conversion from l_fp
 //----------------------------------------------------------------------
 
-void test_FromLFPbittest(void) {
-       struct timeval timevalClose = timeval_init(0,1);
+void
+test_FromLFPbittest(void) {
+       struct timeval timevalClose = timeval_init(0, 1);
        // Not *exactly* a bittest, because 2**32 tests would take a
        // really long time even on very fast machines! So we do test
        // every 1000 fractional units.
@@ -516,42 +559,48 @@ void test_FromLFPbittest(void) {
                r = lfp_intv_to_tval(a);
                // The conversion might be off by one microsecond when
                // comparing to calculated value.
-               TEST_ASSERT_TRUE(AssertTimevalClose(E,r,timevalClose));
+               TEST_ASSERT_TRUE(AssertTimevalClose(E, r, timevalClose));
        }
 }
 
-void test_FromLFPrelPos(void) {
-       struct timeval timevalClose = timeval_init(0,1);
+
+void
+test_FromLFPrelPos(void) {
+       struct timeval timevalClose = timeval_init(0, 1);
        int i = 0;      
-       for (i = 0; i < COUNTOF(fdata); i++) {
+       for (i = 0; i < COUNTOF(fdata); ++i) {
                l_fp a = l_fp_init(1, fdata[i].frac);
                struct timeval E = timeval_init(1, fdata[i].usec);
                struct timeval r;
 
                r = lfp_intv_to_tval(a);
-               TEST_ASSERT_TRUE(AssertTimevalClose(E,r,timevalClose));
+               TEST_ASSERT_TRUE(AssertTimevalClose(E, r, timevalClose));
        }
 }
 
-void test_FromLFPrelNeg(void) {
-       struct timeval timevalClose = timeval_init(0,1);
+
+void
+test_FromLFPrelNeg(void) {
+       struct timeval timevalClose = timeval_init(0, 1);
        int i = 0;
-       for (i = 0; i < COUNTOF(fdata); i++) {
+       for (i = 0; i < COUNTOF(fdata); ++i) {
                l_fp a = l_fp_init(~0, fdata[i].frac);
                struct timeval E = timeval_init(-1, fdata[i].usec);
                struct timeval r;
 
                r = lfp_intv_to_tval(a);
-               TEST_ASSERT_TRUE(AssertTimevalClose(E,r,timevalClose));
+               TEST_ASSERT_TRUE(AssertTimevalClose(E, r, timevalClose));
        }
 }
 
+
 // usec -> frac -> usec roundtrip, using a prime start and increment
-void test_LFProundtrip(void) {
+void
+test_LFProundtrip(void) {
        int32_t t = -1;
        u_int32 i = 5;
        for (t = -1; t < 2; ++t)
-               for (i = 5; i < 1000000; i+=11) {
+               for (i = 5; i < 1000000; i += 11) {
                        struct timeval E = timeval_init(t, i);
                        l_fp a;
                        struct timeval r;
@@ -566,7 +615,8 @@ void test_LFProundtrip(void) {
 // string formatting
 //----------------------------------------------------------------------
 
-void test_ToString(void) {
+void
+test_ToString(void) {
        static const struct {
                time_t       sec;
                long         usec;