$(NULL)
noinst_HEADERS = \
- sntptest.h \
- c_sntptest.h \
fileHandlingTest.h \
- c_fileHandlingTest.h \
+ sntptest.h \
+ g_fileHandlingTest.h \
+ g_sntptest.h \
$(NULL)
dist_check_SCRIPTS = tests-runner
$(srcdir)/run-networking.c \
$(NULL)
+
test_keyFile_CFLAGS = \
-I$(top_srcdir)/unity \
$(NULL)
+++ /dev/null
-#ifndef FILE_HANDLING_TEST_H
-#define FILE_HANDLING_TEST_H
-
-#include "stdlib.h"
-#include "c_sntptest.h"
-
-#include <string.h>
-#include <unistd.h>
-
-
-enum DirectoryType {
- INPUT_DIR = 0,
- 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;
-
- char cwd[1024];
- if (getcwd(cwd, sizeof(cwd)) != NULL)
- printf("Current working dir: %s\n", cwd);
-
- if(strstr(cwd,"sub/") == NULL){
- strcpy(path,"../../../sntp/tests/data/");
- }
- else
- if(strstr(cwd,"_build") == NULL){ //if it's run as make distcheck, it's in a different directory!
- strcpy(path,"../../../sntp/tests/data/");
- }
-
- else {
- strcpy(path,"../../../../sntp/tests/data/");
- }
-
- //strcpy(path,"");
- strcat(path,filename);
- printf("PATH IS : %s\n",path);
- return path;
-}
-
-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) {
- int currentLine = 1;
-
- char * actualLine=NULL;
- char * expectedLine = NULL;
- size_t lenAct = 0;
- size_t lenExp = 0;
- ssize_t readAct,readExp;
-
- while ( ( (readAct = getline(&actualLine, &lenAct, actual)) != -1) && ( (readExp = getline(&expectedLine, &lenExp, expected)) != -1 ) ) {
-
- //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);
-}
-
-
-#endif // FILE_HANDLING_TEST_H
+++ /dev/null
-#ifndef SNTPTEST_H
-#define SNTPTEST_H
-
-//#include "tests_main.h"
-
-#include "ntp_stdlib.h"
-#include "sntp-opts.h"
-
-
-sntptest() {
- optionSaveState(&sntpOptions);
-}
-/*
-~sntptest() {
- optionRestore(&sntpOptions);
-}
-*/
-void ActivateOption(const char* option, const char* argument) {
- const int ARGV_SIZE = 4;
-
- char* opts[ARGV_SIZE];
-
- opts[0] = estrdup("sntpopts");
- opts[1] = estrdup(option);
- opts[2] = estrdup(argument);
- opts[3] = estrdup("127.0.0.1");
-
- optionProcess(&sntpOptions, ARGV_SIZE, opts);
-}
-
-
-#endif // SNTPTEST_H
-#include "sntptest.h"
+#include "g_sntptest.h"
extern "C" {
#include "crypto.h"
#ifndef FILE_HANDLING_TEST_H
#define FILE_HANDLING_TEST_H
+#include "stdlib.h"
#include "sntptest.h"
-#include <fstream>
-#include <string>
+#include <string.h>
+#include <unistd.h>
-using std::ifstream;
-using std::string;
-using std::ios;
-class fileHandlingTest : public sntptest {
-protected:
- enum DirectoryType {
- INPUT_DIR = 0,
- OUTPUT_DIR = 1
- };
-
- std::string CreatePath(const char* filename, DirectoryType argument) {
- std::string path;
+enum DirectoryType {
+ INPUT_DIR = 0,
+ OUTPUT_DIR = 1
+};
- if (m_params.size() >= argument + 1) {
- path = m_params[argument];
- }
+const char * CreatePath(const char* filename, enum DirectoryType argument) {
+
+ char * path = malloc (sizeof (char) * 256);
- if (path[path.size()-1] != DIR_SEP && !path.empty()) {
- path.append(1, DIR_SEP);
- }
- path.append(filename);
+ /*
+ if (m_params.size() >= argument + 1) {
+ path = m_params[argument];
+ }
- return path;
+ if (path[path.size()-1] != DIR_SEP && !path.empty()) {
+ path.append(1, DIR_SEP);
}
+ */
+ //strcpy(path,filename);
+ //path.append(filename);
- int GetFileSize(ifstream& file) {
- int initial = file.tellg();
+ //return path;
- file.seekg(0, ios::end);
- int length = file.tellg();
- file.seekg(initial);
+ char cwd[1024];
+ if (getcwd(cwd, sizeof(cwd)) != NULL)
+ printf("Current working dir: %s\n", cwd);
+
+ if(strstr(cwd,"sub/") == NULL){
+ strcpy(path,"../../../sntp/tests/data/");
+ }
+ else
+ if(strstr(cwd,"_build") == NULL){ //if it's run as make distcheck, it's in a different directory!
+ strcpy(path,"../../../sntp/tests/data/");
+ }
- return length;
+ else {
+ strcpy(path,"../../../../sntp/tests/data/");
}
- void CompareFileContent(ifstream& expected, ifstream& actual) {
- int currentLine = 1;
- while (actual.good() && expected.good()) {
- string actualLine, expectedLine;
- getline(actual, actualLine);
- getline(expected, expectedLine);
-
- EXPECT_EQ(expectedLine, actualLine) << "Comparision failed on line " << currentLine;
- currentLine++;
+ //strcpy(path,"");
+ strcat(path,filename);
+ printf("PATH IS : %s\n",path);
+ return path;
+}
+
+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) {
+ int currentLine = 1;
+
+ char actualLine[1024];
+ char expectedLine[1024];
+ size_t lenAct = sizeof actualLine;
+ size_t lenExp = sizeof expectedLine;
+
+ while ( ( (fgets(actualLine, lenAct, actual)) != NULL)
+ && ( (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;
}
- }
- void ClearFile(const std::string& filename) {
- std::ofstream clear(filename.c_str(), ios::trunc);
- ASSERT_TRUE(clear.good());
- clear.close();
+ //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);
+}
+
#endif // FILE_HANDLING_TEST_H
--- /dev/null
+#ifndef FILE_HANDLING_TEST_H
+#define FILE_HANDLING_TEST_H
+
+#include "g_sntptest.h"
+
+#include <fstream>
+#include <string>
+
+using std::ifstream;
+using std::string;
+using std::ios;
+
+class fileHandlingTest : public sntptest {
+protected:
+ enum DirectoryType {
+ INPUT_DIR = 0,
+ OUTPUT_DIR = 1
+ };
+
+ std::string CreatePath(const char* filename, DirectoryType argument) {
+ std::string path;
+
+ if (m_params.size() >= argument + 1) {
+ path = m_params[argument];
+ }
+
+ if (path[path.size()-1] != DIR_SEP && !path.empty()) {
+ path.append(1, DIR_SEP);
+ }
+ path.append(filename);
+
+ return path;
+ }
+
+ int GetFileSize(ifstream& file) {
+ int initial = file.tellg();
+
+ file.seekg(0, ios::end);
+ int length = file.tellg();
+ file.seekg(initial);
+
+ return length;
+ }
+
+ void CompareFileContent(ifstream& expected, ifstream& actual) {
+ int currentLine = 1;
+ while (actual.good() && expected.good()) {
+ string actualLine, expectedLine;
+ getline(actual, actualLine);
+ getline(expected, expectedLine);
+
+ EXPECT_EQ(expectedLine, actualLine) << "Comparision failed on line " << currentLine;
+ currentLine++;
+ }
+ }
+
+ void ClearFile(const std::string& filename) {
+ std::ofstream clear(filename.c_str(), ios::trunc);
+ ASSERT_TRUE(clear.good());
+ clear.close();
+ }
+};
+
+#endif // FILE_HANDLING_TEST_H
-#include "fileHandlingTest.h"
+#include "g_fileHandlingTest.h"
extern "C" {
#include "crypto.h"
-#include "sntptest.h"
+#include "g_sntptest.h"
extern "C" {
#include "kod_management.h"
-#include "fileHandlingTest.h"
+#include "g_fileHandlingTest.h"
extern "C" {
#include "kod_management.h"
-#include "sntptest.h"
+#include "g_sntptest.h"
extern "C" {
#include "networking.h"
--- /dev/null
+#ifndef SNTPTEST_H
+#define SNTPTEST_H
+
+#include "tests_main.h"
+
+extern "C" {
+#include "ntp_stdlib.h"
+#include "sntp-opts.h"
+};
+
+class sntptest : public ntptest {
+protected:
+ sntptest() {
+ optionSaveState(&sntpOptions);
+ }
+
+ ~sntptest() {
+ optionRestore(&sntpOptions);
+ }
+
+ void ActivateOption(const char* option, const char* argument) {
+ const int ARGV_SIZE = 4;
+
+ char* opts[ARGV_SIZE];
+
+ opts[0] = estrdup("sntpopts");
+ opts[1] = estrdup(option);
+ opts[2] = estrdup(argument);
+ opts[3] = estrdup("127.0.0.1");
+
+ optionProcess(&sntpOptions, ARGV_SIZE, opts);
+ }
+};
+
+#endif // SNTPTEST_H
#include "config.h"
-#include "c_fileHandlingTest.h"
+#include "fileHandlingTest.h"
#include "ntp_stdlib.h"
#include "ntp_types.h"
#include "config.h"
#include "ntp_types.h"
-#include "c_sntptest.h"
+#include "sntptest.h"
#include "ntp_stdlib.h"
#include "sntp-opts.h"
#include "ntp_stdlib.h" // For estrdup()
-#include "c_fileHandlingTest.h"
+#include "fileHandlingTest.h"
#include "kod_management.h"
-#include "sntptest.h"
+#include "g_sntptest.h"
extern "C" {
#include "networking.h"
#include "config.h"
-#include "c_sntptest.h"
+#include "sntptest.h"
#include "networking.h"
-#include "sntptest.h"
+#include "g_sntptest.h"
extern "C" {
#include "kod_management.h"
-#include "sntptest.h"
+#include "g_sntptest.h"
extern "C" {
#include "networking.h"
int main(int argc, char *argv[])
{
progname = argv[0];
- //printf("NUM: %d , %s\n",argc,argv[0]);
Unity.TestFile = "keyFile.c";
UnityBegin("keyFile.c");
RUN_TEST(test_ReadEmptyKeyFile, 53);
#ifndef SNTPTEST_H
#define SNTPTEST_H
-#include "tests_main.h"
+//#include "tests_main.h"
-extern "C" {
#include "ntp_stdlib.h"
#include "sntp-opts.h"
-};
-
-class sntptest : public ntptest {
-protected:
- sntptest() {
- optionSaveState(&sntpOptions);
- }
-
- ~sntptest() {
- optionRestore(&sntpOptions);
- }
-
- void ActivateOption(const char* option, const char* argument) {
- const int ARGV_SIZE = 4;
-
- char* opts[ARGV_SIZE];
-
- opts[0] = estrdup("sntpopts");
- opts[1] = estrdup(option);
- opts[2] = estrdup(argument);
- opts[3] = estrdup("127.0.0.1");
-
- optionProcess(&sntpOptions, ARGV_SIZE, opts);
- }
-};
+
+
+sntptest() {
+ optionSaveState(&sntpOptions);
+}
+/*
+~sntptest() {
+ optionRestore(&sntpOptions);
+}
+*/
+void ActivateOption(const char* option, const char* argument) {
+ const int ARGV_SIZE = 4;
+
+ char* opts[ARGV_SIZE];
+
+ opts[0] = estrdup("sntpopts");
+ opts[1] = estrdup(option);
+ opts[2] = estrdup(argument);
+ opts[3] = estrdup("127.0.0.1");
+
+ optionProcess(&sntpOptions, ARGV_SIZE, opts);
+}
+
#endif // SNTPTEST_H
-#include "sntptest.h"
-#include "fileHandlingTest.h"
+#include "g_sntptest.h"
+#include "g_fileHandlingTest.h"
extern "C" {
#include "main.h"