summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/sntp/tests/kodFile.c
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2015-10-26 11:35:40 +0000
committerglebius <glebius@FreeBSD.org>2015-10-26 11:35:40 +0000
commitc62812877398840dae0ba74b03e9e6a43cc56fc5 (patch)
tree304551aa93f09787d4f56a966c6409faf1b1bcb0 /contrib/ntp/sntp/tests/kodFile.c
parent9e809ce638c9be9ffb800ced1b91c0e8997f4c9e (diff)
downloadFreeBSD-src-c62812877398840dae0ba74b03e9e6a43cc56fc5.zip
FreeBSD-src-c62812877398840dae0ba74b03e9e6a43cc56fc5.tar.gz
Upgrade NTP to 4.2.8p4.
Security: FreeBSD-SA-15:25.ntp Security: CVE-2015-7871 Security: CVE-2015-7855 Security: CVE-2015-7854 Security: CVE-2015-7853 Security: CVE-2015-7852 Security: CVE-2015-7851 Security: CVE-2015-7850 Security: CVE-2015-7849 Security: CVE-2015-7848 Security: CVE-2015-7701 Security: CVE-2015-7703 Security: CVE-2015-7704, CVE-2015-7705 Security: CVE-2015-7691, CVE-2015-7692, CVE-2015-7702
Diffstat (limited to 'contrib/ntp/sntp/tests/kodFile.c')
-rw-r--r--contrib/ntp/sntp/tests/kodFile.c74
1 files changed, 42 insertions, 32 deletions
diff --git a/contrib/ntp/sntp/tests/kodFile.c b/contrib/ntp/sntp/tests/kodFile.c
index 7daec21..6eb0971 100644
--- a/contrib/ntp/sntp/tests/kodFile.c
+++ b/contrib/ntp/sntp/tests/kodFile.c
@@ -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,32 @@ extern int kod_db_cnt;
extern struct kod_entry** kod_db;
extern char* kod_db_file;
-void setUp() {
- kod_db_cnt = 0;
- kod_db = NULL;
-}
+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 tearDown() {
+void
+setUp(void) {
+ kod_db_cnt = 0;
+ kod_db = NULL;
}
-void test_ReadEmptyFile() {
+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
+test_ReadCorrectFile(void) {
kod_init_kod_db(CreatePath("kod-test-correct", INPUT_DIR), TRUE);
TEST_ASSERT_EQUAL(2, kod_db_cnt);
@@ -50,7 +58,9 @@ void test_ReadCorrectFile() {
TEST_ASSERT_EQUAL(0xfff, res->timestamp);
}
-void test_ReadFileWithBlankLines() {
+
+void
+test_ReadFileWithBlankLines(void) {
kod_init_kod_db(CreatePath("kod-test-blanks", INPUT_DIR), TRUE);
TEST_ASSERT_EQUAL(3, kod_db_cnt);
@@ -73,31 +83,30 @@ void test_ReadFileWithBlankLines() {
TEST_ASSERT_EQUAL(0xabcd, res->timestamp);
}
-void test_WriteEmptyFile() {
- //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() {
- //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 +114,19 @@ void test_WriteFileWithSingleEntry() {
// 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() {
- //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 +144,12 @@ void test_WriteFileWithMultipleEntries() {
// 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));
}
-
OpenPOWER on IntegriCloud