Scl test flist: Difference between revisions

From STRIDE Wiki
Jump to navigation Jump to search
No edit summary
Line 45: Line 45:


== Examples ==
== Examples ==
<source lang=c>
#include <srtest.h>


    /*
int test1();
    * scl_test_flist uses runtime test services for
int test2();
    * dynamic suite/test creation
    *
    * @description
    * scl_test_flist uses the runtime C API directly to create dynamic test suites
    * and test cases.
    *
    */
    #include <srtest.h>
    int test_setup();
    int test1();
    int test2();
    int test_teardown();
   
   
    #ifdef _SCL
#ifdef _SCL
    #pragma scl_test_flist("Foo", test1, test2)
#pragma scl_test_flist("Foo", test1, test2)
    #endif
#endif
</source>


== See Also ==
== See Also ==

Revision as of 00:29, 2 October 2008

The scl_test_flist pragma

The scl_test_flist pragma captures a list of external functions as a Test Unit. Once captured, each external function becomes a test method. STRIDE will generate appropriate code for execution of the test methods.

Syntax

#pragma scl_test_flist(test-unit-name, function-1, function-2..n)
Parameters Type Description
test-unit-name String Name of test unit into which a list of external functions will be assembled.
function-1 String Name of the first external function to be captured.
function-2..n [Optional] String Optional names of second and subsequent external functions to be captured.

Notes

  • The external functions must meet the following conditions:
    • Their parameter lists must be empty (void).
    • They cannot be overloaded.
    • They cannot be overloaded operators.
    • They may not be template functions.
    • They may throw exceptions when compiled in CPP mode.
    • They cannot have been previously captured with scl_function, or another scl_test_flist pragma.
    • They cannot be public static class methods.
    • They must return a pass/fail result. The return type may be declared void or an integer type (bool is acceptable in C++ mode). If void is the return type, any calls to the test function default to successful.
  • Once an external function has been captured with scl_test_flist, that function may not then be captured again with an scl_function pragma, or another scl_test_flist pragma, or used with any other qualification pragmas.
  • Use of this pragma requires an include of srtest.h.
  • The test-unit-name may not have been specified with a prior scl_test_flist pragma.
  • The test-unit-name may not be the name of an existing routine.
  • In CPP-compile mode, the external function(s) must have been declared using 'extern "C"'.
  • There is no way to associate a SMID value with an external function, as with scl_func.

Examples

#include <srtest.h>

int test1();
int test2();
 
#ifdef _SCL
#pragma scl_test_flist("Foo", test1, test2)
#endif

See Also

  • Refer to the Test_Units page for more information on capturing and qualifying test units.