98 parser = argparse.ArgumentParser()
99 parser.add_argument(
100 '--variant',
101 dest='variant',
102 action='store',
103 default='android_profile_arm64',
104 help='The engine variant to run tests for.'
105 )
106 parser.add_argument(
107 '--build-id',
108 default=os.environ.get('SWARMING_TASK_ID', 'local_test'),
109 help='A unique build identifier for this test. Used to sort results in the GCS bucket.'
110 )
111
112 args = parser.parse_args()
113
114 apks_dir = os.path.join(out_dir, args.variant, 'firebase_apks')
115 apks = set(glob.glob('%s/*.apk' % apks_dir))
116
117 if not apks:
118 print(
'No APKs found at %s' % apks_dir)
119 return 1
120
121 git_revision = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=script_dir)
122 git_revision = byte_str_decode(git_revision)
123 git_revision = git_revision.strip()
124
125 for retry in range(MAX_RETRY_ATTEMPTS):
126 if retry > 0:
127 print(
'Retrying %s' % apks)
128
129 results = []
130 for apk in sorted(apks):
131 results_dir = '%s/%s/%s' % (os.path.basename(apk), git_revision, args.build_id)
132 process = run_firebase_test(apk, results_dir)
133 results.append((apk, results_dir, process))
134
135 for apk, results_dir, process in results:
136 print(
'===== Test output for %s' % apk)
137 for line in iter(process.stdout.readline, ''):
139
140 return_code = process.wait()
141 if return_code in FTL_INFRA_FAILURE_CODES:
142 print(
'Firebase test %s failed with infrastructure error code: %s' % (apk, return_code))
143 continue
144 if return_code != 0:
145 print(
'Firebase test %s failed with code: %s' % (apk, return_code))
146 sys.exit(return_code)
147
148 print(
'Checking logcat for %s' % results_dir)
149 check_logcat(results_dir)
150
151 if 'scenario' in apk:
152 print(
'Checking timeline for %s' % results_dir)
153 check_timeline(results_dir)
154
155 apks.remove(apk)
156
157 if not apks:
158 break
159
160 return 0
161
162