trappy: Fix systrace userspace parsing tests
@@ -17,6 +17,8 @@ import utils_tests
import trappy
+import numpy as np
+
class TestSystrace(utils_tests.SetupDirectory):
def __init__(self, *args, **kwargs):
@@ -55,14 +57,32 @@ class TestSystrace(utils_tests.SetupDirectory):
def test_systrace_userspace(self):
"""Test parsing of userspace events"""
+ # Test a 'B' event (begin)
trace = trappy.SysTrace("trace_sf.html")
dfr = trace.tracing_mark_write.data_frame
- self.assertTrue(dfr['__pid'].iloc[2], 7459)
- self.assertTrue(dfr['__comm'].iloc[2], 'RenderThread')
- self.assertTrue(dfr['pid'].iloc[2], 7459)
- self.assertTrue(dfr['event'].iloc[2], 'B')
- self.assertTrue(dfr['func'].iloc[2], 'notifyFramePending')
- self.assertTrue(dfr['data'].iloc[-2], 'HW_VSYNC_0')
+ self.assertEquals(dfr['__pid'].iloc[2], 7591)
+ self.assertEquals(dfr['__comm'].iloc[2], 'RenderThread')
+ self.assertEquals(dfr['pid'].iloc[2], 7459)
+ self.assertEquals(dfr['event'].iloc[2], 'B')
+ self.assertEquals(dfr['func'].iloc[2], 'notifyFramePending')
+ self.assertEquals(dfr['data'].iloc[2], None)
+
+ # Test a 'C' event (count)
+ self.assertEquals(dfr['__pid'].iloc[-2], 612)
+ self.assertEquals(dfr['__comm'].iloc[-2], 'HwBinder:594_1')
+ self.assertEquals(dfr['pid'].iloc[-2], 594)
+ self.assertEquals(dfr['func'].iloc[-2], 'HW_VSYNC_0')
+ self.assertEquals(dfr['event'].iloc[-2], 'C')
+ self.assertEquals(dfr['data'].iloc[-2], '0')
+
+ # Test an 'E' event (end)
+ edfr = dfr[dfr['event'] == 'E']
+ self.assertEquals(edfr['__pid'].iloc[0], 7591)
+ self.assertEquals(edfr['__comm'].iloc[0], 'RenderThread')
+ self.assertTrue(np.isnan(edfr['pid'].iloc[0]))
+ self.assertEquals(edfr['func'].iloc[0], None)
+ self.assertEquals(edfr['event'].iloc[0], 'E')
+ self.assertEquals(edfr['data'].iloc[0], None)
def test_systrace_line_num(self):
"""Test for line numbers in a systrace"""
