]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
c_fileHandlingTest.h:
authorDamir Tomic <viperus@ntp.org>
Fri, 19 Jun 2015 11:58:37 +0000 (13:58 +0200)
committerDamir Tomic <viperus@ntp.org>
Fri, 19 Jun 2015 11:58:37 +0000 (13:58 +0200)
  added different paths depening on the build dir, maybe this will work on freebsd
run-keyFile.c:
  slight change

bk: 558403edVtZV7qfVMYMd2cV5sVe4Sg

sntp/tests/c_fileHandlingTest.h
sntp/tests/run-keyFile.c

index 34d368923e03c62a9156fbd217af06554e8e170e..2ce075c6071a94f445c2e27397462820a20711ee 100644 (file)
@@ -5,6 +5,7 @@
 #include "c_sntptest.h"
 
 #include <string.h>
+#include <unistd.h>
 
 
 enum DirectoryType {
@@ -14,7 +15,7 @@ enum DirectoryType {
 
 const char * CreatePath(const char* filename, enum DirectoryType argument) {
        
-        char * path = malloc (sizeof (char) * 100);
+        char * path = malloc (sizeof (char) * 256);
 
        /*
        if (m_params.size() >= argument + 1) {
@@ -30,7 +31,20 @@ const char * CreatePath(const char* filename, enum DirectoryType argument) {
 
        //return path;
 
-       strcpy(path,"../../../sntp/tests/data/");
+       char cwd[1024];
+       if (getcwd(cwd, sizeof(cwd)) != NULL)
+               printf("Current working dir: %s\n", cwd);
+       
+
+       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/");
+       }
+
+       
        strcat(path,filename);
 
        return path;
index 0a6380d33b35f684f05af9096f7f6b7285698856..43b7f9466c7eb557b96e5c1c2e4de030a5a831c8 100644 (file)
@@ -47,6 +47,7 @@ char *progname;
 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);