mobly icon indicating copy to clipboard operation
mobly copied to clipboard

Mobly exits without cleaning resources if receives a SIGTERM signal

Open mhaoli opened this issue 3 years ago • 0 comments

Currently, Mobly won't clean requested resources if receives a SIGTERM signal.

We can use a simple test to reproduce the bug:

import logging
import os
from mobly import base_test
from mobly import test_runner
from mobly.controllers import android_device


class SingleTest(base_test.BaseTestClass):
  def setup_class(self):
    self.dut = self.register_controller(android_device)[0]
    self.dut.load_snippet('mbs', 'com.google.android.mobly.snippet.example1')
    self._get_snippet_client_info()
    logging.info('pid of the whole test process: %d', os.getpid())

  def test_sleep_and_send_rpc_multiple_times(self):
    import signal
    signal.raise_signal(signal.SIGTERM)
    logging.info("Won't run on this line.")

  def _get_snippet_client_info(self):
    self.client_port = self.dut.mbs.host_port
    self.client_pid = self.dut.mbs._proc.pid
    logging.info('single_test_client_host_port: %d.' % self.dut.mbs.host_port)
    logging.info('single_test_client_pid: %d.' % self.dut.mbs._proc.pid)


if __name__ == '__main__':
  test_runner.main()

The running log shows that Mobly doesn't clean the following resources: logcat service processes, server processes, ports used for adb forwarding.

Screenshot from 2022-02-23 19-24-23

mhaoli avatar Feb 23 '22 11:02 mhaoli