test: force TMPDIR to /tmp if it is unset

This way we can rely on it everywhere without having multiple checks for it.
This commit is contained in:
Peter Hutterer 2021-06-21 13:13:41 +10:00 committed by Wim Taymans
parent 00bc5f0e3b
commit 3c798ea413

View file

@ -521,8 +521,6 @@ static int remove_file(const char *fpath, const struct stat *sb, int typeflag, s
int r;
/* Safety check: bail out if somehow we left TMPDIR */
if (!tmpdir)
tmpdir = "/tmp";
spa_assert(spa_strneq(fpath, tmpdir, strlen(tmpdir)));
r = remove(fpath);
@ -543,9 +541,6 @@ static void remove_xdg_runtime_dir(const char *xdg_dir)
/* Safety checks, we really don't want to recursively remove a
* random directory due to a bug */
if (!tmpdir)
tmpdir = "/tmp";
spa_assert(spa_strneq(xdg_dir, tmpdir, strlen(tmpdir)));
r = spa_scnprintf(path, sizeof(path), "%s/pwtest.dir", xdg_dir);
spa_assert((size_t)r == strlen(xdg_dir) + 11);
@ -1264,6 +1259,9 @@ int main(int argc, char **argv)
find_suites(ctx, suite_filter);
add_tests(ctx);
if (getenv("TMPDIR") == NULL)
setenv("TMPDIR", "/tmp", 1);
ctx->xdg_dir = make_xdg_runtime_dir();
switch (mode) {