193707cbaSBrenda J. Butlertdc - Adding plugins for tdc
293707cbaSBrenda J. Butler
393707cbaSBrenda J. ButlerAuthor: Brenda J. Butler - bjb@mojatatu.com
493707cbaSBrenda J. Butler
593707cbaSBrenda J. ButlerADDING PLUGINS
693707cbaSBrenda J. Butler--------------
793707cbaSBrenda J. Butler
893707cbaSBrenda J. ButlerA new plugin should be written in python as a class that inherits from TdcPlugin.
993707cbaSBrenda J. ButlerThere are some examples in plugin-lib.
1093707cbaSBrenda J. Butler
1193707cbaSBrenda J. ButlerThe plugin can be used to add functionality to the test framework,
1293707cbaSBrenda J. Butlersuch as:
1393707cbaSBrenda J. Butler
1493707cbaSBrenda J. Butler- adding commands to be run before and/or after the test suite
1593707cbaSBrenda J. Butler- adding commands to be run before and/or after the test cases
1693707cbaSBrenda J. Butler- adding commands to be run before and/or after the execute phase of the test cases
1793707cbaSBrenda J. Butler- ability to alter the command to be run in any phase:
1893707cbaSBrenda J. Butler    pre        (the pre-suite stage)
1993707cbaSBrenda J. Butler    prepare
2093707cbaSBrenda J. Butler    execute
2193707cbaSBrenda J. Butler    verify
2293707cbaSBrenda J. Butler    teardown
2393707cbaSBrenda J. Butler    post       (the post-suite stage)
2493707cbaSBrenda J. Butler- ability to add to the command line args, and use them at run time
2593707cbaSBrenda J. Butler
2693707cbaSBrenda J. Butler
2793707cbaSBrenda J. ButlerThe functions in the class should follow the following interfaces:
2893707cbaSBrenda J. Butler
2993707cbaSBrenda J. Butler    def __init__(self)
3093707cbaSBrenda J. Butler    def pre_suite(self, testcount, testidlist)     # see "PRE_SUITE" below
3193707cbaSBrenda J. Butler    def post_suite(self, ordinal)                  # see "SKIPPING" below
3293707cbaSBrenda J. Butler    def pre_case(self, test_ordinal, testid)       # see "PRE_CASE" below
3393707cbaSBrenda J. Butler    def post_case(self)
3493707cbaSBrenda J. Butler    def pre_execute(self)
3593707cbaSBrenda J. Butler    def post_execute(self)
3693707cbaSBrenda J. Butler    def adjust_command(self, stage, command)       # see "ADJUST" below
3793707cbaSBrenda J. Butler    def add_args(self, parser)                     # see "ADD_ARGS" below
3893707cbaSBrenda J. Butler    def check_args(self, args, remaining)          # see "CHECK_ARGS" below
3993707cbaSBrenda J. Butler
4093707cbaSBrenda J. Butler
4193707cbaSBrenda J. ButlerPRE_SUITE
4293707cbaSBrenda J. Butler
4393707cbaSBrenda J. ButlerThis method takes a testcount (number of tests to be run) and
4493707cbaSBrenda J. Butlertestidlist (array of test ids for tests that will be run).  This is
4593707cbaSBrenda J. Butleruseful for various things, including when an exception occurs and the
4693707cbaSBrenda J. Butlerrest of the tests must be skipped.  The info is stored in the object,
4793707cbaSBrenda J. Butlerand the post_suite method can refer to it when dumping the "skipped"
4893707cbaSBrenda J. ButlerTAP output.  The tdc.py script will do that for the test suite as
4993707cbaSBrenda J. Butlerdefined in the test case, but if the plugin is being used to run extra
5093707cbaSBrenda J. Butlertests on each test (eg, check for memory leaks on associated
5193707cbaSBrenda J. Butlerco-processes) then that other tap output can be generated in the
5293707cbaSBrenda J. Butlerpost-suite method using this info passed in to the pre_suite method.
5393707cbaSBrenda J. Butler
5493707cbaSBrenda J. Butler
5593707cbaSBrenda J. ButlerSKIPPING
5693707cbaSBrenda J. Butler
5793707cbaSBrenda J. ButlerThe post_suite method will receive the ordinal number of the last
5893707cbaSBrenda J. Butlertest to be attempted.  It can use this info when outputting
5993707cbaSBrenda J. Butlerthe TAP output for the extra test cases.
6093707cbaSBrenda J. Butler
6193707cbaSBrenda J. Butler
6293707cbaSBrenda J. ButlerPRE_CASE
6393707cbaSBrenda J. Butler
6493707cbaSBrenda J. ButlerThe pre_case method will receive the ordinal number of the test
6593707cbaSBrenda J. Butlerand the test id.  Useful for outputing the extra test results.
6693707cbaSBrenda J. Butler
6793707cbaSBrenda J. Butler
6893707cbaSBrenda J. ButlerADJUST
6993707cbaSBrenda J. Butler
7093707cbaSBrenda J. ButlerThe adjust_command method receives a string representing
7193707cbaSBrenda J. Butlerthe execution stage and a string which is the actual command to be
7293707cbaSBrenda J. Butlerexecuted.  The plugin can adjust the command, based on the stage of
7393707cbaSBrenda J. Butlerexecution.
7493707cbaSBrenda J. Butler
7593707cbaSBrenda J. ButlerThe stages are represented by the following strings:
7693707cbaSBrenda J. Butler
7793707cbaSBrenda J. Butler    'pre'
7893707cbaSBrenda J. Butler    'setup'
7993707cbaSBrenda J. Butler    'command'
8093707cbaSBrenda J. Butler    'verify'
8193707cbaSBrenda J. Butler    'teardown'
8293707cbaSBrenda J. Butler    'post'
8393707cbaSBrenda J. Butler
8493707cbaSBrenda J. ButlerThe adjust_command method must return the adjusted command so tdc
8593707cbaSBrenda J. Butlercan use it.
8693707cbaSBrenda J. Butler
8793707cbaSBrenda J. Butler
8893707cbaSBrenda J. ButlerADD_ARGS
8993707cbaSBrenda J. Butler
9093707cbaSBrenda J. ButlerThe add_args method receives the argparser object and can add
9193707cbaSBrenda J. Butlerarguments to it.  Care should be taken that the new arguments do not
9293707cbaSBrenda J. Butlerconflict with any from tdc.py or from other plugins that will be used
9393707cbaSBrenda J. Butlerconcurrently.
9493707cbaSBrenda J. Butler
9593707cbaSBrenda J. ButlerThe add_args method should return the argparser object.
9693707cbaSBrenda J. Butler
9793707cbaSBrenda J. Butler
9893707cbaSBrenda J. ButlerCHECK_ARGS
9993707cbaSBrenda J. Butler
10093707cbaSBrenda J. ButlerThe check_args method is so that the plugin can do validation on
10193707cbaSBrenda J. Butlerthe args, if needed.  If there is a problem, and Exception should
10293707cbaSBrenda J. Butlerbe raised, with a string that explains the problem.
10393707cbaSBrenda J. Butler
10493707cbaSBrenda J. Butlereg:  raise Exception('plugin xxx, arg -y is wrong, fix it')
105