blob: 9aa4ae67e2e849f4eda85dc234ffe822f7172130 [file] [log] [blame]
You Wangdb927a52016-02-26 11:03:28 -08001"""
2This file contains the Event class for CHOTestMonkey
3Author: you@onlab.us
4"""
5from threading import Lock
6
Jon Hall2bb3e212017-05-24 17:07:25 -07007
You Wangdb927a52016-02-26 11:03:28 -08008class EventType:
Jon Hall2bb3e212017-05-24 17:07:25 -07009
You Wangdb927a52016-02-26 11:03:28 -080010 def __init__( self ):
11 self.map = {}
Jon Hall2bb3e212017-05-24 17:07:25 -070012 # Group events ( >100 ) should be divided into individual events by the generator before going to the scheduler
You Wangdb927a52016-02-26 11:03:28 -080013 self.NULL = 0
14 for eventName in main.params[ 'EVENT' ].keys():
15 typeString = main.params[ 'EVENT' ][ eventName ][ 'typeString' ]
16 typeIndex = int( main.params[ 'EVENT' ][ eventName ][ 'typeIndex' ] )
17 setattr( self, typeString, typeIndex )
18 self.map[ typeIndex ] = typeString
19
Jon Hall2bb3e212017-05-24 17:07:25 -070020
You Wangdb927a52016-02-26 11:03:28 -080021class EventStates:
Jon Hall2bb3e212017-05-24 17:07:25 -070022
You Wangdb927a52016-02-26 11:03:28 -080023 def __init__( self ):
24 self.map = {}
25 self.FAIL = 0
26 self.map[ 0 ] = 'FAIL'
27 self.PASS = 1
28 self.map[ 1 ] = 'PASS'
29 self.ABORT = -1
30 self.map[ -1 ] = 'ABORT'
31
Jon Hall2bb3e212017-05-24 17:07:25 -070032
You Wangdb927a52016-02-26 11:03:28 -080033class Event:
Jon Hall2bb3e212017-05-24 17:07:25 -070034
You Wangdb927a52016-02-26 11:03:28 -080035 """
36 Event class for CHOTestMonkey
37 It is the super class for CheckEvent and NetworkEvent
38 """
39 def __init__( self ):
40 self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
41 self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
42 self.eventLock = Lock()
43 self.variableLock = Lock()
44
45 def startEvent( self, args=None ):
46 """
47 Start running the event
48 """
49 return EventStates().PASS