Loading system/gd/cert/gd_base_test.py +8 −6 Original line number Diff line number Diff line Loading @@ -75,13 +75,15 @@ class GdBaseTestClass(BaseTestClass): "Failed to make root canal ports available") # Start root canal process self.rootcanal_process = subprocess.Popen( [ rootcanal_cmd = [ rootcanal, str(rootcanal_test_port), str(rootcanal_hci_port), str(rootcanal_link_layer_port) ], ] self.log.debug("Running %s" % " ".join(rootcanal_cmd)) self.rootcanal_process = subprocess.Popen( rootcanal_cmd, cwd=get_gd_root(), env=os.environ.copy(), stdout=subprocess.PIPE, Loading system/gd/cert/gd_device.py +24 −4 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ # limitations under the License. from abc import ABC from datetime import datetime import inspect import logging import os Loading Loading @@ -204,6 +205,7 @@ class GdDeviceBase(ABC): signal_socket.listen(1) # Start backing process logging.debug("Running %s" % " ".join(self.cmd)) self.backing_process = subprocess.Popen( self.cmd, cwd=get_gd_root(), Loading Loading @@ -487,6 +489,7 @@ class GdAndroidDevice(GdDeviceBase): "adb", "-s", self.serial_number, "logcat", "-T", "1", "-v", "year", "-v", "uid" ] logging.debug("Running %s", " ".join(self.logcat_cmd)) self.logcat_process = subprocess.Popen( self.logcat_cmd, stdout=subprocess.PIPE, Loading @@ -506,6 +509,8 @@ class GdAndroidDevice(GdDeviceBase): color=self.terminal_color) # Done run parent setup logging.info("Done preparation for %s, starting backing process" % self.serial_number) super().setup() def teardown(self): Loading Loading @@ -561,7 +566,7 @@ class GdAndroidDevice(GdDeviceBase): host_tz = time.strftime("%z") if device_tz != host_tz: target_timezone = utils.get_timezone_olson_id() logging.info("Device timezone %s does not match host timezone %s, " logging.debug("Device timezone %s does not match host timezone %s, " "syncing them by setting timezone to %s" % (device_tz, host_tz, target_timezone)) self.adb.shell("setprop persist.sys.timezone %s" % target_timezone) Loading @@ -572,6 +577,22 @@ class GdAndroidDevice(GdDeviceBase): "Device timezone %s still does not match host " "timezone %s after reset" % (device_tz, host_tz)) self.adb.shell("date %s" % time.strftime("%m%d%H%M%Y.%S")) datetime_format = "%Y-%m-%dZ%H:%M:%S%z" host_time = datetime.today() try: device_time = datetime.strptime( self.adb.shell("date +'%s'" % datetime_format), datetime_format) except ValueError: asserts.fail("Failed to get time after sync") return max_delta_seconds = 0.5 asserts.assert_almost_equal( (device_time - host_time).total_seconds(), 0, msg="Device time %s and host time %s off by >%dms after sync" % (device_time.isoformat, host_time.isoformat(), int(max_delta_seconds * 1000)), delta=max_delta_seconds) def push_or_die(self, src_file_path, dst_file_path, push_timeout=300): """Pushes a file to the Android device Loading @@ -582,7 +603,6 @@ class GdAndroidDevice(GdDeviceBase): push_timeout: How long to wait for the push to finish in seconds """ try: self.ensure_verity_disabled() out = self.adb.push( '%s %s' % (src_file_path, dst_file_path), timeout=push_timeout) if 'error' in out: Loading Loading
system/gd/cert/gd_base_test.py +8 −6 Original line number Diff line number Diff line Loading @@ -75,13 +75,15 @@ class GdBaseTestClass(BaseTestClass): "Failed to make root canal ports available") # Start root canal process self.rootcanal_process = subprocess.Popen( [ rootcanal_cmd = [ rootcanal, str(rootcanal_test_port), str(rootcanal_hci_port), str(rootcanal_link_layer_port) ], ] self.log.debug("Running %s" % " ".join(rootcanal_cmd)) self.rootcanal_process = subprocess.Popen( rootcanal_cmd, cwd=get_gd_root(), env=os.environ.copy(), stdout=subprocess.PIPE, Loading
system/gd/cert/gd_device.py +24 −4 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ # limitations under the License. from abc import ABC from datetime import datetime import inspect import logging import os Loading Loading @@ -204,6 +205,7 @@ class GdDeviceBase(ABC): signal_socket.listen(1) # Start backing process logging.debug("Running %s" % " ".join(self.cmd)) self.backing_process = subprocess.Popen( self.cmd, cwd=get_gd_root(), Loading Loading @@ -487,6 +489,7 @@ class GdAndroidDevice(GdDeviceBase): "adb", "-s", self.serial_number, "logcat", "-T", "1", "-v", "year", "-v", "uid" ] logging.debug("Running %s", " ".join(self.logcat_cmd)) self.logcat_process = subprocess.Popen( self.logcat_cmd, stdout=subprocess.PIPE, Loading @@ -506,6 +509,8 @@ class GdAndroidDevice(GdDeviceBase): color=self.terminal_color) # Done run parent setup logging.info("Done preparation for %s, starting backing process" % self.serial_number) super().setup() def teardown(self): Loading Loading @@ -561,7 +566,7 @@ class GdAndroidDevice(GdDeviceBase): host_tz = time.strftime("%z") if device_tz != host_tz: target_timezone = utils.get_timezone_olson_id() logging.info("Device timezone %s does not match host timezone %s, " logging.debug("Device timezone %s does not match host timezone %s, " "syncing them by setting timezone to %s" % (device_tz, host_tz, target_timezone)) self.adb.shell("setprop persist.sys.timezone %s" % target_timezone) Loading @@ -572,6 +577,22 @@ class GdAndroidDevice(GdDeviceBase): "Device timezone %s still does not match host " "timezone %s after reset" % (device_tz, host_tz)) self.adb.shell("date %s" % time.strftime("%m%d%H%M%Y.%S")) datetime_format = "%Y-%m-%dZ%H:%M:%S%z" host_time = datetime.today() try: device_time = datetime.strptime( self.adb.shell("date +'%s'" % datetime_format), datetime_format) except ValueError: asserts.fail("Failed to get time after sync") return max_delta_seconds = 0.5 asserts.assert_almost_equal( (device_time - host_time).total_seconds(), 0, msg="Device time %s and host time %s off by >%dms after sync" % (device_time.isoformat, host_time.isoformat(), int(max_delta_seconds * 1000)), delta=max_delta_seconds) def push_or_die(self, src_file_path, dst_file_path, push_timeout=300): """Pushes a file to the Android device Loading @@ -582,7 +603,6 @@ class GdAndroidDevice(GdDeviceBase): push_timeout: How long to wait for the push to finish in seconds """ try: self.ensure_verity_disabled() out = self.adb.push( '%s %s' % (src_file_path, dst_file_path), timeout=push_timeout) if 'error' in out: Loading