mirror of
https://gitee.com/openharmony/distributeddatamgr_datamgr_service
synced 2024-11-23 06:50:35 +00:00
delete DfxFuzzTest
Signed-off-by: htt1997 <hutao105@huawei.com>
This commit is contained in:
parent
035481bf83
commit
d8fa57ccf3
1
BUILD.gn
1
BUILD.gn
@ -32,7 +32,6 @@ group("fuzztest") {
|
||||
"test/fuzztest/autolaunch_fuzzer:fuzztest",
|
||||
"test/fuzztest/blob_fuzzer:fuzztest",
|
||||
"test/fuzztest/devicekvstore_fuzzer:fuzztest",
|
||||
"test/fuzztest/dfx_fuzzer:fuzztest",
|
||||
"test/fuzztest/distributedkvdatamanager_fuzzer:fuzztest",
|
||||
"test/fuzztest/kvstoredisksize_fuzzer:fuzztest",
|
||||
"test/fuzztest/kvstorescheduler_fuzzer:fuzztest",
|
||||
|
@ -1,59 +0,0 @@
|
||||
# Copyright (c) 2022 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("DfxFuzzTest") {
|
||||
module_out_path = "datamgr_service/adapter"
|
||||
|
||||
include_dirs = [
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/dfx/src",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/dfx/src/behaviour",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/dfx/src/fault",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/dfx/src/statistic",
|
||||
"//commonlibrary/c_utils/base/include",
|
||||
]
|
||||
|
||||
fuzz_config_file =
|
||||
"//foundation/distributeddatamgr/datamgr_service/test/fuzztest/dfx_fuzzer"
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "dfx_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter",
|
||||
"//third_party/openssl:libcrypto_shared",
|
||||
]
|
||||
|
||||
external_deps = [ "c_utils:utils" ]
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [
|
||||
# deps file
|
||||
":DfxFuzzTest",
|
||||
]
|
||||
}
|
||||
###############################################################################
|
@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
|
||||
FUZZ
|
@ -1,135 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 "dfx_fuzzer.h"
|
||||
|
||||
#include <any>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "reporter.h"
|
||||
#include "value_hash.h"
|
||||
|
||||
using namespace OHOS::DistributedKv;
|
||||
using namespace OHOS::DistributedDataDfx;
|
||||
namespace OHOS {
|
||||
void FaultReporterFuzz(FaultReporter *faultReporter, const std::string &strBase, const FaultMsg &faultMsg,
|
||||
const CommFaultMsg &commFaultMsg, const DBFaultMsg &dbFaultMsg)
|
||||
{
|
||||
faultReporter->Report(faultMsg);
|
||||
faultReporter->Report(commFaultMsg);
|
||||
faultReporter->Report(dbFaultMsg);
|
||||
}
|
||||
|
||||
void DatabaseStatisticFuzz(const std::string &strBase, int intBase)
|
||||
{
|
||||
auto databaseStatistic = Reporter::GetInstance()->DatabaseStatistic();
|
||||
DbStat ds = {
|
||||
.userId = strBase,
|
||||
.appId = strBase,
|
||||
.storeId = strBase,
|
||||
.dbSize = intBase
|
||||
};
|
||||
databaseStatistic->Report(ds);
|
||||
}
|
||||
|
||||
void VisitStatisticFuzz(const std::string &strBase)
|
||||
{
|
||||
auto visitStatistic = Reporter::GetInstance()->VisitStatistic();
|
||||
struct VisitStat visitStat = { strBase, strBase };
|
||||
visitStatistic->Report(visitStat);
|
||||
std::string myuid = strBase;
|
||||
std::string result;
|
||||
ValueHash valueHash;
|
||||
valueHash.CalcValueHash(myuid, result);
|
||||
}
|
||||
|
||||
void TrafficStatisticFuzz(const std::string &strBase, int intBase)
|
||||
{
|
||||
auto trafficStatistic = Reporter::GetInstance()->TrafficStatistic();
|
||||
struct TrafficStat trafficStat = { strBase, strBase, intBase, intBase };
|
||||
trafficStatistic->Report(trafficStat);
|
||||
}
|
||||
|
||||
void ApiPerformanceStatisticFuzz(const std::string &strBase, uint64_t uint64Base)
|
||||
{
|
||||
auto apiPerformanceStatistic = Reporter::GetInstance()->ApiPerformanceStatistic();
|
||||
struct ApiPerformanceStat apiPerformanceStat = { strBase, uint64Base, uint64Base, uint64Base };
|
||||
apiPerformanceStatistic->Report(apiPerformanceStat);
|
||||
}
|
||||
|
||||
void BehaviourReporterFuzz(const std::string &strBase)
|
||||
{
|
||||
auto behaviourReporter = Reporter::GetInstance()->BehaviourReporter();
|
||||
struct BehaviourMsg behaviourMsg {
|
||||
.userId = strBase,
|
||||
.appId = strBase,
|
||||
.storeId = strBase,
|
||||
.extensionInfo = strBase,
|
||||
.behaviourType = BehaviourType::DATABASE_BACKUP
|
||||
};
|
||||
behaviourReporter->Report(behaviourMsg);
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
std::string fuzzStr(data, data + size);
|
||||
int fuzzInt = static_cast<int>(size);
|
||||
int32_t fuzzInt32 = static_cast<int32_t>(size);
|
||||
uint64_t fuzzUInt64 = static_cast<uint64_t>(size);
|
||||
|
||||
struct FaultMsg faultMsg {
|
||||
.faultType = FaultType::SERVICE_FAULT,
|
||||
.moduleName = fuzzStr,
|
||||
.interfaceName = fuzzStr,
|
||||
.errorType = Fault::RF_CLOSE_DB
|
||||
};
|
||||
struct CommFaultMsg commFaultMsg {
|
||||
.userId = fuzzStr,
|
||||
.appId = fuzzStr,
|
||||
.storeId = fuzzStr,
|
||||
.errorCode = { fuzzInt32 }
|
||||
};
|
||||
struct DBFaultMsg dbFaultMsg {
|
||||
.appId = fuzzStr,
|
||||
.storeId = fuzzStr,
|
||||
.moduleName = fuzzStr,
|
||||
.errorType = Fault::DF_DB_DAMAGE
|
||||
};
|
||||
|
||||
auto srvFault = Reporter::GetInstance()->ServiceFault();
|
||||
OHOS::FaultReporterFuzz(srvFault, fuzzStr, faultMsg, commFaultMsg, dbFaultMsg);
|
||||
|
||||
auto rtFault = Reporter::GetInstance()->RuntimeFault();
|
||||
OHOS::FaultReporterFuzz(rtFault, fuzzStr, faultMsg, commFaultMsg, dbFaultMsg);
|
||||
|
||||
auto dbFault = Reporter::GetInstance()->DatabaseFault();
|
||||
OHOS::FaultReporterFuzz(dbFault, fuzzStr, faultMsg, commFaultMsg, dbFaultMsg);
|
||||
|
||||
auto comFault = Reporter::GetInstance()->CommunicationFault();
|
||||
OHOS::FaultReporterFuzz(comFault, fuzzStr, faultMsg, commFaultMsg, dbFaultMsg);
|
||||
|
||||
OHOS::DatabaseStatisticFuzz(fuzzStr, fuzzInt);
|
||||
OHOS::TrafficStatisticFuzz(fuzzStr, fuzzInt);
|
||||
OHOS::VisitStatisticFuzz(fuzzStr);
|
||||
OHOS::ApiPerformanceStatisticFuzz(fuzzStr, fuzzUInt64);
|
||||
OHOS::BehaviourReporterFuzz(fuzzStr);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 DFX_FUZZER_H
|
||||
#define DFX_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "Dfx_fuzzer"
|
||||
|
||||
#endif // DFX_FUZZER_H
|
||||
|
@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 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.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>30</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
Loading…
Reference in New Issue
Block a user