manpagez: man pages & more
info dejagnu
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.3.3 Utility Procedures

lib/utils.exp’ defines these utility procedures:

getdirs dir
getdirs dir pattern

Returns a list of all the directories in the single directory dir that match pattern. If you do not specify pattern, getdirs assumes ‘*’. You may use the common shell wildcard characters in pattern. If no directories match the pattern, then a NULL string is returned.

find dir pattern

Search for files whose names match pattern (using shell wildcard characters for filename expansion). Search subdirectories recursively, starting at dir. The result is the list of files whose names match; if no files match, the result is empty. Filenames in the result include all intervening subdirectory names. If no files match the pattern, then a NULL string is returned.

which binary

Searches the execution path for an executable file binary, like the the BSD which utility. This procedure uses the shell environment variable ‘PATH’. It returns 0 if the binary is not in the path, or if there is no ‘PATH’ environment variable. If binary is in the path, it returns the full path to binary.

grep filename regexp
grep filename regexp line

Search the file called filename (a fully specified path) for lines that contain a match for regular expression regexp. The result is a list of all the lines that match. If no lines match, the result is an empty string. Specify regexp using the standard regular expression style used by the Unix utility program grep.

Use the optional third argument ‘line’ to start lines in the result with the line number in filename. (This argument is simply an option flag; type it just as shown—‘line’.)

diff filename filename

Compares the two files and returns a 1 if they match, or a 0 if they don’t. If verbose is set, then it’ll print the differences to the screen.

slay name

This look in the process table for name and send it a unix SIGINT, killing the process.

absolute path

This procedure takes the relative path, and converts it to an absolute path.

psource filename

This sources the file filename, and traps all errors. It also ignores all extraneous output. If there was an error it returns a 1, otherwise it returns a 0.

prune list pattern

Remove elements of the Tcl list list. Elements are fields delimited by spaces. The result is a copy of list, without any elements that match pattern. You can use the common shell wildcard characters to specify pattern.

setenv var val

Sets the variable var to the value val.

unsetenv var

Unsets the environment variable var

getenv var

returns the value of var in the environment if it exists, otherwise it returns NULL.

runtest_file_p runtests testcase

Search runtests for testcase and return 1 if found, 0 if not. runtests is a list of two elements. The first is a copy of what was on the right side of the = if ‘foo.exp="…"’ was specified, or an empty string if no such argument is present. The second is the pathname of the current testcase under consideration. This is used by tools like compilers where each testcase is a file.

prune_system_crud system text

For system system, delete text the host or target operating system might issue that will interfere with pattern matching of program output in text. An example is the message that is printed if a shared library is out of date.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2024
Individual documents may contain additional copyright information.