summaryrefslogtreecommitdiff
path: root/startop/scripts/trace_analyzer/lib/trace2db_test.py
diff options
context:
space:
mode:
authorYan Wang <yawanng@google.com>2019-07-16 15:29:08 -0700
committerYan Wang <yawanng@google.com>2019-07-17 15:47:54 -0700
commit315ae2d4c4396fa4f19f5a2be0d73afb9cfa7b31 (patch)
tree9709dd02de97377349c53eee645e100d58585e68 /startop/scripts/trace_analyzer/lib/trace2db_test.py
parentede8b187e99c9b68841d036d0045fee5bd1e1e82 (diff)
Add support of trace duration for host python compiler.
The basic idea is add timestamp for MmFilemapAddToPageCache. Treat the first receiving MmFilemapAddToPageCache timestamp as the start time. The end time is the sum of start time and duration. Any MmFilemapAddToPageCache after end time is filtered out. Test: pytest trace2db_test.py Bug: 137398235 Change-Id: Ib9c439f3ae0ca666eacb08492361217d89adec34
Diffstat (limited to 'startop/scripts/trace_analyzer/lib/trace2db_test.py')
-rwxr-xr-xstartop/scripts/trace_analyzer/lib/trace2db_test.py34
1 files changed, 27 insertions, 7 deletions
diff --git a/startop/scripts/trace_analyzer/lib/trace2db_test.py b/startop/scripts/trace_analyzer/lib/trace2db_test.py
index b67cffa51cde..3b326f000a7d 100755
--- a/startop/scripts/trace_analyzer/lib/trace2db_test.py
+++ b/startop/scripts/trace_analyzer/lib/trace2db_test.py
@@ -32,17 +32,10 @@ See also https://docs.pytest.org/en/latest/usage.html
"""
# global imports
-from contextlib import contextmanager
import io
-import shlex
-import sys
-import typing
-
from copy import deepcopy
# pip imports
-import pytest
-
# local imports
from trace2db import *
@@ -197,6 +190,33 @@ NonUserFacing6-5246 ( 1322) [005] .... 16138.357581: mm_filemap_add_to_page_cac
assert_eq_ignore_id(MmFilemapAddToPageCache(dev=64774, dev_major=253, dev_minor=6,
ino=0x9a64, page=0x000000006e0f8322, pfn=797894, ofs=4096), second_to_last_row)
+def test_timestamp_filter():
+ test_contents = """
+ MediaStoreImpor-27212 (27176) [000] .... 16136.595194: mm_filemap_add_to_page_cache: dev 253:6 ino 7580 page=0000000060e990c7 pfn=677646 ofs=159744
+ NonUserFacing6-5246 ( 1322) [005] .... 16139.357581: mm_filemap_add_to_page_cache: dev 253:6 ino 9a64 page=000000006e0f8322 pfn=797894 ofs=4096
+ MediaStoreImpor-27212 (27176) [000] .... 16136.604126: mm_filemap_add_to_page_cache: dev 253:6 ino b1d8 page=0000000098d4d2e2 pfn=829676 ofs=0
+ """
+
+ t2d = parse_trace_file_to_db(test_contents)
+ session = t2d.session
+
+ end_time = 16137.0
+
+ results = session.query(MmFilemapAddToPageCache).join(
+ MmFilemapAddToPageCache.raw_ftrace_entry).filter(
+ RawFtraceEntry.timestamp <= end_time).order_by(
+ MmFilemapAddToPageCache.id).all()
+
+ assert len(results) == 2
+ assert_eq_ignore_id(
+ MmFilemapAddToPageCache(dev=64774, dev_major=253, dev_minor=6,
+ ino=0x7580, page=0x0000000060e990c7, pfn=677646,
+ ofs=159744), results[0])
+ assert_eq_ignore_id(
+ MmFilemapAddToPageCache(dev=64774, dev_major=253, dev_minor=6,
+ ino=0xb1d8, page=0x0000000098d4d2e2, pfn=829676,
+ ofs=0), results[1])
+
if __name__ == '__main__':
pytest.main()