1 tdc - Adding plugins for tdc 1 tdc - Adding plugins for tdc 2 2 3 Author: Brenda J. Butler - bjb@mojatatu.com 3 Author: Brenda J. Butler - bjb@mojatatu.com 4 4 5 ADDING PLUGINS 5 ADDING PLUGINS 6 -------------- 6 -------------- 7 7 8 A new plugin should be written in python as a 8 A new plugin should be written in python as a class that inherits from TdcPlugin. 9 There are some examples in plugin-lib. 9 There are some examples in plugin-lib. 10 10 11 The plugin can be used to add functionality to 11 The plugin can be used to add functionality to the test framework, 12 such as: 12 such as: 13 13 14 - adding commands to be run before and/or afte 14 - adding commands to be run before and/or after the test suite 15 - adding commands to be run before and/or afte 15 - adding commands to be run before and/or after the test cases 16 - adding commands to be run before and/or afte 16 - adding commands to be run before and/or after the execute phase of the test cases 17 - ability to alter the command to be run in an 17 - ability to alter the command to be run in any phase: 18 pre (the pre-suite stage) 18 pre (the pre-suite stage) 19 prepare 19 prepare 20 execute 20 execute 21 verify 21 verify 22 teardown 22 teardown 23 post (the post-suite stage) 23 post (the post-suite stage) 24 - ability to add to the command line args, and 24 - ability to add to the command line args, and use them at run time 25 25 26 26 27 The functions in the class should follow the f 27 The functions in the class should follow the following interfaces: 28 28 29 def __init__(self) 29 def __init__(self) 30 def pre_suite(self, testcount, testidlist) 30 def pre_suite(self, testcount, testidlist) # see "PRE_SUITE" below 31 def post_suite(self, ordinal) 31 def post_suite(self, ordinal) # see "SKIPPING" below 32 def pre_case(self, test_ordinal, testid) 32 def pre_case(self, test_ordinal, testid) # see "PRE_CASE" below 33 def post_case(self) 33 def post_case(self) 34 def pre_execute(self) 34 def pre_execute(self) 35 def post_execute(self) 35 def post_execute(self) 36 def adjust_command(self, stage, command) 36 def adjust_command(self, stage, command) # see "ADJUST" below 37 def add_args(self, parser) 37 def add_args(self, parser) # see "ADD_ARGS" below 38 def check_args(self, args, remaining) 38 def check_args(self, args, remaining) # see "CHECK_ARGS" below 39 39 40 40 41 PRE_SUITE 41 PRE_SUITE 42 42 43 This method takes a testcount (number of tests 43 This method takes a testcount (number of tests to be run) and 44 testidlist (array of test ids for tests that w 44 testidlist (array of test ids for tests that will be run). This is 45 useful for various things, including when an e 45 useful for various things, including when an exception occurs and the 46 rest of the tests must be skipped. The info i 46 rest of the tests must be skipped. The info is stored in the object, 47 and the post_suite method can refer to it when 47 and the post_suite method can refer to it when dumping the "skipped" 48 TAP output. The tdc.py script will do that fo 48 TAP output. The tdc.py script will do that for the test suite as 49 defined in the test case, but if the plugin is 49 defined in the test case, but if the plugin is being used to run extra 50 tests on each test (eg, check for memory leaks 50 tests on each test (eg, check for memory leaks on associated 51 co-processes) then that other tap output can b 51 co-processes) then that other tap output can be generated in the 52 post-suite method using this info passed in to 52 post-suite method using this info passed in to the pre_suite method. 53 53 54 54 55 SKIPPING 55 SKIPPING 56 56 57 The post_suite method will receive the ordinal 57 The post_suite method will receive the ordinal number of the last 58 test to be attempted. It can use this info wh 58 test to be attempted. It can use this info when outputting 59 the TAP output for the extra test cases. 59 the TAP output for the extra test cases. 60 60 61 61 62 PRE_CASE 62 PRE_CASE 63 63 64 The pre_case method will receive the ordinal n 64 The pre_case method will receive the ordinal number of the test 65 and the test id. Useful for outputing the ext 65 and the test id. Useful for outputing the extra test results. 66 66 67 67 68 ADJUST 68 ADJUST 69 69 70 The adjust_command method receives a string re 70 The adjust_command method receives a string representing 71 the execution stage and a string which is the 71 the execution stage and a string which is the actual command to be 72 executed. The plugin can adjust the command, 72 executed. The plugin can adjust the command, based on the stage of 73 execution. 73 execution. 74 74 75 The stages are represented by the following st 75 The stages are represented by the following strings: 76 76 77 'pre' 77 'pre' 78 'setup' 78 'setup' 79 'command' 79 'command' 80 'verify' 80 'verify' 81 'teardown' 81 'teardown' 82 'post' 82 'post' 83 83 84 The adjust_command method must return the adju 84 The adjust_command method must return the adjusted command so tdc 85 can use it. 85 can use it. 86 86 87 87 88 ADD_ARGS 88 ADD_ARGS 89 89 90 The add_args method receives the argparser obj 90 The add_args method receives the argparser object and can add 91 arguments to it. Care should be taken that th 91 arguments to it. Care should be taken that the new arguments do not 92 conflict with any from tdc.py or from other pl 92 conflict with any from tdc.py or from other plugins that will be used 93 concurrently. 93 concurrently. 94 94 95 The add_args method should return the argparse 95 The add_args method should return the argparser object. 96 96 97 97 98 CHECK_ARGS 98 CHECK_ARGS 99 99 100 The check_args method is so that the plugin ca 100 The check_args method is so that the plugin can do validation on 101 the args, if needed. If there is a problem, a 101 the args, if needed. If there is a problem, and Exception should 102 be raised, with a string that explains the pro 102 be raised, with a string that explains the problem. 103 103 104 eg: raise Exception('plugin xxx, arg -y is wr 104 eg: raise Exception('plugin xxx, arg -y is wrong, fix it')
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.