brintos

brintos / linux-shallow public Read only

0
0
Text · 3.3 KiB · c18f88d Raw
105 lines · plain
1tdc - Adding plugins for tdc2 3Author: Brenda J. Butler - bjb@mojatatu.com4 5ADDING PLUGINS6--------------7 8A new plugin should be written in python as a class that inherits from TdcPlugin.9There are some examples in plugin-lib.10 11The plugin can be used to add functionality to the test framework,12such as:13 14- adding commands to be run before and/or after the test suite15- adding commands to be run before and/or after the test cases16- adding commands to be run before and/or after the execute phase of the test cases17- ability to alter the command to be run in any phase:18    pre        (the pre-suite stage)19    prepare20    execute21    verify22    teardown23    post       (the post-suite stage)24- ability to add to the command line args, and use them at run time25 26 27The functions in the class should follow the following interfaces:28 29    def __init__(self)30    def pre_suite(self, testcount, testidlist)     # see "PRE_SUITE" below31    def post_suite(self, ordinal)                  # see "SKIPPING" below32    def pre_case(self, test_ordinal, testid)       # see "PRE_CASE" below33    def post_case(self)34    def pre_execute(self)35    def post_execute(self)36    def adjust_command(self, stage, command)       # see "ADJUST" below37    def add_args(self, parser)                     # see "ADD_ARGS" below38    def check_args(self, args, remaining)          # see "CHECK_ARGS" below39 40 41PRE_SUITE42 43This method takes a testcount (number of tests to be run) and44testidlist (array of test ids for tests that will be run).  This is45useful for various things, including when an exception occurs and the46rest of the tests must be skipped.  The info is stored in the object,47and the post_suite method can refer to it when dumping the "skipped"48TAP output.  The tdc.py script will do that for the test suite as49defined in the test case, but if the plugin is being used to run extra50tests on each test (eg, check for memory leaks on associated51co-processes) then that other tap output can be generated in the52post-suite method using this info passed in to the pre_suite method.53 54 55SKIPPING56 57The post_suite method will receive the ordinal number of the last58test to be attempted.  It can use this info when outputting59the TAP output for the extra test cases.60 61 62PRE_CASE63 64The pre_case method will receive the ordinal number of the test65and the test id.  Useful for outputing the extra test results.66 67 68ADJUST69 70The adjust_command method receives a string representing71the execution stage and a string which is the actual command to be72executed.  The plugin can adjust the command, based on the stage of73execution.74 75The stages are represented by the following strings:76 77    'pre'78    'setup'79    'command'80    'verify'81    'teardown'82    'post'83 84The adjust_command method must return the adjusted command so tdc85can use it.86 87 88ADD_ARGS89 90The add_args method receives the argparser object and can add91arguments to it.  Care should be taken that the new arguments do not92conflict with any from tdc.py or from other plugins that will be used93concurrently.94 95The add_args method should return the argparser object.96 97 98CHECK_ARGS99 100The check_args method is so that the plugin can do validation on101the args, if needed.  If there is a problem, and Exception should102be raised, with a string that explains the problem.103 104eg:  raise Exception('plugin xxx, arg -y is wrong, fix it')105