Skip to content

Commit

Permalink
Implement collect logs
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverBzH committed Sep 24, 2024
1 parent c3dbc92 commit f6dc333
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions avatar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from avatar.runner import SuiteRunner
from mobly import base_test
from mobly import signals
from pathlib import Path
from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Sized, Tuple, Type, TypeVar

# public symbols
Expand Down Expand Up @@ -147,6 +148,13 @@ def stop_all(self) -> None:
server.stop()
self._clients.clear()

def collect_logs(self, path: Path) -> None:
"""Collects logs from all Pandora servers."""
if not len(self._servers):
return
for server in self._servers:
server.collect_logs(path)


def _load_pandora_server_class(class_path: str) -> Type[pandora_server.PandoraServer[Any]]:
"""Dynamically load a PandoraServer from a user-specified module+class.
Expand Down
9 changes: 9 additions & 0 deletions avatar/pandora_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from contextlib import suppress
from mobly.controllers import android_device
from mobly.controllers.android_device import AndroidDevice
from pathlib import Path
from typing import Generic, Optional, TypeVar

ANDROID_SERVER_PACKAGE = 'com.android.pandora'
Expand Down Expand Up @@ -65,6 +66,11 @@ def start(self) -> PandoraClient:

def stop(self) -> None:
"""Stops and cleans up the Pandora server on the device."""
pass

def collect_logs(self, path: Path) -> None:
"""Collects logs from all Pandora servers."""
pass


class BumblePandoraServer(PandoraServer[BumblePandoraDevice]):
Expand Down Expand Up @@ -151,3 +157,6 @@ def stop(self) -> None:
self.device.adb.forward(['--remove', f'tcp:{self._port}']) # type: ignore
self._instrumentation.join()
self._instrumentation = None

def collect_logs(self, path: Path) -> None:
self.device.take_bug_report(destination=path) # type: ignore

0 comments on commit f6dc333

Please sign in to comment.