Home Corporate Contacts TETware Knowledgebase |
ProductsSolutionsInformationDatasheetDocumentationFAQKnowledgebase |
Return to Knowledgebase Index12. How to run test cases in a known environmentYou 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 "$@" TET_EXEC_TOOL= exec-tool When you specify the name of an exec tool, it should be either:
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
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
#!/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 See also
|