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