1import unittest 2 3from parser.input import MATCHER, MATCHER_FOR_OLD 4 5class TestInput(unittest.TestCase): 6 def check_match(self, line): 7 m = MATCHER.match(line) 8 self.assertTrue(m, "'" + line + "'") 9 10 def check_old_match(self, line): 11 m = MATCHER_FOR_OLD.match(line) 12 self.assertTrue(m, "'" + line + "'") 13 14 def test_thread_names(self): 15 lines = """ 16 NeuralNetworks-5143 ( 5143) [005] ...1 142.924145: tracing_mark_write: B|5143|[NN_L 17 <...>-5149 ( 774) [000] ...1 143.103773: tracing_mark_write: B|774|[NN_LDV_PC][validat 18 <...>-756 ( 756) [000] ...1 143.140553: tracing_mark_write: B|756|HIDL::IDevice::prepa 19 <...>-5149 (-----) [001] ...1 143.149856: tracing_mark_write: B|756|[NN_LCC_PE][optim 20 HwBinder:784_1-5236 ( 784) [001] ...1 397.528915: tracing_mark_write: B|784|HIDL:: 21 GLThread 35-1739 ( 1500) [001] ...1 277.001798: tracing_mark_write: B|1500|HIDL::IMapper::importBuffer::passthrough") 22 allocator@1.0-s-757 ( 757) [005] ...1 1700.939402: tracing_mark_write: E|757 23 """ 24 for line in lines.splitlines(): 25 line = line.strip() 26 if line: 27 self.check_match(line) 28 29 def test_old_systrace(self): 30 lines = """ 31 <...>-4762 [007] .... 407453.701225: tracing_mark_write: B|4762|HIDL::IServiceManager::getTransport::client 32 <...>-550 [007] .... 407453.701675: tracing_mark_write: E|550 33 <...>-4840 [005] .... 407457.494359: tracing_mark_write: B|4828|[SW][NN_LI_PE]StepExecutor::startComputeOnDevice::execute 34 <...>-4840 [005] .... 407457.494365: tracing_mark_write: B|4828|HIDL::IPreparedModel::execute::client 35 <...>-13947 [005] .... 407457.494606: tracing_mark_write: B|13947|HIDL::IPreparedModel::execute::server 36 <...>-13949 [005] .... 407457.508264: tracing_mark_write: B|13947|HIDL::IExecutionCallback::notify::client""" 37 for line in lines.splitlines(): 38 line = line.strip() 39 if line: 40 self.check_old_match(line) 41