1 ##############################################################################
2 # Copyright (c) 2016 Juan Qiu and others
3 # juan_ qiu@tongji.edu.cn
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
11 class ActionPlayer(object):
13 Abstract the action functions of attacker,
14 monitor, operation, resultchecker and mybe others in future
21 class AttackerPlayer(ActionPlayer):
23 def __init__(self, attacker, intermediate_variables):
24 self.underlyingAttacker = attacker
25 self.underlyingAttacker.intermediate_variables \
26 = intermediate_variables
29 self.underlyingAttacker.inject_fault()
32 class OperationPlayer(ActionPlayer):
34 def __init__(self, operation, intermediate_variables):
35 self.underlyingOperation = operation
36 self.underlyingOperation.intermediate_variables \
37 = intermediate_variables
40 self.underlyingOperation.run()
43 class MonitorPlayer(ActionPlayer):
45 def __init__(self, monitor, intermediate_variables):
46 self.underlyingmonitor = monitor
47 self.underlyingmonitor.intermediate_variables \
48 = intermediate_variables
51 self.underlyingmonitor.start_monitor()
54 class ResultCheckerPlayer(ActionPlayer):
56 def __init__(self, resultChecker, intermediate_variables):
57 self.underlyingresultChecker = resultChecker
58 self.underlyingresultChecker.intermediate_variables \
59 = intermediate_variables
62 self.underlyingresultChecker.verify()