AddingPlugins.txt 3.3 KB

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