提交 798210a9 编写于 作者: X xionglei6

init:add fuzztest

Signed-off-by: Nxionglei6 <xionglei6@huawei.com>
上级 d6793472
...@@ -147,6 +147,48 @@ ohos_fuzztest("ReadFileInDirFuzzTest") { ...@@ -147,6 +147,48 @@ ohos_fuzztest("ReadFileInDirFuzzTest") {
defines = [ "STARTUP_INIT_TEST" ] defines = [ "STARTUP_INIT_TEST" ]
} }
ohos_fuzztest("ServiceControlStartFuzzTest") {
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/init_lite/services/param:param_client",
]
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "ServiceControlStart_fuzzer/ServiceControlStart_fuzzer.cpp" ]
defines = [ "STARTUP_INIT_TEST" ]
}
ohos_fuzztest("ServiceControlStopFuzzTest") {
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/init_lite/services/param:param_client",
]
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "ServiceControlStop_fuzzer/ServiceControlStop_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 "ServiceControlStart_fuzzer.h"
#include "service_control.h"
namespace OHOS {
bool FuzzServiceControlStart(const uint8_t* data, size_t size)
{
bool result = false;
if (!ServiceControl(reinterpret_cast<const char*>(data)), START) {
result = true;
}
return result;
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::FuzzServiceControlStart(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 "ServiceControlStart_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 "ServiceControlStop_fuzzer.h"
#include "service_control.h"
namespace OHOS {
bool FuzzServiceControlStop(const uint8_t* data, size_t size)
{
bool result = false;
if (!ServiceControl(reinterpret_cast<const char*>(data)), STOP) {
result = true;
}
return result;
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::FuzzServiceControlStop(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 "ServiceControlStop_fuzzer"
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册