androidlog.py (2005B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 from pathlib import Path 5 6 from mozperftest.layers import Layer 7 8 9 class AndroidLog(Layer): 10 """Runs an android log test.""" 11 12 name = "androidlog" 13 activated = False 14 arguments = { 15 "first-timestamp": { 16 "type": str, 17 "default": None, 18 "help": "First timestamp regexp", 19 }, 20 "second-timestamp": { 21 "type": str, 22 "default": None, 23 "help": "Second timestamp regexp", 24 }, 25 "subtest-name": { 26 "type": str, 27 "default": "TimeToDisplayed", 28 "help": "Name of the metric that is produced", 29 }, 30 } 31 32 def _get_logcat(self): 33 logcat = self.get_arg("android-capture-logcat") 34 if logcat is None: 35 raise NotImplementedError() 36 # check if the path is absolute or relative to output 37 path = Path(logcat) 38 if not path.is_absolute(): 39 return Path(self.get_arg("output"), path).resolve() 40 return path.resolve() 41 42 def __call__(self, metadata): 43 app_name = self.get_arg("android-app-name") 44 first_ts = r".*Start proc.*" + app_name.replace(".", r"\.") + ".*" 45 second_ts = r".*Fully drawn.*" + app_name.replace(".", r"\.") + ".*" 46 options = { 47 "first-timestamp": self.get_arg("first-timestamp", first_ts), 48 "second-timestamp": self.get_arg("second-timestamp", second_ts), 49 "processor": self.env.hooks.get("logcat_processor"), 50 "transform-subtest-name": self.get_arg("subtest-name"), 51 } 52 53 metadata.add_result({ 54 "results": str(self._get_logcat()), 55 "transformer": "LogCatTimeTransformer", 56 "transformer-options": options, 57 "name": "LogCat", 58 }) 59 60 return metadata