From 20284c5f5e68649fd728fa499b8b7189a470613a Mon Sep 17 00:00:00 2001 From: yuyan0428 Date: Wed, 14 Dec 2022 08:11:46 +0000 Subject: [PATCH 1/4] Signed-off-by: yuyan0428 Signed-off-by: yuyan0428 --- src/core/command/run.py | 6 +++--- src/core/driver/drivers.py | 9 +------- src/core/testcase/testcase_manager.py | 31 +++++++++++++++++++++------ 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/core/command/run.py b/src/core/command/run.py index f1d6de9..35e27fe 100755 --- a/src/core/command/run.py +++ b/src/core/command/run.py @@ -226,11 +226,11 @@ class Run(object): if scheduler is None: LOG.error("Can not find the scheduler plugin.") else: + options.testcases_path = self.get_tests_out_path(options.productform) + options.resource_path = os.path.abspath(os.path.join( + sys.framework_root_dir, "..", "resource")) if is_lite_product(options.productform, sys.source_code_root_path): - options.testcases_path = options.target_outpath - options.resource_path = os.path.abspath(os.path.join( - sys.framework_root_dir, "..", "resource")) if options.productform.find("wifiiot") != -1: scheduler.update_test_type_in_source(".bin", DeviceTestType.ctest_lite) diff --git a/src/core/driver/drivers.py b/src/core/driver/drivers.py index 488dda5..3cd1c2a 100755 --- a/src/core/driver/drivers.py +++ b/src/core/driver/drivers.py @@ -753,14 +753,7 @@ class JSUnitTestDriver(IDriver): resource_manager = ResourceManager() resource_data_dic, resource_dir = resource_manager.get_resource_data_dic(suite_file) - if suffix_name == ".hap": - json_file_path = suite_file.replace(".hap", ".json") - if os.path.exists(json_file_path): - timeout = self._get_json_shell_timeout(json_file_path) - else: - timeout = ResourceManager.get_nodeattrib_data(resource_data_dic) - else: - timeout = ResourceManager.get_nodeattrib_data(resource_data_dic) + timeout = ResourceManager.get_nodeattrib_data(resource_data_dic) resource_manager.process_preparer_data(resource_data_dic, resource_dir, self.config.device) main_result = self._install_hap(suite_file) result = ResultManager(suite_file, self.config) diff --git a/src/core/testcase/testcase_manager.py b/src/core/testcase/testcase_manager.py index a95b73a..99a5914 100755 --- a/src/core/testcase/testcase_manager.py +++ b/src/core/testcase/testcase_manager.py @@ -120,7 +120,26 @@ class TestCaseManager(object): if suffix_name == ".dex": suite_file_dictionary.get("DEX").append(suite_file) elif suffix_name == ".hap": - suite_file_dictionary.get("JST").append(suite_file) + if self.get_hap_test_driver(suite_file) == "OHJSUnitTest": + # 如果stage测试指定了-tp,只有部件名与moduleInfo中part一致的HAP包才会加入最终执行的队列 + if options.testpart != [] and options.testpart[0] != self.get_part_name_test_file( + suite_file): + continue + # 如果stage测试指定了-ts,只有完全匹配的HAP包才会加入最终执行的队列 + if options.testsuit != "": + testsuit_list = options.testsuit.split(";") + is_match = False + for suite_item in testsuit_list: + if suite_item == prefix_name: + is_match = True + break + if not is_match: + continue + if not self.check_hap_test_file(suite_file): + continue + suite_file_dictionary.get("OHJST").append(suite_file) + if self.get_hap_test_driver(suite_file) == "JSUnitTest": + suite_file_dictionary.get("JST").append(suite_file) elif suffix_name == ".py": if not self.check_python_test_file(suite_file): continue @@ -225,11 +244,11 @@ class TestCaseManager(object): if "kits" in data_dic.keys(): kits_list = data_dic.get("kits") if len(kits_list) > 0: - kits_dict = kits_list[0] - if "test-file-name" in kits_dict.keys(): - return True - else: - return False + for kits_dict in kits_list: + if "test-file-name" not in kits_dict.keys(): + continue + else: + return True else: return False return False -- Gitee From 324e9647e61cd2f02f8650b2f58108ed999e2c38 Mon Sep 17 00:00:00 2001 From: yuyan0428 Date: Wed, 14 Dec 2022 09:48:20 +0000 Subject: [PATCH 2/4] Signed-off-by: yuyan0428 Signed-off-by: yuyan0428 --- README_zh.md | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/README_zh.md b/README_zh.md index 3b7f6c1..f3bb35a 100755 --- a/README_zh.md +++ b/README_zh.md @@ -484,6 +484,8 @@ subsystem # 子系统 > **说明:根据测试类型的不同,在具体编写过程中可选择不同的测试类型:** > - ohos_unittest:单元测试 + > - ohos_js_unittest: FA模型js用例单元测试 + > - ohos_js_stage_unittest: stage模型ets用例单元测试 > - ohos_moduletest:模块测试 > - ohos_systemtest:系统测试 > - ohos_performancetest:性能测试 @@ -501,7 +503,7 @@ subsystem # 子系统 ``` > **说明:** 进行条件分组的目的在于执行用例时可以选择性的执行某一种特定类型的用例。 -- **JavaScript用例编译配置示例** +- ** FA模型JavaScript用例编译配置示例** ``` # Copyright (C) 2021 XXXX Device Co., Ltd. @@ -634,6 +636,48 @@ subsystem # 子系统 ``` > **说明:** 进行条件分组的目的在于执行用例时可以选择性的执行某一种特定类型的用例。 +- ** stage模型ets用例编译配置示例** + + ``` + # Copyright (C) 2022 XXXX Device Co., Ltd. + + import("//build/test.gni") + + want_output_path = "developertest/stage_test" + + ohos_js_stage_unittest("ActsBundleMgrStageEtsTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actbmsstageetstest_js_assets", + ":actbmsstageetstest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsBundleMgrStageEtsTest" + subsystem_name = "developertest" + part_name = "stage_test" // 部件名称 + module_out_path = want_output_path // 必须定义输出路径 + } + ohos_app_scope("actbmsstageetstest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] + } + ohos_js_assets("actbmsstageetstest_js_assets") { + source_dir = "entry/src/main/ets" + } + ohos_resources("actbmsstageetstest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actbmsstageetstest_app_profile" ] + hap_profile = "entry/src/main/module.json" + } + group("unittest") { + testonly = true + deps = [] + deps += [ ":ActsBundleMgrStageEtsTest" ] + } + ``` + > **说明:** 进行条件分组的目的在于执行用例时可以选择性的执行某一种特定类型的用例。 + **Fuzz测试** [Fuzz编译文件编写规范](https://gitee.com/openharmony/test_developertest/blob/master/libs/fuzzlib/README_zh.md) -- Gitee From ce6299197c010d3752922d194396239caa77f1ec Mon Sep 17 00:00:00 2001 From: yuyan0428 Date: Mon, 19 Dec 2022 03:12:05 +0000 Subject: [PATCH 3/4] Signed-off-by: yuyan0428 Signed-off-by: yuyan0428 --- examples/detector/src/detector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/detector/src/detector.cpp b/examples/detector/src/detector.cpp index a354fff..b581a5d 100644 --- a/examples/detector/src/detector.cpp +++ b/examples/detector/src/detector.cpp @@ -26,7 +26,7 @@ namespace DetectorTest { const int START_INDEX = 3; } -namespace{ +namespace { bool IsPrime(int n) { if (n <= 1) { -- Gitee From 201a045d6c89dab8c3330ce95107c13abe0b6e19 Mon Sep 17 00:00:00 2001 From: yuyan0428 Date: Tue, 20 Dec 2022 06:35:08 +0000 Subject: [PATCH 4/4] Signed-off-by: yuyan0428 Signed-off-by: yuyan0428 --- src/core/driver/drivers.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core/driver/drivers.py b/src/core/driver/drivers.py index 3cd1c2a..bb2da3d 100755 --- a/src/core/driver/drivers.py +++ b/src/core/driver/drivers.py @@ -753,7 +753,14 @@ class JSUnitTestDriver(IDriver): resource_manager = ResourceManager() resource_data_dic, resource_dir = resource_manager.get_resource_data_dic(suite_file) - timeout = ResourceManager.get_nodeattrib_data(resource_data_dic) + if suffix_name == ".hap": + json_file_path = suite_file.replace(".hap", ".json") + if os.path.exists(json_file_path): + timeout = self._get_json_shell_timeout(json_file_path) + else: + timeout = ResourceManager.get_nodeattrib_data(resource_data_dic) + else: + timeout = ResourceManager.get_nodeattrib_data(resource_data_dic) resource_manager.process_preparer_data(resource_data_dic, resource_dir, self.config.device) main_result = self._install_hap(suite_file) result = ResultManager(suite_file, self.config) @@ -920,6 +927,8 @@ class JSUnitTestDriver(IDriver): driver_dict = data_dic.get("driver") if driver_dict and "test-timeout" in driver_dict.keys(): test_timeout = int(driver_dict["shell-timeout"]) / 1000 + else: + return return test_timeout except JSONDecodeError: return test_timeout -- Gitee