提交 c7e374ea 编写于 作者: X xionglei6

init: fix bugs

Signed-off-by: Nxionglei6 <xionglei6@huawei.com>
上级 d51f8e68
...@@ -27,10 +27,10 @@ fs_manager_sources = [ ...@@ -27,10 +27,10 @@ fs_manager_sources = [
ohos_shared_library("libbegetutil") { ohos_shared_library("libbegetutil") {
sources = [ sources = [
"begetctl_utils/begetctl_utils.c",
"file/init_file.c", "file/init_file.c",
"reboot/init_reboot_innerkits.c", "reboot/init_reboot_innerkits.c",
"socket/init_socket.c", "socket/init_socket.c",
"begetctl_utils/begetctl_utils.c",
] ]
sources += fs_manager_sources sources += fs_manager_sources
......
...@@ -147,48 +147,6 @@ ohos_fuzztest("ReadFileInDirFuzzTest") { ...@@ -147,48 +147,6 @@ ohos_fuzztest("ReadFileInDirFuzzTest") {
defines = [ "STARTUP_INIT_TEST" ] defines = [ "STARTUP_INIT_TEST" ]
} }
ohos_fuzztest("StartDynamicProcessFuzzTest") {
module_out_path = module_output_path
include_dirs = [ "//base/startup/init_lite/interfaces/innerkits/include" ]
deps = [
"//base/startup/init_lite/interfaces/innerkits:libbegetutil",
"//base/startup/syspara_lite/interfaces/innerkits/native/syspara:syspara",
]
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "StartDynamicProcess_fuzzer/StartDynamicProcess_fuzzer.cpp" ]
defines = [ "STARTUP_INIT_TEST" ]
}
ohos_fuzztest("StopDynamicProcessFuzzTest") {
module_out_path = module_output_path
include_dirs = [ "//base/startup/init_lite/interfaces/innerkits/include" ]
deps = [
"//base/startup/init_lite/interfaces/innerkits:libbegetutil",
"//base/startup/syspara_lite/interfaces/innerkits/native/syspara:syspara",
]
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "StopDynamicProcess_fuzzer/StopDynamicProcess_fuzzer.cpp" ]
defines = [ "STARTUP_INIT_TEST" ]
}
ohos_fuzztest("SystemDumpParametersFuzzTest") { ohos_fuzztest("SystemDumpParametersFuzzTest") {
module_out_path = module_output_path module_out_path = module_output_path
......
/*
* Copyright (c) 2021 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 "StartDynamicProcess_fuzzer.h"
#include "dynamic_service.h"
namespace OHOS {
bool FuzzStartDynamicProcess(const uint8_t* data, size_t size)
{
bool result = false;
if (!StartDynamicProcess(reinterpret_cast<const char*>(data))) {
result = true;
}
return result;
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::FuzzStartDynamicProcess(data, size);
return 0;
}
/*
* Copyright (c) 2021 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.
*/
#ifndef TEST_FUZZTEST_STARTDYNAMICPROCESS_FUZZER_H
#define TEST_FUZZTEST_STARTDYNAMICPROCESS_FUZZER_H
#define FUZZ_PROJECT_NAME "StartDynamicProcess_fuzzer"
#endif
/*
* Copyright (c) 2021 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 "StopDynamicProcess_fuzzer.h"
#include "dynamic_service.h"
namespace OHOS {
bool FuzzStopDynamicProcess(const uint8_t* data, size_t size)
{
bool result = false;
if (!StopDynamicProcess(reinterpret_cast<const char*>(data))) {
result = true;
}
return result;
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::FuzzStopDynamicProcess(data, size);
return 0;
}
/*
* Copyright (c) 2021 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.
*/
#ifndef TEST_FUZZTEST_STOPDYNAMICPROCESS_FUZZER_H
#define TEST_FUZZTEST_STOPDYNAMICPROCESS_FUZZER_H
#define FUZZ_PROJECT_NAME "StopDynamicProcess_fuzzer"
#endif
...@@ -33,7 +33,6 @@ config("utest_config") { ...@@ -33,7 +33,6 @@ config("utest_config") {
ohos_unittest("init_ut") { ohos_unittest("init_ut") {
module_out_path = "startup/init" module_out_path = "startup/init"
sources = [ sources = [
"//base/startup/init_lite/interfaces/innerkits/dynamic_service/dynamic_service.c",
"//base/startup/init_lite/interfaces/innerkits/file/init_file.c", "//base/startup/init_lite/interfaces/innerkits/file/init_file.c",
"//base/startup/init_lite/interfaces/innerkits/fs_manager/fs_manager_log.c", "//base/startup/init_lite/interfaces/innerkits/fs_manager/fs_manager_log.c",
"//base/startup/init_lite/interfaces/innerkits/fs_manager/fstab.c", "//base/startup/init_lite/interfaces/innerkits/fs_manager/fstab.c",
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <cinttypes> #include <cinttypes>
#include <sys/mount.h> #include <sys/mount.h>
#include "dynamic_service.h"
#include "fs_manager/fs_manager.h" #include "fs_manager/fs_manager.h"
#include "fs_manager/fs_manager_log.h" #include "fs_manager/fs_manager_log.h"
#include "init_log.h" #include "init_log.h"
...@@ -34,25 +33,6 @@ public: ...@@ -34,25 +33,6 @@ public:
void TearDown() {}; void TearDown() {};
}; };
HWTEST_F(InnerkitsUnitTest, TestDynamicService, TestSize.Level1)
{
const char *name = "updater_sa";
int32_t ret = StopDynamicProcess(name);
EXPECT_EQ(ret, 0);
ret = StartDynamicProcess(name);
EXPECT_EQ(ret, 0);
name = "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111";
ret = StopDynamicProcess(name);
EXPECT_EQ(ret, -1);
ret = StartDynamicProcess(name);
EXPECT_EQ(ret, -1);
name = nullptr;
ret = StopDynamicProcess(name);
EXPECT_EQ(ret, -1);
ret = StartDynamicProcess(name);
EXPECT_EQ(ret, -1);
}
HWTEST_F(InnerkitsUnitTest, ReadFstabFromFile_unitest, TestSize.Level1) HWTEST_F(InnerkitsUnitTest, ReadFstabFromFile_unitest, TestSize.Level1)
{ {
Fstab *fstab = nullptr; Fstab *fstab = nullptr;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册