tests: Fix KeyFile test so it works from harness
authorSimon Wilkinson <sxw@your-file-system.com>
Sun, 13 Mar 2011 15:47:36 +0000 (15:47 +0000)
committerDerrick Brashear <shadow@dementia.org>
Sun, 13 Mar 2011 20:40:20 +0000 (13:40 -0700)
The auth/keys test tries to find a file that's distributed as part
of the test suite. However, it currently only looks in the CWD to
find it. Modify the test so that if it's run from the test harness,
it will use the harnesses SOURCE environment variable to locate the
KeyFile

Change-Id: I93e16a01eae79b38ab01c81a57d2a47c28479b27
Reviewed-on: http://gerrit.openafs.org/4213
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>

tests/auth/keys-t.c

index 9e53958..ba7391e 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;
@@ -114,8 +115,18 @@ int main(int argc, char **argv)
     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;