12.  
How to run test cases in a known environment
You can use an exec tool to do this.
For example, suppose you want to make sure that a test case always
executes in the C locale.
The exec tool might look like this:
#!/bin/sh
# set and export the variables
LANG=C
LC_CTYPE=C
LC_MESSAGES=C
LC_NUMERIC=C
LC_TIME=C
export LANG LC_CTYPE LC_MESSAGES LC_NUMERIC LC_TIME
# then execute the test case
exec "$@"
 
 
Then, put the following assignment in the execute mode configuration
file:
TET_EXEC_TOOL= exec-tool
 
 
where
 exec-tool
is the name of the shell script that you have just created.
When you specify the name of an exec tool, it should be either:
 
- 
relative to the test case execution directory; or:
 
  
- 
an absolute path name; or:
 
  
- 
in one of the directories listed in the
PATH
environment variable.
 
  
 
 
Points to note: 
- 
A name relative to the test case execution directory won't work unless
you have
TET_EXEC_IN_PLACE=true
in the execute mode configuration.
 
  
- 
On a Win32 system the name of a shell script should have a
.ksh
suffix.
Or you can say:
TET_EXEC_TOOL=sh
TET_EXEC_FILE= exec-tool
 
 
in the execute mode configuration.
 
  
- 
On a Win32 system a shell script should not start with a
#!
line.
 
 
 
 There follows an example of a more sophisticated exec tool: 
Question
 
We have a problem where different installations
by different users often have a different environment which can
affect the test results obtained.
We would like to be able to specify a set of environment variables in a
file and have
tcc
put them in the environment when test cases are executed.
 
Answer
 
You can use an exec tool to do this.
In the following example, the exec tool gets the name of the environment
file to use from a variable called
TS_ENV_FILE
in the execute mode configuration.
 
#!/bin/sh
#
# exec tool which executes a test case with environment taken from
# the file defined by the TS_ENV_FILE configuration variable
#
# extract the value of TS_ENV_FILE from the configuration for the
# current mode of operation -
# ignore blank lines and comments in the config file
#
# (the value of TET_CONFIG is set by tcc before invoking the build tool)
TS_ENV_FILE=
eval `sed -n 's/#.*//
	/^[ 	]*\$/d
	/^TS_ENV_FILE=/s/\([^=]*\)=\(.*\)/\1="\2"/p' ${TET_CONFIG:?}`
# if a TS_ENV_FILE has been defined, read it in
if test ! -z "$TS_ENV_FILE"
then
	if test -r $TS_ENV_FILE
	then
		set -a
		. $TS_ENV_FILE
	else
		echo "$0: can't read environment file $TS_ENV_FILE" 1>&2
		exit 1
	fi
fi
# finally, execute the test case
exec "$@"
 
 
 
Then put the following lines in the execute mode configuration file:
TET_EXEC_TOOL= exec-tool
TS_ENV_FILE= env-file
 
 
When you do this, environment variables defined in
 env-file
will be put in the environment when test cases are executed.
See also
 
- 
``Execute mode processing'' and
``Configuration variables which modify TETware's operation''
in the TETware Programmers Guide.
 
  
- 
Users of Win32 systems should check out the section
entitled ``Executable files'' in Appendix H of the TETware User Guide.
 
 
 
        
       |