Home | History | Annotate | Download | only in live
      1 #!/usr/bin/env python3.4
      2 #
      3 #   Copyright 2017 - Google
      4 #
      5 #   Licensed under the Apache License, Version 2.0 (the "License");
      6 #   you may not use this file except in compliance with the License.
      7 #   You may obtain a copy of the License at
      8 #
      9 #       http://www.apache.org/licenses/LICENSE-2.0
     10 #
     11 #   Unless required by applicable law or agreed to in writing, software
     12 #   distributed under the License is distributed on an "AS IS" BASIS,
     13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 #   See the License for the specific language governing permissions and
     15 #   limitations under the License.
     16 """
     17     Test Script for Telephony Post Flight check.
     18 """
     19 import os
     20 from acts import utils
     21 from acts.asserts import fail
     22 from acts.base_test import BaseTestClass
     23 from acts.test_decorators import test_tracker_info
     24 from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
     25 
     26 
     27 class TelLivePostflightTest(TelephonyBaseTest):
     28     def __init__(self, controllers):
     29         BaseTestClass.__init__(self, controllers)
     30 
     31     def setup_class(self):
     32         pass
     33 
     34     def teardown_class(self):
     35         pass
     36 
     37     def setup_test(self):
     38         pass
     39 
     40     def on_pass(self, *arg):
     41         pass
     42 
     43     def on_fail(self, *arg):
     44         pass
     45 
     46     @test_tracker_info(uuid="ba6e260e-d2e1-4c01-9d51-ef2df1591039")
     47     @TelephonyBaseTest.tel_test_wrap
     48     def test_check_crash(self):
     49         msg = ""
     50         for ad in self.android_devices:
     51             post_crash = ad.check_crash_report(self.test_id)
     52             pre_crash = getattr(ad, "crash_report_preflight", [])
     53             crash_diff = list(set(post_crash).difference(set(pre_crash)))
     54             if crash_diff:
     55                 msg += "%s find new crash reports %s " % (ad.serial,
     56                                                           crash_diff)
     57                 ad.log.error("Find new crash reports %s", crash_diff)
     58                 crash_path = os.path.join(ad.log_path, self.test_name,
     59                                           "Crashes")
     60                 utils.create_dir(crash_path)
     61                 ad.pull_files(crash_diff, crash_path)
     62                 self._ad_take_bugreport(ad, self.test_name, self.begin_time)
     63         if msg:
     64             fail(msg)
     65         return True
     66 
     67     @test_tracker_info(uuid="a94a0145-27be-4610-90f7-3af561d1b1ec")
     68     @TelephonyBaseTest.tel_test_wrap
     69     def test_check_dialer_crash(self):
     70         msg = ""
     71         for ad in self.android_devices:
     72             tombstones = ad.get_file_names("/data/tombstones/")
     73             if not tombstones: continue
     74             for tombstone in tombstones:
     75                 if ad.adb.shell("cat %s | grep pid | grep dialer" % tombstone):
     76                     message = "%s dialer crash: %s " % (ad.serial, tombstone)
     77                     ad.log.error(message)
     78                     msg += message
     79                     crash_path = os.path.join(ad.log_path, self.test_name,
     80                                               "Crashes")
     81                     utils.create_dir(crash_path)
     82                     ad.pull_files([tombstone], crash_path)
     83         if msg:
     84             fail(msg)
     85         return True
     86 
     87     @test_tracker_info(uuid="707d4a33-2e21-40ea-bd27-d15f4e3ff0f0")
     88     @TelephonyBaseTest.tel_test_wrap
     89     def test_check_data_accounting_failures(self):
     90         msg = ""
     91         for ad in self.android_devices:
     92             ad.log.info("data_accounting_errors: %s", dict(ad.data_accounting))
     93             if any(ad.data_accounting.values()):
     94                 msg += "%s %s" % (ad.serial, dict(ad.data_accounting))
     95         if msg:
     96             fail(msg)
     97         return True
     98