summaryrefslogtreecommitdiff
path: root/common/tests
diff options
context:
space:
mode:
authorStef Walter <stef@thewalter.net>2013-07-17 09:51:32 +0200
committerStef Walter <stef@thewalter.net>2013-07-18 08:13:20 +0200
commit81a6e16539e5e4a27c55194ae095cc4a75d08ade (patch)
tree70e409e938e60c326f95d85ac059efb58f48286a /common/tests
parenteb8f5859b1349f8147ba47a1da8032df192f2370 (diff)
tools: Use $TMPDIR instead of $TEMP
TMPDIR is a more standard environment variable for locating the temp directory on Unix. In addition since this is only used in tests, remove the code from the generic p11_path_expand() func. In general remove the possibility for forks to put $HOME or $TEMP environment variables in configured paths. This was possible due to code in p11_path_expand() but not something we supported. https://bugzilla.redhat.com/show_bug.cgi?id=985017
Diffstat (limited to 'common/tests')
-rw-r--r--common/tests/test-path.c31
1 files changed, 1 insertions, 30 deletions
diff --git a/common/tests/test-path.c b/common/tests/test-path.c
index 1f85dbb..0077cd0 100644
--- a/common/tests/test-path.c
+++ b/common/tests/test-path.c
@@ -114,50 +114,21 @@ test_expand (void)
#ifdef OS_UNIX
putenv ("HOME=/home/blah");
check_equals_and_free ("/home/blah/my/path",
- p11_path_expand ("$HOME/my/path"));
- check_equals_and_free ("/home/blah/my/path",
p11_path_expand ("~/my/path"));
check_equals_and_free ("/home/blah",
- p11_path_expand ("$HOME"));
- check_equals_and_free ("/home/blah",
p11_path_expand ("~"));
- putenv ("TEMP=/tmpdir");
- check_equals_and_free ("/tmpdir/my/path",
- p11_path_expand ("$TEMP/my/path"));
- check_equals_and_free ("/tmpdir",
- p11_path_expand ("$TEMP"));
#else /* OS_WIN32 */
putenv ("HOME=C:\\Users\\blah");
check_equals_and_free ("C:\\Users\\blah\\path",
- p11_path_expand ("$HOME/path"));
- check_equals_and_free ("C:\\Users\\blah\\path",
- p11_path_expand ("$HOME\\path"));
- check_equals_and_free ("C:\\Users\\blah\\path",
- p11_path_expand ("~/path"));
+ p11_path_expand ("~/my/path"));
check_equals_and_free ("C:\\Users\\blah\\path",
p11_path_expand ("~\\path"));
-
- putenv ("TEMP=C:\\Temp Directory");
- check_equals_and_free ("C:\\Temp Directory\\path",
- p11_path_expand ("$TEMP/path"));
- check_equals_and_free ("C:\\Temp Directory\\path",
- p11_path_expand ("$TEMP\\path"));
#endif
putenv("HOME=");
- path = p11_path_expand ("$HOME/this/is/my/path");
- assert (strstr (path, "this/is/my/path") != NULL);
- free (path);
-
- putenv("HOME=");
path = p11_path_expand ("~/this/is/my/path");
assert (strstr (path, "this/is/my/path") != NULL);
free (path);
-
- putenv("TEMP=");
- path = p11_path_expand ("$TEMP/this/is/my/path");
- assert (strstr (path, "this/is/my/path") != NULL);
- free (path);
}
static void