From 99b70134242965fe84c19767c02897ae06e6c923 Mon Sep 17 00:00:00 2001 From: Wen HU Date: Fri, 1 May 2020 12:27:40 -0400 Subject: [PATCH 1/2] [maple_ir] fix parsing incomplete interface types 1. incomplete interface types are initialized as incomplete class types in ParseDefinedTypename() 2. IsIncomplete() is a method in MIRType so no need to cast modified: src/maple_ir/src/parser.cpp --- src/maple_ir/src/parser.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/maple_ir/src/parser.cpp b/src/maple_ir/src/parser.cpp index e727391c1a..5c9b09ea5e 100644 --- a/src/maple_ir/src/parser.cpp +++ b/src/maple_ir/src/parser.cpp @@ -849,7 +849,7 @@ bool MIRParser::ParseStructType(TyIdx &styIdx) { MIRType *prevType = GlobalTables::GetTypeTable().GetTypeFromTyIdx(styIdx); ASSERT(prevType->GetKind() == kTypeStruct || prevType->GetKind() == kTypeStructIncomplete, "type kind should be consistent."); - if (static_cast(prevType)->IsIncomplete() && !(structType.IsIncomplete())) { + if (prevType->IsIncomplete() && !(structType.IsIncomplete())) { structType.SetNameStrIdx(prevType->GetNameStrIdx()); structType.SetTypeIndex(styIdx); GlobalTables::GetTypeTable().SetTypeWithTyIdx(styIdx, structType.CopyMIRTypeNode()); @@ -880,7 +880,7 @@ bool MIRParser::ParseClassType(TyIdx &styidx) { MIRType *prevType = GlobalTables::GetTypeTable().GetTypeFromTyIdx(styidx); ASSERT(prevType->GetKind() == kTypeClass || prevType->GetKind() == kTypeClassIncomplete, "type kind should be consistent."); - if (static_cast(prevType)->IsIncomplete() && !(classType.IsIncomplete())) { + if (prevType->IsIncomplete() && !(classType.IsIncomplete())) { classType.SetNameStrIdx(prevType->GetNameStrIdx()); classType.SetTypeIndex(styidx); GlobalTables::GetTypeTable().SetTypeWithTyIdx(styidx, classType.CopyMIRTypeNode()); @@ -921,9 +921,9 @@ bool MIRParser::ParseInterfaceType(TyIdx &sTyIdx) { } if (sTyIdx != 0u) { MIRType *prevType = GlobalTables::GetTypeTable().GetTypeFromTyIdx(sTyIdx); - ASSERT(prevType->GetKind() == kTypeInterface || prevType->GetKind() == kTypeInterfaceIncomplete, + ASSERT(prevType->GetKind() == kTypeInterface || prevType->IsIncomplete(), "type kind should be consistent."); - if (static_cast(prevType)->IsIncomplete() && !(interfaceType.IsIncomplete())) { + if (prevType->IsIncomplete() && !(interfaceType.IsIncomplete())) { interfaceType.SetNameStrIdx(prevType->GetNameStrIdx()); interfaceType.SetTypeIndex(sTyIdx); GlobalTables::GetTypeTable().SetTypeWithTyIdx(sTyIdx, interfaceType.CopyMIRTypeNode()); -- Gitee From 20bf21c72ae6f70a105988bd10f01198d05bc691 Mon Sep 17 00:00:00 2001 From: XiaGuochao Date: Wed, 29 Apr 2020 17:39:54 +0800 Subject: [PATCH 2/2] Bugfix: Fix invalid testlist parameter --- test/README.md | 20 +++++++++---- test/maple_test/configs.py | 6 +--- test/maple_test/maple_test.cfg | 1 - test/maple_test/task.py | 54 +++++++++++++++++++++++++++------- test/maple_test/test.py | 4 +-- test/maple_test/utils.py | 2 +- 6 files changed, 61 insertions(+), 26 deletions(-) diff --git a/test/README.md b/test/README.md index 428b09abe1..83cc79d9d3 100644 --- a/test/README.md +++ b/test/README.md @@ -50,10 +50,18 @@ level = INFO 依赖环境变量:MAPLE_ROOT -### 运行已配置的所有测试套 +### 运行测试套 + +#### irbuild_test + +```shell +python3 test/main.py test/testsuite/irbuild_test -j20 -pFAIL +``` + +#### ouroboros ```shell -python3 test/main.py -j20 --timeout=120 +python3 test/main.py test/testsuite/ouroboros -j20 -pFAIL ``` 参数说明:指定参数会覆盖框架配置文件中的设置 @@ -183,19 +191,19 @@ ouroboros测试套是基于 `Java` 测试用例的测试套 运行ourobors下的子文件夹: -`python3 test/main.py test/testsuite/ouroboros/string_test -j20` +`python3 test/main.py test/testsuite/ouroboros/string_test --test_cfg=test/testsuite/ouroboros/test.cfg -j20` 运行ourobors下的单一测试用例: -`python3 test/main.py test/testsuite/ouroboros/string_test` +`python3 test/main.py test/testsuite/ouroboros/string_test/RT0001-rt-string-ReflectString/ReflectString.java --test_cfg=test/testsuite/ouroboros/test.cfg` 只输出失败用例: -`python3 test/main.py test/testsuite/ouroboros/ -j20 -pFAIL` +`python3 test/main.py test/testsuite/ouroboros/string_test/RT0001-rt-string-ReflectString/ReflectString.java --test_cfg=test/testsuite/ouroboros/test.cfg -pFAIL` 屏幕输出详细运行日至: -`python3 test/main.py test/testsuite/ouroboros/string_test -j20` +`python3 test/main.py test/testsuite/ouroboros/string_test/RT0001-rt-string-ReflectString/ReflectString.java --test_cfg=test/testsuite/ouroboros/test.cfg --verbose` ### 测试套配置 diff --git a/test/maple_test/configs.py b/test/maple_test/configs.py index 3cce3d61e0..52afa52769 100644 --- a/test/maple_test/configs.py +++ b/test/maple_test/configs.py @@ -169,10 +169,6 @@ def parse_args(): ) args = parser.parse_args() - if args.test_list and not args.test_cfg: - print("Error: When specify test list, need also specify test configure file\n") - parser.print_help() - sys.exit(0) test_framework_config = { "cfg": args.cfg, @@ -218,7 +214,7 @@ def parser_maple_test_config_file(maple_test_cfg_file): else: test_paths = [] test_suite_config = { - "test_paths": [BASE_DIR / path for path in test_paths if path], + "test_paths": [complete_path(BASE_DIR / path) for path in test_paths if path], } log_config = { "dir": complete_path( diff --git a/test/maple_test/maple_test.cfg b/test/maple_test/maple_test.cfg index 06848399cf..e2c0cab928 100644 --- a/test/maple_test/maple_test.cfg +++ b/test/maple_test/maple_test.cfg @@ -3,7 +3,6 @@ # 指定测试套路径,以‘:’划分 dir = ../testsuite/irbuild_test: - ../testsuite/ouroboros: [running] #指定运行时的临时路径 diff --git a/test/maple_test/task.py b/test/maple_test/task.py index bb62de23a7..cfc913038b 100644 --- a/test/maple_test/task.py +++ b/test/maple_test/task.py @@ -109,7 +109,7 @@ class TestSuiteTask: self.path = complete_path(test_path) self.cfg_path = cfg_path - + config = read_config(self.cfg_path) if config is None: raise TestError( @@ -144,9 +144,9 @@ class TestSuiteTask: ) top_dir = top_config.base_dir if user_test_list is None: - top_testlist = self._get_testlist(raw_top_config, top_dir) + top_testlist_path = self._get_testlist(raw_top_config, top_dir) else: - top_testlist = read_list(top_dir / user_test_list) + top_testlist_path = top_dir / user_test_list if user_config_set: run_config_set = user_config_set @@ -169,11 +169,14 @@ class TestSuiteTask: config = TaskConfig(cfg, raw_config, top_config, user_config, user_env) name = config.name base_dir = config.base_dir - testlist = self._get_testlist(raw_config, base_dir) + if cfg == self.cfg_path: + testlist_path = top_testlist_path + else: + testlist_path = self._get_testlist(raw_config, base_dir) self.task_set_result[name] = OrderedDict( {PASS: 0, FAIL: 0, NOT_RUN: 0, UNRESOLVED: 0} ) - for case in self._search_list(base_dir, testlist): + for case in self._search_list(base_dir, testlist_path): task = SingleTask(case, config, running_config) self.task_set[name].append(task) self.task_set_result[name][task.result[0]] += 1 @@ -189,16 +192,39 @@ class TestSuiteTask: testlist_path = base_dir / "testlist" else: testlist_path = base_dir / testlist_path - testlist = read_list(testlist_path) - return testlist + return testlist_path - def _search_list(self, base_dir, testlist): + def _search_list(self, base_dir, testlist_path): logger = configs.LOGGER suffixes = self.suffix_comments.keys() - include, exclude = testlist + include, exclude = read_list(testlist_path) case_files = set() cases = [] - case_files = self._search_case(include, exclude, base_dir, suffixes) + all_test_case, exclude_test_case = self._search_case( + include, exclude, base_dir, suffixes + ) + case_files = set() + for pattern in all_test_case: + _cases = all_test_case[pattern] + if _cases: + case_files.update(_cases) + else: + logger.info( + "Testlist: {}, ALL-TEST-CASE: {} is contain not test case".format( + testlist_path, pattern + ) + ) + for pattern in exclude_test_case: + _cases = exclude_test_case[pattern] + if _cases: + case_files -= _cases + else: + logger.info( + "Testlist: {}, EXCLUDE-TEST-CASE: {} is contain not test case".format( + testlist_path, pattern + ) + ) + if self.path.is_file(): case_files = [self.path] else: @@ -219,13 +245,19 @@ class TestSuiteTask: @staticmethod def _search_case(include, exclude, base_dir, suffixes): case_files = set() + all_test_case = {} + exclude_test_case = {} for glob_pattern in include: + all_test_case[glob_pattern] = set() for include_path in base_dir.glob(glob_pattern): case_files.update(ls_all(include_path, suffixes)) + all_test_case[glob_pattern].update(ls_all(include_path, suffixes)) for glob_pattern in exclude: + exclude_test_case[glob_pattern] = set() for exclude_path in base_dir.glob(glob_pattern): case_files -= set(ls_all(exclude_path, suffixes)) - return case_files + exclude_test_case[glob_pattern].update(ls_all(exclude_path, suffixes)) + return all_test_case, exclude_test_case def serial_run_task(self): for tasks_name in self.task_set: diff --git a/test/maple_test/test.py b/test/maple_test/test.py index 570dc585d4..fd853ec862 100644 --- a/test/maple_test/test.py +++ b/test/maple_test/test.py @@ -99,7 +99,7 @@ def extract_commands(comment_lines): def read_list(path): if not path.exists(): - return {"**"}, {} + return {"*"}, {} valid_lines, _ = split_comment("#", read_file(path)) include_flag = "[ALL-TEST-CASE]" exclude_flag = "[EXCLUDE-TEST-CASE]" @@ -116,5 +116,5 @@ def read_list(path): else: case_list.add(line) if not case_list: - case_list = {"**"} + case_list = {"*"} return case_list, exclude_case_list diff --git a/test/maple_test/utils.py b/test/maple_test/utils.py index 26f9cb0d8a..fa27c7f14a 100644 --- a/test/maple_test/utils.py +++ b/test/maple_test/utils.py @@ -71,7 +71,7 @@ def read_file(file_path): def read_config(file_path): """Read config file based on encoding and return test config""" - if not file_path.exists(): + if not file_path.exists() or not file_path.is_file(): return None config = configparser.ConfigParser() config.optionxform = str -- Gitee