aboutsummaryrefslogtreecommitdiff
path: root/tests/test_base.py
diff options
context:
space:
mode:
authorPatrick Bellasi <patrick.bellasi@arm.com>2015-04-24 16:32:35 +0100
committerJavi Merino <javi.merino@arm.com>2015-08-12 16:03:46 +0100
commit990f9252241074aca73612d4f25ae84ae0c32ea5 (patch)
tree3dcde01bb9c18ca65c6c1e70471487cb5f82c752 /tests/test_base.py
parentd721b27ead40c39efa1f1febdd853f9b04c54984 (diff)
downloadtrappy-990f9252241074aca73612d4f25ae84ae0c32ea5.tar.gz
run: update special fields regexp to parse task names with a space
Chrome spawn a number of tasks which have a space in between. This produces trace files which could have events starting with, for example: AsyncTask #1-9241 [001] 1033.379578: This patch update the regular expression used to parse the special fields at the beginning of each event in such a way to properly grab the taskname even when it presents a space in it. The propose patch should be valid as long as we could assume there is not tasks which name includes the "[" char. This patch adds also a test case to verify proper parsing of all common fields for a set of events. The set of events could easily be extended to check for more tasks names. Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
Diffstat (limited to 'tests/test_base.py')
-rw-r--r--tests/test_base.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/test_base.py b/tests/test_base.py
index 2fe435b..a57a798 100644
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -82,6 +82,46 @@ class TestBase(utils_tests.SetupDirectory):
self.assertEquals(set(dfr.columns), expected_columns)
self.assertEquals(dfr["power"].iloc[0], 61)
+ def test_parse_special_fields(self):
+ """TestBase: Task name, PID, CPU and timestamp are properly paresed """
+
+ events = {
+ '1001.456789' : { 'task': 'rcu_preempt', 'pid': 1123, 'cpu': 001 },
+ '1002.456789' : { 'task': 'rs:main', 'pid': 2123, 'cpu': 002 },
+ '1003.456789' : { 'task': 'AsyncTask #1', 'pid': 3123, 'cpu': 003 },
+ '1004.456789' : { 'task': 'kworker/1:1H', 'pid': 4123, 'cpu': 004 },
+ '1005.456789' : { 'task': 'jbd2/sda2-8', 'pid': 5123, 'cpu': 005 },
+ }
+
+ in_data = """"""
+ for timestamp in sorted(events):
+ in_data+="{0:>16s}-{1:d} [{2:04d}] {3:s}: event0: tag=value\n".\
+ format(
+ events[timestamp]['task'],
+ events[timestamp]['pid'],
+ events[timestamp]['cpu'],
+ timestamp
+ )
+
+ expected_columns = set(["__comm", "__pid", "__cpu", "tag"])
+
+ with open("trace.txt", "w") as fout:
+ fout.write(in_data)
+
+ cr2.register_dynamic('Event0', 'event0', scope="sched")
+ run = cr2.Run()
+ dfr = run.event0.data_frame
+
+ self.assertEquals(set(dfr.columns), expected_columns)
+
+ for idx in range(len(events)):
+ timestap = str( dfr.index[idx]+float(events.keys()[0]))
+ self.assertTrue(timestamp in events)
+ self.assertEquals(dfr["__comm"].iloc[idx], events[timestap]['task'])
+ self.assertEquals(dfr["__pid"].iloc[idx], events[timestap]['pid'])
+ self.assertEquals(dfr["__cpu"].iloc[idx], events[timestap]['cpu'])
+
+
def test_parse_values_concatenation(self):
"""TestBase: Trace with space separated values created a valid DataFrame"""