From 926755bf222cfaf39a4e4437c468a7a9030fe7a1 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Sun, 13 Mar 2011 15:47:36 +0000 Subject: [PATCH] tests: Fix KeyFile test so it works from harness 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 Reviewed-by: Derrick Brashear --- tests/auth/keys-t.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/auth/keys-t.c b/tests/auth/keys-t.c index 9e53958c1f..ba7391e0a7 100644 --- a/tests/auth/keys-t.c +++ b/tests/auth/keys-t.c @@ -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;