TclMPI  1.2
Tcl Bindings for MPI
tclmpi_test Namespace Reference

Functions

proc test_format (kind, cmd, result)
 
proc compare (reflist, result)
 
proc ser_init (args)
 
proc par_init (args)
 
proc run_return (cmd, retval)
 
proc run_error (cmd, errormsg)
 
proc par_return (cmd, retval, comm=tclmpi::comm_world)
 
proc par_error (cmd, retval, comm=tclmpi::comm_world)
 
proc test_summary (section)
 

Variables

set version
 version of the package
 
variable comm = tclmpi::comm_world
 shortcut for world communicator
 
variable master = 0
 rank of MPI master process
 
variable rank = 0
 rank of this MPI process on $comm
 
variable size = 1
 number of processes on $comm
 
variable int = tclmpi::int
 shortcut for tclmpi::int data type
 
variable intint = tclmpi::intint
 shortcut for tclmpi::intint data type
 
variable maxloc = tclmpi::maxloc
 shortcut for tclmpi::maxloc operator
 
variable minloc = tclmpi::minloc
 shortcut for tclmpi::minloc operator
 
variable pass = 0
 counter for successful tests
 
variable fail = 0
 counter for failed tests
 

Detailed Description

TclMPI test harness implementation namespace

This namespace contains several Tcl procedures that are used to conduct unit tests on the TclMPI package. For simplicity paths are hardcoded, so that this file must not be moved around and stay in the same directory as the individual tests, which in turn have to be in a subdirectory of the directory where the TclMPI shared object and/or the tclmpish extended Tcl shell reside.

Function Documentation

◆ compare()

proc tclmpi_test::compare ( reflist  ,
result   
)

partial result and error message comparison

Parameters
reflistlist of strings that have to appear in the result
resultresult string
Returns
1 if all reflist strings were found in result

This function does an inexact comparison of the reference data to the actual result. The reference is a list of strings, each of which has to be matched in a case insensitive string search. The function returns a 1 if all tests did match.

◆ par_error()

proc tclmpi_test::par_error ( cmd  ,
retval  ,
comm  = tclmpi::comm_world 
)

run a parallel test that is expected to produce a Tcl error

Parameters
cmdlist of strings or lists with the commands to execute
retvallist of the expected error message(s) or return values
commcommunicator. defaults to world communicator
Returns
empty

This function executes the lists command lines passed in $cmd in parallel each command taken from the list based on the rank of the individual MPI task on the communicator and intercepts its resulting error message or return value using the 'catch' command. It is then checked if one of the commands failed as expected and actual return value are then compared against the expected reference passed in the $retval list with similar assignments to the individual ranks as the commands. If one of the strings does not match or all command unexpectedly succeeded failure is reported otherwise success.

◆ par_init()

proc tclmpi_test::par_init ( args  )

init for parallel tests

Parameters
argsall parameters are ignored
Returns
empty

This function will perform an initialization of the parallel environment for subsequent parallel tests. It also initializes the global variables $rank and $size.

◆ par_return()

proc tclmpi_test::par_return ( cmd  ,
retval  ,
comm  = tclmpi::comm_world 
)

run a parallel test that is expected to succeed

Parameters
cmdlist of strings or lists with the commands to execute
retvallist of the expected return values
commcommunicator. defaults to world communicator
Returns
empty

This function executes the lists command lines passed in $cmd in parallel each command taken from the list based on the rank of the individual MPI task on the communicator and intercepts its resulting return value using the 'catch' command. The actual return value is then compared against the expected reference passed in the $retval list, similarly assigned to the individual ranks as the commands. The result is compared on all ranks and if one of the commands failed or the actual return value is not equal to the expected one, failure is reported and both, expected and and actual results are printed on one of the failing ranks. The error reporting expects that the MPI communicator remains usable after failure.

◆ run_error()

proc tclmpi_test::run_error ( cmd  ,
errormsg   
)

run a serial test that is expected to fail

Parameters
cmdstring or list with the command to execute
errormsgexpected error message contents
Returns
empty

This function executes the command line passed in $cmd and intercepts its resulting error using the 'catch' command. The actual error message is then compared against the expected reference passed in $errormsg. The test is passed if the two strings match, otherwise failure is reported and both the expected and actual error messages are printed. Also an unexpectedly successful execution is considered a failure and its result reported for reference.

◆ run_return()

proc tclmpi_test::run_return ( cmd  ,
retval   
)

run a serial test that is expected to succeed

Parameters
cmdstring or list with the command to execute
retvalexpected return value contents
Returns
empty

This function executes the command line passed in $cmd and intercepts its resulting return value using the 'catch' command. The actual return value is then compared against the expected reference passed in $retval. The test is passed if the two strings match, otherwise failure is reported and both the expected and actual results are printed. Also an unexpectedly failure of the command is reported as failure and the resulting error message is reported for debugging.

◆ ser_init()

proc tclmpi_test::ser_init ( args  )

init for serial tests

Parameters
argsall parameters are ignored
Returns
empty

This function will perform a simple init test requesting the tclmpi package and matching it against the current verison number. It will also initialize some commonly used global variables. If called from a parallel environment, it will only execute and produce output on the master process

◆ test_format()

proc tclmpi_test::test_format ( kind  ,
cmd  ,
result   
)

format output

Parameters
kindstring representing the kind of test (max 11 chars).
cmdstring representing the command. will be truncated as needed.
resultstring indicating the result (PASS or FAIL/reason)
Returns
the formatted string

This function will format a test summary message, so that it does not break the output on a regular terminal screen. The first column will be the total number of the test computed from the sum of passed and failed tests, followed by a string describing the test type, the command executed and a result string. The command string in the middle will be truncated as needed to not break the format.

◆ test_summary()

proc tclmpi_test::test_summary ( section  )

print result summary

Parameters
sectionnumber of the test section
Returns
empty

This function will print a nicely formatted summary of the tests. If executed in parallel only the master rank of the world communicator will produce output.