Windows: do not call time() in a loop
[openafs.git] / tests / auth / keys-t.c
index 9e53958..19ab98a 100644 (file)
@@ -101,6 +101,7 @@ int main(int argc, char **argv)
     struct afsconf_typedKeyList *typedKeyList;
     char *dirname;
     char *keyfile;
+    char *keyfilesrc;
     afs_int32 kvno;
     int code;
     int i;
@@ -109,13 +110,23 @@ int main(int argc, char **argv)
 
     /* Create a temporary afs configuration directory */
 
-    dirname = buildTestConfig();
+    dirname = afstest_BuildTestConfig();
 
     if (asprintf(&keyfile, "%s/KeyFile", dirname) == -1)
        goto out;
 
+    /* Work out the path to our KeyFile. If the test harness hasn't set
+     * the SOURCE environment variable, then assume it is in our CWD */
+    if (getenv("SOURCE") == NULL) {
+       keyfilesrc = strdup("KeyFile");
+    } else {
+       if (asprintf(&keyfilesrc, "%s/auth/KeyFile", getenv("SOURCE")) == -1)
+           goto out;
+    }
+
     /* First, copy in a known keyfile */
-    code = copy("KeyFile", keyfile);
+    code = copy(keyfilesrc, keyfile);
+    free(keyfilesrc);
     if (code)
        goto out;
 
@@ -546,12 +557,12 @@ int main(int argc, char **argv)
 
     afsconf_Close(dir);
 
-    unlinkTestConfig(dirname);
+    afstest_UnlinkTestConfig(dirname);
     free(dirname);
     free(keyfile);
 
     /* Start a new test configuration */
-    dirname = buildTestConfig();
+    dirname = afstest_BuildTestConfig();
     dir = afsconf_Open(dirname);
     ok(dir != NULL, "Sucessfully opened brand new config directory");
     if (dir == NULL)
@@ -572,7 +583,7 @@ int main(int argc, char **argv)
        " ... with the right key");
 
 out:
-    unlinkTestConfig(dirname);
+    afstest_UnlinkTestConfig(dirname);
 
     return 0;
 }