1122 parser = argparse.ArgumentParser(
1123 description="""
1124In order to learn the details of running tests in the engine, please consult the
1125Flutter Wiki page on the subject: https://github.com/flutter/flutter/wiki/Testing-the-engine
1126"""
1127 )
1128 all_types = [
1129 'engine',
1130 'dart',
1131 'dart-host',
1132 'benchmarks',
1133 'java',
1134 'android',
1135 'objc',
1136 'font-subset',
1137 'impeller-golden',
1138 ]
1139
1140 parser.add_argument(
1141 '--variant',
1142 dest='variant',
1143 action='store',
1144 default='host_debug_unopt',
1145 help='The engine build variant to run the tests for.'
1146 )
1147 parser.add_argument(
1148 '--type',
1149 type=str,
1150 default='all',
1151 help=
'A list of test types, default is "all" (equivalent to "%s")' % (
','.
join(all_types))
1152 )
1153 parser.add_argument(
1154 '--engine-filter', type=str, default='', help='A list of engine test executables to run.'
1155 )
1156 parser.add_argument(
1157 '--dart-filter',
1158 type=str,
1159 default='',
1160 help='A list of Dart test script base file names to run in '
1161 'flutter_tester (example: "image_filter_test.dart").'
1162 )
1163 parser.add_argument(
1164 '--dart-host-filter',
1165 type=str,
1166 default='',
1167 help='A list of Dart test scripts to run with the Dart CLI.'
1168 )
1169 parser.add_argument(
1170 '--java-filter',
1171 type=str,
1172 default='',
1173 help='A single Java test class to run (example: "io.flutter.SmokeTest")'
1174 )
1175 parser.add_argument(
1176 '--android-variant',
1177 dest='android_variant',
1178 action='store',
1179 default='android_debug_unopt',
1180 help='The engine build variant to run java or android tests for'
1181 )
1182 parser.add_argument(
1183 '--ios-variant',
1184 dest='ios_variant',
1185 action='store',
1186 default='ios_debug_sim_unopt',
1187 help='The engine build variant to run objective-c tests for'
1188 )
1189 parser.add_argument(
1190 '--verbose-dart-snapshot',
1191 dest='verbose_dart_snapshot',
1192 action='store_true',
1193 default=False,
1194 help='Show extra dart snapshot logging.'
1195 )
1196 parser.add_argument(
1197 '--objc-filter',
1198 type=str,
1199 default=None,
1200 help=(
1201 'Filter parameter for which objc tests to run '
1202 '(example: "IosUnitTestsTests/SemanticsObjectTest/testShouldTriggerAnnouncement")'
1203 )
1204 )
1205 parser.add_argument(
1206 '--coverage',
1207 action='store_true',
1208 default=None,
1209 help='Generate coverage reports for each unit test framework run.'
1210 )
1211 parser.add_argument(
1212 '--engine-capture-core-dump',
1213 dest='engine_capture_core_dump',
1214 action='store_true',
1215 default=False,
1216 help='Capture core dumps from crashes of engine tests.'
1217 )
1218 parser.add_argument(
1219 '--use-sanitizer-suppressions',
1220 dest='sanitizer_suppressions',
1221 action='store_true',
1222 default=False,
1223 help='Provide the sanitizer suppressions lists to the via environment to the tests.'
1224 )
1225 parser.add_argument(
1226 '--adb-path',
1227 dest='adb_path',
1228 action='store',
1229 default=None,
1230 help='Provide the path of adb used for android tests. By default it looks on $PATH.'
1231 )
1232 parser.add_argument(
1233 '--quiet',
1234 dest='quiet',
1235 action='store_true',
1236 default=False,
1237 help='Only emit output when there is an error.'
1238 )
1239 parser.add_argument(
1240 '--logs-dir',
1241 dest='logs_dir',
1242 type=str,
1243 help='The directory that verbose logs will be copied to in --quiet mode.',
1244 )
1245 parser.add_argument(
1246 '--no-skia-gold',
1247 dest='no_skia_gold',
1248 action='store_true',
1249 default=False,
1250 help='Do not compare golden images with Skia Gold.',
1251 )
1252
1253 args = parser.parse_args()
1254
1255 logger.addHandler(console_logger_handler)
1256 logger.addHandler(file_logger_handler)
1257 logger.setLevel(logging.INFO)
1258 if args.quiet:
1259 file_logger_handler.setLevel(logging.INFO)
1260 console_logger_handler.setLevel(logging.WARNING)
1261 else:
1262 console_logger_handler.setLevel(logging.INFO)
1263
1264 if args.type == 'all':
1265 types = all_types
1266 else:
1267 types = args.type.split(',')
1268
1269 build_dir = os.path.join(OUT_DIR, args.variant)
1270 if args.type != 'java' and args.type != 'android':
1271 assert os.path.exists(build_dir), 'Build variant directory %s does not exist!' % build_dir
1272
1273 if args.sanitizer_suppressions:
1275 ), 'The sanitizer suppressions flag is only supported on Linux and Mac.'
1276 file_dir = os.path.dirname(os.path.abspath(__file__))
1277 command = [
1278 'env', '-i', 'bash', '-c',
1279 'source {}/sanitizer_suppressions.sh >/dev/null && env'.
format(file_dir)
1280 ]
1281 process = subprocess.Popen(command, stdout=subprocess.PIPE)
1282 for line in process.stdout:
1283 key, _, value = line.decode('utf8').strip().partition('=')
1284 os.environ[key] = value
1285 process.communicate()
1286
1287 success = True
1288
1289 engine_filter = args.engine_filter.split(',') if args.engine_filter else None
1290 if 'engine' in types:
1291 run_cc_tests(build_dir, engine_filter, args.coverage, args.engine_capture_core_dump)
1292
1293
1294 if 'impeller' in types:
1295 build_name = args.variant
1296 try:
1300 build_dir,
1301 'impeller_unittests',
1302 engine_filter,
1303 repeat_flags,
1304 coverage=args.coverage,
1305 extra_env=extra_env,
1306 gtest=True
1307 )
1308 finally:
1310
1311 if 'dart' in types:
1312 dart_filter = args.dart_filter.split(',') if args.dart_filter else None
1316
1317 if 'dart-host' in types:
1318 dart_filter = args.dart_host_filter.split(',') if args.dart_host_filter else None
1320 tasks = []
1321 for dart_host_package, extra_opts in dart_host_packages:
1322 if dart_filter is None or dart_host_package in dart_filter:
1323 tasks += list(
1325 build_dir,
1326 os.path.join(BUILDROOT_DIR, dart_host_package),
1327 extra_opts,
1328 )
1329 )
1330
1332
1333 if 'java' in types:
1334 assert not is_windows(),
"Android engine files can't be compiled on Windows."
1335 java_filter = args.java_filter
1336 if ',' in java_filter or '*' in java_filter:
1337 logger.wraning(
1338 'Can only filter JUnit4 tests by single entire class name, '
1339 'eg "io.flutter.SmokeTest". Ignoring filter=' + java_filter
1340 )
1341 java_filter = None
1343
1344 if 'android' in types:
1345 assert not is_windows(),
"Android engine files can't be compiled on Windows."
1347
1348 if 'objc' in types:
1349 assert is_mac(),
'iOS embedding tests can only be run on macOS.'
1351
1352
1353 if 'benchmarks' in types
and not is_windows():
1356
1357 variants_to_skip = ['host_release', 'host_profile']
1358
1360 matches = [variant for variant in variants_to_skip if variant in args.variant]
1361 return len(matches) > 0
1362
1363 if (
'engine' in types
or 'font-subset' in types)
and not should_skip(args.variant):
1364 cmd = ['python3', 'test.py', '--variant', args.variant]
1365 if 'arm64' in args.variant:
1366 cmd += ['--target-cpu', 'arm64']
1367 run_cmd(cmd, cwd=FONT_SUBSET_DIR)
1368
1369 if 'impeller-golden' in types:
1371
1372 if args.quiet and args.logs_dir:
1373 shutil.copy(LOG_FILE, os.path.join(args.logs_dir, 'run_tests.log'))
1374
1375 return 0 if success else 1
1376
1377
static bool should_skip(const char *sink, const char *src, const char *srcOptions, const char *name)
uint32_t uint32_t * format
def run_engine_tasks_in_parallel(tasks)
def run_impeller_golden_tests(str build_dir, bool require_skia_gold=False)
def run_java_tests(executable_filter, android_variant='android_debug_unopt')
def run_benchmark_tests(build_dir)
def run_cc_tests(build_dir, executable_filter, coverage, capture_core_dump)
def run_android_tests(android_variant='android_debug_unopt', adb_path=None)
def run_objc_tests(ios_variant='ios_debug_sim_unopt', test_filter=None)
def vulkan_validation_env(build_dir)
def run_engine_benchmarks(build_dir, executable_filter)
def start_virtual_x(child_build_name, build_dir)
def stop_virtual_x(child_build_name)