From 2f7fe81b9826726b8fe6e5aa0972e4ac103b6019 Mon Sep 17 00:00:00 2001 From: dongwei Date: Wed, 17 Aug 2022 18:23:33 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E5=A4=84=E7=90=86=20OHJS=E6=9C=AC=E5=9C=B0=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dongwei --- src/core/command/console.py | 2 ++ src/core/command/run.py | 2 ++ src/core/testcase/testcase_manager.py | 34 ++++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/core/command/console.py b/src/core/command/console.py index 7ae9ff5..14bba2e 100755 --- a/src/core/command/console.py +++ b/src/core/command/console.py @@ -389,6 +389,7 @@ class Console(object): product_form) return build_result + @dataclass class ConfigConst(object): action = "action" @@ -431,5 +432,6 @@ class ConfigConst(object): component_base_kit = "component_base_kit" support_component = "support_component" + ############################################################################## ############################################################################## diff --git a/src/core/command/run.py b/src/core/command/run.py index 56fc47d..ba3d8c4 100755 --- a/src/core/command/run.py +++ b/src/core/command/run.py @@ -159,6 +159,8 @@ class Run(object): DeviceTestType.ctest_lite) else: print("productform is not wifiiot") + options.testcases_path = self.get_acts_tests_out_path(options.productform) + options.resource_path = self.get_acts_tests_out_path(options.productform) scheduler.exec_command(command, options) return diff --git a/src/core/testcase/testcase_manager.py b/src/core/testcase/testcase_manager.py index 6569245..1cbe096 100755 --- a/src/core/testcase/testcase_manager.py +++ b/src/core/testcase/testcase_manager.py @@ -36,6 +36,7 @@ TESTFILE_TYPE_DATA_DIC = { "PYT": [], "CXX": [], "BIN": [], + "OHJST": [], "JST": [], } FILTER_SUFFIX_NAME_LIST = [".TOC", ".info", ".pyc"] @@ -150,9 +151,18 @@ class TestCaseManager(object): continue if not self.check_hap_test_file(acts_suite_file): continue - acts_suit_file_dic["JST"].append(acts_suite_file) + if not self.get_hap_test_driver(acts_suite_file): + continue + if self.get_hap_test_driver(acts_suite_file) == "OHJSUnitTest": + acts_suit_file_dic["OHJST"].append(acts_suite_file) + print(" acts_suit_file_dic['OHJST'] :%s" % acts_suit_file_dic["OHJST"]) + if self.get_hap_test_driver(acts_suite_file) == "JSUnitTest": + acts_suit_file_dic["JST"].append(acts_suite_file) + else: LOG.error("acts %s is not exist." % acts_test_case_path) + + print(" acts_suit_file_dic :%s" % acts_suit_file_dic) return acts_suit_file_dic @classmethod @@ -229,6 +239,28 @@ class TestCaseManager(object): finally: print(" check hap test file finally") + @classmethod + def get_hap_test_driver(cls, hap_file_path): + if hap_file_path.endswith(".hap"): + json_file_path = hap_file_path.replace(".hap", ".json") + if os.path.exists(json_file_path): + with open(json_file_path, 'r') as json_file: + data_dic = json.load(json_file) + if not data_dic: + return False + else: + if "driver" in data_dic.keys(): + driver_dict = data_dic.get("driver") + if bool(driver_dict): + driver_type = driver_dict.get("type") + return driver_type + else: + LOG.error("%s has not set driver." % hap_file_path) + else: + return False + else: + return False + @classmethod def get_part_name_test_file(cls, hap_file_path): if hap_file_path.endswith(".hap"): -- Gitee From 356e48ca8a171ae17c50ebfdd50d0211720367d8 Mon Sep 17 00:00:00 2001 From: dongwei Date: Thu, 18 Aug 2022 09:34:19 +0800 Subject: [PATCH 2/5] code check Signed-off-by: dongwei --- src/core/testcase/testcase_manager.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/core/testcase/testcase_manager.py b/src/core/testcase/testcase_manager.py index 1cbe096..f5a813c 100755 --- a/src/core/testcase/testcase_manager.py +++ b/src/core/testcase/testcase_manager.py @@ -155,14 +155,10 @@ class TestCaseManager(object): continue if self.get_hap_test_driver(acts_suite_file) == "OHJSUnitTest": acts_suit_file_dic["OHJST"].append(acts_suite_file) - print(" acts_suit_file_dic['OHJST'] :%s" % acts_suit_file_dic["OHJST"]) if self.get_hap_test_driver(acts_suite_file) == "JSUnitTest": acts_suit_file_dic["JST"].append(acts_suite_file) - else: LOG.error("acts %s is not exist." % acts_test_case_path) - - print(" acts_suit_file_dic :%s" % acts_suit_file_dic) return acts_suit_file_dic @classmethod -- Gitee From d986e5a4e5cccf7389c81bf7a963a37528d87ec0 Mon Sep 17 00:00:00 2001 From: dongwei Date: Thu, 18 Aug 2022 16:54:37 +0800 Subject: [PATCH 3/5] code check Signed-off-by: dongwei --- src/core/build/build_testcases.py | 4 +-- src/core/command/console.py | 2 +- src/core/command/run.py | 4 +-- src/core/driver/drivers.py | 2 +- src/core/testcase/testcase_manager.py | 52 ++++++++++++--------------- 5 files changed, 28 insertions(+), 36 deletions(-) diff --git a/src/core/build/build_testcases.py b/src/core/build/build_testcases.py index 560ebb1..895f439 100755 --- a/src/core/build/build_testcases.py +++ b/src/core/build/build_testcases.py @@ -210,9 +210,7 @@ class BuildTestcases(object): if len(para.subsystem) > 0: input_subsystem = ",".join(para.subsystem) acts_build_command.append(BUILD_TARGET_SUBSYSTEM % input_subsystem) - if para.testsuit != "" and len(para.subsystem) > 0: - acts_build_command.append(BUILD_TARGET_SUITE % para.testsuit) - elif para.testsuit != "" and len(para.subsystem) == 0: + if para.testsuit != "" and len(para.subsystem) == 0: LOG.error("Please specify subsystem.") return if os.path.exists(BUILD_FILEPATH): diff --git a/src/core/command/console.py b/src/core/command/console.py index 14bba2e..87efd62 100755 --- a/src/core/command/console.py +++ b/src/core/command/console.py @@ -312,7 +312,6 @@ class Console(object): return parse_result - @classmethod def _process_command_help(cls, para_list): if para_list[0] == ToolCommandType.TOOLCMD_KEY_HELP: @@ -337,6 +336,7 @@ class Console(object): LOG.error("Wrong gen command.") return + # run命令执行入口 @classmethod def _process_command_run(cls, command, options): diff --git a/src/core/command/run.py b/src/core/command/run.py index ba3d8c4..f791475 100755 --- a/src/core/command/run.py +++ b/src/core/command/run.py @@ -80,6 +80,8 @@ class Run(object): if "actstest" in options.testtype: test_dict = self.get_acts_test_dict(options) + options.testcases_path = self.get_acts_tests_out_path(options.productform) + options.resource_path = self.get_acts_tests_out_path(options.productform) else: test_dict = self.get_test_dict(options) @@ -159,8 +161,6 @@ class Run(object): DeviceTestType.ctest_lite) else: print("productform is not wifiiot") - options.testcases_path = self.get_acts_tests_out_path(options.productform) - options.resource_path = self.get_acts_tests_out_path(options.productform) scheduler.exec_command(command, options) return diff --git a/src/core/driver/drivers.py b/src/core/driver/drivers.py index b2ed169..fb2221a 100755 --- a/src/core/driver/drivers.py +++ b/src/core/driver/drivers.py @@ -606,7 +606,7 @@ class CppTestDriver(IDriver): ############################################################################## ############################################################################## -@Plugin(type=Plugin.DRIVER, id=DeviceTestType.jsunit_test) +#@Plugin(type=Plugin.DRIVER, id=DeviceTestType.jsunit_test) class JSUnitTestDriver(IDriver): """ JSUnitTestDriver is a Test that runs a native test package on given device. diff --git a/src/core/testcase/testcase_manager.py b/src/core/testcase/testcase_manager.py index f5a813c..ae39971 100755 --- a/src/core/testcase/testcase_manager.py +++ b/src/core/testcase/testcase_manager.py @@ -151,10 +151,9 @@ class TestCaseManager(object): continue if not self.check_hap_test_file(acts_suite_file): continue - if not self.get_hap_test_driver(acts_suite_file): - continue if self.get_hap_test_driver(acts_suite_file) == "OHJSUnitTest": acts_suit_file_dic["OHJST"].append(acts_suite_file) + print("acts_suit_file_dic[‘OHJST’] :%s " % acts_suit_file_dic["OHJST"]) if self.get_hap_test_driver(acts_suite_file) == "JSUnitTest": acts_suit_file_dic["JST"].append(acts_suite_file) else: @@ -237,38 +236,33 @@ class TestCaseManager(object): @classmethod def get_hap_test_driver(cls, hap_file_path): + data_dic = cls.get_hap_json(hap_file_path) + if not data_dic: + return False + else: + if "driver" in data_dic.keys(): + driver_dict = data_dic.get("driver") + if bool(driver_dict): + driver_type = driver_dict.get("type") + return driver_type + else: + LOG.error("%s has not set driver." % hap_file_path) + + @classmethod + def get_hap_json(cls, hap_file_path): if hap_file_path.endswith(".hap"): json_file_path = hap_file_path.replace(".hap", ".json") if os.path.exists(json_file_path): with open(json_file_path, 'r') as json_file: data_dic = json.load(json_file) - if not data_dic: - return False - else: - if "driver" in data_dic.keys(): - driver_dict = data_dic.get("driver") - if bool(driver_dict): - driver_type = driver_dict.get("type") - return driver_type - else: - LOG.error("%s has not set driver." % hap_file_path) - else: - return False - else: - return False + return data_dic @classmethod def get_part_name_test_file(cls, hap_file_path): - if hap_file_path.endswith(".hap"): - module_info_file_path = hap_file_path.replace(".hap", ".moduleInfo") - if os.path.exists(module_info_file_path): - with open(module_info_file_path, 'r') as json_file: - data_dic = json.load(json_file) - if not data_dic: - return False - else: - if "part" in data_dic.keys(): - part_name = data_dic["part"] - return part_name - else: - return "space" \ No newline at end of file + data_dic = cls.get_hap_json(hap_file_path) + if not data_dic: + return False + else: + if "part" in data_dic.keys(): + part_name = data_dic["part"] + return part_name \ No newline at end of file -- Gitee From e08f9e060415c9f44cdd1a6e4ed8514cb0b93348 Mon Sep 17 00:00:00 2001 From: dongwei Date: Thu, 18 Aug 2022 17:45:27 +0800 Subject: [PATCH 4/5] code check Signed-off-by: dongwei --- src/core/testcase/testcase_manager.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/core/testcase/testcase_manager.py b/src/core/testcase/testcase_manager.py index ae39971..a23de04 100755 --- a/src/core/testcase/testcase_manager.py +++ b/src/core/testcase/testcase_manager.py @@ -153,7 +153,6 @@ class TestCaseManager(object): continue if self.get_hap_test_driver(acts_suite_file) == "OHJSUnitTest": acts_suit_file_dic["OHJST"].append(acts_suite_file) - print("acts_suit_file_dic[‘OHJST’] :%s " % acts_suit_file_dic["OHJST"]) if self.get_hap_test_driver(acts_suite_file) == "JSUnitTest": acts_suit_file_dic["JST"].append(acts_suite_file) else: @@ -197,7 +196,6 @@ class TestCaseManager(object): break return is_valid_status - @classmethod def check_python_test_file(cls, suite_file): if suite_file.endswith(".py"): @@ -206,7 +204,6 @@ class TestCaseManager(object): return True return False - @classmethod def check_hap_test_file(cls, hap_file_path): try: -- Gitee From 97113bcbf2abc73152bf9e6b738175ab1073f11a Mon Sep 17 00:00:00 2001 From: dongwei Date: Fri, 19 Aug 2022 11:05:43 +0800 Subject: [PATCH 5/5] code check Signed-off-by: dongwei --- src/core/build/build_testcases.py | 3 +++ src/core/command/console.py | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/build/build_testcases.py b/src/core/build/build_testcases.py index 895f439..73cc1d0 100755 --- a/src/core/build/build_testcases.py +++ b/src/core/build/build_testcases.py @@ -22,6 +22,8 @@ import json import shutil import subprocess import platform +import time + from xdevice import platform_logger from core.utils import get_build_output_path from core.utils import scan_support_product @@ -257,6 +259,7 @@ class BuildTestcases(object): # 编译ACTS测试用例 def build_acts_testcases(self, para): self._delete_acts_testcase_dir(para.productform) + time.sleep(5) build_result = self._execute_build_acts_command(para) return build_result diff --git a/src/core/command/console.py b/src/core/command/console.py index 87efd62..f9e6189 100755 --- a/src/core/command/console.py +++ b/src/core/command/console.py @@ -336,8 +336,6 @@ class Console(object): LOG.error("Wrong gen command.") return - - # run命令执行入口 @classmethod def _process_command_run(cls, command, options): if command == ToolCommandType.TOOLCMD_KEY_RUN: -- Gitee