summaryrefslogtreecommitdiffstats
path: root/python/mozperftest/mozperftest/test/androidlog.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/mozperftest/mozperftest/test/androidlog.py')
-rw-r--r--python/mozperftest/mozperftest/test/androidlog.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/python/mozperftest/mozperftest/test/androidlog.py b/python/mozperftest/mozperftest/test/androidlog.py
new file mode 100644
index 0000000000..88bf01f2fe
--- /dev/null
+++ b/python/mozperftest/mozperftest/test/androidlog.py
@@ -0,0 +1,62 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from pathlib import Path
+
+from mozperftest.layers import Layer
+
+
+class AndroidLog(Layer):
+ """Runs an android log test."""
+
+ name = "androidlog"
+ activated = False
+ arguments = {
+ "first-timestamp": {
+ "type": str,
+ "default": None,
+ "help": "First timestamp regexp",
+ },
+ "second-timestamp": {
+ "type": str,
+ "default": None,
+ "help": "Second timestamp regexp",
+ },
+ "subtest-name": {
+ "type": str,
+ "default": "TimeToDisplayed",
+ "help": "Name of the metric that is produced",
+ },
+ }
+
+ def _get_logcat(self):
+ logcat = self.get_arg("android-capture-logcat")
+ if logcat is None:
+ raise NotImplementedError()
+ # check if the path is absolute or relative to output
+ path = Path(logcat)
+ if not path.is_absolute():
+ return Path(self.get_arg("output"), path).resolve()
+ return path.resolve()
+
+ def __call__(self, metadata):
+ app_name = self.get_arg("android-app-name")
+ first_ts = r".*Start proc.*" + app_name.replace(".", r"\.") + ".*"
+ second_ts = r".*Fully drawn.*" + app_name.replace(".", r"\.") + ".*"
+ options = {
+ "first-timestamp": self.get_arg("first-timestamp", first_ts),
+ "second-timestamp": self.get_arg("second-timestamp", second_ts),
+ "processor": self.env.hooks.get("logcat_processor"),
+ "transform-subtest-name": self.get_arg("subtest-name"),
+ }
+
+ metadata.add_result(
+ {
+ "results": str(self._get_logcat()),
+ "transformer": "LogCatTimeTransformer",
+ "transformer-options": options,
+ "name": "LogCat",
+ }
+ )
+
+ return metadata