Back to home page

OSCL-LXR

 
 

    


0001 tdc - Adding plugins for tdc
0002 
0003 Author: Brenda J. Butler - bjb@mojatatu.com
0004 
0005 ADDING PLUGINS
0006 --------------
0007 
0008 A new plugin should be written in python as a class that inherits from TdcPlugin.
0009 There are some examples in plugin-lib.
0010 
0011 The plugin can be used to add functionality to the test framework,
0012 such as:
0013 
0014 - adding commands to be run before and/or after the test suite
0015 - adding commands to be run before and/or after the test cases
0016 - adding commands to be run before and/or after the execute phase of the test cases
0017 - ability to alter the command to be run in any phase:
0018     pre        (the pre-suite stage)
0019     prepare
0020     execute
0021     verify
0022     teardown
0023     post       (the post-suite stage)
0024 - ability to add to the command line args, and use them at run time
0025 
0026 
0027 The functions in the class should follow the following interfaces:
0028 
0029     def __init__(self)
0030     def pre_suite(self, testcount, testidlist)     # see "PRE_SUITE" below
0031     def post_suite(self, ordinal)                  # see "SKIPPING" below
0032     def pre_case(self, test_ordinal, testid)       # see "PRE_CASE" below
0033     def post_case(self)
0034     def pre_execute(self)
0035     def post_execute(self)
0036     def adjust_command(self, stage, command)       # see "ADJUST" below
0037     def add_args(self, parser)                     # see "ADD_ARGS" below
0038     def check_args(self, args, remaining)          # see "CHECK_ARGS" below
0039 
0040 
0041 PRE_SUITE
0042 
0043 This method takes a testcount (number of tests to be run) and
0044 testidlist (array of test ids for tests that will be run).  This is
0045 useful for various things, including when an exception occurs and the
0046 rest of the tests must be skipped.  The info is stored in the object,
0047 and the post_suite method can refer to it when dumping the "skipped"
0048 TAP output.  The tdc.py script will do that for the test suite as
0049 defined in the test case, but if the plugin is being used to run extra
0050 tests on each test (eg, check for memory leaks on associated
0051 co-processes) then that other tap output can be generated in the
0052 post-suite method using this info passed in to the pre_suite method.
0053 
0054 
0055 SKIPPING
0056 
0057 The post_suite method will receive the ordinal number of the last
0058 test to be attempted.  It can use this info when outputting
0059 the TAP output for the extra test cases.
0060 
0061 
0062 PRE_CASE
0063 
0064 The pre_case method will receive the ordinal number of the test
0065 and the test id.  Useful for outputing the extra test results.
0066 
0067 
0068 ADJUST
0069 
0070 The adjust_command method receives a string representing
0071 the execution stage and a string which is the actual command to be
0072 executed.  The plugin can adjust the command, based on the stage of
0073 execution.
0074 
0075 The stages are represented by the following strings:
0076 
0077     'pre'
0078     'setup'
0079     'command'
0080     'verify'
0081     'teardown'
0082     'post'
0083 
0084 The adjust_command method must return the adjusted command so tdc
0085 can use it.
0086 
0087 
0088 ADD_ARGS
0089 
0090 The add_args method receives the argparser object and can add
0091 arguments to it.  Care should be taken that the new arguments do not
0092 conflict with any from tdc.py or from other plugins that will be used
0093 concurrently.
0094 
0095 The add_args method should return the argparser object.
0096 
0097 
0098 CHECK_ARGS
0099 
0100 The check_args method is so that the plugin can do validation on
0101 the args, if needed.  If there is a problem, and Exception should
0102 be raised, with a string that explains the problem.
0103 
0104 eg:  raise Exception('plugin xxx, arg -y is wrong, fix it')