tests: Generalize temp dir management 32/14632/4
authorAndrew Deason <adeason@sinenomine.net>
Thu, 2 Jul 2020 02:18:04 +0000 (21:18 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 13 Aug 2021 21:50:23 +0000 (17:50 -0400)
commit71acc392a399d70aec033dfe31f010d6f5cfb565
tree5b851e22606d622b42f9e3006cd292e45306bc4e
parent15d033d0df85695f0d5a38e03cdfa51301d7f650
tests: Generalize temp dir management

Currently, afstest_BuildTestConfig calls afstest_mkdtemp (our thin
wrapper around mkdtemp) to create its temporary config dir. We may
want to make new tests, though, that create a temp dir for other
purposes. To make that easier, move a little more code into
afstest_mkdtemp, so the caller doesn't need to construct the template.

To allow callers to clean up such temporary dirs, change
afstest_UnlinkTestConfig into a more general function,
afstest_rmdtemp. Allow this new function to remove all files in a dir,
not just files one-level-deep. To avoid needing to write our own
traversal and removal logic, just run 'rm -rf' via a new function,
afstest_systemlp().

Move these temp dir-related functions from config.c into files.c,
since they are no longer specific to config dirs.

Change-Id: I16750a2f30e98c9ca2e14dfb7d3fc9bc5d456e8d
Reviewed-on: https://gerrit.openafs.org/14632
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
tests/auth/authcon-t.c
tests/auth/keys-t.c
tests/auth/realms-t.c
tests/auth/superuser-t.c
tests/auth/writekeyfile.c
tests/common/common.h
tests/common/config.c
tests/common/exec.c
tests/common/files.c
tests/volser/vos-t.c