mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 06:50:12 +00:00
tests: Put tmp dirs in objdir, not /tmp
Currently, all tests that use afstest_mkdtemp() generate a temporary dir in /tmp, which is removed when the test is done (unless MAKECHECK isn't set, or the test prematurely exits/crashes). The /tmp dir on a system may not be the best choice; it may be limited in size, and it's visible to other users, which is annoying if we are littering the dir with afs_XXXXXX dirs if broken tests are running during development. Instead, use a tmp dir in the objdir of the current build (specifically, tests/tmp/). Since this is the same dir we're building the tree in, we must be able to write to it and it should have plenty of space. And it will almost certainly get cleaned up eventually, even with broken tests, since it will get removed when the build tree is inevitably removed. While we're doing this, run the paths from afstest_src_path and afstest_obj_path through realpath(), so our tmp paths (and other paths) look a little cleaner, and don't look like /home/user/openafs/tests/../tests/tmp/foo. Change-Id: I6633f58ac1f6ef34e33b51cc19d3bff7a4f3fdb0 Reviewed-on: https://gerrit.openafs.org/14864 Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
parent
6aa129e743
commit
a737126035
@ -41,8 +41,16 @@ char *
|
||||
afstest_mkdtemp(void)
|
||||
{
|
||||
char *template;
|
||||
char *tmp;
|
||||
|
||||
template = afstest_asprintf("%s/afs_XXXXXX", gettmpdir());
|
||||
tmp = afstest_obj_path("tests/tmp");
|
||||
|
||||
/* Try to make sure 'tmp' exists. */
|
||||
(void)mkdir(tmp, 0700);
|
||||
|
||||
template = afstest_asprintf("%s/afs_XXXXXX", tmp);
|
||||
|
||||
free(tmp);
|
||||
|
||||
#if defined(HAVE_MKDTEMP)
|
||||
return mkdtemp(template);
|
||||
@ -93,6 +101,8 @@ static char *
|
||||
path_from_tdir(char *env_var, char *filename)
|
||||
{
|
||||
char *tdir;
|
||||
char *path;
|
||||
char *top_rel, *top_abs;
|
||||
|
||||
/* C_TAP_SOURCE/C_TAP_BUILD in the env points to 'tests/' in the
|
||||
* srcdir/objdir. */
|
||||
@ -107,12 +117,25 @@ path_from_tdir(char *env_var, char *filename)
|
||||
tdir = "..";
|
||||
}
|
||||
|
||||
/* 'tdir' points to the 'tests' dir, so go up one level to get to the top
|
||||
* srcdir/objdir. */
|
||||
top_rel = afstest_asprintf("%s/..", tdir);
|
||||
top_abs = realpath(top_rel, NULL);
|
||||
free(top_rel);
|
||||
if (top_abs == NULL) {
|
||||
sysbail("realpath");
|
||||
}
|
||||
|
||||
/*
|
||||
* The given 'filename' is specified relative to the top srcdir/objdir.
|
||||
* Since 'tdir' points to 'tests/', go up one level before following
|
||||
* 'filename'.
|
||||
* The given 'filename' is relative to the top srcdir/objdir, so to get the
|
||||
* full path, append 'filename' to the top srcdir/objdir. Note that the
|
||||
* given path may not exist yet, so we cannot run the full path through
|
||||
* realpath().
|
||||
*/
|
||||
return afstest_asprintf("%s/../%s", tdir, filename);
|
||||
path = afstest_asprintf("%s/%s", top_abs, filename);
|
||||
free(top_abs);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
char *
|
||||
|
Loading…
Reference in New Issue
Block a user