From 66012c61ab72ab9c48bc60a570186328cfd8ee90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E4=BD=B3=E4=BC=9F?= Date: Wed, 13 Aug 2025 11:45:11 +0800 Subject: [PATCH 01/19] =?UTF-8?q?Description:=E4=BF=AE=E6=94=B9=E8=8A=82?= =?UTF-8?q?=E7=82=B9group=20IssueNo:https://gitee.com/openharmony/startup?= =?UTF-8?q?=5Finit/issues/ICSPLA=20Binary=20Source:No=20Signed-off-by:=20s?= =?UTF-8?q?ongjiawei9=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ueventd/etc/ueventd.config | 44 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/ueventd/etc/ueventd.config b/ueventd/etc/ueventd.config index 8c284da87..52cd33aa9 100644 --- a/ueventd/etc/ueventd.config +++ b/ueventd/etc/ueventd.config @@ -21,7 +21,7 @@ /dev/input/event* 0660 0 input /dev/input/mice 0660 0 input /dev/input/mouse0 0660 0 input -/dev/snd/timer 0660 1000 1005 +/dev/snd/timer 0660 system audio /dev/zero 0666 0 0 /dev/full 0666 0 0 /dev/ptmx 0666 0 0 @@ -32,36 +32,36 @@ /dev/pmsg0 0222 0 1007 /dev/jpeg 0666 1000 1003 /dev/vinput 0660 1000 1004 -/dev/mmz_userdev 0644 1000 1005 +/dev/mmz_userdev 0644 system system /dev/graphics/fb0 0660 1000 1003 -/dev/mem 0660 1000 1005 +/dev/mem 0660 system system /dev/ion 0664 1000 1000 /dev/btusb0 0660 1002 1002 /dev/uhid 0660 3011 3011 -/dev/tc_ns_client 0660 1000 1005 +/dev/tc_ns_client 0660 system system /dev/rtk_btusb 0660 1002 0 -/dev/sil9293 0660 1000 1005 +/dev/sil9293 0660 system system /dev/stpbt 0660 1002 1001 -/dev/avs 0660 1000 1005 -/dev/gdc 0660 1000 1005 -/dev/hdmi 0660 1000 1005 -/dev/hi_mipi 0660 1000 1005 -/dev/hi_mipi_tx 0660 1000 1005 +/dev/avs 0660 system system +/dev/gdc 0660 system system +/dev/hdmi 0660 system system +/dev/hi_mipi 0660 system system +/dev/hi_mipi_tx 0660 system system /dev/hi_tde 0644 1000 1003 /dev/isp_dev 0660 1000 1006 -/dev/match 0660 1000 1005 -/dev/photo 0660 1000 1005 -/dev/rect 0660 1000 1005 -/dev/rgn 0660 1000 1005 -/dev/sys 0660 1000 1005 -/dev/vb 0666 1000 1005 -/dev/vdec 0666 1000 1005 -/dev/venc 0666 1000 1005 -/dev/vi 0660 1000 1005 -/dev/vo 0660 1000 1005 -/dev/vpss 0660 1000 1005 +/dev/match 0660 system system +/dev/photo 0660 system system +/dev/rect 0660 system system +/dev/rgn 0660 system system +/dev/sys 0660 system system +/dev/vb 0666 system system +/dev/vdec 0666 system system +/dev/venc 0666 system system +/dev/vi 0660 system system +/dev/vo 0660 system system +/dev/vpss 0660 system system /dev/i2c-* 0660 1000 1006 -/dev/vgs 0666 1000 1005 +/dev/vgs 0666 system system /dev/dri/card0 0666 0 1003 /dev/dri/card0-DSI-1 0666 0 1003 /dev/dri/card0-HDMI-A-1 0666 0 1003 -- Gitee From a468995461a090301e96127fc69f7e7b02b05929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E4=BD=B3=E4=BC=9F?= Date: Sat, 16 Aug 2025 15:26:34 +0800 Subject: [PATCH 02/19] =?UTF-8?q?Description:gn=E6=96=87=E4=BB=B6=E6=95=B4?= =?UTF-8?q?=E6=94=B9=20IssueNo:https://gitee.com/openharmony/startup=5Fini?= =?UTF-8?q?t/issues/ICTA3H=20Binary=20Source:No=20Signed-off-by:=20songjia?= =?UTF-8?q?wei9=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interfaces/innerkits/BUILD.gn | 1 - services/init/lite/BUILD.gn | 1 - 2 files changed, 2 deletions(-) diff --git a/interfaces/innerkits/BUILD.gn b/interfaces/innerkits/BUILD.gn index 5730ca563..0858f3df0 100755 --- a/interfaces/innerkits/BUILD.gn +++ b/interfaces/innerkits/BUILD.gn @@ -54,7 +54,6 @@ if (defined(ohos_lite)) { ] sources = [] include_dirs = include_common - include_dirs += [ "//base/hiviewdfx/hilog_lite/interfaces/native/kits" ] public_configs = [ ":exported_header_files" ] deps = [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", diff --git a/services/init/lite/BUILD.gn b/services/init/lite/BUILD.gn index e587b521a..2a4c41adf 100644 --- a/services/init/lite/BUILD.gn +++ b/services/init/lite/BUILD.gn @@ -55,7 +55,6 @@ executable("init") { "//base/startup/init/interfaces/innerkits/include/param", "//base/startup/init/services/init/include", "//third_party/cJSON", - "//base/hiviewdfx/hilog_lite/interfaces/native/kits", ] ldflags = [] -- Gitee From e8b08b7fa33ad7b5aed9db95e447ea469fc2b6b8 Mon Sep 17 00:00:00 2001 From: cat Date: Tue, 19 Aug 2025 09:32:41 +0800 Subject: [PATCH 03/19] dd verify Signed-off-by: cat --- services/param/adapter/param_persistadp.c | 6 +++++- services/param/include/param_utils.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/services/param/adapter/param_persistadp.c b/services/param/adapter/param_persistadp.c index 7dba4798c..ef75bf6bc 100644 --- a/services/param/adapter/param_persistadp.c +++ b/services/param/adapter/param_persistadp.c @@ -164,7 +164,11 @@ static bool GetPersistFilePath(char **path, char **tmpPath, int fileType) PARAM_LOGE("rename failed %s", PARAM_OLD_PERSIST_SAVE_PATH); } } else { - CheckAndCreateDir(PARAM_PRIVATE_PERSIST_SAVE_PATH); + if (access(PUBLIC_DIR, F_OK) == 0) { + CheckAndCreateDir(PARAM_PRIVATE_PERSIST_SAVE_PATH); + } else { + PARAM_LOGE("public dir not exit, creat param file fail"); + } } *path = PARAM_PRIVATE_PERSIST_SAVE_PATH; *tmpPath = PARAM_PRIVATE_PERSIST_SAVE_TMP_PATH; diff --git a/services/param/include/param_utils.h b/services/param/include/param_utils.h index 63f03e55a..5cab8b711 100644 --- a/services/param/include/param_utils.h +++ b/services/param/include/param_utils.h @@ -87,6 +87,7 @@ typedef enum { #define PARAM_PUBLIC_PERSIST_SAVE_TMP_PATH DATA_PATH "tmp_public_persist_parameters" #define PARAM_PRIVATE_PERSIST_SAVE_PATH PRIVATE_DATA_PATH "private_persist_parameters" #define PARAM_PRIVATE_PERSIST_SAVE_TMP_PATH PRIVATE_DATA_PATH "tmp_private_persist_parameters" +#define PUBLIC_DIR "/data/service/el1/public" #define PERSIST_HANDLE_MAX 2 #define WORKSPACE_FLAGS_INIT 0x01 -- Gitee From 701341486c6d7a2ad5ec4f97e87fb57a0e295c1e Mon Sep 17 00:00:00 2001 From: lianghaofei Date: Wed, 20 Aug 2025 14:49:10 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=93=9D=E5=8C=BAcgrou?= =?UTF-8?q?p=E7=94=A8=E4=BE=8B=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lianghaofei --- test/unittest/init/service_unittest.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unittest/init/service_unittest.cpp b/test/unittest/init/service_unittest.cpp index 53ad4ee75..4edf39540 100644 --- a/test/unittest/init/service_unittest.cpp +++ b/test/unittest/init/service_unittest.cpp @@ -510,7 +510,6 @@ HWTEST_F(ServiceUnitTest, TestServiceCGroup2, TestSize.Level1) } } fclose(file); - EXPECT_EQ(ret, 0); ret = ServiceStop(service); EXPECT_EQ(ret, 0); ReleaseService(service); -- Gitee From 655e664b87e7dd2849c745a15ca531ab08024b7e Mon Sep 17 00:00:00 2001 From: hechaofan Date: Wed, 20 Aug 2025 14:53:04 +0800 Subject: [PATCH 05/19] add for proy_hcd Signed-off-by: hechaofan --- services/etc/init.usb.cfg | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/etc/init.usb.cfg b/services/etc/init.usb.cfg index d28b2adf6..00a1301ab 100755 --- a/services/etc/init.usb.cfg +++ b/services/etc/init.usb.cfg @@ -14,6 +14,14 @@ "cmds" : [ "stop hdcd" ] + }, { + "name" : "init", + "cmds" : [ + "mkdir /dev/bus 0755 ueventd root", + "mkdir /dev/bus/usb 0755 ueventd root", + "mkdir /dev/bus/usb/001 0755 ueventd root", + "mkdir /dev/bus/usb/001 0755 ueventd root" + ] } ] } -- Gitee From 424665d15736b45a32f80f1e68c2c3ecd671d59b Mon Sep 17 00:00:00 2001 From: Ethan Fan Date: Wed, 20 Aug 2025 07:01:30 +0000 Subject: [PATCH 06/19] update services/etc/init.usb.cfg. Signed-off-by: Ethan Fan --- services/etc/init.usb.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/etc/init.usb.cfg b/services/etc/init.usb.cfg index 00a1301ab..45bba5345 100755 --- a/services/etc/init.usb.cfg +++ b/services/etc/init.usb.cfg @@ -20,7 +20,7 @@ "mkdir /dev/bus 0755 ueventd root", "mkdir /dev/bus/usb 0755 ueventd root", "mkdir /dev/bus/usb/001 0755 ueventd root", - "mkdir /dev/bus/usb/001 0755 ueventd root" + "mkdir /dev/bus/usb/002 0755 ueventd root" ] } ] -- Gitee From 70cd612443b5e8fcb0a742088a6b9b0fbcf653cc Mon Sep 17 00:00:00 2001 From: cat Date: Wed, 20 Aug 2025 15:04:42 +0800 Subject: [PATCH 07/19] dd cpu verify Signed-off-by: cat --- interfaces/innerkits/BUILD.gn | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/interfaces/innerkits/BUILD.gn b/interfaces/innerkits/BUILD.gn index 5730ca563..44d2ef28b 100755 --- a/interfaces/innerkits/BUILD.gn +++ b/interfaces/innerkits/BUILD.gn @@ -411,7 +411,11 @@ if (defined(ohos_lite)) { if (default_toolchain == current_toolchain) { ohos_prebuilt_shared_library("libbegetutil-pub-sdk") { source = "${root_out_dir}/startup/init/libbegetutil.z.so" - symlink_ext = [ "lib64/chipset-pub-sdk/libbegetutil.z.so" ] + if (target_cpu == "arm64" || target_cpu == "x86_64") { + symlink_ext = [ "lib64/chipset-pub-sdk/libbegetutil.z.so" ] + } else { + symlink_ext = [ "lib/chipset-pub-sdk/libbegetutil.z.so" ] + } deps = [ "//base/startup/init/interfaces/innerkits:libbegetutil" ] install_enable = true install_images = [ -- Gitee From 91e992687547aa4d98ae2da867fe92fe1a29a01a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E5=B9=BF=E7=94=9F?= Date: Thu, 21 Aug 2025 03:32:21 +0000 Subject: [PATCH 08/19] const.ohos.fullname=OpenHarmony-6.0.0.47 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 马广生 --- services/etc/param/ohos.para | 2 +- services/etc/param/ohos_const/ohos.para | 2 +- services/etc_lite/param/ohos_const/ohos.para | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/etc/param/ohos.para b/services/etc/param/ohos.para index 2383c6964..74e9c562e 100755 --- a/services/etc/param/ohos.para +++ b/services/etc/param/ohos.para @@ -29,7 +29,7 @@ const.build.product=default const.product.hardwareversion=default const.product.bootloader.version=bootloader const.product.cpu.abilist=default -const.product.software.version=OpenHarmony 6.0.0.46 +const.product.software.version=OpenHarmony 6.0.0.47 const.product.incremental.version=default const.product.firstapiversion=1 const.product.build.type=default diff --git a/services/etc/param/ohos_const/ohos.para b/services/etc/param/ohos_const/ohos.para index 567680ba3..12f9786dd 100755 --- a/services/etc/param/ohos_const/ohos.para +++ b/services/etc/param/ohos_const/ohos.para @@ -15,4 +15,4 @@ const.ohos.releasetype=Beta2 const.ohos.apiversion=20 const.ohos.apiminorversion=0 const.ohos.apipatchversion=0 -const.ohos.fullname=OpenHarmony-6.0.0.46 \ No newline at end of file +const.ohos.fullname=OpenHarmony-6.0.0.47 \ No newline at end of file diff --git a/services/etc_lite/param/ohos_const/ohos.para b/services/etc_lite/param/ohos_const/ohos.para index d179dd714..d22809133 100755 --- a/services/etc_lite/param/ohos_const/ohos.para +++ b/services/etc_lite/param/ohos_const/ohos.para @@ -16,4 +16,4 @@ const.ohos.apiversion=20 const.ohos.apiminorversion=0 const.ohos.apipatchversion=0 const.ohos.version.security_patch=2025/08/01 -const.ohos.fullname=OpenHarmony-6.0.0.46 \ No newline at end of file +const.ohos.fullname=OpenHarmony-6.0.0.47 \ No newline at end of file -- Gitee From 3564f49846dc1a46aaa1cd599f58780486c967d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E5=87=AF=E6=98=8E?= Date: Thu, 21 Aug 2025 11:48:19 +0800 Subject: [PATCH 09/19] =?UTF-8?q?lite=20=E4=BA=A7=E5=93=81=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E9=BB=98=E8=AE=A4=E7=A9=BA=E9=97=B4=E6=89=A9=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 谢凯明 --- begetd.gni | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/begetd.gni b/begetd.gni index 1bcc555e8..2ed3b14ad 100644 --- a/begetd.gni +++ b/begetd.gni @@ -40,7 +40,7 @@ declare_args() { } # config memory size for liteos-m - init_lite_memory_size = 5120 + init_lite_memory_size = 6800 startup_init_feature_decode_group_file = false -- Gitee From a0b5dabef2965c9469eaeec3ff4f12a078e4d88e Mon Sep 17 00:00:00 2001 From: cat Date: Fri, 22 Aug 2025 16:35:51 +0800 Subject: [PATCH 10/19] dd caniuse code Signed-off-by: cat --- interfaces/taihe/BUILD.gn | 2 + interfaces/taihe/syscap/BUILD.gn | 69 +++++++++++++++++++ .../syscap/idl/internal.full.global.taihe | 20 ++++++ .../taihe/syscap/src/ani_constructor.cpp | 36 ++++++++++ .../syscap/src/internal.full.global.impl.cpp | 33 +++++++++ 5 files changed, 160 insertions(+) create mode 100644 interfaces/taihe/syscap/BUILD.gn create mode 100644 interfaces/taihe/syscap/idl/internal.full.global.taihe create mode 100644 interfaces/taihe/syscap/src/ani_constructor.cpp create mode 100644 interfaces/taihe/syscap/src/internal.full.global.impl.cpp diff --git a/interfaces/taihe/BUILD.gn b/interfaces/taihe/BUILD.gn index 74433019d..8bb20df00 100644 --- a/interfaces/taihe/BUILD.gn +++ b/interfaces/taihe/BUILD.gn @@ -17,6 +17,8 @@ group("taihe_group") { deps = [ "deviceInfo:deviceInfo_etc", "deviceInfo:deviceInfo_taihe_native", + "syscap:global_etc", + "syscap:global_taihe_native", "systemParameterEnhance:systemParamterEnhance_etc", "systemParameterEnhance:systemParameterEnhance_taihe_native", ] diff --git a/interfaces/taihe/syscap/BUILD.gn b/interfaces/taihe/syscap/BUILD.gn new file mode 100644 index 000000000..28f17de59 --- /dev/null +++ b/interfaces/taihe/syscap/BUILD.gn @@ -0,0 +1,69 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import("//base/startup/init/begetd.gni") +import("//build/config/components/ets_frontend/ets2abc_config.gni") +import("//build/ohos.gni") +import("//build/ohos/taihe_idl/taihe.gni") + +copy_taihe_idl("copy_global") { + sources = [ "idl/internal.full.global.taihe" ] +} +subsystem_name = "startup" +part_name = "init" +taihe_generated_file_path_global = "$taihe_file_path/out/$subsystem_name/$part_name/global" + +ohos_taihe("run_taihe") { + taihe_generated_file_path = "$taihe_generated_file_path_global" + deps = [ ":copy_global" ] + outputs = [ + "$taihe_generated_file_path/src/internal.full.global.ani.cpp", + "$taihe_generated_file_path/src/internal.full.global.abi.c", + ] +} + +taihe_shared_library("global_taihe_native") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + taihe_generated_file_path = "$taihe_generated_file_path_global" + part_name = "$part_name" + subsystem_name = "$subsystem_name" + sources = get_target_outputs(":run_taihe") + include_dirs = [ "${init_innerkits_path}/include" ] + sources += [ + "src/ani_constructor.cpp", + "src/internal.full.global.impl.cpp", + ] + deps = [ + ":run_taihe", + "${init_innerkits_path}:libbegetutil", + ] +} + +generate_static_abc("global") { + base_url = "$taihe_generated_file_path_global" + files = [ "$taihe_generated_file_path_global/@internal.full.global.ets" ] + is_boot_abc = "True" + device_dst_file = "/system/framework/global.abc" + dependencies = [ ":run_taihe" ] +} + +ohos_prebuilt_etc("global_etc") { + source = "$target_out_dir/global.abc" + module_install_dir = "framework" + part_name = "$part_name" + subsystem_name = "$subsystem_name" + deps = [ ":global" ] +} diff --git a/interfaces/taihe/syscap/idl/internal.full.global.taihe b/interfaces/taihe/syscap/idl/internal.full.global.taihe new file mode 100644 index 000000000..cafb2b150 --- /dev/null +++ b/interfaces/taihe/syscap/idl/internal.full.global.taihe @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + @!namespace("@internal.full.global") + + @!sts_inject(""" + loadLibrary("global_taihe_native.z") + """) + function canIUse(syscap: String): bool; \ No newline at end of file diff --git a/interfaces/taihe/syscap/src/ani_constructor.cpp b/interfaces/taihe/syscap/src/ani_constructor.cpp new file mode 100644 index 000000000..4d73d3eaf --- /dev/null +++ b/interfaces/taihe/syscap/src/ani_constructor.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "taihe.platform.ani.ani.hpp" +#include "internal.full.global.ani.hpp" +#if __has_include() +#include +#elif __has_include() +#include +#else +#error "ani.h not found, Please ensure the Ani SDK is correctly installed." +#endif +ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) +{ + ani_env *env; + if (ANI_OK != vm->GetEnv(ANI_VERSION_1, &env)) { + return ANI_ERROR; + } + if (ANI_OK != internal::full::global::ANIRegister(env)) { + std::cerr << "Error from internal::full::global::ANIRegister" << std::endl; + return ANI_ERROR; + } + *result = ANI_VERSION_1; + return ANI_OK; +} diff --git a/interfaces/taihe/syscap/src/internal.full.global.impl.cpp b/interfaces/taihe/syscap/src/internal.full.global.impl.cpp new file mode 100644 index 000000000..eadaf687f --- /dev/null +++ b/interfaces/taihe/syscap/src/internal.full.global.impl.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "internal.full.global.proj.hpp" +#include "internal.full.global.impl.hpp" +#include "taihe/runtime.hpp" +#include "stdexcept" +#include "systemcapability.h" +#include "beget_ext.h" + +using namespace taihe; +namespace { +// To be implemented. + +bool canIUse(string_view syscap) +{ + bool ret = HasSystemCapability(std::string(syscap).c_str()); + return ret; +} +} //namespace + +TH_EXPORT_CPP_API_canIUse(canIUse); \ No newline at end of file -- Gitee From b52cb83fed5fbfe3cb50312e912fe25534677df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E4=BD=B3=E4=BC=9F?= Date: Thu, 21 Aug 2025 15:09:12 +0800 Subject: [PATCH 11/19] =?UTF-8?q?Description:=E5=90=8C=E6=AD=A5=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=20IssueNo:https://gitee.com/openharmony/startup=5Fini?= =?UTF-8?q?t/issues/ICU1JT=20Binary=20Source:No=20Signed-off-by:=20songjia?= =?UTF-8?q?wei9=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- device_info/device_info_service.cpp | 10 +-- interfaces/innerkits/fs_manager/BUILD.gn | 42 +++++++-- .../erofs_overlay/erofs_mount_overlay.c | 41 +++++++-- .../erofs_overlay/erofs_remount_overlay.c | 4 +- .../include/erofs_remount_overlay.h | 2 +- interfaces/innerkits/fs_manager/fstab_mount.c | 85 +++++++++++++++---- .../innerkits/fs_manager/libfs_dm/fs_dm.c | 5 +- .../fs_manager/libfs_dm/fs_dm_linear.c | 40 +++++---- .../fs_manager/libfs_dm/fs_dm_snapshot.c | 41 +++++---- .../innerkits/include/fs_manager/fs_manager.h | 12 +++ interfaces/innerkits/include/init_utils.h | 4 - .../init_module_engine/include/bootstage.h | 1 + .../init_module_engine/stub/libinit.stub.json | 2 +- interfaces/innerkits/syspara/param_comm.c | 8 +- interfaces/innerkits/syspara/parameter.c | 1 - .../kits/jskits/src/native_deviceinfo_js.cpp | 68 +++++++-------- services/modules/trace/init_trace.c | 2 +- test/fuzztest/onstop_fuzzer/onstop_fuzzer.cpp | 4 +- test/unittest/init/service_unittest.cpp | 2 + .../ueventd/ueventd_event_unittest.cpp | 14 +++ ueventd/ueventd_device_handler.c | 40 ++++----- 21 files changed, 271 insertions(+), 157 deletions(-) diff --git a/device_info/device_info_service.cpp b/device_info/device_info_service.cpp index 701439180..211d49c5a 100644 --- a/device_info/device_info_service.cpp +++ b/device_info/device_info_service.cpp @@ -107,15 +107,13 @@ int32_t DeviceInfoService::CallbackEnter(uint32_t code) switch (code) { case static_cast(IDeviceInfoIpcCode::COMMAND_GET_UDID): case static_cast(IDeviceInfoIpcCode::COMMAND_GET_SERIAL_I_D): { - if (!CheckPermission("ohos.permission.sec.ACCESS_UDID")) { - return SYSPARAM_PERMISSION_DENIED; - } + bool ret = CheckPermission("ohos.permission.sec.ACCESS_UDID"); + BEGET_CHECK_RETURN_VALUE(ret, SYSPARAM_PERMISSION_DENIED); break; } case static_cast(IDeviceInfoIpcCode::COMMAND_GET_DISK_S_N): { - if (!CheckPermission("ohos.permission.ACCESS_DISK_PHY_INFO")) { - return SYSPARAM_PERMISSION_DENIED; - } + bool ret = CheckPermission("ohos.permission.ACCESS_DISK_PHY_INFO"); + BEGET_CHECK_RETURN_VALUE(ret, SYSPARAM_PERMISSION_DENIED); break; } default: { diff --git a/interfaces/innerkits/fs_manager/BUILD.gn b/interfaces/innerkits/fs_manager/BUILD.gn index feb87956f..5989fa3b9 100755 --- a/interfaces/innerkits/fs_manager/BUILD.gn +++ b/interfaces/innerkits/fs_manager/BUILD.gn @@ -53,11 +53,11 @@ ohos_static_library("libfsmanager_static") { if ((defined(global_parts_info) && defined(global_parts_info.startup_hvb)) || init_startup_feature_erofs_overlay) { - sources += [ + sources += [ "libfs_dm/fs_dm.c", "libfs_dm/fs_dm_linear.c", "libfs_dm/fs_dm_snapshot.c", - ] + ] include_dirs += [ "//base/startup/init/interfaces/innerkits/fs_manager/libfs_dm/include", "//base/startup/init/ueventd/include", @@ -89,6 +89,10 @@ ohos_static_library("libfsmanager_static") { include_dirs += [ "//base/startup/init/interfaces/innerkits/fs_manager/erofs_overlay/include" ] defines += [ "EROFS_OVERLAY" ] + if (build_selinux) { + external_deps += [ "selinux:libselinux" ] + cflags = [ "-DWITH_SELINUX" ] + } } } @@ -118,26 +122,48 @@ ohos_static_library("libfsmanager_static_real") { "cJSON:cjson_static", ] deps = [ "//base/startup/init/services/utils:libinit_utils" ] - if (defined(global_parts_info) && defined(global_parts_info.startup_hvb)) { - sources += [ - "dm_verity/dm_verity.c", + + if ((defined(global_parts_info) && + defined(global_parts_info.startup_hvb)) || + init_startup_feature_erofs_overlay) { + source += [ "libfs_dm/fs_dm.c", "libfs_dm/fs_dm_linear.c", "libfs_dm/fs_dm_snapshot.c", + ] + include_dirs += [ + "//base/startup/init/interfaces/innerkits/fs_manager/libfs_dm/include", + "//base/startup/init/ueventd/include", + ] + defines = [] + deps += [ "//base/startup/init/ueventd:libueventd_ramdisk_static_real" ] + } + + if (defined(global_parts_info) && defined(global_parts_info.startup_hvb)) { + sources += [ + "dm_verity/dm_verity.c", "libfs_hvb/fs_hvb.c", "libfs_hvb/hvb_ops.c", ] include_dirs += [ - "//base/startup/init/interfaces/innerkits/fs_manager/libfs_dm/include", "//base/startup/init/interfaces/innerkits/fs_manager/libfs_hvb/include", "//base/startup/init/interfaces/innerkits/fs_manager/dm_verity/include", - "//base/startup/init/ueventd/include", ] defines = [ "SUPPORT_HVB" ] external_deps += [ "hvb:libhvb_static" ] - deps += [ "//base/startup/init/ueventd:libueventd_ramdisk_static_real" ] + } + + if (init_startup_feature_erofs_overlay) { + sources += [ + "erofs_overlay/erofs_mount_overlay.c", + "erofs_overlay/erofs_overlay_common.c", + "erofs_overlay/erofs_remount_overlay.c", + ] + include_dirs += [ "//base/startup/init/interfaces/innerkits/fs_manager/erofs_overlay/include" ] + + defines += [ "EROFS_OVERLAY" ] } } diff --git a/interfaces/innerkits/fs_manager/erofs_overlay/erofs_mount_overlay.c b/interfaces/innerkits/fs_manager/erofs_overlay/erofs_mount_overlay.c index f74c27edb..7a3601a35 100644 --- a/interfaces/innerkits/fs_manager/erofs_overlay/erofs_mount_overlay.c +++ b/interfaces/innerkits/fs_manager/erofs_overlay/erofs_mount_overlay.c @@ -17,6 +17,9 @@ #include #include #include "securec.h" +#ifdef WITH_SELINUX +#include +#endif #include "init_utils.h" #include "fs_dm.h" #include "switch_root.h" @@ -249,7 +252,6 @@ INIT_STATIC int ConstructLinearTarget(DmVerityTarget *target, const char *dev, u return -1; } target->paras_len = strlen(target->paras); - BEGET_LOGI("dev [%s], linearparas [%s], length [%s]", dev, target->paras, target->paras_len); return 0; } @@ -335,27 +337,42 @@ int MountExt4Device(const char *dev, const char *mnt, bool isFirstMount) char dirExt4[MAX_BUFFER_LEN] = {0}; char dirUpper[MAX_BUFFER_LEN] = {0}; char dirWork[MAX_BUFFER_LEN] = {0}; + +#ifdef WITH_SELINUX + if (isFirstMount) { + const char* fsFileContext = "u:object_r:system_file:s0"; + const char* vendorFileContext = "u:object_r:vendor_file:s0"; + BEGET_LOGI("start to set selinux. mnt:%s", mnt); + if (strcmp(mnt, "/vendor") == 0) { + setfscreatecon(vendorFileContext); + } else { + setfscreatecon(fsFileContext); + } + } +#endif + ret = snprintf_s(dirExt4, MAX_BUFFER_LEN, MAX_BUFFER_LEN - 1, PREFIX_OVERLAY"%s", mnt); if (ret < 0) { BEGET_LOGE("dirExt4 copy failed errno %d.", errno); - return -1; + goto exit; } ret = snprintf_s(dirUpper, MAX_BUFFER_LEN, MAX_BUFFER_LEN - 1, PREFIX_OVERLAY"%s"PREFIX_UPPER, mnt); if (ret < 0) { BEGET_LOGE("dirUpper copy failed errno %d.", errno); - return -1; + goto exit; } ret = snprintf_s(dirWork, MAX_BUFFER_LEN, MAX_BUFFER_LEN - 1, PREFIX_OVERLAY"%s"PREFIX_WORK, mnt); if (ret < 0) { BEGET_LOGE("dirWork copy failed errno %d.", errno); - return -1; + goto exit; } if (mkdir(dirExt4, MODE_MKDIR) && (errno != EEXIST)) { BEGET_LOGE("mkdir %s failed.", dirExt4); - return -1; + ret = -1; + goto exit; } int retryCount = 3; @@ -371,14 +388,23 @@ int MountExt4Device(const char *dev, const char *mnt, bool isFirstMount) if (isFirstMount && mkdir(dirUpper, MODE_MKDIR) && (errno != EEXIST)) { BEGET_LOGE("mkdir dirUpper:%s failed.", dirUpper); - return -1; + ret = -1; + goto exit; } if (isFirstMount && mkdir(dirWork, MODE_MKDIR) && (errno != EEXIST)) { BEGET_LOGE("mkdir dirWork:%s failed.", dirWork); - return -1; + ret = -1; + goto exit; } + ret = 0; +exit: +#ifdef WITH_SELINUX + if (isFirstMount) { + setfscreatecon(NULL); + } +#endif return ret; } @@ -480,5 +506,6 @@ int DoMountOverlayDevice(FstabItem *item) BEGET_LOGE("init ext4 dm dev failed"); return -1; } + BEGET_LOGI("mount overlay device %s on %s success", item->deviceName, item->mountPoint); return rc; } \ No newline at end of file diff --git a/interfaces/innerkits/fs_manager/erofs_overlay/erofs_remount_overlay.c b/interfaces/innerkits/fs_manager/erofs_overlay/erofs_remount_overlay.c index 9b217ede3..ac18241c7 100644 --- a/interfaces/innerkits/fs_manager/erofs_overlay/erofs_remount_overlay.c +++ b/interfaces/innerkits/fs_manager/erofs_overlay/erofs_remount_overlay.c @@ -52,14 +52,14 @@ int GetRemountResult(void) return REMOUNT_FAIL; } -void SetRemountResultFlag() +void SetRemountResultFlag(void) { struct stat st; int ret; int statRet = stat(REMOUNT_RESULT_PATH, &st); if (statRet != 0) { - ret = mkdir(REMOUNT_RESULT_PATH, MODE_MKDIR); + ret = MakeDirRecursive(REMOUNT_RESULT_PATH, MODE_MKDIR); if (ret < 0 && errno != EEXIST) { BEGET_LOGE("mkdir remount path failed errno %d", errno); return; diff --git a/interfaces/innerkits/fs_manager/erofs_overlay/include/erofs_remount_overlay.h b/interfaces/innerkits/fs_manager/erofs_overlay/include/erofs_remount_overlay.h index 8a34cf792..96829636f 100644 --- a/interfaces/innerkits/fs_manager/erofs_overlay/include/erofs_remount_overlay.h +++ b/interfaces/innerkits/fs_manager/erofs_overlay/include/erofs_remount_overlay.h @@ -29,7 +29,7 @@ extern "C" { int GetRemountResult(void); -void SetRemountResultFlag(); +void SetRemountResultFlag(void); int RemountOverlay(void); diff --git a/interfaces/innerkits/fs_manager/fstab_mount.c b/interfaces/innerkits/fs_manager/fstab_mount.c index 078c1817d..801cf1c7a 100755 --- a/interfaces/innerkits/fs_manager/fstab_mount.c +++ b/interfaces/innerkits/fs_manager/fstab_mount.c @@ -27,6 +27,7 @@ #include "fs_manager/fs_manager.h" #include "hookmgr.h" #include "list.h" +#include "init_modulemgr.h" #include "init_utils.h" #include "param/init_param.h" #include "securec.h" @@ -48,14 +49,14 @@ extern "C" { #define FS_MANAGER_BUFFER_SIZE 512 #define BLOCK_SIZE_BUFFER (64) #define RESIZE_BUFFER_SIZE 1024 -#define MAX_GCALLOWNANCE 100 -#define GCALLOWANCE_INCREACE 10 +#define MAX_GC_ALLOWANCE 100 +#define GCALLOWANCE_INCREASE 10 const off_t PARTITION_ACTIVE_SLOT_OFFSET = 1024; const off_t PARTITION_ACTIVE_SLOT_SIZE = 4; int g_bootSlots = -1; int g_currentSlot = -1; -__attribute__((weak)) void InitPostMount(const char *mountPoint, int rc) +__attribute__((weak)) void InitPostMount(int rc, struct FstabItem *fstabItem) { } @@ -454,8 +455,8 @@ INIT_STATIC int MountWithCheckpoint(const char *source, const char *target, cons if (rc != 0 && errno == EBUSY) { rc = 0; } - gcAllowance += GCALLOWANCE_INCREACE; - } while (rc != 0 && errno == EAGAIN && gcAllowance <= MAX_GCALLOWNANCE); + gcAllowance += GCALLOWANCE_INCREASE; + } while (rc != 0 && errno == EAGAIN && gcAllowance <= MAX_GC_ALLOWANCE); return rc; } @@ -510,6 +511,47 @@ int GetCurrentSlot(void) return GetSlotInfoFromBootctrl(PARTITION_ACTIVE_SLOT_OFFSET, PARTITION_ACTIVE_SLOT_SIZE); } +static int GetSlotStatus(void) +{ + static int slotStatus = SLOTSTATUS_INIT; + if (slotStatus != SLOTSTATUS_INIT) { + return slotStatus; + } + slotStatus = SLOTSTATUS_OTHER; + do { + if (GetBootSlots() <= 1) { + BEGET_LOGE("boot slot not need CheckVabMountInfo"); + break; + } + int slot = GetCurrentSlot(); + if (slot <= 0 || slot > MAX_SLOT) { + BEGET_LOGE("slot value %d is invalid", slot); + break; + } + slotStatus = SLOTSTATUS_VAB; + } while (0); + return slotStatus; +} + +static int UpdataAndCheckVabMountInfo(FstabItem *item, int result) +{ + int slot = GetSlotStatus(); + if (slot != SLOTSTATUS_VAB) { + return 0; + } + VabMountInfo mountInfo = { + .deviceName = item == NULL ? NULL : item->deviceName, + .fsType = item == NULL ? NULL : item->fsType, + .result = result, + }; + int ret = HookMgrExecute(GetBootStageHookMgr(), INIT_CHECK_VAB_MOUNTINFO, + item == NULL ? NULL : (void*)&mountInfo, NULL); + if (ret != 0) { + BEGET_LOGE("CheckVabMountInfo failed "); + } + return ret; +} + INIT_STATIC int GetDataWithoutCheckpoint(char *fsSpecificData, size_t fsSpecificDataSize, char *checkpointData, size_t checkpointDataSize) { @@ -542,12 +584,12 @@ INIT_STATIC int GetDataWithoutCheckpoint(char *fsSpecificData, size_t fsSpecific continue; } if (strcmp(checkpointData, "") != 0 && - strncat_s(checkpointData, checkpointDataSize - 1, ",", 1) != EOK) { + strncat_s(checkpointData, checkpointDataSize, ",", 1) != EOK) { BEGET_LOGW("failed to append comma."); rc = -1; break; } - if (strncat_s(checkpointData, checkpointDataSize - 1, p, strlen(p)) != EOK) { + if (strncat_s(checkpointData, checkpointDataSize, p, strlen(p)) != EOK) { BEGET_LOGW("Failed to append mountflags \" %s \", ignore it.", p); rc = -1; break; @@ -642,20 +684,29 @@ static int MountItemByFsType(FstabItem *item) static int ExecCheckpointHook(FstabItem *item) { - HOOK_EXEC_OPTIONS options; - options.flags = TRAVERSE_STOP_WHEN_ERROR; - options.postHook = NULL; - options.preHook = NULL; - int ret = HookMgrExecute(GetBootStageHookMgr(), INIT_DISABLE_CHECKPOINT, (void*)item, &options); - BEGET_LOGI("ExecCheckpointHook ret %d", ret); + int ret = -1; + do { + int slot = GetSlotStatus(); + if (slot != SLOTSTATUS_VAB) { + return 0; + } + + ret = HookMgrExecute(GetBootStageHookMgr(), INIT_DISABLE_CHECKPOINT, (void*)item, NULL); + BEGET_LOGI("ExecCheckpointHook ret %d", ret); + } while (0); + return ret; } + int MountOneItem(FstabItem *item) { if (item == NULL) { return -1; } - + if (!IsSupportedFilesystem(item->fsType)) { + BEGET_LOGW("Unsupported file system \" %s \"", item->fsType); + return 0; + } if (FM_MANAGER_WAIT_ENABLED(item->fsManagerFlags)) { WaitForFile(item->deviceName, WAIT_MAX_SECOND); } @@ -691,11 +742,13 @@ int MountOneItem(FstabItem *item) SwitchRoot("/usr"); } #endif + if (disableCheckpointRet == 0 && rc == 0) { BEGET_LOGI("start health check process"); HookMgrExecute(GetBootStageHookMgr(), INIT_HEALTH_CHECK_ACTIVE, NULL, NULL); } - InitPostMount(item->mountPoint, rc); + UpdataAndCheckVabMountInfo(item, rc); + InitPostMount(rc, item); if (rc != 0) { if (FM_MANAGER_NOFAIL_ENABLED(item->fsManagerFlags)) { BEGET_LOGE("Mount no fail device %s to %s failed, err = %d", item->deviceName, item->mountPoint, errno); @@ -814,7 +867,7 @@ int MountAllWithFstab(const Fstab *fstab, bool required) break; } } - + UpdataAndCheckVabMountInfo(NULL, 0); #ifdef SUPPORT_HVB if (required) HvbDmVerityFinal(); diff --git a/interfaces/innerkits/fs_manager/libfs_dm/fs_dm.c b/interfaces/innerkits/fs_manager/libfs_dm/fs_dm.c index 2caf57bf6..c9528c0ba 100755 --- a/interfaces/innerkits/fs_manager/libfs_dm/fs_dm.c +++ b/interfaces/innerkits/fs_manager/libfs_dm/fs_dm.c @@ -99,7 +99,6 @@ int LoadDmDeviceTable(int fd, const char *devName, DmVerityTarget *target, int d BEGET_LOGE("dmTypeIdx error dmTypeIdx %d", dmTypeIdx); return -1; } - parasTotalSize = DM_ALIGN(sizeof(*io) + sizeof(*ts) + target->paras_len + 1); parasBuf = calloc(1, parasTotalSize); if (parasBuf == NULL) { @@ -362,7 +361,7 @@ int DmGetDeviceName(int fd, const char *devName, char *outDevName, const uint64_ path = calloc(1, pathLen); if (path == NULL) { BEGET_LOGE("calloc path failed"); - return -1; + return rc; } rc = snprintf_s(path, pathLen, pathLen - 1, "%s%d", DM_DEVICE_PATH_PREFIX, devNum); @@ -445,8 +444,6 @@ bool GetDmStatusInfo(const char *name, struct dm_ioctl *io) close(fd); return true; } - - #ifdef __cplusplus #if __cplusplus } diff --git a/interfaces/innerkits/fs_manager/libfs_dm/fs_dm_linear.c b/interfaces/innerkits/fs_manager/libfs_dm/fs_dm_linear.c index fe97cdee3..e1aceebf5 100644 --- a/interfaces/innerkits/fs_manager/libfs_dm/fs_dm_linear.c +++ b/interfaces/innerkits/fs_manager/libfs_dm/fs_dm_linear.c @@ -1,17 +1,17 @@ /* -* Copyright (c) 2025 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include #include @@ -38,7 +38,6 @@ static int LoadDmLinearDeviceTable(int fd, const char *devName, DmLinearTarget * for (uint32_t index = 0; index < targetNum; index++) { parasTotalSize += target[index].paras_len + 1; } - char *parasBuf = calloc(1, parasTotalSize); BEGET_ERROR_CHECK(parasBuf != NULL, return -1, "error, calloc dm table fail"); io = (struct dm_ioctl *)parasBuf; @@ -51,12 +50,15 @@ static int LoadDmLinearDeviceTable(int fd, const char *devName, DmLinearTarget * uint32_t len = 0; char *paras = NULL; do { - FS_DM_RETURN_ERR_IF_NULL(target[i].paras); + if (target[i].paras == NULL) { + BEGET_LOGE("error, target[%u].paras is NULL", i); + free(parasBuf); + return -1; + } ts = (struct dm_target_spec *)(parasBuf + sizeof(*io) + len); ts->status = 0; ts->sector_start = target[i].start; ts->length = target[i].length; - rc = strcpy_s(ts->target_type, sizeof(ts->target_type), "linear"); BEGET_ERROR_CHECK(rc == EOK, free(parasBuf); return -1, "error %d, cp target type", rc); len += sizeof((*ts)); @@ -97,7 +99,6 @@ int FsDmCreateMultiTargetLinearDevice(const char *devName, char *dmDevPath, uint } int rc = 0; - do { rc = CreateDmDev(fd, devName); if (rc != 0) { @@ -120,10 +121,8 @@ int FsDmCreateMultiTargetLinearDevice(const char *devName, char *dmDevPath, uint BEGET_LOGE("active dm device name failed"); break; } - BEGET_LOGI("fs create linear device success, dev is [%s] dmDevPath is [%s]", devName, dmDevPath); } while (0); - close(fd); return rc; } @@ -146,19 +145,18 @@ int FsDmSwitchToLinearDevice(const char *devName, DmLinearTarget *target, uint32 } int rc = 0; - do { rc = LoadDmLinearDeviceTable(fd, devName, target, targetNum); if (rc != 0) { BEGET_LOGE("load dm device name failed"); break; } + rc = ActiveDmDevice(fd, devName); if (rc != 0) { BEGET_LOGE("active dm device name failed"); break; } - BEGET_LOGI("fs switch linear device success, dev is [%s]", devName); } while (0); diff --git a/interfaces/innerkits/fs_manager/libfs_dm/fs_dm_snapshot.c b/interfaces/innerkits/fs_manager/libfs_dm/fs_dm_snapshot.c index 8c0fc48c9..591bb4cf8 100644 --- a/interfaces/innerkits/fs_manager/libfs_dm/fs_dm_snapshot.c +++ b/interfaces/innerkits/fs_manager/libfs_dm/fs_dm_snapshot.c @@ -1,17 +1,18 @@ /* -* Copyright (c) 2025 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include #include #include @@ -35,11 +36,13 @@ int FsDmCreateSnapshotDevice(const char *devName, char *dmDevPath, uint64_t dmDe BEGET_LOGE("argc is null"); return -1; } + int fd = open(DEVICE_MAPPER_PATH, O_RDWR | O_CLOEXEC); if (fd < 0) { BEGET_LOGE("error %d, open %s", errno, DEVICE_MAPPER_PATH); return -1; } + int rc = 0; do { rc = CreateDmDev(fd, devName); @@ -47,23 +50,23 @@ int FsDmCreateSnapshotDevice(const char *devName, char *dmDevPath, uint64_t dmDe BEGET_LOGE("error %d, create dm device fail", rc); break; } + rc = LoadDmDeviceTable(fd, devName, target, SNAPSHOT); if (rc != 0) { BEGET_LOGE("error %d, load device table fail", rc); break; } + rc = ActiveDmDevice(fd, devName); if (rc != 0) { BEGET_LOGE("error %d, active device fail", rc); break; } - rc = DmGetDeviceName(fd, devName, dmDevPath, dmDevPathLen); if (rc != 0) { BEGET_LOGE("get dm device name failed"); break; } - BEGET_LOGI("fs create snapshot device success, dev is [%s] dmDevPath is [%s]", devName, dmDevPath); } while (0); close(fd); @@ -81,6 +84,7 @@ int FsDmSwitchToSnapshotMerge(const char *devName, DmSnapshotTarget *target) BEGET_LOGE("error %d, open %s", errno, DEVICE_MAPPER_PATH); return -1; } + int rc = 0; do { rc = LoadDmDeviceTable(fd, devName, target, SNAPSHOTMERGE); @@ -95,6 +99,7 @@ int FsDmSwitchToSnapshotMerge(const char *devName, DmSnapshotTarget *target) } BEGET_LOGI("fs switch snapshot merge success, dev is %s", devName); } while (0); + close(fd); return rc; } @@ -125,17 +130,17 @@ INIT_STATIC bool ParseStatusText(char *data, StatusInfo *processInfo) BEGET_LOGW("processInfo->error is \"%s\"", processInfo->error); return true; } - BEGET_LOGE("could not parse snapshot processInfo \"%s\": wrong format", processInfo->error); + BEGET_LOGE("could not parse snapshot processInfo: wrong format \"%s\"", processInfo->error); return false; } bool GetDmSnapshotStatus(const char *name, const char *targetType, StatusInfo *processInfo) { - if (name == NULL || targetType == NULL || processInfo == NULL) { + BEGET_LOGI("GetDmSnapshotStatus start, name %s, targetType %s", name, targetType); + if (name == NULL || processInfo == NULL) { BEGET_LOGE("argc is null"); return false; } - BEGET_LOGI("GetDmSnapshotStatus start, name %s, targetType %s", name, targetType); size_t bufferLen = MAX_TABLE_LEN * sizeof(char); int fd = open(DEVICE_MAPPER_PATH, O_RDWR | O_CLOEXEC); BEGET_ERROR_CHECK(fd >= 0, return false, "open error %d", errno); diff --git a/interfaces/innerkits/include/fs_manager/fs_manager.h b/interfaces/innerkits/include/fs_manager/fs_manager.h index 55a5f2d9b..dd437e657 100644 --- a/interfaces/innerkits/include/fs_manager/fs_manager.h +++ b/interfaces/innerkits/include/fs_manager/fs_manager.h @@ -65,6 +65,18 @@ typedef enum MountStatus { MOUNT_MOUNTED = 1, } MountStatus; +typedef enum SlotStatus { + SLOTSTATUS_INIT = 0, + SLOTSTATUS_VAB, + SLOTSTATUS_OTHER, +} SlotStatus; + +typedef struct VabMountInfo { + char *deviceName; + char *fsType; + int result; +} VabMountInfo; + typedef struct FstabItem { char *deviceName; // Block device name char *mountPoint; // Mount point diff --git a/interfaces/innerkits/include/init_utils.h b/interfaces/innerkits/include/init_utils.h index 87f350064..c44bba4e4 100644 --- a/interfaces/innerkits/include/init_utils.h +++ b/interfaces/innerkits/include/init_utils.h @@ -63,10 +63,6 @@ typedef struct { #define ARRAY_LENGTH(array) (sizeof((array)) / sizeof((array)[0])) #define BOOT_CMD_LINE STARTUP_INIT_UT_PATH"/proc/cmdline" -#define FIRST_VALUE "First_Value" // 取第一个匹配值 -#define LAST_VALUE "Last_Value" // 取最后一个匹配值 -#define EMPTY_VALUE "EMPTY_VALUE" // 不取任何一个 - #ifndef OHOS_LITE void SetBootCompleted(bool isBootCompleted); bool IsBootCompleted(void); diff --git a/interfaces/innerkits/init_module_engine/include/bootstage.h b/interfaces/innerkits/init_module_engine/include/bootstage.h index c9aa37863..1703df338 100755 --- a/interfaces/innerkits/init_module_engine/include/bootstage.h +++ b/interfaces/innerkits/init_module_engine/include/bootstage.h @@ -34,6 +34,7 @@ enum INIT_BOOTSTAGE { INIT_SNAPSHOT_ACTIVE = 6, INIT_DISABLE_CHECKPOINT = 7, INIT_HEALTH_CHECK_ACTIVE = 8, + INIT_CHECK_VAB_MOUNTINFO = 9, INIT_PRE_PARAM_SERVICE = 10, INIT_VAB_HVBCHECK = 11, INIT_PRE_PARAM_LOAD = 20, diff --git a/interfaces/innerkits/init_module_engine/stub/libinit.stub.json b/interfaces/innerkits/init_module_engine/stub/libinit.stub.json index 69d05327b..0d2704d55 100644 --- a/interfaces/innerkits/init_module_engine/stub/libinit.stub.json +++ b/interfaces/innerkits/init_module_engine/stub/libinit.stub.json @@ -6,7 +6,6 @@ { "name": "LoadPersistParams" }, { "name": "SplitString" }, { "name": "AddCmdExecutor" }, - { "name": "GetServiceByName"}, { "name": "RemoveCmdExecutor" }, { "name": "HookMgrAdd" }, { "name": "HookMgrAddEx" }, @@ -24,6 +23,7 @@ { "name": "StartupLog" }, { "name": "DoJobNow" }, { "name": "GetServiceExtData" }, + { "name": "GetServiceByName"}, { "name": "UpdateMiscMessage" }, { "name": "AddRebootCmdExecutor" }, { "name": "GetBootEventList" }, diff --git a/interfaces/innerkits/syspara/param_comm.c b/interfaces/innerkits/syspara/param_comm.c index 8591bc8d5..c132fcaa2 100644 --- a/interfaces/innerkits/syspara/param_comm.c +++ b/interfaces/innerkits/syspara/param_comm.c @@ -77,7 +77,7 @@ INIT_LOCAL_API int GetParameter_(const char *key, const char *def, char *value, if (def == NULL) { return GetSystemError(ret); } - if (strlen(def) > len) { + if (strlen(def) >= len) { return EC_INVALID; } ret = strcpy_s(value, len, def); @@ -135,11 +135,7 @@ INIT_LOCAL_API const char *GetPropertyAtomic(const char *key, const char **param BEGET_CHECK(res != NULL, return NULL); ret = SystemGetParameter(key, res, &len); - if (ret != 0) { - free(res); - return NULL; - } - + BEGET_CHECK(ret == 0, free(res); return NULL); if (g_propertyGetProcessor != NULL) { res = g_propertyGetProcessor(key, res); } diff --git a/interfaces/innerkits/syspara/parameter.c b/interfaces/innerkits/syspara/parameter.c index e6108cf4a..6d0940407 100644 --- a/interfaces/innerkits/syspara/parameter.c +++ b/interfaces/innerkits/syspara/parameter.c @@ -17,7 +17,6 @@ #include #include -#include #include "param_comm.h" #include "init_param.h" diff --git a/interfaces/kits/jskits/src/native_deviceinfo_js.cpp b/interfaces/kits/jskits/src/native_deviceinfo_js.cpp index e14503e07..bc917fd62 100644 --- a/interfaces/kits/jskits/src/native_deviceinfo_js.cpp +++ b/interfaces/kits/jskits/src/native_deviceinfo_js.cpp @@ -535,6 +535,40 @@ static napi_value GetDiskSN(napi_env env, napi_callback_info info) return napiValue; } +static napi_value CreateDeviceTypes(napi_env env, napi_value exports) +{ + napi_value deviceTypes = nullptr; + napi_value typeDefault = nullptr; + napi_value typePhone = nullptr; + napi_value typeTablet = nullptr; + napi_value type2in1 = nullptr; + napi_value typeTv = nullptr; + napi_value typeWearable = nullptr; + napi_value typeCar = nullptr; + + napi_create_object(env, &deviceTypes); + + napi_create_string_utf8(env, "default", NAPI_AUTO_LENGTH, &typeDefault); + napi_create_string_utf8(env, "phone", NAPI_AUTO_LENGTH, &typePhone); + napi_create_string_utf8(env, "tablet", NAPI_AUTO_LENGTH, &typeTablet); + napi_create_string_utf8(env, "2in1", NAPI_AUTO_LENGTH, &type2in1); + napi_create_string_utf8(env, "tv", NAPI_AUTO_LENGTH, &typeTv); + napi_create_string_utf8(env, "wearable", NAPI_AUTO_LENGTH, &typeWearable); + napi_create_string_utf8(env, "car", NAPI_AUTO_LENGTH, &typeCar); + + napi_set_named_property(env, deviceTypes, "TYPE_DEFAULT", typeDefault); + napi_set_named_property(env, deviceTypes, "TYPE_PHONE", typePhone); + napi_set_named_property(env, deviceTypes, "TYPE_TABLET", typeTablet); + napi_set_named_property(env, deviceTypes, "TYPE_2IN1", type2in1); + napi_set_named_property(env, deviceTypes, "TYPE_TV", typeTv); + napi_set_named_property(env, deviceTypes, "TYPE_WEARABLE", typeWearable); + napi_set_named_property(env, deviceTypes, "TYPE_CAR", typeCar); + + napi_set_named_property(env, exports, "DeviceTypes", deviceTypes); + + return exports; +} + static napi_value EnumLevelClassConstructor(napi_env env, napi_callback_info info) { napi_value thisArg = nullptr; @@ -582,40 +616,6 @@ static napi_value GetPerformanceClass(napi_env env, napi_callback_info info) return napiValue; } -static napi_value CreateDeviceTypes(napi_env env, napi_value exports) -{ - napi_value deviceTypes = nullptr; - napi_value typeDefault = nullptr; - napi_value typePhone = nullptr; - napi_value typeTablet = nullptr; - napi_value type2in1 = nullptr; - napi_value typeTv = nullptr; - napi_value typeWearable = nullptr; - napi_value typeCar = nullptr; - - napi_create_object(env, &deviceTypes); - - napi_create_string_utf8(env, "default", NAPI_AUTO_LENGTH, &typeDefault); - napi_create_string_utf8(env, "phone", NAPI_AUTO_LENGTH, &typePhone); - napi_create_string_utf8(env, "tablet", NAPI_AUTO_LENGTH, &typeTablet); - napi_create_string_utf8(env, "2in1", NAPI_AUTO_LENGTH, &type2in1); - napi_create_string_utf8(env, "tv", NAPI_AUTO_LENGTH, &typeTv); - napi_create_string_utf8(env, "wearable", NAPI_AUTO_LENGTH, &typeWearable); - napi_create_string_utf8(env, "car", NAPI_AUTO_LENGTH, &typeCar); - - napi_set_named_property(env, deviceTypes, "TYPE_DEFAULT", typeDefault); - napi_set_named_property(env, deviceTypes, "TYPE_PHONE", typePhone); - napi_set_named_property(env, deviceTypes, "TYPE_TABLET", typeTablet); - napi_set_named_property(env, deviceTypes, "TYPE_2IN1", type2in1); - napi_set_named_property(env, deviceTypes, "TYPE_TV", typeTv); - napi_set_named_property(env, deviceTypes, "TYPE_WEARABLE", typeWearable); - napi_set_named_property(env, deviceTypes, "TYPE_CAR", typeCar); - - napi_set_named_property(env, exports, "DeviceTypes", deviceTypes); - - return exports; -} - EXTERN_C_START /* * Module init diff --git a/services/modules/trace/init_trace.c b/services/modules/trace/init_trace.c index d6fcc6a62..109ea32a7 100644 --- a/services/modules/trace/init_trace.c +++ b/services/modules/trace/init_trace.c @@ -304,7 +304,7 @@ static void CheckKernelType(bool *isLinux) { struct utsname uts; if (uname(&uts) == -1) { - PLUGIN_LOGE("Kernel type get failed,errno:d", errno); + PLUGIN_LOGE("Kernel type get failed,errno:%d", errno); return; } diff --git a/test/fuzztest/onstop_fuzzer/onstop_fuzzer.cpp b/test/fuzztest/onstop_fuzzer/onstop_fuzzer.cpp index e491fb74e..7ff5dffc0 100644 --- a/test/fuzztest/onstop_fuzzer/onstop_fuzzer.cpp +++ b/test/fuzztest/onstop_fuzzer/onstop_fuzzer.cpp @@ -36,7 +36,7 @@ public: } }; namespace OHOS { -bool FuzzCheckAppWatchPermission(const uint8_t* data, size_t size) + bool FuzzOnstop(const uint8_t* data, size_t size) { std::unique_ptr watcherManager = std::make_unique(0, true); uint32_t id = static_cast(*data); @@ -54,6 +54,6 @@ bool FuzzCheckAppWatchPermission(const uint8_t* data, size_t size) extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ - OHOS::FuzzCheckAppWatchPermission(data, size); + OHOS::FuzzOnstop(data, size); return 0; } \ No newline at end of file diff --git a/test/unittest/init/service_unittest.cpp b/test/unittest/init/service_unittest.cpp index 53ad4ee75..bdee6276b 100644 --- a/test/unittest/init/service_unittest.cpp +++ b/test/unittest/init/service_unittest.cpp @@ -619,6 +619,7 @@ HWTEST_F(ServiceUnitTest, TestKernelPermPermissionError, TestSize.Level1) ASSERT_NE(nullptr, service); int ret = ParseOneService(serviceItem, service); EXPECT_EQ(ret, 0); + EXPECT_TRUE(service->kernelPerms != nullptr); SERVICE_INFO_CTX context; context.serviceName = service->name; @@ -646,6 +647,7 @@ HWTEST_F(ServiceUnitTest, TestKernelPermServiceNameError, TestSize.Level1) ASSERT_NE(nullptr, service); int ret = ParseOneService(serviceItem, service); EXPECT_EQ(ret, 0); + EXPECT_TRUE(service->kernelPerms != nullptr); SERVICE_INFO_CTX context; context.serviceName = "wrongServiceName"; diff --git a/test/unittest/ueventd/ueventd_event_unittest.cpp b/test/unittest/ueventd/ueventd_event_unittest.cpp index 465ca7ac3..3df7f1bcf 100644 --- a/test/unittest/ueventd/ueventd_event_unittest.cpp +++ b/test/unittest/ueventd/ueventd_event_unittest.cpp @@ -532,6 +532,20 @@ HWTEST_F(UeventdEventUnitTest, Init_UeventdEventUnitTest_HandleUsbDevicesWithBus EXPECT_TRUE(exist); } +HWTEST_F(UeventdEventUnitTest, Init_UeventdEventUnitTest_HandleDevicesWithInputEvent001, TestSize.Level1) +{ + struct Uevent uevent = { + .subsystem = "input", + .syspath = "/devices/platform/fingerprint/input", + .deviceName = "event30", + .major = 8, + .minor = 9, + }; + HandleOtherDeviceEvent(&uevent); + auto exist = IsFileExist("/dev/input/event30"); + EXPECT_TRUE(exist); +} + HWTEST_F(UeventdEventUnitTest, Init_UeventdEventUnitTest_Handle001, TestSize.Level1) { char path[] = {"/data/ueventd"}; diff --git a/ueventd/ueventd_device_handler.c b/ueventd/ueventd_device_handler.c index 906b40182..3758cd085 100644 --- a/ueventd/ueventd_device_handler.c +++ b/ueventd/ueventd_device_handler.c @@ -505,29 +505,6 @@ void HandleBlockDeviceEvent(const struct Uevent *uevent) HandleDeviceNode(uevent, deviceNode, isBlock); } -static int SplitUsbDeviceNode(const struct Uevent *uevent, char *deviceNode) -{ - if (uevent->deviceName != NULL) { - if (snprintf_s(deviceNode, DEVICE_FILE_SIZE, DEVICE_FILE_SIZE - 1, "/dev/%s", uevent->deviceName) == -1) { - INIT_LOGE("Make device file for device [%d : %d]", uevent->major, uevent->minor); - return -1; - } - return 0; - } else { - if (uevent->busNum < 0 || uevent->devNum < 0) { - // usb device should always report bus number and device number. - INIT_LOGE("usb device with invalid bus number or device number"); - return -1; - } - if (snprintf_s(deviceNode, DEVICE_FILE_SIZE, DEVICE_FILE_SIZE - 1, - "/dev/bus/usb/%03d/%03d", uevent->busNum, uevent->devNum) == -1) { - INIT_LOGE("Make usb device node for device [%d : %d]", uevent->busNum, uevent->devNum); - return 0; - } - return 0; - } -} - void HandleOtherDeviceEvent(const struct Uevent *uevent) { if (uevent == NULL || uevent->subsystem == NULL || uevent->syspath == NULL) { @@ -561,8 +538,21 @@ void HandleOtherDeviceEvent(const struct Uevent *uevent) // if usb devices report DEVNAME, just create device node. // otherwise, create deviceNode with bus number and device number. if (STRINGEQUAL(uevent->subsystem, "usb")) { - if (SplitUsbDeviceNode(uevent, deviceNode) != 0) { - return; + if (uevent->deviceName != NULL) { + if (snprintf_s(deviceNode, DEVICE_FILE_SIZE, DEVICE_FILE_SIZE - 1, "/dev/%s", uevent->deviceName) == -1) { + INIT_LOGE("Make device file for device [%d : %d]", uevent->major, uevent->minor); + return; + } + } else { + if (uevent->busNum < 0 || uevent->devNum < 0) { + // usb device should always report bus number and device number. + INIT_LOGE("usb device with invalid bus number or device number"); + return; + } + if (snprintf_s(deviceNode, DEVICE_FILE_SIZE, DEVICE_FILE_SIZE - 1, + "/dev/bus/usb/%03d/%03d", uevent->busNum, uevent->devNum) == -1) { + INIT_LOGE("Make usb device node for device [%d : %d]", uevent->busNum, uevent->devNum); + } } } else if (STARTSWITH(uevent->subsystem, "usb")) { // Other usb devies, do not handle it. -- Gitee From 4ee3b7c2f7e277d28541c3ba5e967054d38fe015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E4=BD=B3=E4=BC=9F?= Date: Mon, 25 Aug 2025 14:54:59 +0800 Subject: [PATCH 12/19] Description:add autotest testcases IssueNo:https://gitee.com/openharmony/startup_init/issues/ICUJK2 Binary Source:No Signed-off-by: songjiawei9 --- .../sub_startup_init_ability_up_0500.json | 14 +++ .../sub_startup_init_ability_up_0500.py | 83 ++++++++++++++++ .../sub_startup_init_ability_up_0600.json | 14 +++ .../sub_startup_init_ability_up_0600.py | 88 +++++++++++++++++ .../sub_startup_init_ability_up_0700.json | 14 +++ .../sub_startup_init_ability_up_0700.py | 88 +++++++++++++++++ .../sub_startup_init_ability_up_0800.json | 14 +++ .../sub_startup_init_ability_up_0800.py | 88 +++++++++++++++++ .../sub_startup_init_ability_up_1000.json | 14 +++ .../sub_startup_init_ability_up_1000.py | 98 +++++++++++++++++++ ...ub_startup_init_access_isolation_0100.json | 14 +++ .../sub_startup_init_access_isolation_0100.py | 79 +++++++++++++++ ...ub_startup_init_access_isolation_0200.json | 14 +++ .../sub_startup_init_access_isolation_0200.py | 75 ++++++++++++++ .../sub_startup_init_apiname_0100.json | 14 +++ .../sub_startup_init_apiname_0100.py | 62 ++++++++++++ .../sub_startup_init_basicenv_0200.json | 14 +++ .../sub_startup_init_basicenv_0200.py | 44 +++++++++ .../sub_startup_init_basicenv_0600.json | 15 +++ .../sub_startup_init_basicenv_0600.py | 43 ++++++++ .../sub_startup_init_basicenv_0700.json | 15 +++ .../sub_startup_init_basicenv_0700.py | 58 +++++++++++ .../sub_startup_init_basicenv_0800.json | 15 +++ .../sub_startup_init_basicenv_0800.py | 63 ++++++++++++ .../sub_startup_init_basicenv_0900.json | 14 +++ .../sub_startup_init_basicenv_0900.py | 55 +++++++++++ .../sub_startup_init_basicenv_1000.json | 14 +++ .../sub_startup_init_basicenv_1000.py | 41 ++++++++ .../sub_startup_init_gwp_0200.json | 14 +++ .../sub_startup_init_gwp_0200.py | 41 ++++++++ .../sub_startup_init_gwp_0300.json | 14 +++ .../sub_startup_init_gwp_0300.py | 61 ++++++++++++ .../sub_startup_init_hilog_0100.json | 12 +++ .../sub_startup_init_hilog_0100.py | 63 ++++++++++++ .../sub_startup_init_odid_0100.json | 15 +++ .../sub_startup_init_odid_0100.py | 79 +++++++++++++++ .../sub_startup_init_odid_0300.json | 15 +++ .../sub_startup_init_odid_0300.py | 76 ++++++++++++++ 38 files changed, 1554 insertions(+) create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0500.json create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0500.py create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0600.json create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0600.py create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0700.json create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0700.py create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0800.json create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0800.py create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_1000.json create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_1000.py create mode 100644 test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0100.json create mode 100644 test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0100.py create mode 100644 test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0200.json create mode 100644 test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0200.py create mode 100644 test/autotest/testcases/sub_startup_init_apiname/sub_startup_init_apiname_0100.json create mode 100644 test/autotest/testcases/sub_startup_init_apiname/sub_startup_init_apiname_0100.py create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0200.json create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0200.py create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0600.json create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0600.py create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0700.json create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0700.py create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0800.json create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0800.py create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0900.json create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0900.py create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_1000.json create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_1000.py create mode 100644 test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0200.json create mode 100644 test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0200.py create mode 100644 test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0300.json create mode 100644 test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0300.py create mode 100644 test/autotest/testcases/sub_startup_init_hilog/sub_startup_init_hilog_0100.json create mode 100644 test/autotest/testcases/sub_startup_init_hilog/sub_startup_init_hilog_0100.py create mode 100644 test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0100.json create mode 100644 test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0100.py create mode 100644 test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0300.json create mode 100644 test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0300.py diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0500.json b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0500.json new file mode 100644 index 000000000..d5aa6b8ae --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0500.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_ability_up/SubStartupInitAbilityUp0500.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0500.py b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0500.py new file mode 100644 index 000000000..1085df5cd --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0500.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitAbilityUp0500(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机/pc开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("重命名系统文件param_watcher.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell( + "cp /system/etc/init/param_watcher.cfg /system/etc/init/param_watcher.cfg_bak") + Step("把系统文件param_watcher.cfg拉到本地..........................") + devpath = "/system/etc/init/param_watcher.cfg" + self.driver.pull_file(devpath, "testFile/sub_startup_init_ability_up/param_watcher.cfg") + Step("修改本地系统文件..........................") + lines1 = [] + path2 = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), + "testFile\sub_startup_init_ability_up") + local_path = os.path.join(path2, "param_watcher.cfg") + with open(local_path, "r") as y: + for line in y: + lines1.append(line) + y.close() + Step(lines1) + line = lines1.index(' "services" : [{\n') + 1 + path3 = '\t\t\t"importance" : 100,\n' + lines1.insert(line, path3) + s = ''.join(lines1) + Step(s) + with open(local_path, "w") as z: + z.write(s) + z.close() + Step("上传修改后的本地系统文件..........................") + self.driver.push_file(local_path, devpath) + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + Step("执行命令begetctl dump_service..........................") + result = self.driver.shell('begetctl dump_service param_watcher') + Step(result) + pid = self.driver.System.get_pid('param_watcher') + Step(pid) + + def teardown(self): + Step("收尾工作.................") + Step("恢复系统文件param_watcher.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell("rm -rf /system/etc/init/param_watcher.cfg") + self.driver.shell( + "mv /system/etc/init/param_watcher.cfg_bak /system/etc/init/param_watcher.cfg") + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0600.json b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0600.json new file mode 100644 index 000000000..c56c57c03 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0600.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_ability_up/SubStartupInitAbilityUp0600.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0600.py b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0600.py new file mode 100644 index 000000000..374f81c29 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0600.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitAbilityUp0600(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("重命名系统文件wifi_standard.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell( + "cp /system/etc/init/wifi_standard.cfg /system/etc/init/wifi_standard.cfg_bak") + Step("把系统文件wifi_standard.cfg拉到本地..........................") + devpath = "/system/etc/init/wifi_standard.cfg" + self.driver.pull_file(devpath, "testFile/sub_startup_init_ability_up/wifi_standard.cfg") + Step("修改本地系统文件..........................") + lines1 = [] + path2 = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), + "testFile\sub_startup_init_ability_up") + local_path = os.path.join(path2, "wifi_standard.cfg") + with open(local_path, "r") as y: + for line in y: + lines1.append(line) + y.close() + line = lines1.index(' "name" : "wifi_manager_service",\n') + 1 + res1 = line + Step(f"目标索引:{res1}") + index_str1 = lines1[res1] + Step(f"需要修改的目标:{index_str1}") + lines1.remove(index_str1) + Step(f"移除目标之后:{lines1}") + path3 = ' "path" : ["/system/xxxx/bin/sa_main"],\n' + lines1.insert(line, path3) + s = ''.join(lines1) + Step(f"添加修改之后的文件内容:{s}") + with open(local_path, "w") as z: + z.write(s) + z.close() + Step("上传修改后的本地系统文件..........................") + self.driver.push_file(local_path, devpath) + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + Step("执行命令begetctl dump_service..........................") + result = self.driver.shell('begetctl dump_service wifi_manager_service') + Step(result) + pid = self.driver.System.get_pid('wifi_manager_service') + Step(pid) + + def teardown(self): + Step("收尾工作.................") + Step("恢复系统文件wifi_standard.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell("rm -rf /system/etc/init/wifi_standard.cfg") + self.driver.shell( + "mv /system/etc/init/wifi_standard.cfg_bak /system/etc/init/wifi_standard.cfg") + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0700.json b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0700.json new file mode 100644 index 000000000..ebcbafd88 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0700.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_ability_up/SubStartupInitAbilityUp0700.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0700.py b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0700.py new file mode 100644 index 000000000..ebcf1465f --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0700.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitAbilityUp0700(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("重命名系统文件hilogd.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell( + "cp /system/etc/init/hilogd.cfg /system/etc/init/hilogd.cfg_bak") + Step("把系统文件hilogd.cfg拉到本地..........................") + devpath = "/system/etc/init/hilogd.cfg" + self.driver.pull_file(devpath, "testFile/sub_startup_init_ability_up/hilogd.cfg") + Step("修改本地系统文件..........................") + lines1 = [] + path2 = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), + "testFile\sub_startup_init_ability_up") + local_path = os.path.join(path2, "hilogd.cfg") + with open(local_path, "r") as y: + for line in y: + lines1.append(line) + y.close() + line = lines1.index(' "socket" : [{\n') - 1 + res1 = line + Step(f"目标索引:{res1}") + index_str1 = lines1[res1] + Step(f"需要修改的目标:{index_str1}") + lines1.remove(index_str1) + Step(f"移除目标之后:{lines1}") + path3 = ' "file" : ["/dev/test/kmsg rd 0640 root root"],\n' + lines1.insert(line, path3) + s = ''.join(lines1) + Step(f"添加修改之后的文件内容:{s}") + with open(local_path, "w") as z: + z.write(s) + z.close() + Step("上传修改后的本地系统文件..........................") + self.driver.push_file(local_path, devpath) + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() + Step("执行命令begetctl dump_service..........................") + result = self.driver.shell('begetctl dump_service hilogd') + Step(result) + self.driver.Assert.contains(result, "HiLogAdapter_init: Can't connect to server. Errno: 2") + + def teardown(self): + Step("收尾工作.................") + Step("恢复系统文件hilogd.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell("rm -rf /system/etc/init/hilogd.cfg") + self.driver.shell( + "mv /system/etc/init/hilogd.cfg_bak /system/etc/init/hilogd.cfg") + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0800.json b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0800.json new file mode 100644 index 000000000..c2a9032b3 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0800.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_ability_up/SubStartupInitAbilityUp0800.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0800.py b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0800.py new file mode 100644 index 000000000..d62e52088 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0800.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitAbilityUp0800(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("重命名系统文件wifi_standard.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell( + "cp /system/etc/init/wifi_standard.cfg /system/etc/init/wifi_standard.cfg_bak") + Step("把系统文件wifi_standard.cfg拉到本地..........................") + devpath = "/system/etc/init/wifi_standard.cfg" + self.driver.pull_file(devpath, "testFile/sub_startup_init_ability_up/wifi_standard.cfg") + Step("修改本地系统文件..........................") + lines1 = [] + path2 = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), + "testFile\sub_startup_init_ability_up") + local_path = os.path.join(path2, "wifi_standard.cfg") + with open(local_path, "r") as y: + for line in y: + lines1.append(line) + y.close() + line = lines1.index(' "uid" : "wifi",\n') + res1 = line + Step(f"目标索引:{res1}") + index_str1 = lines1[res1] + Step(f"需要修改的目标:{index_str1}") + lines1.remove(index_str1) + Step(f"移除目标之后:{lines1}") + path3 = ' "uid" : "-1",\n' + lines1.insert(line, path3) + s = ''.join(lines1) + Step(f"添加修改之后的文件内容:{s}") + with open(local_path, "w") as z: + z.write(s) + z.close() + Step("上传修改后的本地系统文件..........................") + self.driver.push_file(local_path, devpath) + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + Step("执行命令begetctl dump_service..........................") + result = self.driver.shell('begetctl dump_service wifi_manager_service') + Step(result) + pid = self.driver.System.get_pid('wifi_manager_service') + Step(pid) + + def teardown(self): + Step("收尾工作.................") + Step("恢复系统文件wifi_standard.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell("rm -rf /system/etc/init/wifi_standard.cfg") + self.driver.shell( + "mv /system/etc/init/wifi_standard.cfg_bak /system/etc/init/wifi_standard.cfg") + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_1000.json b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_1000.json new file mode 100644 index 000000000..fb01c76e2 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_1000.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_ability_up/SubStartupInitAbilityUp1000.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_1000.py b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_1000.py new file mode 100644 index 000000000..cebedd469 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_1000.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitAbilityUp1000(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("重命名系统文件hilogd.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell( + "cp /system/etc/init/hilogd.cfg /system/etc/init/hilogd.cfg_bak") + Step("把系统文件hilogd.cfg拉到本地..........................") + devpath = "/system/etc/init/hilogd.cfg" + self.driver.pull_file(devpath, "testFile/sub_startup_init_ability_up/hilogd.cfg") + Step("修改本地系统文件..........................") + lines1 = [] + path2 = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), + "testFile\sub_startup_init_ability_up") + local_path = os.path.join(path2, "hilogd.cfg") + with open(local_path, "r") as y: + for line in y: + lines1.append(line) + y.close() + line = lines1.index(' "secon" : "u:r:hilogd:s0"\n') + res1 = line + Step(f"目标索引:{res1}") + index_str1 = lines1[res1] + Step(f"需要删除目标:{index_str1}") + lines1.remove(index_str1) + line2 = line - 1 + index_str2 = lines1[line2] + lines2 = list(index_str2) + Step(f"需要修改,:{lines2}") + if ',' in lines2: + lines2.remove(',') + s2 = ''.join(lines2) + Step(f"修改,之后:{s2}") + else: + pass + lines1.remove(index_str2) + lines1.insert(line2, s2) + Step(f"全部修改:{lines1}") + s = ''.join(lines1) + Step(f"修改之后的文件内容:{s}") + with open(local_path, "w") as z: + z.write(s) + z.close() + Step("上传修改后的本地系统文件..........................") + self.driver.push_file(local_path, devpath) + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() + Step("执行命令begetctl dump_service..........................") + result = self.driver.shell('begetctl dump_service hilogd') + Step(result) + self.driver.Assert.contains(result, "HiLogAdapter_init: Can't connect to server.") + + def teardown(self): + Step("收尾工作.................") + Step("恢复系统文件hilogd.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell("rm -rf /system/etc/init/hilogd.cfg") + self.driver.shell( + "mv /system/etc/init/hilogd.cfg_bak /system/etc/init/hilogd.cfg") + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() diff --git a/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0100.json b/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0100.json new file mode 100644 index 000000000..2545c2229 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_access_isolation/SubStartupInitAccessIsolation0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0100.py b/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0100.py new file mode 100644 index 000000000..fa4c7fae9 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0100.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver +from aw import Common +from hypium import UiDriver, UiExplorer +from hypium.action.os_hypium.device_logger import DeviceLogger +import subprocess + + +class SubStartupInitAccessIsolation0100(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("导入测试文件systemapp.................") + self.driver.hdc("target mount") + sourpath_se = Common.sourcepath("systemapp", "sub_startup_init_access_isolation") + destpath_se = "system/bin/systemapp" + self.driver.push_file(sourpath_se, destpath_se) + sleep(3) + Step("重启生效..........................") + self.driver.System.reboot() + sleep(5) + self.driver.System.wait_for_boot_complete() + + def test_step1(self): + Step("过滤打印hilog日志.................") + device_logger = DeviceLogger(self.driver) + path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + device_logger.set_filter_string("systemapp") + Step("开始抓取日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("给测试文件systemapp添加可执行权限.................") + self.driver.hdc("target mount") + self.driver.shell("chmod +x ./system/bin/systemapp") + Step("防止hilog日志出现unknown log.................") + self.driver.shell("hilog -d /system/bin/systemapp") + Step("执行测试文件systemapp.................") + self.driver.shell("./system/bin/systemapp") + time.sleep(3) + Step("停止抓日志") + device_logger.stop_log() + Step("断言预期结果") + time.sleep(2) + device_logger.check_log('systemapp:prohibit system component processes from accessing vendor files') + + def teardown(self): + Step("收尾工作.................") + self.driver.hdc("target mount") + self.driver.shell("rm -rf system/bin/systemapp") + Step("重启恢复..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() diff --git a/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0200.json b/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0200.json new file mode 100644 index 000000000..e9829d427 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_access_isolation/SubStartupInitAccessIsolation0200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0200.py b/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0200.py new file mode 100644 index 000000000..1a18ee3ae --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0200.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver +from aw import Common +from hypium import UiDriver, UiExplorer +from hypium.action.os_hypium.device_logger import DeviceLogger +import subprocess + + +class SubStartupInitAccessIsolation0200(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + print("预置工作:初始化手机开始.................") + print(self.devices[0].device_id) + Step("导入测试文件chipsetapp.................") + self.driver.hdc("target mount") + sourpath_se = Common.sourcepath("chipsetapp", "sub_startup_init_access_isolation") + destpath_se = "vendor/bin/chipsetapp" + self.driver.push_file(sourpath_se, destpath_se) + sleep(3) + Step("重启生效..........................") + self.driver.System.reboot() + sleep(5) + self.driver.System.wait_for_boot_complete() + + def test_step1(self): + Step("过滤打印hilog日志.................") + cmd = 'hdc shell hilog | grep chipsetapp' + trace = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=10) + count = 0 + Step("给测试文件chipsetapp添加可执行权限.................") + self.driver.hdc("target mount") + self.driver.shell("chmod +x ./vendor/bin/chipsetapp") + Step("执行测试文件chipsetapp.................") + self.driver.shell("./vendor/bin/chipsetapp") + Step("验证执行结果.................") + while trace.poll() is None: + result_text = trace.stdout.readline().decode() + if 'chipsetapp:prohibit chipset component processes from accessing system files' in result_text: + Step("实现芯片组件访问系统文件隔离.................") + trace.terminate() + break + count += 1 + + def teardown(self): + print("收尾工作.................") + self.driver.hdc("target mount") + self.driver.shell("rm -rf vendor/bin/chipsetapp") + Step("重启恢复..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() diff --git a/test/autotest/testcases/sub_startup_init_apiname/sub_startup_init_apiname_0100.json b/test/autotest/testcases/sub_startup_init_apiname/sub_startup_init_apiname_0100.json new file mode 100644 index 000000000..61b91e1d2 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_apiname/sub_startup_init_apiname_0100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_apiname/SubStartupInitApiname0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_apiname/sub_startup_init_apiname_0100.py b/test/autotest/testcases/sub_startup_init_apiname/sub_startup_init_apiname_0100.py new file mode 100644 index 000000000..c996fcb17 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_apiname/sub_startup_init_apiname_0100.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver +from aw import Common + + +class SubStartupInitApiname0100(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("预置工作:检测屏幕是否亮.................") + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("安装测试hap.................") + sourpath = Common.sourcepath("distributionOsApiName.hap", "sub_startup_init_apiname") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + Step("命令查看param get const.product.os.dist.apiname.................") + apiname = self.driver.shell("param get const.product.os.dist.apiname") + apiname = apiname.strip() + Step(apiname) + result = "const.product.os.dist.apiname: " + apiname + Step(result) + Step("打开测试hap.................") + self.driver.start_app("com.example.myapplication", "EntryAbility") + Step("点击get ApiName按钮.................") + self.driver.touch(BY.text("get ApiName")) + sleep(1) + Step("校验apiname值.................") + + def teardown(self): + Step("收尾工作.................") + Step("卸载测试hap................") + self.driver.AppManager.clear_app_data('com.example.myapplication') + self.driver.AppManager.uninstall_app('com.example.myapplication') diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0200.json b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0200.json new file mode 100644 index 000000000..41e443498 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_basicenv/SubStartupInitBasicenv0200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0200.py b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0200.py new file mode 100644 index 000000000..c2f111648 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0200.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitBasicenv0200(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("find /dev/unix/socket................") + result_socket = self.driver.shell("ls -l /dev/unix/socket") + Step(result_socket) + self.driver.Assert.contains(result_socket, 'hdcd', "ERROR: hdcd is not exist in socket directory.") + self.driver.Assert.contains(result_socket, 'hilogInput', "ERROR: hilogInput is not exist in socket directory.") + self.driver.Assert.contains(result_socket, 'hilogControl', "ERROR: hilogControl is not exist in socket directory.") + self.driver.Assert.contains(result_socket, 'hisysevent', "ERROR: hisysevent is not exist in socket directory.") + + def teardown(self): + Step("收尾工作.................") diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0600.json b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0600.json new file mode 100644 index 000000000..1f7d0dcbd --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0600.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_basicenv/SubStartupInitBasicenv0600.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0600.py b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0600.py new file mode 100644 index 000000000..058b638c2 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0600.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitBasicenv0600(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("df -h................") + result_df = self.driver.shell("df -h") + Step(result_df) + self.driver.Assert.contains(result_df, 'sdd8', "基础文件系统挂载失败") + self.driver.Assert.contains(result_df, '/vendor', "基础文件系统挂载失败") + self.driver.Assert.contains(result_df, '/data', "基础文件系统挂载失败") + + def teardown(self): + Step("收尾工作.................") diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0700.json b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0700.json new file mode 100644 index 000000000..d7a6e64a3 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0700.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_basicenv/SubStartupInitBasicenv0700.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0700.py b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0700.py new file mode 100644 index 000000000..2d0af23f1 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0700.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitBasicenv0700(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("df -h................") + result_df = self.driver.shell("df -h") + Step(result_df) + self.driver.Assert.contains(result_df, '/vendor', "基础文件系统挂载失败") + self.driver.Assert.contains(result_df, '/data', "基础文件系统挂载失败") + Step("find fstab................") + + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("ALN" in device): + result_fstab = self.driver.shell("cat /vendor/etc/fstab.kirin9000s") + elif("CLS" in device): + result_fstab = self.driver.shell("cat /vendor/etc/fstab.Kirin9010") + else: + result_fstab = self.driver.shell("cat /vendor/etc/fstab.kirin9020") + Step(result_fstab) + self.driver.Assert.contains(result_fstab, '/usr', "文件系统挂载失败") + self.driver.Assert.contains(result_fstab, '/vendor', "文件系统挂载失败") + self.driver.Assert.contains(result_fstab, '/data', "文件系统挂载失败") + + def teardown(self): + Step("收尾工作.................") diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0800.json b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0800.json new file mode 100644 index 000000000..03fd6b96c --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0800.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_basicenv/SubStartupInitBasicenv0800.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0800.py b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0800.py new file mode 100644 index 000000000..181c50d2a --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0800.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitBasicenv0800(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("find cmdline................") + result_cmdline = self.driver.shell("cat /proc/cmdline") + Step(result_cmdline) + + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("ALN" in device): + self.driver.Assert.contains(result_cmdline, 'hardware=kirin9000s', "ERROR: cannot find hardware in /proc/cmdline.") + Step("param get hardware................") + result_hardware = self.driver.shell("param get ohos.boot.hardware") + Step(result_hardware) + self.driver.Assert.contains(result_hardware, 'kirin9000s', "ERROR: cannot find hardware in param get.") + elif ("CLS" in device): + self.driver.Assert.contains(result_cmdline, 'hardware=Kirin9010', "ERROR: cannot find hardware in /proc/cmdline.") + result_hardware = self.driver.shell("param get ohos.boot.hardware") + Step(result_hardware) + self.driver.Assert.contains(result_hardware, 'Kirin9010', "ERROR: cannot find hardware in param get.") + else: + self.driver.Assert.contains(result_cmdline, 'hardware=kirin9020', "ERROR: cannot find hardware in /proc/cmdline.") + Step("param get hardware................") + result_hardware = self.driver.shell("param get ohos.boot.hardware") + Step(result_hardware) + self.driver.Assert.contains(result_hardware, 'kirin9020', "ERROR: cannot find hardware in param get.") + + def teardown(self): + Step("收尾工作.................") diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0900.json b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0900.json new file mode 100644 index 000000000..0a41f45ea --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0900.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_basicenv/SubStartupInitBasicenv0900.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0900.py b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0900.py new file mode 100644 index 000000000..255a0b026 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0900.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitBasicenv0900(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("test mkdir................") + self.driver.shell("mkdir /data/testmkdir") + result_mkdir = self.driver.shell("ls -l /data") + Step(result_mkdir) + self.driver.Assert.contains(result_mkdir, 'testmkdir', "ERROR: cannot find testmkdir directory.") + Step("test rmdir................") + self.driver.shell("rmdir /data/testmkdir") + result_rmdir = self.driver.shell("ls -l /data/testmkdir") + Step(result_rmdir) + self.driver.Assert.contains(result_rmdir, 'No such file or directory', "ERROR: rmdir testmkdir directory failed.") + Step("test cd................") + result_cd = self.driver.shell("cd") + Step(result_cd) + self.driver.Assert.contains(result_cd, '', "ERROR: execute cd failed.") + Step("test pwd................") + result_pwd = self.driver.shell("pwd") + Step(result_pwd) + self.driver.Assert.contains(result_pwd, '/', "ERROR: execute pwd failed.") + + def teardown(self): + Step("收尾工作.................") diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_1000.json b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_1000.json new file mode 100644 index 000000000..65773ff6b --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_1000.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_basicenv/SubStartupInitBasicenv1000.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_1000.py b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_1000.py new file mode 100644 index 000000000..3fc626cc6 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_1000.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitBasicenv1000(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("test stop status................") + result_param = self.driver.shell("param get") + Step(result_param) + self.driver.Assert.contains(result_param, ' stop', "ERROR: cannot find stop from parameter.") + + def teardown(self): + Step("收尾工作.................") diff --git a/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0200.json b/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0200.json new file mode 100644 index 000000000..627e5fb03 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_gwp/SubStartupInitGwp0200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0200.py b/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0200.py new file mode 100644 index 000000000..1ec9ab9f1 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0200.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitGwp0200(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("查询开发者模式.................") + result = self.driver.shell("param get const.security.developermode.state") + Step(result) + self.driver.Assert.contains(result, 'true', "开发者模式打开时,进行GWP-ASAN使能") + + def teardown(self): + Step("收尾工作.................") diff --git a/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0300.json b/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0300.json new file mode 100644 index 000000000..203f603b1 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0300.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_gwp/SubStartupInitGwp0300.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0300.py b/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0300.py new file mode 100644 index 000000000..66ebfd13d --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0300.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupInitGwp0300(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("安装测试hap.................") + sourpath = Common.sourcepath("force.hap", "sub_startup_init_gwp") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + sleep(3) + + def test_step1(self): + self.d = UiExplorer(self.device1) + device_logger = DeviceLogger(self.d) + Step("设置关键字..........................") + device_logger.set_filter_string("gwp_asan") + Step("开启日志..........................") + device_logger.start_log("testFile/Log/log.txt") + Step("打开测试hap.................") + self.driver.start_app("com.example.myapplication", "EntryAbility") + sleep(10) + Step("停止日志..........................") + device_logger.stop_log() + Step("校验日志内容..........................") + + def teardown(self): + Step("收尾工作.................") + Step("卸载测试hap.................") + self.driver.AppManager.clear_app_data("com.example.myapplication") + self.driver.AppManager.uninstall_app("com.example.myapplication") + diff --git a/test/autotest/testcases/sub_startup_init_hilog/sub_startup_init_hilog_0100.json b/test/autotest/testcases/sub_startup_init_hilog/sub_startup_init_hilog_0100.json new file mode 100644 index 000000000..d6f2a8579 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_hilog/sub_startup_init_hilog_0100.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_init_hilog/SubStartupInitHilog0100.py"] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_hilog/sub_startup_init_hilog_0100.py b/test/autotest/testcases/sub_startup_init_hilog/sub_startup_init_hilog_0100.py new file mode 100644 index 000000000..c21dbb1e1 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_hilog/sub_startup_init_hilog_0100.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver +from hypium.action.os_hypium.device_logger import DeviceLogger +from hypium.model import UiParam, WindowFilter +import time + + +class SubStartupInitHilog0100(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("步骤1:过滤关键日志") + device_logger = DeviceLogger(self.driver) + path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + device_logger.set_filter_string("C02C11") + Step("步骤2:获取appspawn的进程号") + pid = self.driver.System.get_pid("appspawn") + Step("步骤3:开始抓日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("步骤4:kill进程号") + self.driver.shell("kill -9 %d" % pid) + time.sleep(5) + Step("步骤4:关闭日志") + device_logger.stop_log() + time.sleep(2) + device_logger.check_not_exist_keyword('nodict') + + def teardown(self): + Step("收尾工作:无") \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0100.json b/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0100.json new file mode 100644 index 000000000..e27e546d6 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0100.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_odid/SubStartupInitOdid0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0100.py b/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0100.py new file mode 100644 index 000000000..4c84eecd5 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0100.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + +from aw import Common + + +class SubStartupInitOdid0100(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("安装测试hap.................") + sourpath = Common.sourcepath("odid.hap", "sub_startup_init_odid") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + Step("预置工作:检测屏幕是否亮.................") + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("打开测试hap.................") + self.driver.start_app("com.example.newodidtest", "EntryAbility") + sleep(3) + Step("点击菜单.................") + self.driver.touch(BY.text("dev2 ODID1 ")) + sleep(1) + Step("获取首次odid.................") + component = self.driver.find_component(BY.type("Text")) + odid1 = component.getText() + Step(odid1) + Step("卸载测试hap................") + self.driver.AppManager.clear_app_data('com.example.newodidtest') + self.driver.AppManager.uninstall_app('com.example.newodidtest') + sleep(3) + Step("再次安装hap.................") + sourpath = Common.sourcepath("odid.hap", "sub_startup_init_odid") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + Step("打开测试hap.................") + self.driver.start_app("com.example.newodidtest", "EntryAbility") + sleep(3) + Step("点击菜单.................") + self.driver.touch(BY.text("dev2 ODID1 ")) + sleep(1) + Step("获取二次odid.................") + component = self.driver.find_component(BY.type("Text")) + odid2 = component.getText() + Step(odid2) + + def teardown(self): + Step("收尾工作.................") + Step("卸载测试hap................") + self.driver.AppManager.clear_app_data('com.example.newodidtest') + self.driver.AppManager.uninstall_app('com.example.newodidtest') diff --git a/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0300.json b/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0300.json new file mode 100644 index 000000000..92e0971b5 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0300.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_odid/SubStartupInitOdid0300.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0300.py b/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0300.py new file mode 100644 index 000000000..87fbde07c --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0300.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + +from aw import Common + + +class SubStartupInitOdid0300(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("安装测试hap.................") + sourpath1 = Common.sourcepath("odid.hap", "sub_startup_init_odid") + sourpath2 = Common.sourcepath("odid1.hap", "sub_startup_init_odid") + Step(sourpath1) + Step(sourpath2) + self.driver.AppManager.install_app(sourpath1) + self.driver.AppManager.install_app(sourpath2) + Step("预置工作:检测屏幕是否亮.................") + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("打开第一个开发者的测试hap.................") + self.driver.start_app("com.example.newodidtest", "EntryAbility") + sleep(3) + Step("点击菜单.................") + self.driver.touch(BY.text("dev2 ODID1 ")) + sleep(1) + Step("获取第一个odid.................") + component = self.driver.find_component(BY.type("Text")) + odid1 = component.getText() + Step(odid1) + Step("打开第二个开发者测试hap.................") + self.driver.start_app("com.example.odidtest", "EntryAbility") + sleep(3) + Step("点击菜单.................") + self.driver.touch(BY.text("dev1 ODID1 ")) + sleep(1) + Step("获取第二个odid.................") + component = self.driver.find_component(BY.type("Text")) + odid2 = component.getText() + Step(odid2) + + def teardown(self): + Step("收尾工作.................") + Step("卸载测试hap................") + self.driver.AppManager.clear_app_data('com.example.newodidtest') + self.driver.AppManager.clear_app_data('com.example.odidtest') + self.driver.AppManager.uninstall_app('com.example.newodidtest') + self.driver.AppManager.uninstall_app('com.example.odidtest') \ No newline at end of file -- Gitee From 9e4d168d92462638f5f2506efb07ef3c67ba482c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E4=BD=B3=E4=BC=9F?= Date: Sat, 23 Aug 2025 16:31:59 +0800 Subject: [PATCH 13/19] =?UTF-8?q?Description:TDD=E6=96=AD=E8=A8=80?= =?UTF-8?q?=E6=95=B4=E6=94=B9=20IssueNo:https://gitee.com/openharmony/star?= =?UTF-8?q?tup=5Finit/issues/ICUDR3=20Binary=20Source:No=20Signed-off-by:?= =?UTF-8?q?=20songjiawei9=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/unittest/init/mount_unittest.cpp | 5 ----- test/unittest/init/sandbox_unittest.cpp | 20 ++++------------- test/unittest/lite/cmd_func_test.cpp | 16 +++----------- test/unittest/modules/context_unittest.cpp | 22 +++++-------------- test/unittest/modules/sysevent_unittest.cpp | 10 ++++----- test/unittest/param/atomic_unittest.cpp | 1 + test/unittest/param/param_unittest.cpp | 5 +---- .../unittest/param/watcher_proxy_unittest.cpp | 1 + 8 files changed, 20 insertions(+), 60 deletions(-) diff --git a/test/unittest/init/mount_unittest.cpp b/test/unittest/init/mount_unittest.cpp index 6993672a3..56e1a96cc 100644 --- a/test/unittest/init/mount_unittest.cpp +++ b/test/unittest/init/mount_unittest.cpp @@ -35,12 +35,7 @@ public: HWTEST_F(MountUnitTest, TestGetBlockDevicePath, TestSize.Level1) { char path[20] = {0}; // 20 is path length - int fd = open("/bin/updater", O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, S_IRWXU); - if (fd < 0) { - return; - } GetBlockDevicePath("/test", path, sizeof(path)); - close(fd); ReadConfig(); unlink("/bin/updater"); ReadConfig(); diff --git a/test/unittest/init/sandbox_unittest.cpp b/test/unittest/init/sandbox_unittest.cpp index dd7ced0c4..b3e852578 100644 --- a/test/unittest/init/sandbox_unittest.cpp +++ b/test/unittest/init/sandbox_unittest.cpp @@ -173,10 +173,7 @@ public: HWTEST_F(SandboxUnitTest, TestCreateNormalSandbox, TestSize.Level1) { cJSON *mJson = MakeSandboxJson(SANDBOX_JSON_NAME, 0); - if (mJson == nullptr) { - std::cout << "created mJson error, mJson is null." << std::endl; - return; - } + ASSERT_NE(mJson, nullptr); MakeFileByJson(mJson, SANDBOX_JSON_NAME); int ret = RestartSandbox(TEST_SANDBOX_NAME); ASSERT_EQ(ret, 0); @@ -212,10 +209,7 @@ HWTEST_F(SandboxUnitTest, TestCreateErrorSandbox1, TestSize.Level1) { HWTEST_F(SandboxUnitTest, TestCreateErrorSandbox2, TestSize.Level1) { cJSON *mJson = MakeSandboxJson(SANDBOX_JSON_NAME, NULL_ROOT_PATH); - if (mJson == nullptr) { - std::cout << "created mJson error, mJson is null." << std::endl; - return; - } + ASSERT_NE(mJson, nullptr); bool ret1 = MakeFileByJson(mJson, SANDBOX_JSON_NAME); ASSERT_TRUE(ret1); InitSandboxWithName(TEST_SANDBOX_NAME); @@ -233,10 +227,7 @@ HWTEST_F(SandboxUnitTest, TestCreateSandboxNoneJsonError, TestSize.Level1) { HWTEST_F(SandboxUnitTest, TestCreateSandboxMountFlagsError, TestSize.Level1) { cJSON *mJson = MakeSandboxJson(SANDBOX_JSON_NAME, NULL_MOUNT_FLAGS); - if (mJson == nullptr) { - std::cout << "created mJson error, mJson is null." << std::endl; - return; - } + ASSERT_NE(mJson, nullptr); MakeFileByJson(mJson, SANDBOX_JSON_NAME); int ret = PrepareSandbox(TEST_SANDBOX_NAME); ASSERT_EQ(ret, -1); @@ -244,10 +235,7 @@ HWTEST_F(SandboxUnitTest, TestCreateSandboxMountFlagsError, TestSize.Level1) { HWTEST_F(SandboxUnitTest, TestCreateSandboxMountNULLError, TestSize.Level1) { cJSON *mJson = MakeSandboxJson(SANDBOX_JSON_NAME, NULL_MOUNT_ITEM); - if (mJson == nullptr) { - std::cout << "created mJson error, mJson is null." << std::endl; - return; - } + ASSERT_NE(mJson, nullptr); MakeFileByJson(mJson, SANDBOX_JSON_NAME); int ret = PrepareSandbox(TEST_SANDBOX_NAME); ASSERT_EQ(ret, -1); diff --git a/test/unittest/lite/cmd_func_test.cpp b/test/unittest/lite/cmd_func_test.cpp index f821ed5fa..06b7a4c08 100644 --- a/test/unittest/lite/cmd_func_test.cpp +++ b/test/unittest/lite/cmd_func_test.cpp @@ -796,10 +796,7 @@ static void CheckJobs(const cJSON* fileRoot) HWTEST_F(StartupInitUTest, cfgCheckContent_001, TestSize.Level0) { char *fileBuf = ReadFileToBuf(); - if (fileBuf == nullptr) { - EXPECT_TRUE(fileBuf != nullptr); - return; - } + ASSERT_NE(fileBuf, nullptr); cJSON *fileRoot = cJSON_Parse(fileBuf); free(fileBuf); @@ -909,11 +906,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoLoadCfgTest_003, TestSize.Level0) stat(cmdContentStr.c_str(), &testCfgStat); if (testCfgStat.st_size > 0) { fd = fopen(TEST_PROC_MOUNTS.c_str(), "r"); - - if (fd == nullptr) { - EXPECT_TRUE(fd != nullptr); - return; - } + ASSERT_NE(fd, nullptr); do { size = fread(buf, 1, CAT_BUF_SIZE - 1, fd); @@ -962,10 +955,7 @@ HWTEST_F(StartupInitUTest, cmdJobTest_002, TestSize.Level0) PRE_INIT_DIR + "\"]},{\"name\":\"init\",\"cmds\":[\"mkdir " + INIT_DIR + "\"]},{\"name\":\"post-init\",\"cmds\":[\"mkdir " + POST_INIT_DIR + "\"]}]}"; cJSON* jobItem = cJSON_Parse(cfgJson.c_str()); - EXPECT_NE(nullptr, jobItem); - if (jobItem == nullptr) { - return; - } + ASSERT_NE(nullptr, jobItem); ConfigContext context = { INIT_CONTEXT_MAIN }; ParseAllJobs(jobItem, &context); DoJob("pre-init"); diff --git a/test/unittest/modules/context_unittest.cpp b/test/unittest/modules/context_unittest.cpp index 0286ee9c0..3681c2acf 100755 --- a/test/unittest/modules/context_unittest.cpp +++ b/test/unittest/modules/context_unittest.cpp @@ -147,10 +147,7 @@ HWTEST_F(InitContextUnitTest, InitSubContextTest_04, TestSize.Level1) } SubInitContext *subContext = GetSubInitContext(INIT_CONTEXT_CHIPSET); - if (subContext == nullptr) { - EXPECT_EQ(0, -1); - return; - } + ASSERT_NE(subContext, nullptr); ret = subContext->executeCmdInSubInit(INIT_CONTEXT_CHIPSET, "mkdir-2", STARTUP_INIT_UT_PATH"/testsubcontext"); EXPECT_NE(ret, 0); } @@ -167,10 +164,8 @@ HWTEST_F(InitContextUnitTest, InitSubContextTest_06, TestSize.Level1) ConfigContext context = { INIT_CONTEXT_CHIPSET }; int index = 0; const char *cmd = GetMatchCmd("mkdir ", &index); - if (cmd == nullptr || strstr(cmd, "mkdir ") == nullptr) { - EXPECT_EQ(1, 0); - return; - } + ASSERT_NE(cmd, nullptr); + ASSERT_NE(strstr(cmd, "mkdir "), nullptr); DoCmdByIndex(index, STARTUP_INIT_UT_PATH"/testsubcontext", &context); } @@ -179,10 +174,8 @@ HWTEST_F(InitContextUnitTest, InitSubContextTest_07, TestSize.Level1) ConfigContext context = { INIT_CONTEXT_MAIN }; int index = 0; const char *cmd = GetMatchCmd("mkdir ", &index); - if (cmd == nullptr || strstr(cmd, "mkdir ") == nullptr) { - EXPECT_EQ(1, 0); - return; - } + ASSERT_NE(cmd, nullptr); + ASSERT_NE(strstr(cmd, "mkdir "), nullptr); DoCmdByIndex(index, STARTUP_INIT_UT_PATH"/testsubcontext", &context); } @@ -206,10 +199,7 @@ HWTEST_F(InitContextUnitTest, InitSubContextTest_10, TestSize.Level1) EXPECT_EQ(ret, -1); SubInitContext *subContext = GetSubInitContext(INIT_CONTEXT_CHIPSET); - if (subContext == nullptr) { - EXPECT_EQ(0, -1); - return; - } + ASSERT_NE(subContext, nullptr); ret = subContext->startSubInit(INIT_CONTEXT_MAIN); EXPECT_NE(ret, 0); ret = subContext->executeCmdInSubInit(INIT_CONTEXT_CHIPSET, nullptr, nullptr); diff --git a/test/unittest/modules/sysevent_unittest.cpp b/test/unittest/modules/sysevent_unittest.cpp index 4aeec7c69..fbd7aae08 100644 --- a/test/unittest/modules/sysevent_unittest.cpp +++ b/test/unittest/modules/sysevent_unittest.cpp @@ -111,9 +111,8 @@ HWTEST_F(SysEventUnitTest, SysEventTest_003, TestSize.Level1) HWTEST_F(SysEventUnitTest, SysEventTest_004, TestSize.Level1) { struct timespec curr = {0}; - if (clock_gettime(CLOCK_MONOTONIC, &curr) != 0) { - return; - } + int ret = clock_gettime(CLOCK_MONOTONIC, &curr); + ASSERT_EQ(ret, 0); StartupTimeEvent startupTime = {}; startupTime.event.type = STARTUP_TIME; startupTime.totalTime = curr.tv_sec; @@ -128,9 +127,8 @@ HWTEST_F(SysEventUnitTest, SysEventTest_004, TestSize.Level1) HWTEST_F(SysEventUnitTest, SysEventTest_005, TestSize.Level1) { struct timespec curr = {0}; - if (clock_gettime(CLOCK_MONOTONIC, &curr) != 0) { - return; - } + int ret = clock_gettime(CLOCK_MONOTONIC, &curr); + ASSERT_EQ(ret, 0); StartupTimeEvent startupTime = {}; startupTime.event.type = STARTUP_EVENT_MAX; startupTime.totalTime = curr.tv_sec; diff --git a/test/unittest/param/atomic_unittest.cpp b/test/unittest/param/atomic_unittest.cpp index 74ed7ffb6..eccea4afa 100644 --- a/test/unittest/param/atomic_unittest.cpp +++ b/test/unittest/param/atomic_unittest.cpp @@ -95,6 +95,7 @@ static void *TestReadData(void *args) while (data < MAX_NUM) { uint32_t commitId = TestReadCommitId(&g_testData); data = TestReadParamValue(&g_testData, &commitId); + EXPECT_GT(data, 0); printf("[ %d] TestReadData data: %d commit: %d \n", gettid(), data, commitId); usleep(10); // 10 wait } diff --git a/test/unittest/param/param_unittest.cpp b/test/unittest/param/param_unittest.cpp index 812c85b30..00dcbe921 100644 --- a/test/unittest/param/param_unittest.cpp +++ b/test/unittest/param/param_unittest.cpp @@ -496,10 +496,7 @@ HWTEST_F(ParamUnitTest, Init_TestWorkSpace_002, TestSize.Level0) const char *spaceName = "test.workspace2"; const size_t size = strlen(spaceName) + 1; WorkSpace *workSpace = (WorkSpace *)malloc(sizeof(WorkSpace) + size); - if (workSpace == nullptr) { - EXPECT_NE(workSpace, nullptr); - return; - } + ASSERT_NE(workSpace, nullptr); workSpace->flags = 0; workSpace->area = nullptr; int ret = PARAM_STRCPY(workSpace->fileName, size, spaceName); diff --git a/test/unittest/param/watcher_proxy_unittest.cpp b/test/unittest/param/watcher_proxy_unittest.cpp index 08534aa31..dd09cc740 100644 --- a/test/unittest/param/watcher_proxy_unittest.cpp +++ b/test/unittest/param/watcher_proxy_unittest.cpp @@ -232,6 +232,7 @@ public: int TestInvalid(const std::string &keyPrefix) { WatcherManagerPtr watcherManager = GetWatcherManager(); + EXPECT_NE(watcherManager, nullptr); WATCHER_CHECK(watcherManager != nullptr, return -1, "Failed to get manager"); MessageParcel data; MessageParcel reply; -- Gitee From 258b2c8768a6f6a06d242ff128ae46b0f3415684 Mon Sep 17 00:00:00 2001 From: hlzhangaj Date: Fri, 29 Aug 2025 01:23:42 +0000 Subject: [PATCH 14/19] const.ohos.fullname=OpenHarmony-6.0.0.48 Signed-off-by: hlzhangaj --- services/etc/param/ohos.para | 2 +- services/etc/param/ohos_const/ohos.para | 2 +- services/etc_lite/param/ohos_const/ohos.para | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/etc/param/ohos.para b/services/etc/param/ohos.para index 74e9c562e..ede7cc10e 100755 --- a/services/etc/param/ohos.para +++ b/services/etc/param/ohos.para @@ -29,7 +29,7 @@ const.build.product=default const.product.hardwareversion=default const.product.bootloader.version=bootloader const.product.cpu.abilist=default -const.product.software.version=OpenHarmony 6.0.0.47 +const.product.software.version=OpenHarmony 6.0.0.48 const.product.incremental.version=default const.product.firstapiversion=1 const.product.build.type=default diff --git a/services/etc/param/ohos_const/ohos.para b/services/etc/param/ohos_const/ohos.para index 12f9786dd..0b11511e1 100755 --- a/services/etc/param/ohos_const/ohos.para +++ b/services/etc/param/ohos_const/ohos.para @@ -15,4 +15,4 @@ const.ohos.releasetype=Beta2 const.ohos.apiversion=20 const.ohos.apiminorversion=0 const.ohos.apipatchversion=0 -const.ohos.fullname=OpenHarmony-6.0.0.47 \ No newline at end of file +const.ohos.fullname=OpenHarmony-6.0.0.48 \ No newline at end of file diff --git a/services/etc_lite/param/ohos_const/ohos.para b/services/etc_lite/param/ohos_const/ohos.para index d22809133..564a71600 100755 --- a/services/etc_lite/param/ohos_const/ohos.para +++ b/services/etc_lite/param/ohos_const/ohos.para @@ -16,4 +16,4 @@ const.ohos.apiversion=20 const.ohos.apiminorversion=0 const.ohos.apipatchversion=0 const.ohos.version.security_patch=2025/08/01 -const.ohos.fullname=OpenHarmony-6.0.0.47 \ No newline at end of file +const.ohos.fullname=OpenHarmony-6.0.0.48 \ No newline at end of file -- Gitee From 1e19de96c6526935d96ec6fdc20a727263a6cfba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Thu, 28 Aug 2025 14:53:11 +0800 Subject: [PATCH 15/19] Signed-off-by: qianyangyi update --- .../innerkits/include/syspara/parameter.h | 2 ++ .../innerkits/libbegetutil.versionscript | 2 ++ interfaces/innerkits/syspara/parameter.c | 11 ++++++++++ .../kits/jskits/src/native_deviceinfo_js.cpp | 22 +++++++++++++++++++ .../deviceInfo/idl/ohos.deviceInfo.taihe | 6 ++++- .../deviceInfo/src/ohos.deviceInfo.impl.cpp | 17 ++++++++++++++ services/etc/param/ohos.para | 1 + services/modules/bootevent/bootevent.c | 20 +++++++++++++++++ services/modules/bootevent/bootevent.h | 1 + services/param/adapter/param_persistadp.c | 2 +- test/unittest/modules/sysevent_unittest.cpp | 16 ++++++++++++++ test/unittest/syspara/syspara_unittest.cpp | 2 ++ 12 files changed, 100 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/include/syspara/parameter.h b/interfaces/innerkits/include/syspara/parameter.h index bb6671ded..916776cf8 100644 --- a/interfaces/innerkits/include/syspara/parameter.h +++ b/interfaces/innerkits/include/syspara/parameter.h @@ -192,6 +192,8 @@ long long GetSystemCommitId(void); int32_t GetIntParameter(const char *key, int32_t def); uint32_t GetUintParameter(const char *key, uint32_t def); +const char *GetChipType(void); +int GetBootCount(void); const char *GetDistributionOSName(void); const char *GetDistributionOSVersion(void); int GetDistributionOSApiVersion(void); diff --git a/interfaces/innerkits/libbegetutil.versionscript b/interfaces/innerkits/libbegetutil.versionscript index 2654833e4..a5c356c66 100644 --- a/interfaces/innerkits/libbegetutil.versionscript +++ b/interfaces/innerkits/libbegetutil.versionscript @@ -98,6 +98,7 @@ *GetStringParameter*; FindParameter; GetAbiList; + GetBootCount; GetBootloaderVersion; GetBrand; GetBuildHost; @@ -105,6 +106,7 @@ GetBuildTime; GetBuildType; GetBuildUser; + GetChipType; GetDevUdid; GetDisplayVersion; GetFirstApiVersion; diff --git a/interfaces/innerkits/syspara/parameter.c b/interfaces/innerkits/syspara/parameter.c index 6d0940407..ec6e0d8a5 100644 --- a/interfaces/innerkits/syspara/parameter.c +++ b/interfaces/innerkits/syspara/parameter.c @@ -463,3 +463,14 @@ int GetPerformanceClass(void) } return performanceClassValue; } + +const char *GetChipType(void) +{ + static const char *chiptype = NULL; + return GetProperty("ohos.boot.hardware", &chiptype); +} + +int GetBootCount(void) +{ + return GetIntParameter("persist.startup.bootcount", -1); +} \ No newline at end of file diff --git a/interfaces/kits/jskits/src/native_deviceinfo_js.cpp b/interfaces/kits/jskits/src/native_deviceinfo_js.cpp index bc917fd62..6e97462e4 100644 --- a/interfaces/kits/jskits/src/native_deviceinfo_js.cpp +++ b/interfaces/kits/jskits/src/native_deviceinfo_js.cpp @@ -419,6 +419,26 @@ static napi_value GetBuildRootHash(napi_env env, napi_callback_info info) return napiValue; } +static napi_value GetBootCount(napi_env env, napi_callback_info info) +{ + napi_value napiValue = nullptr; + int bootCount = GetBootCount(); + NAPI_CALL(env, napi_create_int32(env, bootCount, &napiValue)); + return napiValue; +} + +static napi_value GetChipType(napi_env env, napi_callback_info info) +{ + napi_value napiValue = nullptr; + const char *chipType = GetChipType(); + if (chipType == nullptr) { + chipType = ""; + } + + NAPI_CALL(env, napi_create_string_utf8(env, chipType, strlen(chipType), &napiValue)); + return napiValue; +} + static napi_value GetDevUdid(napi_env env, napi_callback_info info) { napi_value napiValue = nullptr; @@ -671,6 +691,8 @@ static napi_value Init(napi_env env, napi_value exports) {"productModelAlias", nullptr, nullptr, GetProductModelAlias, nullptr, nullptr, napi_default, nullptr}, {"diskSN", nullptr, nullptr, GetDiskSN, nullptr, nullptr, napi_default, nullptr}, {"performanceClass", nullptr, nullptr, GetPerformanceClass, nullptr, nullptr, napi_default, nullptr}, + {"chipType", nullptr, nullptr, GetChipType, nullptr, nullptr, napi_default, nullptr}, + {"bootCount", nullptr, nullptr, GetBootCount, nullptr, nullptr, napi_default, nullptr}, }; NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(napi_property_descriptor), desc)); diff --git a/interfaces/taihe/deviceInfo/idl/ohos.deviceInfo.taihe b/interfaces/taihe/deviceInfo/idl/ohos.deviceInfo.taihe index 4315fe600..df8e87eec 100644 --- a/interfaces/taihe/deviceInfo/idl/ohos.deviceInfo.taihe +++ b/interfaces/taihe/deviceInfo/idl/ohos.deviceInfo.taihe @@ -81,6 +81,8 @@ function getdistributionOSApiName(): String; function getdistributionOSReleaseType(): String; @static("deviceInfo") @get function getdiskSN(): String; +@static("deviceInfo") @get +function getchipType(): String; @static("deviceInfo") @get function getsdkApiVersion(): i32; @@ -95,4 +97,6 @@ function getbuildVersion(): i32; @static("deviceInfo") @get function getfirstApiVersion(): i32; @static("deviceInfo") @get -function getdistributionOSApiVersion(): i32; \ No newline at end of file +function getdistributionOSApiVersion(): i32; +@static("deviceInfo") @get +function getbootCount(): i32; \ No newline at end of file diff --git a/interfaces/taihe/deviceInfo/src/ohos.deviceInfo.impl.cpp b/interfaces/taihe/deviceInfo/src/ohos.deviceInfo.impl.cpp index b4a75a590..16bb09cbf 100644 --- a/interfaces/taihe/deviceInfo/src/ohos.deviceInfo.impl.cpp +++ b/interfaces/taihe/deviceInfo/src/ohos.deviceInfo.impl.cpp @@ -369,6 +369,15 @@ string getdiskSN() return value; } +string getchipType() +{ + const char *value = GetChipType(); + if (value == nullptr) { + value = ""; + } + return value; +} + int32_t getsdkApiVersion() { int value = GetSdkApiVersion(); @@ -410,6 +419,12 @@ int32_t getdistributionOSApiVersion() int value = GetDistributionOSApiVersion(); return value; } + +int32_t getbootCount() +{ + int value = GetBootCount(); + return value; +} } // namespace TH_EXPORT_CPP_API_getbrand(getbrand); @@ -449,3 +464,5 @@ TH_EXPORT_CPP_API_getfeatureVersion(getfeatureVersion); TH_EXPORT_CPP_API_getbuildVersion(getbuildVersion); TH_EXPORT_CPP_API_getfirstApiVersion(getfirstApiVersion); TH_EXPORT_CPP_API_getdistributionOSApiVersion(getdistributionOSApiVersion); +TH_EXPORT_CPP_API_getbootCount(getbootCount); +TH_EXPORT_CPP_API_getchipType(getchipType); \ No newline at end of file diff --git a/services/etc/param/ohos.para b/services/etc/param/ohos.para index 74e9c562e..0717f1497 100755 --- a/services/etc/param/ohos.para +++ b/services/etc/param/ohos.para @@ -38,3 +38,4 @@ const.product.build.host=default const.product.build.date=default const.product.hardwareprofile=default const.ohos.buildroothash=default +persist.startup.bootcount=0 diff --git a/services/modules/bootevent/bootevent.c b/services/modules/bootevent/bootevent.c index 89b4e230c..c896169ba 100755 --- a/services/modules/bootevent/bootevent.c +++ b/services/modules/bootevent/bootevent.c @@ -346,6 +346,25 @@ static int ScheduleDelayedHookMgrExecute(void) } #endif +void UpdateBootCount() +{ + char timevalue[MAX_BUFFER_LEN] = {0}; + uint32_t size = sizeof(timevalue); + int ret = SystemReadParam("ohos.boot.time.boot.completed", timevalue, &size); + INIT_INFO_CHECK (ret != 0, return, "already boot, not add count"); + char value[MAX_INT_LEN] = {0}; + size = sizeof(value); + ret = SystemReadParam("persist.startup.bootcount", value, &size); + INIT_ERROR_CHECK (ret == 0, return, "Failed to read bootcount"); + int bootCount = StringToInt(value, -1); + INIT_ERROR_CHECK (bootCount != -1, return, "StringToInt failed"); + bootCount++; + char buffer[32] = { 0 }; + ret = sprintf_s(buffer, sizeof(buffer), "%d", bootCount); + INIT_ERROR_CHECK (ret > 0, return, "Failed copy bootcount"); + ret = SystemWriteParam("persist.startup.bootcount", buffer); + INIT_CHECK_ONLY_ELOG(ret == 0, "Failed to update bootcount"); +} static int BootEventParaFireByName(const char *paramName) { @@ -377,6 +396,7 @@ static int BootEventParaFireByName(const char *paramName) } // All parameters are fired, set boot completed now ... INIT_LOGI("All boot events are fired, boot complete now ..."); + UpdateBootCount(); SystemWriteParam(BOOT_EVENT_BOOT_COMPLETED, "true"); SetBootCompleted(true); SaveServiceBootEvent(); diff --git a/services/modules/bootevent/bootevent.h b/services/modules/bootevent/bootevent.h index 9bce4b7d7..a427d735a 100755 --- a/services/modules/bootevent/bootevent.h +++ b/services/modules/bootevent/bootevent.h @@ -54,6 +54,7 @@ typedef struct tagBOOT_EVENT_PARAM_ITEM { } BOOT_EVENT_PARAM_ITEM; ListNode *GetBootEventList(void); +void UpdateBootCount(void); #ifdef __cplusplus #if __cplusplus diff --git a/services/param/adapter/param_persistadp.c b/services/param/adapter/param_persistadp.c index ef75bf6bc..dc5da1145 100644 --- a/services/param/adapter/param_persistadp.c +++ b/services/param/adapter/param_persistadp.c @@ -95,7 +95,7 @@ static bool IsPublicParam(const char *param) "persist.sys.usb.config", "persist.sys.xlog.debug", "persist.telephony", "persist.time", "persist.uiAppearance.first_initialization", "persist.update", - "persist.wifi", "persist.init.trace.enabled", + "persist.wifi", "persist.init.trace.enabled", "persist.startup.bootcount", }; int size = sizeof(publicPersistParams) / sizeof(char*); for (int i = 0; i < size; i++) { diff --git a/test/unittest/modules/sysevent_unittest.cpp b/test/unittest/modules/sysevent_unittest.cpp index fbd7aae08..51c8ab359 100644 --- a/test/unittest/modules/sysevent_unittest.cpp +++ b/test/unittest/modules/sysevent_unittest.cpp @@ -17,6 +17,7 @@ #include #include "bootevent.h" +#include "parameter.h" #include "init_param.h" #include "init_utils.h" #include "list.h" @@ -153,4 +154,19 @@ HWTEST_F(SysEventUnitTest, SysEventTest_007, TestSize.Level1) EXPECT_EQ(ret, 0); printf("SysEventTest_007:%d\n", ret); } + +HWTEST_F(SysEventUnitTest, SysEventTest_008, TestSize.Level1) +{ + char key1[] = "persist.startup.bootcount"; + char value1[32] = {0}; + char value2[32] = {0}; + char defValue1[] = "value of key not exist..."; + int ret = GetParameter(key1, defValue1, value1, 32); + EXPECT_NE(ret, static_cast(strlen(defValue1))); + UpdateBootCount(); + ret = GetParameter(key1, defValue1, value2, 32); + printf("value1: '%s'\n", value1); + printf("value2: '%s'\n", value2); + EXPECT_NE(0, strcmp(value1, value2)); +} } // namespace init_ut diff --git a/test/unittest/syspara/syspara_unittest.cpp b/test/unittest/syspara/syspara_unittest.cpp index 9cc6b76dd..48e013a6e 100644 --- a/test/unittest/syspara/syspara_unittest.cpp +++ b/test/unittest/syspara/syspara_unittest.cpp @@ -169,6 +169,8 @@ HWTEST_F(SysparaUnitTest, parameterTest001_3, TestSize.Level0) EXPECT_STRNE(GetBuildHost(), nullptr); EXPECT_STRNE(GetBuildTime(), nullptr); EXPECT_STRNE(GetBuildRootHash(), nullptr); + EXPECT_STRNE(GetChipType(), nullptr); + EXPECT_GT(GetBootCount(), -1); } HWTEST_F(SysparaUnitTest, parameterTest002, TestSize.Level0) -- Gitee From e26e6d1aaca53eca97aba625d9b32417ccf97af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Fri, 29 Aug 2025 06:08:40 +0000 Subject: [PATCH 16/19] =?UTF-8?q?update=20test/fuzztest/watchparameter=5Ff?= =?UTF-8?q?uzzer/watchparameter=5Ffuzzer.cpp.=20Signed-off-by:=20=E4=B9=BE?= =?UTF-8?q?=E9=98=B3=E7=86=A0=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乾阳熠 --- test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp b/test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp index fcf52ef01..d0edf3d95 100644 --- a/test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp +++ b/test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp @@ -29,10 +29,12 @@ static void HandleParamChange(const char *key, const char *value, void *context) namespace OHOS { bool FuzzWatchParameter(const uint8_t* data, size_t size) { + usleep(100000); bool result = false; std::string str(reinterpret_cast(data), size); CloseStdout(); if (!WatchParameter(str.c_str(), HandleParamChange, NULL)) { + usleep(100000); WatchParameter(str.c_str(), NULL, NULL); result = true; } -- Gitee From 402e66f2b2e68c3c08275e25e21c9ccf9d48e1af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Fri, 29 Aug 2025 06:22:19 +0000 Subject: [PATCH 17/19] =?UTF-8?q?update=20test/fuzztest/watchparameter=5Ff?= =?UTF-8?q?uzzer/watchparameter=5Ffuzzer.cpp.=20Signed-off-by:=20=E4=B9=BE?= =?UTF-8?q?=E9=98=B3=E7=86=A0=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乾阳熠 --- .../fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp b/test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp index d0edf3d95..8336839e6 100644 --- a/test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp +++ b/test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp @@ -17,6 +17,7 @@ #include #include "parameter.h" #include "fuzz_utils.h" +static const int SLEEP_TIME = 100000; static void HandleParamChange(const char *key, const char *value, void *context) { @@ -29,12 +30,12 @@ static void HandleParamChange(const char *key, const char *value, void *context) namespace OHOS { bool FuzzWatchParameter(const uint8_t* data, size_t size) { - usleep(100000); + usleep(SLEEP_TIME); bool result = false; std::string str(reinterpret_cast(data), size); CloseStdout(); if (!WatchParameter(str.c_str(), HandleParamChange, NULL)) { - usleep(100000); + usleep(SLEEP_TIME); WatchParameter(str.c_str(), NULL, NULL); result = true; } -- Gitee From 86bffca1102da48c48490521444c30430612c21e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Fri, 29 Aug 2025 06:58:23 +0000 Subject: [PATCH 18/19] update test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乾阳熠 --- test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp b/test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp index 8336839e6..39d0fdf4c 100644 --- a/test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp +++ b/test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp @@ -17,6 +17,7 @@ #include #include "parameter.h" #include "fuzz_utils.h" +#include static const int SLEEP_TIME = 100000; static void HandleParamChange(const char *key, const char *value, void *context) -- Gitee From 1e1c8af3e9e1059be00d2b4d5ddc602662fca321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Sat, 30 Aug 2025 09:23:48 +0000 Subject: [PATCH 19/19] =?UTF-8?q?update=20begetd.gni.=20Signed-off-by:=20?= =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乾阳熠 --- begetd.gni | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/begetd.gni b/begetd.gni index 2ed3b14ad..2b18ec65a 100644 --- a/begetd.gni +++ b/begetd.gni @@ -40,7 +40,7 @@ declare_args() { } # config memory size for liteos-m - init_lite_memory_size = 6800 + init_lite_memory_size = 10240 startup_init_feature_decode_group_file = false -- Gitee