NAME
tst_tmpdir - create a unique testing directory and make it current.
tst_rmdir - remove the directory created by tst_tmpdir.
SYNOPSIS
void tst_tmpdir()
void tst_rmdir()
extern char *TESTDIR;
DESCRIPTION
The tst_tmpdir() function uses the first three characters of the TCID
global variable as the prefix in forming a unique directory name (via
tempnam(3S)). The directory is then created and made the current
working directory.
If tst_tmpdir() cannot form a unique directory name, create the
directory, or chdir to the directory, it uses tst_brk() to issue "BROK"
messages for all test cases. It then exits via tst_exit(). Because
tst_tmpdir() exits in the event of a problem, a test must call it
before performing any operations that would require running a cleanup
routine.
The tst_rmdir() function recursively removes the directory created by
tst_tmpdir(). This function should be used only as a companion to
tst_tmpdir() and should be called immediately prior to the test exiting
via tst_exit().
tst_rmdir() uses the system(3S) library routine (which in turn calls
fork(2)), so tests that use it cannot treat SIGCLD as an unexpected
signal.
Users may gain access to the name of the temporary directory by
declaring the external character pointer TESTDIR.
DIAGNOSTICS
The tst_rmdir() function will check the TESTDIR global variable to
ensure that the user is not attempting to remove the root directory or
some unspecified directories with a "*" parameter. All error/warning
messages are delivered through tst_res().
SEE ALSO
fork(2), system(3S), tst_res(3), tmpnam(3S).