Home | History | Annotate | Download | only in man3

$Id: tst_tmpdir.3,v 1.1 2000/07/27 16:59:03 alaffin Exp $

Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.

This program is free software; you can redistribute it and/or modify it
under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.

This program is distributed in the hope that it would be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Further, this software is distributed without any warranty that it is
free of the rightful claim of any third person regarding infringement
or the like. Any license provided herein, whether implied or
otherwise, applies only to this software file. Patent licenses, if
any, provided herein do not apply to combinations of this program with
other software, or any other product whatsoever.

You should have received a copy of the GNU General Public License along
with this program; if not, write the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
Mountain View, CA 94043, or:

http://www.sgi.com

For further information regarding this notice, see:

http://oss.sgi.com/projects/GenInfo/NoticeExplan/

TST_TMPDIR 3 07/25/2000 "Linux Test Project"
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_resm().
"SEE ALSO"
fork(2), system(3S), tst_res(3), tmpnam(3S).