1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3# 4# Copyright (c) 2024 Huawei Device Co., Ltd. 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 18from stress_sts_with_runtime import StsStressTestWithRuntime 19from stress_hermes_with_runtime import HermesStressTestWithRuntime 20from stress_test262_with_runtime import Test262StressTestWithRuntime 21from stress_hermes import HermesStressTest 22from stress_node_js import NodeJSStressTest 23from stress_sts import StsStressTest 24from stress_test262 import Test262StressTest 25import sys 26from typing import List 27 28import stress_common 29 30from stress_test import Test 31 32 33def main(): 34 logger = stress_common.create_logger() 35 36 args = stress_common.get_args() 37 38 logger.debug('Initializing stress tests...') 39 logger.debug(f'Runner args: {args}') 40 41 stress_tests = [ 42 Test262StressTest(args), 43 StsStressTest(args), 44 NodeJSStressTest(args), 45 HermesStressTest(args), 46 ] 47 48 if args.with_runtime: 49 stress_tests.append(Test262StressTestWithRuntime(args.repeats, args)) 50 stress_tests.append(HermesStressTestWithRuntime(args)) 51 stress_tests.append(StsStressTestWithRuntime(args.ark_path, args)) 52 53 logger.debug('Running stress tests...') 54 55 for test in stress_tests: 56 logger.debug(f'Running {test.__class__.__name__} test suite...') 57 58 test.prepare() 59 60 tests: List[Test] = test.build() 61 62 results = test.run(tests) 63 64 fail_list = stress_common.get_fail_list(results) 65 66 if args.update_fail_list: 67 stress_common.update_fail_list(test.get_fail_list_path(), 68 fail_list) 69 logger.debug('Failures/Total: %s/%s', len(fail_list), len(results)) 70 return 0 71 72 if not stress_common.check_regression_errors(test.get_fail_list_path(), 73 fail_list): 74 return 1 75 76 if not stress_common.check_fail_list(test.get_fail_list_path(), 77 fail_list): 78 logger.debug('Failures/Total: %s/%s', len(fail_list), len(results)) 79 80 logger.debug('No regressions') 81 logger.debug('Failures/Total: %s/%s', len(fail_list), len(results)) 82 83 return 0 84 85 86if __name__ == '__main__': 87 sys.exit(main()) 88