Update style in TraceTestCase file
This commit is contained in:
parent
40ebb9d09a
commit
481dbea21b
1 changed files with 59 additions and 22 deletions
|
@ -99,7 +99,10 @@ class TraceTestCase(unittest.TestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
cleanup_trace(self._full_path)
|
cleanup_trace(self._full_path)
|
||||||
|
|
||||||
def assertEventsSet(self, event_names: List[str]):
|
def assertEventsSet(
|
||||||
|
self,
|
||||||
|
event_names: List[str],
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Compare given event names to trace events names as sets.
|
Compare given event names to trace events names as sets.
|
||||||
|
|
||||||
|
@ -107,7 +110,10 @@ class TraceTestCase(unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
self.assertSetEqual(set(self._event_names), set(event_names), 'wrong events')
|
self.assertSetEqual(set(self._event_names), set(event_names), 'wrong events')
|
||||||
|
|
||||||
def assertProcessNamesExist(self, names: List[str]):
|
def assertProcessNamesExist(
|
||||||
|
self,
|
||||||
|
names: List[str],
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Check that the given processes exist.
|
Check that the given processes exist.
|
||||||
|
|
||||||
|
@ -119,7 +125,11 @@ class TraceTestCase(unittest.TestCase):
|
||||||
name_trimmed = name[:15]
|
name_trimmed = name[:15]
|
||||||
self.assertTrue(name_trimmed in procnames, 'node name not found in tracepoints')
|
self.assertTrue(name_trimmed in procnames, 'node name not found in tracepoints')
|
||||||
|
|
||||||
def assertValidHandle(self, event: DictEvent, handle_field_names: Union[str, List[str]]):
|
def assertValidHandle(
|
||||||
|
self,
|
||||||
|
event: DictEvent,
|
||||||
|
handle_field_names: Union[str, List[str]],
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Check that the handle associated with a field name is valid.
|
Check that the handle associated with a field name is valid.
|
||||||
|
|
||||||
|
@ -133,7 +143,11 @@ class TraceTestCase(unittest.TestCase):
|
||||||
self.assertIsInstance(handle_value, int, 'handle value not int')
|
self.assertIsInstance(handle_value, int, 'handle value not int')
|
||||||
self.assertGreater(handle_value, 0, f'invalid handle value: {field_name}')
|
self.assertGreater(handle_value, 0, f'invalid handle value: {field_name}')
|
||||||
|
|
||||||
def assertValidQueueDepth(self, event: DictEvent, queue_depth_field_name: str = 'queue_depth'):
|
def assertValidQueueDepth(
|
||||||
|
self,
|
||||||
|
event: DictEvent,
|
||||||
|
queue_depth_field_name: str = 'queue_depth',
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Check that the queue depth value is valid.
|
Check that the queue depth value is valid.
|
||||||
|
|
||||||
|
@ -144,7 +158,11 @@ class TraceTestCase(unittest.TestCase):
|
||||||
self.assertIsInstance(queue_depth_value, int, 'invalid queue depth type')
|
self.assertIsInstance(queue_depth_value, int, 'invalid queue depth type')
|
||||||
self.assertGreater(queue_depth_value, 0, 'invalid queue depth')
|
self.assertGreater(queue_depth_value, 0, 'invalid queue depth')
|
||||||
|
|
||||||
def assertStringFieldNotEmpty(self, event: DictEvent, string_field_name: str):
|
def assertStringFieldNotEmpty(
|
||||||
|
self,
|
||||||
|
event: DictEvent,
|
||||||
|
string_field_name: str,
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Check that a string field is not empty.
|
Check that a string field is not empty.
|
||||||
|
|
||||||
|
@ -154,7 +172,11 @@ class TraceTestCase(unittest.TestCase):
|
||||||
string_field = self.get_field(event, string_field_name)
|
string_field = self.get_field(event, string_field_name)
|
||||||
self.assertGreater(len(string_field), 0, 'empty string')
|
self.assertGreater(len(string_field), 0, 'empty string')
|
||||||
|
|
||||||
def assertEventAfterTimestamp(self, event: DictEvent, timestamp: int):
|
def assertEventAfterTimestamp(
|
||||||
|
self,
|
||||||
|
event: DictEvent,
|
||||||
|
timestamp: int,
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Check that the event happens after the given timestamp.
|
Check that the event happens after the given timestamp.
|
||||||
|
|
||||||
|
@ -163,7 +185,11 @@ class TraceTestCase(unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
self.assertGreater(get_event_timestamp(event), timestamp, 'event not after timestamp')
|
self.assertGreater(get_event_timestamp(event), timestamp, 'event not after timestamp')
|
||||||
|
|
||||||
def assertEventOrder(self, first_event: DictEvent, second_event: DictEvent):
|
def assertEventOrder(
|
||||||
|
self,
|
||||||
|
first_event: DictEvent,
|
||||||
|
second_event: DictEvent,
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Check that the first event was generated before the second event.
|
Check that the first event was generated before the second event.
|
||||||
|
|
||||||
|
@ -176,8 +202,8 @@ class TraceTestCase(unittest.TestCase):
|
||||||
self,
|
self,
|
||||||
events: List[DictEvent],
|
events: List[DictEvent],
|
||||||
expected_number: int,
|
expected_number: int,
|
||||||
msg: str = 'wrong number of events'
|
msg: str = 'wrong number of events',
|
||||||
):
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Check number of events.
|
Check number of events.
|
||||||
|
|
||||||
|
@ -191,8 +217,8 @@ class TraceTestCase(unittest.TestCase):
|
||||||
self,
|
self,
|
||||||
events: List[DictEvent],
|
events: List[DictEvent],
|
||||||
min_expected_number: int,
|
min_expected_number: int,
|
||||||
msg: str = 'wrong number of events'
|
msg: str = 'wrong number of events',
|
||||||
):
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Check that the number of events is greater of equal.
|
Check that the number of events is greater of equal.
|
||||||
|
|
||||||
|
@ -207,8 +233,8 @@ class TraceTestCase(unittest.TestCase):
|
||||||
initial_event: DictEvent,
|
initial_event: DictEvent,
|
||||||
field_name: str,
|
field_name: str,
|
||||||
matching_event_name: str = None,
|
matching_event_name: str = None,
|
||||||
events: List[DictEvent] = None
|
events: List[DictEvent] = None,
|
||||||
):
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Check that the value of a field for a given event has a matching event that follows.
|
Check that the value of a field for a given event has a matching event that follows.
|
||||||
|
|
||||||
|
@ -247,8 +273,8 @@ class TraceTestCase(unittest.TestCase):
|
||||||
event: DictEvent,
|
event: DictEvent,
|
||||||
field_name: str,
|
field_name: str,
|
||||||
value: Any,
|
value: Any,
|
||||||
msg: str = 'wrong field value'
|
msg: str = 'wrong field value',
|
||||||
):
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Check the value of a field.
|
Check the value of a field.
|
||||||
|
|
||||||
|
@ -260,7 +286,11 @@ class TraceTestCase(unittest.TestCase):
|
||||||
actual_value = self.get_field(event, field_name)
|
actual_value = self.get_field(event, field_name)
|
||||||
self.assertEqual(actual_value, value, msg)
|
self.assertEqual(actual_value, value, msg)
|
||||||
|
|
||||||
def get_field(self, event: DictEvent, field_name: str) -> Any:
|
def get_field(
|
||||||
|
self,
|
||||||
|
event: DictEvent,
|
||||||
|
field_name: str,
|
||||||
|
) -> Any:
|
||||||
"""
|
"""
|
||||||
Get field value; will fail test if not found.
|
Get field value; will fail test if not found.
|
||||||
|
|
||||||
|
@ -276,7 +306,10 @@ class TraceTestCase(unittest.TestCase):
|
||||||
else:
|
else:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def get_procname(self, event: DictEvent) -> str:
|
def get_procname(
|
||||||
|
self,
|
||||||
|
event: DictEvent,
|
||||||
|
) -> str:
|
||||||
"""
|
"""
|
||||||
Get procname.
|
Get procname.
|
||||||
|
|
||||||
|
@ -288,7 +321,7 @@ class TraceTestCase(unittest.TestCase):
|
||||||
def get_events_with_name(
|
def get_events_with_name(
|
||||||
self,
|
self,
|
||||||
event_name: str,
|
event_name: str,
|
||||||
events: List[DictEvent] = None
|
events: List[DictEvent] = None,
|
||||||
) -> List[DictEvent]:
|
) -> List[DictEvent]:
|
||||||
"""
|
"""
|
||||||
Get all events with the given name.
|
Get all events with the given name.
|
||||||
|
@ -304,7 +337,7 @@ class TraceTestCase(unittest.TestCase):
|
||||||
def get_events_with_procname(
|
def get_events_with_procname(
|
||||||
self,
|
self,
|
||||||
procname: str,
|
procname: str,
|
||||||
events: List[DictEvent] = None
|
events: List[DictEvent] = None,
|
||||||
) -> List[DictEvent]:
|
) -> List[DictEvent]:
|
||||||
"""
|
"""
|
||||||
Get all events with the given procname.
|
Get all events with the given procname.
|
||||||
|
@ -324,7 +357,7 @@ class TraceTestCase(unittest.TestCase):
|
||||||
self,
|
self,
|
||||||
field_name: str,
|
field_name: str,
|
||||||
field_values: Any,
|
field_values: Any,
|
||||||
events: List[DictEvent] = None
|
events: List[DictEvent] = None,
|
||||||
) -> List[DictEvent]:
|
) -> List[DictEvent]:
|
||||||
"""
|
"""
|
||||||
Get all events with the given field:value.
|
Get all events with the given field:value.
|
||||||
|
@ -344,7 +377,7 @@ class TraceTestCase(unittest.TestCase):
|
||||||
self,
|
self,
|
||||||
field_name: str,
|
field_name: str,
|
||||||
field_values: Any,
|
field_values: Any,
|
||||||
events: List[DictEvent] = None
|
events: List[DictEvent] = None,
|
||||||
) -> List[DictEvent]:
|
) -> List[DictEvent]:
|
||||||
"""
|
"""
|
||||||
Get all events with the given field but not the value.
|
Get all events with the given field but not the value.
|
||||||
|
@ -360,7 +393,11 @@ class TraceTestCase(unittest.TestCase):
|
||||||
events = self._events
|
events = self._events
|
||||||
return [e for e in events if get_field(e, field_name, None) not in field_values]
|
return [e for e in events if get_field(e, field_name, None) not in field_values]
|
||||||
|
|
||||||
def are_events_ordered(self, first_event: DictEvent, second_event: DictEvent):
|
def are_events_ordered(
|
||||||
|
self,
|
||||||
|
first_event: DictEvent,
|
||||||
|
second_event: DictEvent,
|
||||||
|
) -> bool:
|
||||||
"""
|
"""
|
||||||
Check that the first event was generated before the second event.
|
Check that the first event was generated before the second event.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue