blob: 605e43f8f62f4b21c36abfdc5a3dc0194dd2fd29 [file] [log] [blame]
You Wangdb927a52016-02-26 11:03:28 -08001"""
2This file contains classes for CHOTestMonkey that are related to check event
3Author: you@onlab.us
4"""
5from tests.CHOTestMonkey.dependencies.events.Event import EventType, EventStates, Event
6
7class TestEvent( Event ):
8 def __init__( self ):
9 Event.__init__( self )
10
11 def startTestEvent( self ):
12 return EventStates().PASS
13
14 def startEvent( self, args ):
15 with self.eventLock:
16 main.log.info( "%s - starting event" % ( self.typeString ) )
17 result = self.startTestEvent( args )
18 return result
19
20class TestPause( TestEvent ):
21 def __init__( self ):
22 TestEvent.__init__( self )
23 self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
24 self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
25
26 def startTestEvent( self, args=None ):
27 result = EventStates().PASS
28 main.eventScheduler.setRunningState( False )
29 return result
30
31class TestResume( TestEvent ):
32 def __init__( self ):
33 TestEvent.__init__( self )
34 self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
35 self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
36
37 def startTestEvent( self, args=None ):
38 result = EventStates().PASS
39 main.eventScheduler.setRunningState( True )
40 return result
41
42class TestSleep( TestEvent ):
43 def __init__( self ):
44 TestEvent.__init__( self )
45 self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
46 self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
47
48 def startTestEvent( self, args ):
49 import time
50 result = EventStates().PASS
51 if len( args ) < 1:
52 main.log.warn( "%s - Not enough arguments: %s" % ( self.typeString, args ) )
53 result = EventStates().ABORT
54 elif len( args ) > 1:
55 main.log.warn( "%s - Too many arguments: %s" % ( self.typeString, args ) )
56 result = EventStates().ABORT
57 sleepTime = int( args[ 0 ] )
58 time.sleep( sleepTime )
59 return result