addfuzztest

Signed-off-by: lixiang <lixiang493@huawei.com>
This commit is contained in:
lixiang 2024-06-12 13:24:49 +08:00
parent a7fd91010b
commit 72c60042cf
2 changed files with 202 additions and 1 deletions

View File

@ -32,7 +32,10 @@ ohos_fuzztest("StorageManagerFuzzTest") {
] ]
sources = [ "${storage_service_path}/test/fuzztest/storagemanager_fuzzer/storagemanager_fuzzer.cpp" ] sources = [ "${storage_service_path}/test/fuzztest/storagemanager_fuzzer/storagemanager_fuzzer.cpp" ]
defines = [ "STORAGE_LOG_TAG = \"storage_service\"" ] defines = [
"STORAGE_LOG_TAG = \"storage_service\"",
"private=public",
]
deps = [ deps = [
"${bundlemanager_framework_path}/services/bundlemgr:libbms", "${bundlemanager_framework_path}/services/bundlemgr:libbms",
"${storage_service_path}/services/storage_manager:storage_manager", "${storage_service_path}/services/storage_manager:storage_manager",

View File

@ -92,6 +92,184 @@ bool StorageManagerFuzzTest(std::unique_ptr<char[]> data, size_t size)
return true; return true;
} }
bool HandlePrepareAddUserFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandlePrepareAddUser(datas, reply);
return true;
}
bool HandleRemoveUserFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandleRemoveUser(datas, reply);
return true;
}
bool HandlePrepareStartUserFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandlePrepareStartUser(datas, reply);
return true;
}
bool HandleStopUserFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandleStopUser(datas, reply);
return true;
}
bool HandleGetCurrentBundleStatsFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandleGetCurrentBundleStats(datas, reply);
return true;
}
bool HandleMountFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandleMount(datas, reply);
return true;
}
bool HandleUnmountFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandleUnmount(datas, reply);
return true;
}
bool HandlePartitionFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandlePartition(datas, reply);
return true;
}
bool HandleFormatFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandleFormat(datas, reply);
return true;
}
bool HandleGenerateUserKeysFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandleGenerateUserKeys(datas, reply);
return true;
}
bool HandleDeleteUserKeysFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandleDeleteUserKeys(datas, reply);
return true;
}
bool HandleUpdateUserAuthFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandleUpdateUserAuth(datas, reply);
return true;
}
bool HandleActiveUserKeyFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandleActiveUserKey(datas, reply);
return true;
}
bool HandleInactiveUserKeyFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandleInactiveUserKey(datas, reply);
return true;
}
bool HandleLockUserScreenFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandleLockUserScreen(datas, reply);
return true;
}
bool HandleUnlockUserScreenFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandleUnlockUserScreen(datas, reply);
return true;
}
bool HandleUpdateKeyContextFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandleUpdateKeyContext(datas, reply);
return true;
}
bool HandleCreateShareFileFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandleCreateShareFile(datas, reply);
return true;
}
bool HandleDeleteShareFileFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandleDeleteShareFile(datas, reply);
return true;
}
bool HandleSetBundleQuotaFuzzTest(std::unique_ptr<char[]> data, size_t size)
{
MessageParcel datas;
MessageParcel reply;
storageManagerPtr->HandleSetBundleQuota(datas, reply);
return true;
}
} // namespace OHOS::StorageManager } // namespace OHOS::StorageManager
/* Fuzzer entry point */ /* Fuzzer entry point */
@ -114,5 +292,25 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
} }
OHOS::StorageManager::StorageManagerFuzzTest(move(str), size); OHOS::StorageManager::StorageManagerFuzzTest(move(str), size);
OHOS::StorageManager::HandlePrepareAddUserFuzzTest(move(str), size);
OHOS::StorageManager::HandleRemoveUserFuzzTest(move(str), size);
OHOS::StorageManager::HandlePrepareStartUserFuzzTest(move(str), size);
OHOS::StorageManager::HandleStopUserFuzzTest(move(str), size);
OHOS::StorageManager::HandleGetCurrentBundleStatsFuzzTest(move(str), size);
OHOS::StorageManager::HandleMountFuzzTest(move(str), size);
OHOS::StorageManager::HandleUnmountFuzzTest(move(str), size);
OHOS::StorageManager::HandlePartitionFuzzTest(move(str), size);
OHOS::StorageManager::HandleFormatFuzzTest(move(str), size);
OHOS::StorageManager::HandleGenerateUserKeysFuzzTest(move(str), size);
OHOS::StorageManager::HandleDeleteUserKeysFuzzTest(move(str), size);
OHOS::StorageManager::HandleUpdateUserAuthFuzzTest(move(str), size);
OHOS::StorageManager::HandleActiveUserKeyFuzzTest(move(str), size);
OHOS::StorageManager::HandleInactiveUserKeyFuzzTest(move(str), size);
OHOS::StorageManager::HandleLockUserScreenFuzzTest(move(str), size);
OHOS::StorageManager::HandleUnlockUserScreenFuzzTest(move(str), size);
OHOS::StorageManager::HandleUpdateKeyContextFuzzTest(move(str), size);
OHOS::StorageManager::HandleCreateShareFileFuzzTest(move(str), size);
OHOS::StorageManager::HandleDeleteShareFileFuzzTest(move(str), size);
OHOS::StorageManager::HandleSetBundleQuotaFuzzTest(move(str), size);
return 0; return 0;
} }