diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0200.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0200.json new file mode 100644 index 0000000000000000000000000000000000000000..c28c0b1020217455c6c17388fcf73410d5b347c7 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0200.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0200.py new file mode 100644 index 0000000000000000000000000000000000000000..1266a25f027ae025f9e65bb8bc7d1aef4cb9c62f --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0200.py @@ -0,0 +1,118 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_0200(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.native_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample1" + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # hnp进程安装传参校验 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("执行./hnp install") + result = self.driver.shell( + f"{self.hnp_commamd} install") + self.driver.Assert.contains(result, "native manager process exit. ret=8392706") + self.driver.Assert.contains(result, "[ERROR][HNP]hnp install params invalid,uid[(null)],hnp src path[(null)], package name[(null)]") + + Step("执行./hnp install -u 300, 只传userId") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8392706 ") + + Step("执行./hnp install -p baidu, 只传应用软件名") + result = self.driver.shell( + f"{self.hnp_commamd} install -p baidu") + self.driver.Assert.contains(result, + "[ERROR][HNP]hnp install params invalid,uid[(null)]," + "hnp src path[(null)], package name[baidu]") + + Step("执行./hnp install -i hnppath, 只传安装路径") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path}/public/ -n hnp_test1 -v 1.3") + self.driver.Assert.contains(result, "linkNum=0, ret=0") + result = self.driver.shell(f"find {self.pack_out_path}/public/ -name hnp_test1.hnp") + self.driver.Assert.contains(result, f"{self.pack_out_path}/public/hnp_test1.hnp") + + result = self.driver.shell( + f"{self.hnp_commamd} install -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[ERROR][HNP]hnp install params invalid," + "uid[(null)],hnp src path[/data/hnp_test/pack_output], " + "package name[(null)]") + + Step("执行./hnp install -f, 只传-f") + result = self.driver.shell( + f"{self.hnp_commamd} install -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8392706") + + Step("执行./hnp uninstall") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall") + self.driver.Assert.contains(result, + "[ERROR][HNP]hnp uninstall params invalid uid[(null)], package name[(null)]") + + Step("执行./hnp pack") + result = self.driver.shell( + f"{self.hnp_commamd} pack") + self.driver.Assert.contains(result, "[ERROR][HNP]invalid cmd!. cmd:pack") + + Step("执行./hnp help") + result = self.driver.shell( + f"{self.hnp_commamd} help") + self.driver.Assert.contains(result, "install: install one hap package") + self.driver.Assert.contains(result, "uninstall: uninstall one hap package") + + Step("执行./hnp -h") + result = self.driver.shell( + f"{self.hnp_commamd} -h") + self.driver.Assert.contains(result, "install: install one hap package") + self.driver.Assert.contains(result, "uninstall: uninstall one hap package") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0300.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0300.json new file mode 100644 index 0000000000000000000000000000000000000000..ae2157266e00179e47c53fcf95e8d68e40ebc4dc --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0300.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0300.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0300.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0300.py new file mode 100644 index 0000000000000000000000000000000000000000..654cbdefb0afd1a616ef3cfcfe2e1b890b26cb7c --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0300.py @@ -0,0 +1,110 @@ +# -*- coding: utf-8 -*- +import os +from aw import Common +from hypium import * +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_0300(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.native_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute" + self.hnp_public_dir = "hnppublic/bin" + self.hnp_private_dir = "hnp/baidu/bin" + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # hnp进程安装,hnp包路径异常场景 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("安装软件包时,hnp包路径不存在") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i /data/empty_path/ -f") + self.driver.Assert.contains(result, "[ERROR][HNP]hnp install opendir:/data/empty_path/ unsuccess, errno=2") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8392968") + + Step("安装软件包时,hnp包路径长度等于4096") + dir_temp = "/data/" + Common.randomGenerateStingByLen(4090) + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {dir_temp} -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8392968") + + Step("安装软件包时,hnp包路径长度大于4096") + dir_temp = "/data/" + Common.randomGenerateStingByLen(4096) + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {dir_temp} -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8392968") + + Step("安装软件包时,hnp包路径中存在非法字符") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i /data/empty**#…………_path/ -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8392968") + + Step("安装软件包时,安装路径为空文件夹") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0 ") + + Step("安装软件包时没有公有或者私有数据文件夹") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path} -n compute -v 1.3") + self.driver.Assert.contains(result, "linkNum=0, ret=0") + result = self.driver.shell(f"find {self.pack_out_path} -name compute.hnp") + self.driver.Assert.contains(result, f"{self.pack_out_path}/compute.hnp") + + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0 ") + + Step("验证软链接是否生效") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/add 2") + self.driver.Assert.contains(result, "add: inaccessible or not found") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_private_dir}/add 2") + self.driver.Assert.contains(result, "add: inaccessible or not found") + + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0400.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0400.json new file mode 100644 index 0000000000000000000000000000000000000000..e96ab6d372dbdb0ec55372412958bc20eb146520 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0400.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0400.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0400.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0400.py new file mode 100644 index 0000000000000000000000000000000000000000..5175f9fc5483077750e2d4fa6821eb86c9ff9be2 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0400.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_0400(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.native_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute" + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # hnp进程安装,保存路径异常场景 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("将compute工具进行打包") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path}/public -n compute -v 1.0") + self.driver.Assert.contains(result, "linkNum=0, ret=0") + + Step("保存路径不存在") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 301 -i {self.pack_out_path} -p baidu -f") + self.driver.Assert.contains(result, "hnp install uid path[/data/app/el1/bundle/301] is not exist") + + Step("usrId为字符串") + result = self.driver.shell( + f"{self.hnp_commamd} install -u string -i {self.pack_out_path} -p baidu -f") + self.driver.Assert.contains(result, "[ERROR][HNP]hnp install arg uid[string] invalid") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0500.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0500.json new file mode 100644 index 0000000000000000000000000000000000000000..8644760c1e90db6844f62b4ea46110c5493eadd6 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0500.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0500.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0500.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0500.py new file mode 100644 index 0000000000000000000000000000000000000000..bacbacef3d5bb129b95efe1876c4af89d40e2d16 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0500.py @@ -0,0 +1,76 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_0500(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output/" + self.native_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + # 安装用户usrId = 0的场景 & 安装工具为1个的场景 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("将compute工具进行打包") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path}/public -n compute -v 1.0") + self.driver.Assert.contains(result, "linkNum=0, ret=0") + + Step("安装软件时usrId为0") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 0 -p baidu -i {self.pack_out_path} -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0 ") + + Step("校验安装工具生效") + result = self.driver.shell( + f"./{self.default_install_root_path}/0/{self.hnp_public_dir}/add") + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + else: + pass + + Step("卸载安装的工具") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 0 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0 ") + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0600.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0600.json new file mode 100644 index 0000000000000000000000000000000000000000..1851ea5da63b6adc14b13754c4cbf3f1da4472b0 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0600.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0600.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0600.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0600.py new file mode 100644 index 0000000000000000000000000000000000000000..a7fdcfd90fd5d396984f1af52408a151df744d99 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0600.py @@ -0,0 +1,101 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_0600(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/printfHello"] + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 安装目录下存在多个hnp包测试 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("打包两个工具 compute & printfHello") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}/public -n compute -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[1]} -o {self.pack_out_path}/public -n printfHello -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("批量安装compute、printfHello工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0 ") + + Step("验证软链接是否生效") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/del") + self.driver.Assert.contains(result, "End: 1 - 1 = 0") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/add") + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/multiplication") + self.driver.Assert.contains(result, "End: 1 * 1 = 1") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/printfHello 2") + self.driver.Assert.contains(result, "****************hello**************") + + Step("卸载安装的工具") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "hnp uninstall end! ret=0") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/printfHello 2") + self.driver.Assert.contains(result, "printfHello: inaccessible or not found") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0700.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0700.json new file mode 100644 index 0000000000000000000000000000000000000000..68b5aae019e4abd4e769dc240664e6d98541fe64 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0700.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0700.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0700.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0700.py new file mode 100644 index 0000000000000000000000000000000000000000..f8511464ba4869c01bcd15386fd76fe2799a0b2a --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0700.py @@ -0,0 +1,94 @@ +''' +#!!================================================================ +#版权 (C) 2024, Huawei Technologies Co., HUTAF xDevice +#================================================================== +#文 件 名: sub_startup_appspawn_nativeinstall_0700.py +#文件说明: +#作 者: zhangjingjing +#生成日期: 2024-04-09 +#!!================================================================ +''' + +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_0700(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.native_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/native/printfHello" + self.hnp_public_dir = "hnppublic/bin" + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 打包文件未设置软链接路径,安装hnp包时可执行文件在非bin目录下场景 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建一个空目录temp_dir,该目录下存在一个二进制文件printfHello") + self.driver.shell(f"mkdir {self.work_space_path}/temp_dir/") + self.driver.shell(f"cp {self.native_path}/bin/* {self.work_space_path}/temp_dir/") + + Step("打包temp_dir为test.hnp包") + result = self.driver.shell(f"{self.hnpcli_commamd} pack -i {self.work_space_path}/temp_dir/ " + f"-o {self.pack_out_path}/public -n test -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("安装test.hnp") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}/ -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0 ") + + Step("验证软链接是否生效") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/printfHello 2") + self.driver.Assert.contains(result, "printfHello: inaccessible or not found") + + Step("验证是否存在test.org") + result = self.driver.shell(f"find {self.default_install_root_path}/300/hnppublic -name test.org") + self.driver.Assert.contains(result, "test.org") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0800.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0800.json new file mode 100644 index 0000000000000000000000000000000000000000..9505242d54ac7c458978d72d07b89546e91c7dde --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0800.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0800.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0800.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0800.py new file mode 100644 index 0000000000000000000000000000000000000000..abe39a5efd4df23abf61ea92f279842c19bc2102 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0800.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_0800(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/printfHello"] + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 打包文件未设置软链接路径,安装hnp包时可执行文件在bin目录,且bin目录下同时存在一个bin目录,第二个bin目录下存在二进制的测试场景 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建一个temp_dir目录,创建bin/bin目录,bin目录下分别存在一个二进制") + self.driver.shell(f"mkdir {self.work_space_path}/temp_dir/") + self.driver.shell(f"mkdir {self.work_space_path}/temp_dir/bin/") + self.driver.shell(f"mkdir {self.work_space_path}/temp_dir/bin/bin/") + self.driver.shell(f"cp {self.native_path[1]}/bin/printfHello {self.work_space_path}/temp_dir/bin") + self.driver.shell(f"cp {self.native_path[0]}/bin/add {self.work_space_path}/temp_dir/bin/bin") + + Step("打包该native文件为test.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.work_space_path}/temp_dir/ -o " + f"{self.pack_out_path}/public -n test -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("强制安装test.hnp") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path} -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0 ") + + Step("校验bin/printfHello工具生效,bin/bin/add未生效") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/printfHello 2") + self.driver.Assert.contains(result, "****************hello**************") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/add") + self.driver.Assert.contains(result, "add: inaccessible or not found") + + Step("卸载安装的工具") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("清除安装内容") + self.driver.shell(f"rm -rf {self.work_space_path}/temp_dir/") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0900.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0900.json new file mode 100644 index 0000000000000000000000000000000000000000..72489f76eaec9af3253cfdebdaf22fc69b57fa93 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0900.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0900.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0900.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0900.py new file mode 100644 index 0000000000000000000000000000000000000000..98336c841898d8fc34fbde693bcd235107702d60 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_0900.py @@ -0,0 +1,93 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_0900(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 打包文件未设置软链接路径,安装hnp包时可执行文件在bin目录,且bin目录下仅存在一个文件夹 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建一个temp_dir目录,创建bin/test目录") + self.driver.shell(f"mkdir {self.work_space_path}/temp_dir/") + self.driver.shell(f"mkdir {self.work_space_path}/temp_dir/bin/") + self.driver.shell(f"mkdir {self.work_space_path}/temp_dir/bin/test/") + + Step("打包该native文件为test.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.work_space_path}/temp_dir/ " + f"-o {self.pack_out_path}/public -n test -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("强制安装test.hnp") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path} -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0 ") + + Step("验证是否存在test.org") + result = self.driver.shell(f"find {self.default_install_root_path}/300/hnppublic -name test.org") + self.driver.Assert.contains(result, "test.org") + + result = self.driver.shell(f"find {self.default_install_root_path}/300/hnppublic -name bin") + self.driver.Assert.contains(result, "bin") + + Step("验证bin目录下是否存在test文件夹") + result = self.driver.shell(f"find {self.default_install_root_path}/300/hnppublic/bin -name test") + assert ("test" not in result) == True + + Step("清除安装内容") + self.driver.shell(f"rm -rf {self.work_space_path}/temp_dir/") + + Step("卸载安装的工具") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0 ") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1000.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1000.json new file mode 100644 index 0000000000000000000000000000000000000000..23815cee566c36c0b1f3465a168a5c49501f9ec3 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1000.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1000.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1000.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1000.py new file mode 100644 index 0000000000000000000000000000000000000000..6670f46bd9beec78d5fcfe682aecbd70cbe47b2b --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1000.py @@ -0,0 +1,83 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_1000(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/private') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 需要安装的hnp为空文件 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建一个空文件夹empty_dir") + self.driver.shell(f"mkdir {self.work_space_path}/empty_dir/") + + Step("打包该native文件为test.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.work_space_path}/empty_dir/ " + f"-o {self.pack_out_path}/private -n empty -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("强制安装test.hnp") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path} -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0 ") + + Step("验证是否存在test.org") + result = self.driver.shell(f"find {self.default_install_root_path}/300/hnp/baidu -name empty.org") + self.driver.Assert.contains(result, "empty.org") + + Step("卸载安装的工具") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0 ") + + self.driver.shell(f"rm -rf {self.work_space_path}/empty_dir/") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1100.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1100.json new file mode 100644 index 0000000000000000000000000000000000000000..0de1dfd7f634a12f92720ec82d4c083b494008aa --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1100.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1100.py new file mode 100644 index 0000000000000000000000000000000000000000..d2d1b96eab664d83651341eb7a25a6ad98946313 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1100.py @@ -0,0 +1,88 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_1100(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.native_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample1" + self.hnp_public_dir = "hnppublic/bin" + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/private') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 安装单个hnp中存在0软链接 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("打包的sample1包为sample1.hnp,该native包中bin文件下为非可执行文件") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path}/private -n sample1 -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("强制安装sample1.hnp") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path} -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("验证是否存在sample1.org") + result = self.driver.shell(f"find {self.default_install_root_path}/300/hnp/baidu -name sample1.org") + self.driver.Assert.contains(result, "sample1.org") + + Step("验证hnp/baidu/bin目录下是否存在sample.txt") + result = self.driver.shell( + f"find {self.default_install_root_path}/300/hnp/baidu/bin -name sample.txt") + self.driver.Assert.contains(result, "sample.txt") + + Step("卸载安装的工具") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0 ") + + result = self.driver.shell( + f"find {self.default_install_root_path}/300/hnp/baidu/bin -name sample.txt") + self.driver.Assert.contains(result, "No such file or directory") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1200.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1200.json new file mode 100644 index 0000000000000000000000000000000000000000..7b69394bcfd1ddbeb7d0a332dc5c980d48ebd77d --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1200.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1200.py new file mode 100644 index 0000000000000000000000000000000000000000..27db898ebb307607c0b0c90671fc4a7f83f2e2fd --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1200.py @@ -0,0 +1,93 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common + + +class sub_startup_appspawn_nativeinstall_1200(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample1" + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 安装单个hnp中存在1个软链接,软链接文件非可执行文件 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建配置文件,存在一个软链接,软链接类型.txt文件") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/sample.txt" + hnp_cfg_data['install']['links'][0]["target"] = "sample" + hnp_cfg_data['name'] = "sample" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path) + + Step("打包sample1.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("强制安装sample1.hnp") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path} -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("验证hnp/hnppublic/bin目录下是否存在sample") + result = self.driver.shell(f"find {self.default_install_root_path}/300/{self.hnp_public_dir} -name sample") + self.driver.Assert.contains(result, f"sample") + + Step("卸载安装的工具") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0 ") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1300.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1300.json new file mode 100644 index 0000000000000000000000000000000000000000..853810f154db4823b23d3894dbc7f03c3815b837 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1300.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1300.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1300.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1300.py new file mode 100644 index 0000000000000000000000000000000000000000..722557b10f7122d6e4572ade014255d51de20a83 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1300.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common + + +class sub_startup_appspawn_nativeinstall_1300(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/native/printfSymbol" + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 安装单个hnp中存在1个软链接,软链接文件为文件夹 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建配置文件,存在一个软链接,软链接为文件夹") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin" + hnp_cfg_data['install']['links'][0]["target"] = "printfSymbol_bin" + hnp_cfg_data['name'] = "printfSymbol_bin" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path) + + Step("打包printfSymbol_bin.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("强制安装printfSymbol_bin.hnp") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path} -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("校验安装printfSymbol_bin.hnp是否成功,是否存在printfSymbol_bin软链") + result = self.driver.shell(f"find {self.default_install_root_path}/300/{self.hnp_public_dir} " + f"-name printfSymbol_bin") + self.driver.Assert.contains(result, "printfSymbol_bin") + + Step("卸载安装的工具") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1400.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1400.json new file mode 100644 index 0000000000000000000000000000000000000000..994592e791f058e0a183e1e85622e4e85d519218 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1400.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1400.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1400.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1400.py new file mode 100644 index 0000000000000000000000000000000000000000..ef61a7f95a628d1c78517cba77dcacd083f7bf91 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1400.py @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common + + +class sub_startup_appspawn_nativeinstall_1400(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute" + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 安装单个hnp中存在1个软链接,软链接文件为一个bin文件 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建配置文件,存在一个软链接,软链接路径指向其中一个bin文件") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/add" + hnp_cfg_data['install']['links'][0]["target"] = "add" + hnp_cfg_data['name'] = "add" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path) + + Step("打包add.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("强制安装add.hnp") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path} -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("验证软链接是否生效") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/add") + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/del") + self.driver.Assert.contains(result, "del: inaccessible or not found") + + Step("卸载安装的工具") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1500.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1500.json new file mode 100644 index 0000000000000000000000000000000000000000..c789b15665e977828f268fcd62064855f04b81d3 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1500.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1500.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1500.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1500.py new file mode 100644 index 0000000000000000000000000000000000000000..39a23e44d0a8477de847488a3a70ca4220141b3d --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1500.py @@ -0,0 +1,100 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common + + +class sub_startup_appspawn_nativeinstall_1500(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute" + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 安装单个hnp中存在2软链接,全部指向存在文件 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建配置文件,hnp中存在3个bin文件,2个软链接,软链接路径分别指向其中bin文件") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/add" + hnp_cfg_data['install']['links'][0]["target"] = "add" + hnp_cfg_data['install']['links'].append({"source": "bin/del", "target": "del"}) + hnp_cfg_data['name'] = "compute" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path) + + Step("打包compute.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path}/public " + f"-cfg {self.work_space_path}/compute.json") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("强制安装compute.hnp") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path} -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("验证安装compute.hnp是否成功,软链接是否可执行") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/add") + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/del") + self.driver.Assert.contains(result, "End: 1 - 1 = 0") + + Step("卸载安装的工具") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1600.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1600.json new file mode 100644 index 0000000000000000000000000000000000000000..98093ce158edd7d59eaa26a0e017bd956db41512 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1600.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1600.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1600.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1600.py new file mode 100644 index 0000000000000000000000000000000000000000..99b9a0f59dfcfdd0eec1a93adf86053fb15f2fcd --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1600.py @@ -0,0 +1,138 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common + + +class sub_startup_appspawn_nativeinstall_1600(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/readCfgFile", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/printfSymbol"] + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 执行安装包下存在3个hnp包,全部包含软链接 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建compute工具配置文件,存在3个bin文件,3个软链接,软链接路径分别指向其中bin文件") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/add" + hnp_cfg_data['install']['links'][0]["target"] = "add" + hnp_cfg_data['install']['links'].append({"source": "bin/del", "target": "del"}) + hnp_cfg_data['install']['links'].append({"source": "bin/multiplication", "target": "multiplication"}) + hnp_cfg_data['name'] = "compute" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0]) + + Step("创建readCfgFile工具配置文件,存在1个bin文件,1个软链接,软链接路径指向bin文件") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/readCfgFile" + hnp_cfg_data['install']['links'][0]["target"] = "readCfgFile" + hnp_cfg_data['name'] = "readCfgFile" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[1]) + + Step("创建printfSymbol工具配置文件,存在1个bin文件,1个软链接,软链接路径指向bin文件") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/printfSymbol" + hnp_cfg_data['install']['links'][0]["target"] = "printfSymbol" + hnp_cfg_data['name'] = "printfSymbol" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[2]) + + Step("打包compute.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("打包readCfgFile.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[1]} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("打包printfSymbol.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[2]} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("批量安装compute & printfHello & printfSymbol工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("校验设置软链接是否生效") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/add") + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/del") + self.driver.Assert.contains(result, "End: 1 - 1 = 0") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/multiplication") + self.driver.Assert.contains(result, "End: 1 * 1 = 1") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/printfSymbol") + self.driver.Assert.contains(result, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/readCfgFile") + self.driver.Assert.contains(result, "cfg file test test test") + + Step("卸载安装好的native软件包") + self.driver.shell(f"{self.hnp_commamd} uninstall -u 300 -p baidu") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1700.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1700.json new file mode 100644 index 0000000000000000000000000000000000000000..1476611c613cb9797dfb2096086560b5adfafb01 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1700.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1700.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1700.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1700.py new file mode 100644 index 0000000000000000000000000000000000000000..e2aa745d684b0b8099b6778c2f5b3ae3de474f4a --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1700.py @@ -0,0 +1,114 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common + + +class sub_startup_appspawn_nativeinstall_1700(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/readCfgFile", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/printfSymbol"] + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 执行安装包下存在3个hnp包,全部不包含软连接配置 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("打包compute.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}/public -n compute -v 1.2") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("打包readCfgFile.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[1]} " + f"-o {self.pack_out_path}/public -n readCfgFile -v 1.2") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("打包printfSymbol.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[2]} " + f"-o {self.pack_out_path}/public -n printfSymbol -v 1.2") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("批量安装compute & printfHello & printfSymbol工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("校验设置软链接是否生效") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/add") + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/del") + self.driver.Assert.contains(result, "End: 1 - 1 = 0") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/multiplication") + self.driver.Assert.contains(result, "End: 1 * 1 = 1") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/printfSymbol") + self.driver.Assert.contains(result, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/readCfgFile") + self.driver.Assert.contains(result, "cfg file test test test") + + Step("卸载安装好的native软件包") + self.driver.shell(f"{self.hnp_commamd} uninstall -u 300 -p baidu") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1800.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1800.json new file mode 100644 index 0000000000000000000000000000000000000000..a6dd4d31252faa395c65b43857eea0453d3e6623 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1800.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1800.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1800.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1800.py new file mode 100644 index 0000000000000000000000000000000000000000..c16b296c3e35a3b208516ae4751e302654b9ca71 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1800.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common +import shutil + + +class sub_startup_appspawn_nativeinstall_1800(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 安装的native包非hnpcli工具压缩文件 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建一个临时native包") + os.makedirs(f"{self.current_path}/test/") + os.makedirs(f"{self.current_path}/test/bin") + Common.writeDateToFile(f"{self.current_path}/test/bin/test.txt", "testtesttesttest") + + Step("使用zip工具压缩native包,名称为test.hnp") + Common.zip_folder("test", f"{self.current_path}/test.hnp") + self.driver.push_file(f"{self.current_path}\\test.hnp", f"{self.pack_out_path}/public") + Common.deleteFile(f"{self.current_path}\\test.hnp") + shutil.rmtree(f"{self.current_path}/test/") + + Step("安装test.hnp包") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path} -f") + self.driver.Assert.contains(result, "[ERROR][HNP]hnp cfg file not found.") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1900.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1900.json new file mode 100644 index 0000000000000000000000000000000000000000..ca6d064826e8a96a73685458bb5963ac820352e6 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1900.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1900.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1900.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1900.py new file mode 100644 index 0000000000000000000000000000000000000000..8508f4a9c76a3473dcb7efb61c819311785a6aa2 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1900.py @@ -0,0 +1,110 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common + + +class sub_startup_appspawn_nativeinstall_1900(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/printfHello", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/printfSymbol"] + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 安装的native包对应的软链接名称相同 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建printfHello工具配置文件,软连接名称为printfHello") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/printfHello" + hnp_cfg_data['install']['links'][0]["target"] = "printfHello" + hnp_cfg_data['name'] = "printfHello" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0]) + + Step("创建printfSymbol工具配置文件,软连接名称为printfHello") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/printfSymbol" + hnp_cfg_data['install']['links'][0]["target"] = "printfHello" + hnp_cfg_data['name'] = "printfSymbol" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[1]) + + Step("打包printfHello工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("打包printfSymbol工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[1]} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("安装软链接同名工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("验证软连接是否生效") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/printfHello") + self.driver.Assert.contains(result, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@") + + Step("卸载安装好的native软件包") + self.driver.shell(f"{self.hnp_commamd} uninstall -u 300 -p baidu") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/printfHello") + self.driver.Assert.contains(result, "printfHello: inaccessible or not found") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2000.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2000.json new file mode 100644 index 0000000000000000000000000000000000000000..bb014a49412ef66bf2c0edae39552784303d379c --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2000.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2000.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2000.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2000.py new file mode 100644 index 0000000000000000000000000000000000000000..2e43e1b0ed8dd409b940e5c7fd4a8ce5200b6728 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2000.py @@ -0,0 +1,124 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common + + +class sub_startup_appspawn_nativeinstall_2000(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/readCfgFile"] + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/private') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 重复安装名称相同,版本相同的工具 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建compute工具配置文件,软连接名称为add") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/add" + hnp_cfg_data['install']['links'][0]["target"] = "add" + hnp_cfg_data['name'] = "compute" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0]) + + Step("创建readCfgFile工具配置文件,软连接名称为readCfgFile") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/readCfgFile" + hnp_cfg_data['install']['links'][0]["target"] = "readCfgFile" + hnp_cfg_data['name'] = "readCfgFile" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[1]) + + Step("打包printfHello工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}/private") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("打包printfSymbol工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[1]} -o {self.pack_out_path}/private") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("安装compute & readCfgFile工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("验证工具是否生效") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/baidu/bin/readCfgFile") + self.driver.Assert.contains(result, "cfg file test test test") + + Step("重复安装compute & readCfgFile工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8393476 ") + + Step("重复强安装compute & readCfgFile工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path} -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/baidu/bin/readCfgFile") + self.driver.Assert.contains(result, "cfg file test test test") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/baidu/bin/add") + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + + Step("卸载安装好的native软件包") + self.driver.shell(f"{self.hnp_commamd} uninstall -u 300 -p baidu") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2100.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2100.json new file mode 100644 index 0000000000000000000000000000000000000000..b6c78a0830c008d619d2535659e64c02966a053c --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2100.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2100.py new file mode 100644 index 0000000000000000000000000000000000000000..e2bd0ce697921f6a90770b78b300746ddacf9ddd --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2100.py @@ -0,0 +1,145 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common + + +class sub_startup_appspawn_nativeinstall_2100(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/readCfgFile", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/printfHello"] + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 重复安装相同名称,版本不同的安装工具 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建compute工具配置文件,软连接名称为add") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/add" + hnp_cfg_data['install']['links'][0]["target"] = "add" + hnp_cfg_data['name'] = "compute" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0]) + + Step("创建readCfgFile工具配置文件,软连接名称为readCfgFile") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/readCfgFile" + hnp_cfg_data['install']['links'][0]["target"] = "readCfgFile" + hnp_cfg_data['name'] = "readCfgFile" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[1]) + + Step("打包printfHello工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("打包printfSymbol工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[1]} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("安装compute & readCfgFile工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("安装的新的native.hnp") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/printfHello" + hnp_cfg_data['install']['links'][0]["target"] = "printfHello" + hnp_cfg_data['name'] = "readCfgFile" + hnp_cfg_data['version'] = "2.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[2]) + + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[2]} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("重复非强制安装readCfgFile 2.0版本工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8393476 ") + + Step("重复强制安装readCfgFile 2.0版本工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path} -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("验证工具是否生效") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/add") + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/printfHello 2") + self.driver.Assert.contains(result, "****************hello**************") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/readCfgFile") + self.driver.Assert.contains(result, "readCfgFile: inaccessible or not found") + + result = self.driver.shell( + f"find {self.default_install_root_path}/300/hnppublic/readCfgFile.org/ -name readCfgFile_1.0") + assert ("multiplication" not in result) == True + + result = self.driver.shell( + f"find {self.default_install_root_path}/300/hnppublic/readCfgFile.org/ -name readCfgFile_2.0") + self.driver.Assert.contains(result, "readCfgFile_2.0") + + Step("卸载安装好的native软件包") + self.driver.shell(f"{self.hnp_commamd} uninstall -u 300 -p baidu") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2200.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2200.json new file mode 100644 index 0000000000000000000000000000000000000000..2e9bfa69970c1602adfb2cef3c07d5be29fe857d --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2200.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2200.py new file mode 100644 index 0000000000000000000000000000000000000000..70586c40c3e218e0a18a6abdc63132c8ca4fbe4f --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2200.py @@ -0,0 +1,93 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common + + +class sub_startup_appspawn_nativeinstall_2200(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute" + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 安装hnp存在两个软链接,不同的软链接路径,相同的配置名称 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建compute工具配置文件,工具add的软连接名称为compute,工具del的软连接名称为compute") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/add" + hnp_cfg_data['install']['links'][0]["target"] = "compute" + hnp_cfg_data['install']['links'].append({"source": "bin/del", "target": "compute"}) + hnp_cfg_data['name'] = "compute" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path) + + Step("打包compute工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("安装compute工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("验证工具是否生效") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/compute") + self.driver.Assert.contains(result, "End: 1 - 1 = 0") + + Step("卸载安装好的native软件包") + self.driver.shell(f"{self.hnp_commamd} uninstall -u 300 -p baidu") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2300.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2300.json new file mode 100644 index 0000000000000000000000000000000000000000..b2dd1e4d2e989feed8dfdcca5c554ce8aa56e04c --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2300.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2300.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2300.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2300.py new file mode 100644 index 0000000000000000000000000000000000000000..a9679b9cedec284c565affc6db97e23988024727 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2300.py @@ -0,0 +1,102 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common + + +class sub_startup_appspawn_nativeinstall_2300(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute" + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 重复安装hnp中的软链接无target name + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建compute工具配置文件,工具del的软连接名称为del_temp,工具add、multiplication无软链接name") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/del" + hnp_cfg_data['install']['links'][0]["target"] = "del_temp" + hnp_cfg_data['install']['links'].append({"source": "bin/add"}) + hnp_cfg_data['install']['links'].append({"source": "bin/multiplication"}) + hnp_cfg_data['name'] = "compute_no_target" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path) + + Step("打包compute_no_target.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("安装compute_no_target工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("验证工具是否生效") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/del_temp") + self.driver.Assert.contains(result, "End: 1 - 1 = 0") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/add") + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/multiplication") + self.driver.Assert.contains(result, "End: 1 * 1 = 1") + + Step("卸载安装好的native软件包") + self.driver.shell(f"{self.hnp_commamd} uninstall -u 300 -p baidu") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2400.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2400.json new file mode 100644 index 0000000000000000000000000000000000000000..b189f34aecf787b438199d24a8d4eea88c36c82a --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2400.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2400.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2400.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2400.py new file mode 100644 index 0000000000000000000000000000000000000000..9b542c4d838cffdd71b840850bd485c1042bede4 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2400.py @@ -0,0 +1,112 @@ +# -*- coding: utf-8 -*- +from devicetest.core.test_case import Step, TestCase +from hypium import * +import os +import time +import threading +from aw import Common + + +class sub_startup_appspawn_nativeinstall_2400(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute" + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + def worker(self): + Step("执行安装后的软件") + self.driver.shell(f"chmod +x /data/service/hnp/compute.org/compute_1.0/bin/add") + result = self.driver.shell( + f"./data/service/hnp/compute.org/compute_1.0/bin/add 4") + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + + # 重复安装hnp包时,工具正在使用 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建compute工具配置文件,工具add的软连接名称为compute,工具add的软连接名称为compute") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/add" + hnp_cfg_data['install']['links'][0]["target"] = "compute" + hnp_cfg_data['version'] = "1.0" + hnp_cfg_data['name'] = "compute" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path) + + Step("打包compute工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + self.driver.shell(f'mkdir -p /data/service/hnp/compute.org/compute_1.0/') + self.driver.shell(f'cp -r {self.work_space_path}/sub_startup_appspawn_hnp/native/compute/ ' + f'/data/service/hnp/compute.org/compute_1.0/') + + Step("安装compute工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("运行安装工具中的compute程序") + t1 = threading.Thread(target=self.worker) + t1.start() + time.sleep(1) + + Step("重复强制安装相同版本的hnp包") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path} -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + t1.join() + + Step("待程序运行结束后卸载安装好的native软件包") + self.driver.shell(f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.shell(f'rm -rf /data/service/hnp') + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2500.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2500.json new file mode 100644 index 0000000000000000000000000000000000000000..8750c8bf42fe2f12ad907f3717c5684d72358f09 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2500.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2500.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2500.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2500.py new file mode 100644 index 0000000000000000000000000000000000000000..5eab3e2a2666ffdc948a05951e25204eb464c8e0 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2500.py @@ -0,0 +1,125 @@ +# -*- coding: utf-8 -*- + +import os +import time +import threading +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common + + +class sub_startup_appspawn_nativeinstall_2500(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute" + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def worker(self): + Step("执行安装后的软件") + self.driver.shell(f"chmod +x /data/service/hnp/compute.org/compute_1.0/bin/add") + result = self.driver.shell( + f"./data/service/hnp/compute.org/compute_1.0/bin/add 10") + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 重复安装升级版本的hnp包时,工具正在使用 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ALN" in device): + Step("创建compute工具配置文件,工具add的软连接名称为compute") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/add" + hnp_cfg_data['install']['links'][0]["target"] = "compute" + hnp_cfg_data['version'] = "1.0" + hnp_cfg_data['name'] = "compute" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path) + + Step("打包compute工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + self.driver.shell(f'mkdir -p /data/service/hnp/compute.org/compute_1.0/') + self.driver.shell(f'cp -r {self.work_space_path}/sub_startup_appspawn_hnp/native/compute/bin ' + f'/data/service/hnp/compute.org/compute_1.0/') + + Step("安装compute工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + t1 = threading.Thread(target=self.worker) + t1.start() + time.sleep(1) + Step("创建compute工具配置文件,工具del的软连接名称为compute,版本为2.0") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/del" + hnp_cfg_data['install']['links'][0]["target"] = "del" + hnp_cfg_data['version'] = "2.0" + hnp_cfg_data['name'] = "compute" + self.driver.shell(f"rm {self.native_path}/hnp.json") + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path) + + Step("打包升级后的compute.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("重复强制安装不同版本的hnp包") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path} -f") + self.driver.Assert.contains(result, "[ERROR][HNP]hnp install path is running now,") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8392978") + t1.join() + + Step("卸载安装好的native软件包") + self.driver.shell(f"{self.hnp_commamd} uninstall -u 300 -p baidu") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2600.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2600.json new file mode 100644 index 0000000000000000000000000000000000000000..30cb856eb42001e648be96f6fbfea2ed121f3045 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2600.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2600.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2600.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2600.py new file mode 100644 index 0000000000000000000000000000000000000000..1c0e12aefaa1c1405df7544cfe1344e79c1af3ca --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2600.py @@ -0,0 +1,126 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common + + +class sub_startup_appspawn_nativeinstall_2600(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute" + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + self.driver.shell(f'mkdir {self.pack_out_path}/private') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 私有路径与公有路径下安装相同工具 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("打包compute.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path}/public -n compute -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path}/private -n compute -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("美团用户安装compute工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p meituan -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("验证meituan下是否存在compute.org") + result = self.driver.shell(f"find {self.default_install_root_path}/300/hnp/meituan -name compute.org") + self.driver.Assert.contains(result, "compute.org") + + result = self.driver.shell(f"find {self.default_install_root_path}/300/hnppublic -name compute.org") + self.driver.Assert.contains(result, "compute.org") + + Step("验证私有路径软链接是否生效") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/meituan/bin/del") + self.driver.Assert.contains(result, "End: 1 - 1 = 0") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/meituan/bin/add") + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/meituan/bin/multiplication") + self.driver.Assert.contains(result, "End: 1 * 1 = 1") + + Step("验证公有路径软链接是否生效") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/del") + self.driver.Assert.contains(result, "End: 1 - 1 = 0") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/add") + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/multiplication") + self.driver.Assert.contains(result, "End: 1 * 1 = 1") + + Step("卸载美团应用安装软件") + result = self.driver.shell(f"{self.hnp_commamd} uninstall -u 300 -p meituan") + print("卸载", result) + + Step("验证meituan下是否存在compute.org") + result = self.driver.shell(f"find {self.default_install_root_path}/300/hnp/meituan -name compute.org") + assert ("compute.org" not in result) == True + + Step("验证公有路径下是否存在compute.org") + result = self.driver.shell(f"find {self.default_install_root_path}/300/hnppublic -name compute.org") + assert ("compute.org" not in result) == True + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2700.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2700.json new file mode 100644 index 0000000000000000000000000000000000000000..666a507ef813a81c63bb7c8d4419f0b90d464047 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2700.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2700.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2700.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2700.py new file mode 100644 index 0000000000000000000000000000000000000000..0962dfd5ba1a105048304f71144a6f1ec7572d88 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2700.py @@ -0,0 +1,140 @@ +# -*- coding: utf-8 -*- +import os +import time +from hypium import * +import threading +from aw import Common +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_2700(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/readCfgFile", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/printfSymbol", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/printfHello", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample1", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample2"] + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def worker(self): + Step("执行安装后的软件") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/add 4") + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + self.driver.shell(f'mkdir {self.pack_out_path}/private') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 应用程序安装不同的软件(公有 + 私有) + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("打包compute工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}/public -n compute -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("百度安装compute工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("打包printfHello工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[3]} " + f"-o {self.pack_out_path}/private -n printfHello -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("打包printfSymbol工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[2]} " + f"-o {self.pack_out_path}/public -n printfSymbol -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("非强制增量安装软件") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0 ") + + Step("非强制重复安装软件") + self.driver.shell(f'rm {self.pack_out_path}/public/compute.hnp') + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8393476 ") + + Step("验证软链接是否生效") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/baidu/bin/printfHello 2") + self.driver.Assert.contains(result, "****************hello**************") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/del") + self.driver.Assert.contains(result, "End: 1 - 1 = 0") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/add") + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/multiplication") + self.driver.Assert.contains(result, "End: 1 * 1 = 1") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/printfSymbol") + self.driver.Assert.contains(result, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@") + + Step("卸载百度应用软件") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + self.driver.shell(f'rm /data/service/el1/startup/hnp_info.json') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2800.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2800.json new file mode 100644 index 0000000000000000000000000000000000000000..762e3968cdd54b2b4f75e91b6a58207842a6d0a3 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2800.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2800.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2800.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2800.py new file mode 100644 index 0000000000000000000000000000000000000000..b31b70b2ec22ecdd711673815198707c11f90ed7 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2800.py @@ -0,0 +1,188 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common + + +class sub_startup_appspawn_nativeinstall_2800(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/printfHello", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/printfSymbol", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample1", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample2"] + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def worker(self): + Step("执行安装后的软件") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/add 4") + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + self.driver.shell(f'mkdir {self.pack_out_path}/private') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 不同应用程序安装不同的软件 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("打包compute工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}/public -n compute -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("打包printfHello工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[1]} " + f"-o {self.pack_out_path}/private -n printfHello -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("baidu应用软件安装程序") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("meituan应用软件安装程序") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p meituan -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("校验安装工具可用") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/baidu/bin/printfHello 2") + self.driver.Assert.contains(result, "") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/meituan/bin/printfHello 2") + self.driver.Assert.contains(result, "") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/del") + self.driver.Assert.contains(result, "End: 1 - 1 = 0") + + Step("打包printfSymbol工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[2]} " + f"-o {self.pack_out_path}/private -n printfSymbol -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("强制安装elema应用软件安装程序") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p elema -i {self.pack_out_path} -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("校验安装工具可用") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/baidu/bin/printfHello 2") + self.driver.Assert.contains(result, "****************hello**************") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/elema/bin/printfHello 2") + self.driver.Assert.contains(result, "****************hello**************") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/meituan/bin/printfHello 2") + self.driver.Assert.contains(result, "****************hello**************") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/elema/bin/printfSymbol") + self.driver.Assert.contains(result, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/del") + self.driver.Assert.contains(result, "End: 1 - 1 = 0") + + Step("卸载美团与百度安装的软件") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p meituan") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/baidu/bin/printfHello 2") + self.driver.Assert.contains(result, "printfHello: inaccessible or not found") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/meituan/bin/printfHello 2") + self.driver.Assert.contains(result, "printfHello: inaccessible or not found") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/elema/bin/printfHello 2") + self.driver.Assert.contains(result, "****************hello**************") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/elema/bin/printfSymbol") + self.driver.Assert.contains(result, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/del") + self.driver.Assert.contains(result, "End: 1 - 1 = 0") + + Step("卸载饿了吗软件") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p elema") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/elema/bin/printfHello 2") + self.driver.Assert.contains(result, "printfHello: inaccessible or not found") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/elema/bin/printfSymbol") + self.driver.Assert.contains(result, "printfSymbol: inaccessible or not found") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/del") + self.driver.Assert.contains(result, "del: inaccessible or not found") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2900.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2900.json new file mode 100644 index 0000000000000000000000000000000000000000..f5b868daa784a3cbd7c889610c27bb99dfad05d0 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2900.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2900.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2900.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2900.py new file mode 100644 index 0000000000000000000000000000000000000000..aabe8991917c7b1a1d33ab3e1871971d3b9f53e3 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2900.py @@ -0,0 +1,133 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common + + +class sub_startup_appspawn_nativeinstall_2900(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/printfHello", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/printfSymbol", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample1", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample2"] + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def worker(self): + Step("执行安装后的软件") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/add 4") + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + self.driver.shell(f'mkdir {self.pack_out_path}/private') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 多个应用程序安装不同版本的工具 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("打包compute工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}/public -n compute -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("打包printfHello工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[1]} " + f"-o {self.pack_out_path}/private -n printfHello -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("baidu应用软件安装程序") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("打包compute 2.0工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[2]} -o {self.pack_out_path}/public -n compute -v 2.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("非强制安装meituan应用软件安装程序") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p meituan -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8393476") + + Step("强制安装meituan应用软件安装程序") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p meituan -i {self.pack_out_path} -f") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/meituan/bin/printfHello 1") + self.driver.Assert.contains(result, "****************hello**************") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/printfSymbol") + self.driver.Assert.contains(result, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/del") + self.driver.Assert.contains(result, "del: inaccessible or not found") + + Step("卸载美团与百度安装的软件") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p meituan") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/printfSymbol") + self.driver.Assert.contains(result, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@") + + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1000.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1000.json new file mode 100644 index 0000000000000000000000000000000000000000..23815cee566c36c0b1f3465a168a5c49501f9ec3 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1000.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1000.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1000.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1000.py new file mode 100644 index 0000000000000000000000000000000000000000..055881c8caaa9b0aef5e7f113028741b11183caf --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1000.py @@ -0,0 +1,89 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_1000(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + + TestCase.__init__(self, self.TAG, controllers) + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + # hnpcli bin文件调用参数测试 + def test_step1(self): + Step("执行./hnpcli不传任何参数") + result = self.driver.shell(f"{self.hnpcli_commamd}") + + self.driver.Assert.contains(result, + "-i : [required] input path of software package dir") + self.driver.Assert.contains(result, + "-o : [optional] output path of hnp file. " + "if not set then ouput to current directory") + self.driver.Assert.contains(result, + "-n : [optional] software name. if not hnp.json in input dir then must set") + self.driver.Assert.contains(result, + "-v : [optional] software version. " + "if not hnp.json in input dir then must set") + + Step("执行./hnpcli help") + result = self.driver.shell(f"{self.hnpcli_commamd} help") + self.driver.Assert.contains(result, + "usage:hnpcli [-i ]" + "[-o ][-n ][-v ]") + self.driver.Assert.contains(result, + "-i : [required] input path of software package dir") + self.driver.Assert.contains(result, + "-o : [optional] output path of hnp file. " + "if not set then ouput to current directory") + self.driver.Assert.contains(result, + "-n : [optional] software name. if not hnp.json in input dir then must set") + self.driver.Assert.contains(result, + "-v : [optional] software version. " + "if not hnp.json in input dir then must set") + + Step("执行./hnpcli -h") + result = self.driver.shell(f"{self.hnpcli_commamd} help") + self.driver.Assert.contains(result, + "-i : [required] input path of software package dir") + self.driver.Assert.contains(result, + "-o : [optional] output path of hnp file. " + "if not set then ouput to current directory") + self.driver.Assert.contains(result, + "-n : [optional] software name. if not hnp.json in input dir then must set") + self.driver.Assert.contains(result, + "-v : [optional] software version. " + "if not hnp.json in input dir then must set") + + Step("执行./hnpcli pack") + result = self.driver.shell(f"{self.hnpcli_commamd} pack") + self.driver.Assert.contains(result, "[ERROR][HNP]source dir is null.") + + Step("执行./hnpcli pack2") + result = self.driver.shell(f"{self.hnpcli_commamd} pack2") + self.driver.Assert.contains(result, "[ERROR][HNP]invalid cmd!. cmd:pack2") + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1100.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1100.json new file mode 100644 index 0000000000000000000000000000000000000000..0de1dfd7f634a12f92720ec82d4c083b494008aa --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1100.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1100.py new file mode 100644 index 0000000000000000000000000000000000000000..278ebeb52cbc7bc0869ab553b72f09b453293e53 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1100.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_1100(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + + TestCase.__init__(self, self.TAG, controllers) + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample1", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample2"] + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + # hnpcli 打包native包传参个数异常场景 + def test_step1(self): + Step("执行./hnpcli pack -i native包路径") + result = self.driver.shell(f"{self.hnpcli_commamd} pack -i {self.native_path[0]}") + self.driver.Assert.contains(result, "[ERROR][HNP]name or version argv is miss.") + + Step("执行./hnpcli pack -o 存储包目标路径") + result = self.driver.shell(f"{self.hnpcli_commamd} pack -o {self.pack_out_path[0]}") + self.driver.Assert.contains(result, "[ERROR][HNP]source dir is null.") + + Step("执行./hnpcli 传参等于四个参数,./hnpcli pack -i native包路径 -o 存储包目标路径,native包中无cfg配置文件") + result = self.driver.shell(f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "[ERROR][HNP]name or version argv is miss.") + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1200.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1200.json new file mode 100644 index 0000000000000000000000000000000000000000..7b69394bcfd1ddbeb7d0a332dc5c980d48ebd77d --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1200.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1200.py new file mode 100644 index 0000000000000000000000000000000000000000..4ddbef8c5a2fcc7ff91fdd82a1d51411e9d6399c --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1200.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from aw import Common +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_1200(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + + TestCase.__init__(self, self.TAG, controllers) + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + # hnp程序打包native包,native包路径相关测试场景 + def test_step1(self): + Step("native包路径不存在") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.work_space_path}/empty_dir -o {self.pack_out_path} " + f"-n test -v 1.1") + self.driver.Assert.contains(result, "") + Step("native包路径下的文件夹为空") + self.driver.shell(f'mkdir {self.work_space_path}/empty_dir') + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.work_space_path}/empty_dir -o {self.pack_out_path} " + f"-n test -v 1.1") + self.driver.Assert.contains(result, + "[INFO][HNP]PackHnp end. srcPath=/data/hnp_test/empty_dir, " + "hnpName=test, hnpVer=1.1, hnpDstPath=/data/hnp_test/pack_output, linkNum=0, ret=0") + result = self.driver.shell(f"find {self.pack_out_path} -name test.hnp") + self.driver.Assert.contains(result, f"{self.pack_out_path}/test.hnp") + self.driver.shell(f'rm {self.pack_out_path}/test.hnp') + self.driver.shell(f'rm -rf {self.work_space_path}/empty_dir') + Step("native包路径长度等于max_path") + path_temp = Common.randomGenerateStingByLen(4096) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {path_temp} -o {self.pack_out_path} -n test -v 1.1") + self.driver.Assert.contains(result, "[ERROR][HNP]realpath unsuccess.") + Step("native包路径长度超过max_path") + path_temp = Common.randomGenerateStingByLen(4097) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {path_temp} -o {self.pack_out_path} -n test -v 1.1") + self.driver.Assert.contains(result, "[ERROR][HNP]realpath unsuccess.") + Step("native包路径存在非法字符") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i /data/$^*》《%test/ -o {self.pack_out_path} -n test -v 1.1") + self.driver.Assert.contains(result, "[ERROR][HNP]realpath unsuccess.") + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1300.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1300.json new file mode 100644 index 0000000000000000000000000000000000000000..853810f154db4823b23d3894dbc7f03c3815b837 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1300.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1300.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1300.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1300.py new file mode 100644 index 0000000000000000000000000000000000000000..bed791933bedca29e0956c7caa61241ccf30af10 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1300.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from aw import Common +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_1300(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + + TestCase.__init__(self, self.TAG, controllers) + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample1", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample2"] + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + # hnp程序打包native包,存储包目标路径相关测试场景 + def test_step1(self): + Step("存储包目标路径不存在") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}/empty_dir -n test -v 1.1") + self.driver.Assert.contains(result, "[ERROR][HNP]realpath unsuccess. path=/data/hnp_test/pack_output/empty_dir") + Step("存储包目标路径长度等于max_path") + path_temp = Common.randomGenerateStingByLen(4088) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {path_temp} -n test -v 1.1") + self.driver.Assert.contains(result, "[ERROR][HNP]realpath unsuccess.") + Step("存储包目标路径长度大于max_path") + path_temp = Common.randomGenerateStingByLen(4097) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {path_temp} -n test -v 1.1") + self.driver.Assert.contains(result, "[ERROR][HNP]realpath unsuccess.") + Step("/hnpcli pack native包路径 存储包目标路径 -cfg 配置路径,native包路径存在非法字符") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o /data/$^*%test/ -n test -v 1.1") + self.driver.Assert.contains(result, "[ERROR][HNP]realpath unsuccess. path=/data/$^*%test/") + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1400.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1400.json new file mode 100644 index 0000000000000000000000000000000000000000..994592e791f058e0a183e1e85622e4e85d519218 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1400.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1400.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1400.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1400.py new file mode 100644 index 0000000000000000000000000000000000000000..fda773a1cb49bf5db8e9d4001d00f76c2d5fed40 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1400.py @@ -0,0 +1,110 @@ +# -*- coding: utf-8 -*- +import os +import shutil +from hypium import * +from aw import Common +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_1400(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + + TestCase.__init__(self, self.TAG, controllers) + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample1", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample2"] + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_cfg_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp.json" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + + def check_pack_is_correct(self, hnp_name, native_name, cfg_file, del_hnp): + # 校验是否生成了对应的.hnp文件 + result = self.driver.shell(f"find {self.pack_out_path} -name {hnp_name}") + self.driver.Assert.contains(result, f"{self.pack_out_path}/{hnp_name}") + + # 将生成的.hnp文件推到本地 + self.driver.pull_file(self.pack_out_path, self.hnp_test_file_path) + + # 是否删除生成的.hnp文件 + if del_hnp: + self.driver.shell(f'rm {self.pack_out_path}/{hnp_name}') + + # 将hnp.json文件拷贝到native路径下,为文件比较做好准备工作 + shutil.copy2(cfg_file, f"{self.hnp_test_file_path}\\native\\{native_name}") + Common.unzip_hnp(f"{self.hnp_test_file_path}/pack_output/{hnp_name}", + f"{self.hnp_test_file_path}/pack_output/") + + # 比较打包前后两个文件是否一致 + result = Common.compare_folder(f"{self.hnp_test_file_path}\\native\\{native_name}", + f"{self.hnp_test_file_path}/pack_output/{native_name}") + assert result == True + + # 删除测试PC中的残留文件 + Common.deleteFile(f"{self.hnp_test_file_path}\\native\\{native_name}\\hnp.json") + shutil.rmtree(f"{self.hnp_test_file_path}/pack_output/") + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + # hnp程序打包native包,cfg相关测试场景 + def test_step1(self): + Step("native包中无cfg配置文件,不传name与version") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "[ERROR][HNP]name or version argv is miss.") + Step("native包中无cfg配置文件,传name与version") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path} -n test -v 1.1") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + result = self.driver.shell(f"find {self.pack_out_path} -name test.hnp") + self.driver.Assert.contains(result, f"{self.pack_out_path}/test.hnp") + self.driver.shell(f'rm {self.pack_out_path}/test.hnp') + Step("native包中存在cfg配置文件,不传name与version") + self.driver.shell(f'cp -i {self.hnp_cfg_path} {self.native_path[0]}') + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + self.check_pack_is_correct("hnp_test.hnp", "sample1", f"{self.hnp_test_file_path}\\hnp.json", True) + self.driver.shell(f'rm {self.native_path[0]}/hnp.json') + Step("native包中存在cfg配置文件,传name与version") + self.driver.shell(f'cp -i {self.hnp_cfg_path} {self.native_path[0]}') + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path} -n test -v 1.1") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + self.check_pack_is_correct("hnp_test.hnp", "sample1", f"{self.hnp_test_file_path}\\hnp.json", True) + self.driver.shell(f'rm {self.native_path[0]}/hnp.json') + Step( + "调用./hnpcli pack -i native包路径 -o 存储包目标路径 -name test -v test, version为字符串,非常规version表述") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path} -n test -v test") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + self.driver.Assert.contains(result, "hnpName=test, hnpVer=test") + result = self.driver.shell(f"find {self.pack_out_path} -name test.hnp") + self.driver.Assert.contains(result, f"{self.pack_out_path}/test.hnp") + self.driver.shell(f'rm {self.pack_out_path}/test.hnp') + self.driver.shell(f'rm {self.native_path[0]}/hnp.json') + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1500.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1500.json new file mode 100644 index 0000000000000000000000000000000000000000..c789b15665e977828f268fcd62064855f04b81d3 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1500.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1500.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1500.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1500.py new file mode 100644 index 0000000000000000000000000000000000000000..783457e0499e7f7ca2ba67f0a26159831f8fe38a --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1500.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_1500(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + + TestCase.__init__(self, self.TAG, controllers) + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample1", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample2"] + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + # 打包native包时,传参异常 + def test_step1(self): + Step("调用./hnpcli 待打包native软件路径 打包后文件存放路径 -n test") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path} -n test") + self.driver.Assert.contains(result, "[ERROR][HNP]name or version argv is miss.") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8392706") + Step("调用./hnpcli 待打包native软件路径 打包后文件存放路径 -v 1.1") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path} -v 1.1") + self.driver.Assert.contains(result, "[ERROR][HNP]name or version argv is miss.") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8392706") + Step("调用./hnpcli pack native包路径 存储包目标路径 -n "" -v """) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path} -name "" -v """) + self.driver.Assert.contains(result, "[ERROR][HNP]name or version argv is miss.") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8392706") + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1600.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1600.json new file mode 100644 index 0000000000000000000000000000000000000000..98093ce158edd7d59eaa26a0e017bd956db41512 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1600.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1600.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1600.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1600.py new file mode 100644 index 0000000000000000000000000000000000000000..f51428391edc09f77e37853eb602f55a9f332b5b --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1600.py @@ -0,0 +1,99 @@ +# -*- coding: utf-8 -*- +import os +import shutil +from hypium import * +from aw import Common +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_1600(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + + TestCase.__init__(self, self.TAG, controllers) + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample1", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample2"] + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_cfg_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp.json" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + + def check_pack_is_correct(self, hnp_name, native_name, cfg_file, del_hnp): + # 校验是否生成了对应的.hnp文件 + result = self.driver.shell(f"find {self.pack_out_path} -name {hnp_name}") + self.driver.Assert.contains(result, f"{self.pack_out_path}/{hnp_name}") + + # 将生成的.hnp文件推到本地 + self.driver.pull_file(self.pack_out_path, self.hnp_test_file_path) + + # 是否删除生成的.hnp文件 + if del_hnp: + self.driver.shell(f'rm {self.pack_out_path}/{hnp_name}') + + # 将hnp.json文件拷贝到native路径下,为文件比较做好准备工作 + shutil.copy2(cfg_file, f"{self.hnp_test_file_path}\\native\\{native_name}") + Common.unzip_hnp(f"{self.hnp_test_file_path}/pack_output/{hnp_name}", + f"{self.hnp_test_file_path}/pack_output/") + + # 比较打包前后两个文件是否一致 + result = Common.compare_folder(f"{self.hnp_test_file_path}\\native\\{native_name}", + f"{self.hnp_test_file_path}/pack_output/{native_name}") + assert result == True + + # 删除测试PC中的残留文件 + Common.deleteFile(f"{self.hnp_test_file_path}\\native\\{native_name}\\hnp.json") + shutil.rmtree(f"{self.hnp_test_file_path}/pack_output/") + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + # 根据配置打包不同数量的native包 + def test_step1(self): + Step("打包文件存在cfg文件") + self.driver.shell(f'cp -i {self.hnp_cfg_path} {self.native_path[0]}') + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + self.check_pack_is_correct("hnp_test.hnp", "sample1", f"{self.hnp_test_file_path}\\hnp.json", False) + self.driver.shell(f'rm {self.native_path[0]}/hnp.json') + Step("打包文件不存在cfg文件,传入name与version") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path} -n test -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + result = self.driver.shell(f"find {self.pack_out_path} -name test.hnp") + self.driver.Assert.contains(result, f"{self.pack_out_path}/test.hnp") + Step("打包文件不存在cfg文件,传入name与version,其中name与第一次传入不同") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path} -n test2 -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + result = self.driver.shell(f"find {self.pack_out_path} -name test2.hnp") + self.driver.Assert.contains(result, f"{self.pack_out_path}/test2.hnp") + Step("调用./hnpcli 待打包native软件路径(与上不同)打包后文件存放路径(与上相同)-n test -v 1.0") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[1]} -o {self.pack_out_path} -n test -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + result = self.driver.shell(f"find {self.pack_out_path} -name test.hnp") + self.driver.Assert.contains(result, f"{self.pack_out_path}/test.hnp") + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1700.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1700.json new file mode 100644 index 0000000000000000000000000000000000000000..1476611c613cb9797dfb2096086560b5adfafb01 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1700.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1700.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1700.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1700.py new file mode 100644 index 0000000000000000000000000000000000000000..854885b48c920b65528ba528f07c9fad71a78dc7 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1700.py @@ -0,0 +1,110 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from aw import Common +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_1700(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + + TestCase.__init__(self, self.TAG, controllers) + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample1", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample2"] + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + def test_step1(self): + Step("对应的配置文件非json文件") + hnp_cfg_data = """{ + "type": "hnp-config", + "name": "python", + "version": "2.7", + "install": { + "links": [ + { + "source": "bin/python2.7", + "target": "python" + } + ] + }""" + Common.writeDateToFile("hnp.json", hnp_cfg_data) + self.driver.push_file(f"{self.current_path}\\hnp.json", self.native_path[0]) + Common.deleteFile(f"{self.current_path}\\hnp.json") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8392986") + self.driver.shell(f"rm {self.native_path[0]}/hnp.json") + Step("配置文件无type字段") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + del hnp_cfg_data['type'] + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0]) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "[ERROR][HNP]get type info in cfg unsuccess.") + self.driver.shell(f"rm {self.native_path[0]}/hnp.json") + Step("配置文件无name字段") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + del hnp_cfg_data['name'] + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0]) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "[ERROR][HNP]get name info in cfg unsuccess.") + self.driver.shell(f"rm {self.native_path[0]}/hnp.json") + Step("配置文件无version字段") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + del hnp_cfg_data['version'] + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0]) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "[ERROR][HNP]get version info in cfg unsuccess.") + self.driver.shell(f"rm {self.native_path[0]}/hnp.json") + Step("配置文件无install字段") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + del hnp_cfg_data['install'] + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0]) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "[ERROR][HNP]get install info in cfg unsuccess.") + self.driver.shell(f"rm {self.native_path[0]}/hnp.json") + Step("配置文件非hnp类型") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data["type"] = "test" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0]) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "[ERROR][HNP]type info not match.type=test") + self.driver.shell(f"rm {self.native_path[0]}/hnp.json") + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1800.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1800.json new file mode 100644 index 0000000000000000000000000000000000000000..a6dd4d31252faa395c65b43857eea0453d3e6623 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1800.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1800.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1800.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1800.py new file mode 100644 index 0000000000000000000000000000000000000000..360ffc9175bbc41e1990e34289781cd72b6905e1 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1800.py @@ -0,0 +1,117 @@ +# -*- coding: utf-8 -*- +import os +import shutil +from hypium import * +from aw import Common +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_1800(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + + TestCase.__init__(self, self.TAG, controllers) + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample1", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample2"] + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path, delete_file): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + if delete_file: + assert Common.deleteFile(json_file_name) == 0 + + def check_pack_is_correct(self, hnp_name, native_name, cfg_file, del_hnp): + # 校验是否生成了对应的.hnp文件 + result = self.driver.shell(f"find {self.pack_out_path} -name {hnp_name}") + self.driver.Assert.contains(result, f"{self.pack_out_path}/{hnp_name}") + + # 将生成的.hnp文件推到本地 + self.driver.pull_file(self.pack_out_path, self.hnp_test_file_path) + + # 是否删除生成的.hnp文件 + if del_hnp: + self.driver.shell(f'rm {self.pack_out_path}/{hnp_name}') + + # 将hnp.json文件拷贝到native路径下,为文件比较做好准备工作 + shutil.copy2(cfg_file, f"{self.hnp_test_file_path}\\native\\{native_name}") + Common.unzip_hnp(f"{self.hnp_test_file_path}/pack_output/{hnp_name}", + f"{self.hnp_test_file_path}/pack_output/") + + # 比较打包前后两个文件是否一致 + result = Common.compare_folder(f"{self.hnp_test_file_path}\\native\\{native_name}", + f"{self.hnp_test_file_path}/pack_output/{native_name}") + assert result == True + + # 删除测试PC中的残留文件 + Common.deleteFile(f"{self.hnp_test_file_path}\\native\\{native_name}\\hnp.json") + shutil.rmtree(f"{self.hnp_test_file_path}/pack_output/") + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + # 软连接路径与配置名称内容测试 + def test_step1(self): + Step("配置软连接路径正确,但是未配置目标名称") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + del hnp_cfg_data['install']['links'][0]["target"] + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0], False) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + self.check_pack_is_correct("hnp_test.hnp", "sample1", f"{self.current_path}/hnp.json", True) + assert Common.deleteFile(f"{self.current_path}/hnp.json") == 0 + self.driver.shell(f"rm {self.native_path[0]}/hnp.json") + Step("未配置软连接路径,配置了目标名称") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + del hnp_cfg_data['install']['links'][0]["source"] + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0], True) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "[ERROR][HNP]get source info in cfg unsuccess.") + self.driver.shell(f"rm {self.native_path[0]}/hnp.json") + Step("配置软连接路径,配置目标名称为空") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["target"] = None + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0], False) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + self.check_pack_is_correct("hnp_test.hnp", "sample1", f"{self.current_path}/hnp.json", True) + assert Common.deleteFile(f"{self.current_path}/hnp.json") == 0 + self.driver.shell(f"rm {self.native_path[0]}/hnp.json") + Step("配置软连接路径,配置了目标名称长度为0") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["target"] = "" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0], False) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + self.check_pack_is_correct("hnp_test.hnp", "sample1", f"{self.current_path}/hnp.json", True) + assert Common.deleteFile(f"{self.current_path}/hnp.json") == 0 + self.driver.shell(f"rm {self.native_path[0]}/hnp.json") + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1900.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1900.json new file mode 100644 index 0000000000000000000000000000000000000000..ca6d064826e8a96a73685458bb5963ac820352e6 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1900.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_1900.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1900.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1900.py new file mode 100644 index 0000000000000000000000000000000000000000..4a2f576dfe192d6774f5fcdf887f8b2ee2324df8 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_1900.py @@ -0,0 +1,109 @@ +# -*- coding: utf-8 -*- +import os +import shutil +from hypium import * +from aw import Common +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_1900(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + + TestCase.__init__(self, self.TAG, controllers) + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample1", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample2"] + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path, delete_file): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + if delete_file: + assert Common.deleteFile(json_file_name) == 0 + + def check_pack_is_correct(self, hnp_name, native_name, cfg_file, del_hnp): + # 校验是否生成了对应的.hnp文件 + result = self.driver.shell(f"find {self.pack_out_path} -name {hnp_name}") + self.driver.Assert.contains(result, f"{self.pack_out_path}/{hnp_name}") + + # 将生成的.hnp文件推到本地 + self.driver.pull_file(self.pack_out_path, self.hnp_test_file_path) + + # 是否删除生成的.hnp文件 + if del_hnp: + self.driver.shell(f'rm {self.pack_out_path}/{hnp_name}') + + # 将hnp.json文件拷贝到native路径下,为文件比较做好准备工作 + shutil.copy2(cfg_file, f"{self.hnp_test_file_path}\\native\\{native_name}") + Common.unzip_hnp(f"{self.hnp_test_file_path}/pack_output/{hnp_name}", + f"{self.hnp_test_file_path}/pack_output/") + + # 比较打包前后两个文件是否一致 + result = Common.compare_folder(f"{self.hnp_test_file_path}\\native\\{native_name}", + f"{self.hnp_test_file_path}/pack_output/{native_name}") + assert result == True + + # 删除测试PC中的残留文件 + Common.deleteFile(f"{self.hnp_test_file_path}\\native\\{native_name}\\hnp.json") + shutil.rmtree(f"{self.hnp_test_file_path}/pack_output/") + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + # 软连接路径与配置不同关系的测试 + def test_step1(self): + Step("配置文件字段正确,存在两个软连接,不同的软连接路径,相同的配置名称") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'].append({"source": "bin/sample.txt", "target": "hnp_test"}) + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0], False) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "linkNum=2, ret=0") + self.check_pack_is_correct("hnp_test.hnp", "sample1", f"{self.current_path}/hnp.json", False) + Common.deleteFile(f"{self.current_path}/hnp.json") + self.driver.shell(f"rm {self.native_path[0]}/hnp.json") + Step("配置文件字段正确,存在两个软连接,相同的软连接路径,不同的配置名称") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'].append({"source": "bin/sample.txt", "target": "hnp_test2"}) + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0], False) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "linkNum=2, ret=0") + self.check_pack_is_correct("hnp_test.hnp", "sample1", f"{self.current_path}/hnp.json", False) + Common.deleteFile(f"{self.current_path}/hnp.json") + self.driver.shell(f"rm {self.native_path[0]}/hnp.json") + Step("配置文件字段正确,存在多个软连接,相同的软连接路径,相同的配置名称") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + for i in range(5): + hnp_cfg_data['install']['links'].append({"source": "bin/sample.txt", "target": "hnp_test"}) + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0], False) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "linkNum=6, ret=0") + self.check_pack_is_correct("hnp_test.hnp", "sample1", f"{self.current_path}/hnp.json", False) + Common.deleteFile(f"{self.current_path}/hnp.json") + self.driver.shell(f"rm {self.native_path[0]}/hnp.json") + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_2000.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_2000.json new file mode 100644 index 0000000000000000000000000000000000000000..bb014a49412ef66bf2c0edae39552784303d379c --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_2000.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2000.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_2000.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_2000.py new file mode 100644 index 0000000000000000000000000000000000000000..d69c9b21807defb9de1a72b3c9acfc09dcfaf445 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_2000.py @@ -0,0 +1,67 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from aw import Common +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_2000(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + + TestCase.__init__(self, self.TAG, controllers) + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample1", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample2"] + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + # 软连接路径不存在测试场景 + def test_step1(self): + Step("存在一个软连接,软连接路径不存在") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/testsample.txt" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0]) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8393217") + self.driver.shell(f"rm {self.native_path[0]}/hnp.json") + Step("存在两个软连接,其中一个软连接路径不存在") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'].append({"source": "bin/test_sample.txt", "target": "hnp_test2"}) + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0]) + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8393217") + self.driver.shell(f"rm {self.native_path[0]}/hnp.json") + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_2100.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_2100.json new file mode 100644 index 0000000000000000000000000000000000000000..b6c78a0830c008d619d2535659e64c02966a053c --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_2100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeinstall_2100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_2100.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_2100.py new file mode 100644 index 0000000000000000000000000000000000000000..cac90c1f8bcb1d38eb15b7f2648a1a2440deac68 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativepack_2100.py @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from aw import Common +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeinstall_2100(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + + TestCase.__init__(self, self.TAG, controllers) + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" # 测试设备工作路径 + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample1", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/sample2"] + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + # 升级打包同名native包 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("配置文件字段正确,存在两个软连接,不同的软连接路径,相同的配置名称") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0]) + + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}") + self.driver.Assert.contains(result, "linkNum=1, ret=0") + self.driver.shell(f"rm {self.native_path[0]}/hnp.json") + + Step("根据name + version打包与配置文件的同名hnp包") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path} -n hnp_test -v 1.0") + self.driver.Assert.contains(result, "linkNum=0, ret=0") + result = self.driver.shell(f"find {self.pack_out_path} -name hnp_test.hnp") + self.driver.Assert.contains(result, f"{self.pack_out_path}/hnp_test.hnp") + + Step("根据name + version打包与配置文件的同名hnp包,版本号不同") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path} -n hnp_test -v 1.2") + self.driver.Assert.contains(result, "linkNum=0, ret=0") + result = self.driver.shell(f"find {self.pack_out_path} -name hnp_test.hnp") + self.driver.Assert.contains(result, f"{self.pack_out_path}/hnp_test.hnp") + + Step("根据name + version打包与配置文件的同名hnp包,打包的native包与原有不同,版本号不同") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[1]} -o {self.pack_out_path} -n hnp_test1 -v 1.3") + self.driver.Assert.contains(result, "linkNum=0, ret=0") + result = self.driver.shell(f"find {self.pack_out_path} -name hnp_test1.hnp") + self.driver.Assert.contains(result, f"{self.pack_out_path}/hnp_test1.hnp") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0300.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0300.json new file mode 100644 index 0000000000000000000000000000000000000000..6085ce52a26d880f73937c60a43373bc132f385c --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0300.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0300.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0300.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0300.py new file mode 100644 index 0000000000000000000000000000000000000000..661988b1b63db8318520709ebfc30e8e6b771dc1 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0300.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common + + +class sub_startup_appspawn_nativeuninstall_0300(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute" + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 卸载路径不存在测试场景 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("打包compute.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path}/public -n compute -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("安装compute工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("卸载软件usrId不存在") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 301 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8393477 ") + + Step("卸载的应用不存在") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p meituan") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0 ") + + Step("正常卸载") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("重复卸载") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0 ") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0400.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0400.json new file mode 100644 index 0000000000000000000000000000000000000000..a03cb844e223ffba34dfb6ee33c020a1ce63cb39 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0400.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0400.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0400.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0400.py new file mode 100644 index 0000000000000000000000000000000000000000..e49b1585def5b9f1de889c68a85806a0b01845dd --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0400.py @@ -0,0 +1,111 @@ +# -*- coding: utf-8 -*- +import os +import time +from hypium import * +import threading +from aw import Common +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeuninstall_0400(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute" + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def worker(self): + Step("执行安装后的软件") + self.driver.shell(f"chmod +x /data/service/hnp/compute.org/compute_1.0/bin/add") + result = self.driver.shell( + f"./data/service/hnp/compute.org/compute_1.0/bin/add 4") + + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 卸载的软件正在运行的软件(未配置软连接) + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("打包compute.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path}/public -n compute -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("安装compute工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + self.driver.shell(f'mkdir -p /data/service/hnp/compute.org/compute_1.0/') + self.driver.shell(f'cp -r {self.work_space_path}/sub_startup_appspawn_hnp/native/compute/bin ' + f'/data/service/hnp/compute.org/compute_1.0/') + + Step("执行安装的工具") + t1 = threading.Thread(target=self.worker) + t1.start() + time.sleep(1) + Step("卸载百度应用安装工具") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + + self.driver.Assert.contains(result, "[ERROR][HNP]hnp install path is running now,") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8392978") + t1.join() + + Step("待工具运行结束,卸载安装的compute工具") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + result = self.driver.shell(f"find {self.default_install_root_path}/300/hnppublic -name compute.org") + assert ("compute.org" not in result) == True + self.driver.shell(f'rm -rf /data/service/hnp') + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0500.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0500.json new file mode 100644 index 0000000000000000000000000000000000000000..6970867be255ff78ffdfd2c8c9ddfa943a94b46a --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0500.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0500.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0500.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0500.py new file mode 100644 index 0000000000000000000000000000000000000000..41620aeafae1ab7101f6ab9d2d92221181c63e2a --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0500.py @@ -0,0 +1,117 @@ +# -*- coding: utf-8 -*- +import os +import time +from hypium import * +import threading +from aw import Common +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeuninstall_0500(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute" + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def worker(self): + Step("执行安装后的软件") + self.driver.shell(f"chmod +x /data/service/hnp/compute.org/compute_1.0/bin/add") + result = self.driver.shell( + f"./data/service/hnp/compute.org/compute_1.0/bin/add 4") + self.driver.Assert.contains(result, "End: 1 + 1 = 2") + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 卸载的软件正在运行的软件(配置软连接) + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建compute工具配置文件,工具add的软连接名称为compute,工具add的软连接名称为compute") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/add" + hnp_cfg_data['install']['links'][0]["target"] = "add" + hnp_cfg_data['install']['links'].append({"source": "bin/del", "target": "compute"}) + hnp_cfg_data['install']['links'].append({"source": "bin/multiplication", "target": "mul"}) + hnp_cfg_data['name'] = "compute" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path) + + Step("打包compute.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path} -o {self.pack_out_path}/public -n compute -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("安装compute工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + self.driver.shell(f'mkdir -p /data/service/hnp/compute.org/compute_1.0/') + self.driver.shell(f'cp -r {self.work_space_path}/sub_startup_appspawn_hnp/native/compute/bin ' + f'/data/service/hnp/compute.org/compute_1.0/') + + Step("卸载百度应用安装工具") + t1 = threading.Thread(target=self.worker) + t1.start() + time.sleep(1) + Step("正常卸载") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[ERROR][HNP]hnp install path is running now,") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8392978") + t1.join() + + Step("待工具运行结束,卸载安装的compute工具") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + self.driver.shell(f'rm -rf /data/service/hnp') + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0600.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0600.json new file mode 100644 index 0000000000000000000000000000000000000000..6cf6fa8a43e482cee72a3deac551950dd55b33b7 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0600.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0600.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0600.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0600.py new file mode 100644 index 0000000000000000000000000000000000000000..2bc6c23543ba22c3d055c49a3812ac11e1d7e507 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0600.py @@ -0,0 +1,135 @@ +# -*- coding: utf-8 -*- +import os +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common + + +class sub_startup_appspawn_nativeuninstall_0600(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/compute", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/printfHello", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/readCfgFile"] + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + self.driver.shell(f'mkdir {self.pack_out_path}/private') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 卸载的多个软件 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建compute工具配置文件") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/add" + hnp_cfg_data['install']['links'][0]["target"] = "add" + hnp_cfg_data['install']['links'].append({"source": "bin/del", "target": "del"}) + hnp_cfg_data['install']['links'].append({"source": "bin/multiplication", "target": "multiplication"}) + hnp_cfg_data['name'] = "compute" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0]) + + Step("创建readCfgFile工具配置文件") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/readCfgFile" + hnp_cfg_data['install']['links'][0]["target"] = "readCfgFile" + hnp_cfg_data['name'] = "readCfgFile" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[2]) + + Step("打包readCfgFile.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[2]} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("打包compute.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("打包printfHello.hnp") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[1]} " + f"-o {self.pack_out_path}/private -n printfHello -v 1.0") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("批量安装readCfgFile、compute、printfHello、printfHello工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("卸载百度程序对应的软件") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("验证compute工具卸载成功") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/del") + self.driver.Assert.contains(result, "del: inaccessible or not found") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/add") + self.driver.Assert.contains(result, "add: inaccessible or not found") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/hnp/baidu/bin/multiplication") + self.driver.Assert.contains(result, "multiplication: inaccessible or not found") + + Step("验证printfHello工具卸载成功") + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/printfHello") + self.driver.Assert.contains(result, "printfHello: inaccessible or not found") + + result = self.driver.shell( + f"./{self.default_install_root_path}/300/{self.hnp_public_dir}/readCfgFile") + self.driver.Assert.contains(result, "readCfgFile: inaccessible or not found") + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") + diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0700.json b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0700.json new file mode 100644 index 0000000000000000000000000000000000000000..75c651de6c77f90e0fc5c1b7d4db62cbed800154 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0700.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0700.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0700.py b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0700.py new file mode 100644 index 0000000000000000000000000000000000000000..e8d7b401e0d16e10f283a766914333b618035918 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_hnp/sub_startup_appspawn_nativeuninstall_0700.py @@ -0,0 +1,131 @@ +# -*- coding: utf-8 -*- +import os +import time +from hypium import * +import threading +from aw import Common +from devicetest.core.test_case import Step, TestCase + + +class sub_startup_appspawn_nativeuninstall_0700(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + + self.default_install_root_path = "/data/app/el1/bundle" + self.current_path = os.getcwd() + self.driver = UiDriver(self.device1) + self.work_space_path = "/data/hnp_test" + self.pack_out_path = f"{self.work_space_path}/pack_output" + self.hnp_tools_path = f"{self.work_space_path}/sub_startup_appspawn_hnp/hnp" + self.hnp_test_file_path = f"{self.current_path}\\testFile\sub_startup_appspawn_hnp" + self.hnp_commamd = f"./{self.hnp_tools_path}/hnp" + self.hnpcli_commamd = f"./{self.hnp_tools_path}/hnpcli" + self.hnp_public_dir = "hnppublic/bin" + self.native_path = [f"{self.work_space_path}/sub_startup_appspawn_hnp/native/printfSymbol", + f"{self.work_space_path}/sub_startup_appspawn_hnp/native/printfHello"] + + def creat_json_and_push_remote(self, json_file_name, json_data, target_path): + Common.writeJsonDateToFile(json_file_name, json_data) + self.driver.push_file(f"{self.current_path}\\{json_file_name}", target_path) + assert Common.deleteFile(json_file_name) == 0 + + def worker(self): + Step("执行安装后的软件") + self.driver.shell(f"chmod +x /data/service/hnp/printfSymbol.org/printfSymbol_1.0/bin/printfSymbol") + result = self.driver.shell( + f"./data/service/hnp/printfSymbol.org/printfSymbol_1.0/bin/printfSymbol 4") + self.driver.Assert.contains(result, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@") + + def setup(self): + Step("预置工作:初始化PC开始") + Step(self.devices[0].device_id) + + Step("预置工作:创建测试目录,将测试文件拷贝到测试PC") + self.driver.shell(f'mkdir {self.work_space_path}') + + Step("预置工作:创建打包保存文件,为native打包后的保存路径") + self.driver.shell(f'mkdir {self.pack_out_path}') + self.driver.shell(f'mkdir {self.pack_out_path}/public') + + self.driver.push_file(self.hnp_test_file_path, self.work_space_path) + + Step("预置工作:进入到bin文件目录,bin文件增加可执行权限") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnp") + self.driver.shell(f"chmod +x {self.hnp_tools_path}/hnpcli") + + Step("创建一个userId为300的路径,为后续测试使用目录") + self.driver.shell(f"mkdir {self.default_install_root_path}/300") + + # 不同hnp软件包配置的软连接路径不同,target名称相同测试,同名进程运行过程中卸载工具 + def test_step1(self): + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device or "ohos" in device or "ALN" in device): + Step("创建printfSymbol工具配置文件") + hnp_cfg_data = Common.readJsonFile("testFile\sub_startup_appspawn_hnp\hnp.json") + hnp_cfg_data['install']['links'][0]["source"] = "bin/printfSymbol" + hnp_cfg_data['install']['links'][0]["target"] = "print" + hnp_cfg_data['name'] = "printfSymbol" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[0]) + + Step("创建printfHello工具配置文件") + hnp_cfg_data['install']['links'][0]["source"] = "bin/printfHello" + hnp_cfg_data['install']['links'][0]["target"] = "print" + hnp_cfg_data['name'] = "printfHello" + hnp_cfg_data['version'] = "1.0" + self.creat_json_and_push_remote("hnp.json", hnp_cfg_data, self.native_path[1]) + + Step("打包printfSymbol工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[0]} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("打包printfHello工具") + result = self.driver.shell( + f"{self.hnpcli_commamd} pack -i {self.native_path[1]} -o {self.pack_out_path}/public") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + Step("安装printfSymbol、printfHello工具") + result = self.driver.shell( + f"{self.hnp_commamd} install -u 300 -p baidu -i {self.pack_out_path}") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + + self.driver.shell(f'mkdir -p /data/service/hnp/printfSymbol.org/printfSymbol_1.0/') + self.driver.shell(f'mkdir -p /data/service/hnp/printfHello.org/printfHello_1.0/') + self.driver.shell(f'cp -r {self.work_space_path}/sub_startup_appspawn_hnp/native/printfHello/bin ' + f'/data/service/hnp/printfHello.org/printfHello_1.0/') + self.driver.shell(f'cp -r {self.work_space_path}/sub_startup_appspawn_hnp/native/printfSymbol/bin ' + f'/data/service/hnp/printfSymbol.org/printfSymbol_1.0/') + + Step("运行print进程") + t1 = threading.Thread(target=self.worker) + t1.start() + time.sleep(1) + + Step("卸载baidu应用安装的软件") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[ERROR][HNP]hnp install path is running now,") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=8392978") + t1.join() + + Step("待程序运行结束后,卸载baidu应用安装的软件") + result = self.driver.shell( + f"{self.hnp_commamd} uninstall -u 300 -p baidu") + self.driver.Assert.contains(result, "[INFO][HNP]native manager process exit. ret=0") + self.driver.shell(f'rm -rf /data/service/hnp') + else: + pass + + def teardown(self): + self.driver.shell(f'rm -rf {self.work_space_path}') + self.driver.shell(f'rm -rf {self.default_install_root_path}/300/') + Step("收尾工作") +