You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

icomponent.py 2.7 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # Copyright 2020 Huawei Technologies Co., Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ============================================================================
  15. """Component interfaces."""
  16. class IComponent:
  17. """Component interfaces."""
  18. def __init__(self, verification_set):
  19. self.verification_set = verification_set
  20. def __call__(self):
  21. raise NotImplementedError
  22. class IDataComponent(IComponent):
  23. """Create inputs for verification_set."""
  24. def __call__(self):
  25. raise NotImplementedError
  26. class IBuilderComponent(IComponent):
  27. """Build system under test."""
  28. def __call__(self):
  29. raise NotImplementedError
  30. class IExectorComponent(IComponent):
  31. """Execute sut, take (function, input) pairs as input."""
  32. def __init__(self, verification_set, function, inputs):
  33. super(IExectorComponent, self).__init__(verification_set)
  34. self.function = function
  35. self.inputs = inputs
  36. def __call__(self):
  37. raise NotImplementedError
  38. class IVerifierComponent(IComponent):
  39. """Verify sut result, take (expect, result) pairs as input."""
  40. def __init__(self, verification_set, expect, result):
  41. super(IVerifierComponent, self).__init__(verification_set)
  42. self.expect = expect
  43. self.func_result = result
  44. def __call__(self):
  45. raise NotImplementedError
  46. class IFIPolicyComponent(IComponent):
  47. """Combine functions/inputs."""
  48. def __init__(self, verification_set, function, inputs):
  49. super(IFIPolicyComponent, self).__init__(verification_set)
  50. self.function = function
  51. self.inputs = inputs
  52. def __call__(self):
  53. raise NotImplementedError
  54. class IERPolicyComponent(IComponent):
  55. """Combine expects and results."""
  56. def __init__(self, verification_set, expect, result):
  57. super(IERPolicyComponent, self).__init__(verification_set)
  58. self.expect = expect
  59. self.result = result
  60. def __call__(self):
  61. raise NotImplementedError
  62. class IFacadeComponent(IComponent):
  63. """Adapt verification_set."""
  64. def __call__(self):
  65. raise NotImplementedError