162306a36Sopenharmony_citdc - Adding plugins for tdc
262306a36Sopenharmony_ci
362306a36Sopenharmony_ciAuthor: Brenda J. Butler - bjb@mojatatu.com
462306a36Sopenharmony_ci
562306a36Sopenharmony_ciADDING PLUGINS
662306a36Sopenharmony_ci--------------
762306a36Sopenharmony_ci
862306a36Sopenharmony_ciA new plugin should be written in python as a class that inherits from TdcPlugin.
962306a36Sopenharmony_ciThere are some examples in plugin-lib.
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ciThe plugin can be used to add functionality to the test framework,
1262306a36Sopenharmony_cisuch as:
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci- adding commands to be run before and/or after the test suite
1562306a36Sopenharmony_ci- adding commands to be run before and/or after the test cases
1662306a36Sopenharmony_ci- adding commands to be run before and/or after the execute phase of the test cases
1762306a36Sopenharmony_ci- ability to alter the command to be run in any phase:
1862306a36Sopenharmony_ci    pre        (the pre-suite stage)
1962306a36Sopenharmony_ci    prepare
2062306a36Sopenharmony_ci    execute
2162306a36Sopenharmony_ci    verify
2262306a36Sopenharmony_ci    teardown
2362306a36Sopenharmony_ci    post       (the post-suite stage)
2462306a36Sopenharmony_ci- ability to add to the command line args, and use them at run time
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ciThe functions in the class should follow the following interfaces:
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci    def __init__(self)
3062306a36Sopenharmony_ci    def pre_suite(self, testcount, testidlist)     # see "PRE_SUITE" below
3162306a36Sopenharmony_ci    def post_suite(self, ordinal)                  # see "SKIPPING" below
3262306a36Sopenharmony_ci    def pre_case(self, test_ordinal, testid)       # see "PRE_CASE" below
3362306a36Sopenharmony_ci    def post_case(self)
3462306a36Sopenharmony_ci    def pre_execute(self)
3562306a36Sopenharmony_ci    def post_execute(self)
3662306a36Sopenharmony_ci    def adjust_command(self, stage, command)       # see "ADJUST" below
3762306a36Sopenharmony_ci    def add_args(self, parser)                     # see "ADD_ARGS" below
3862306a36Sopenharmony_ci    def check_args(self, args, remaining)          # see "CHECK_ARGS" below
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ciPRE_SUITE
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ciThis method takes a testcount (number of tests to be run) and
4462306a36Sopenharmony_citestidlist (array of test ids for tests that will be run).  This is
4562306a36Sopenharmony_ciuseful for various things, including when an exception occurs and the
4662306a36Sopenharmony_cirest of the tests must be skipped.  The info is stored in the object,
4762306a36Sopenharmony_ciand the post_suite method can refer to it when dumping the "skipped"
4862306a36Sopenharmony_ciTAP output.  The tdc.py script will do that for the test suite as
4962306a36Sopenharmony_cidefined in the test case, but if the plugin is being used to run extra
5062306a36Sopenharmony_citests on each test (eg, check for memory leaks on associated
5162306a36Sopenharmony_cico-processes) then that other tap output can be generated in the
5262306a36Sopenharmony_cipost-suite method using this info passed in to the pre_suite method.
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ciSKIPPING
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ciThe post_suite method will receive the ordinal number of the last
5862306a36Sopenharmony_citest to be attempted.  It can use this info when outputting
5962306a36Sopenharmony_cithe TAP output for the extra test cases.
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ciPRE_CASE
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ciThe pre_case method will receive the ordinal number of the test
6562306a36Sopenharmony_ciand the test id.  Useful for outputing the extra test results.
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ciADJUST
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ciThe adjust_command method receives a string representing
7162306a36Sopenharmony_cithe execution stage and a string which is the actual command to be
7262306a36Sopenharmony_ciexecuted.  The plugin can adjust the command, based on the stage of
7362306a36Sopenharmony_ciexecution.
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ciThe stages are represented by the following strings:
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci    'pre'
7862306a36Sopenharmony_ci    'setup'
7962306a36Sopenharmony_ci    'command'
8062306a36Sopenharmony_ci    'verify'
8162306a36Sopenharmony_ci    'teardown'
8262306a36Sopenharmony_ci    'post'
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ciThe adjust_command method must return the adjusted command so tdc
8562306a36Sopenharmony_cican use it.
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ciADD_ARGS
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ciThe add_args method receives the argparser object and can add
9162306a36Sopenharmony_ciarguments to it.  Care should be taken that the new arguments do not
9262306a36Sopenharmony_ciconflict with any from tdc.py or from other plugins that will be used
9362306a36Sopenharmony_ciconcurrently.
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ciThe add_args method should return the argparser object.
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ciCHECK_ARGS
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ciThe check_args method is so that the plugin can do validation on
10162306a36Sopenharmony_cithe args, if needed.  If there is a problem, and Exception should
10262306a36Sopenharmony_cibe raised, with a string that explains the problem.
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_cieg:  raise Exception('plugin xxx, arg -y is wrong, fix it')
105