cfuzz test odecheck fix

Signed-off-by: 李辉 <lihui359@huawei.com>
Change-Id: I26360867530639bfcae82918fe6c0c69edad3803
This commit is contained in:
李辉 2024-11-06 11:45:54 +00:00
parent d764ecbb05
commit 64a7c7f30e
5 changed files with 11 additions and 80 deletions

View File

@ -18,8 +18,8 @@ group("fuzztest") {
"vsyncconnection_fuzzer:fuzztest",
"vsynccontroller_fuzzer:fuzztest",
"vsyncdistributor_fuzzer:fuzztest",
"vsyncgenerator_fuzzer:fuzztest",
"vsyncreceiver_fuzzer:fuzztest",
"vsyncsampler_fuzzer:fuzztest",
"vsyncgenerator_fuzzer:fuzztest",
]
}

View File

@ -22,7 +22,6 @@
namespace OHOS {
namespace {
// constexpr size_t STR_LEN = 10;
const uint8_t* data_ = nullptr;
size_t size_ = 0;
size_t pos;
@ -48,20 +47,6 @@ namespace OHOS {
return object;
}
/*
* get a string from data_
*/
std::string GetStringFromData(int strlen)
{
char cstr[strlen];
cstr[strlen - 1] = '\0';
for (int i = 0; i < strlen - 1; i++) {
cstr[i] = GetData<char>();
}
std::string str(cstr);
return str;
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
{
if (data == nullptr) {
@ -80,21 +65,7 @@ namespace OHOS {
bool nativeDVSyncSwitch = GetData<bool>();
int32_t bufferCount = GetData<int32_t>();
int32_t highPriorityRate = GetData<int32_t>();
// int64_t windowNodeId = GetData<int64_t>();
// int64_t timestamp = GetData<int64_t>();
// int64_t now = GetData<int64_t>();
// int64_t period = GetData<int64_t>();
// uint32_t refreshRate = GetData<uint32_t>();
// VSyncMode vsyncMode = GetData<VSyncMode>();
// uint32_t vsyncMaxRefreshRate = GetData<uint32_t>();
// std::pair<uint64_t, uint32_t> pair1 = {GetData<uint64_t>(), GetData<uint32_t>()};
// bool waitForVSync = GetData<bool>();
// int64_t vsyncCount = GetData<int64_t>();
// bool isDvsyncThread = GetData<bool>();
// uint32_t pid = GetData<uint32_t>();
// bool isSystemAnimateScene = GetData<bool>();
// uint64_t id = GetData<uint64_t>();
// bool isRender = GetData<bool>();
// test
sptr<Rosen::VSyncGenerator> vsyncGenerator = Rosen::CreateVSyncGenerator();
sptr<Rosen::VSyncController> vsyncController = new Rosen::VSyncController(vsyncGenerator, offset);
@ -105,33 +76,7 @@ namespace OHOS {
vsyncDistributor->SetUiDvsyncSwitch(uiDVSyncSwitch, conn);
vsyncDistributor->SetUiDvsyncConfig(bufferCount);
vsyncDistributor->SetHighPriorityVSyncRate(highPriorityRate, conn);
// vsyncDistributor->AddConnection(conn, windowNodeId);
// vsyncDistributor->RemoveConnection(conn);
// std::mutex mutex;
// std::unique_lock<std::mutex> locker(mutex);
// //vsyncDistributor->WaitForVsyncOrTimeOut(locker);
// std::vector<sptr<Rosen::VSyncConnection>> conns = {conn};
// //vsyncDistributor->PostVSyncEventPreProcess(timestamp, conns);
// vsyncDistributor->DisableVSync();
// vsyncDistributor->EnableVSync();
// #if defined(RS_ENABLE_DVSYNC)
// vsyncDistributor->OnDVSyncTrigger(now, period, refreshRate, vsyncMode, vsyncMaxRefreshRate);
// vsyncDistributor->SendConnectionsToVSyncWindow(now, period, refreshRate, vsyncMode, locker);
// #endif
// vsyncDistributor->OnVSyncTrigger(now, period, refreshRate, vsyncMode, vsyncMaxRefreshRate);
// vsyncDistributor->CheckNeedDisableDvsync(now, period);
// vsyncDistributor->OnConnsRefreshRateChanged({pair1});
// vsyncDistributor->CollectConnectionsLTPO(waitForVSync, timestamp, conns, vsyncCount, isDvsyncThread);
// vsyncDistributor->PostVSyncEvent(conns, timestamp, isDvsyncThread);
// std::string name = GetStringFromData(STR_LEN);
// vsyncDistributor->QosGetPidByName(name, pid);
// vsyncDistributor->SetQosVSyncRateByPid(pid, rate,isSystemAnimateScene);
// vsyncDistributor->SetQosVSyncRate(id, rate, isSystemAnimateScene);
// vsyncDistributor->ChangeConnsRateLocked(vsyncMaxRefreshRate);
// vsyncDistributor->SetFrameIsRender(isRender);
// vsyncDistributor->MarkRSAnimate();
// vsyncDistributor->UnmarkRSAnimate();
// vsyncDistributor->HasPendingUIRNV();
return true;
}
}

View File

@ -14,16 +14,17 @@
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/test.gni")
import("//foundation/graphic/graphic_2d/graphic_config.gni")
module_output_path = "graphic_2d/graphic_2d"
##############################fuzztest##########################################
ohos_fuzztest("VsyncGeneratorFuzzTest") {
fuzz_config_file = "//foundation/graphic/graphic_2d/rosen/modules/composer/vsync/test/fuzztest/vsyncgenerator_fuzzer"
fuzz_config_file = "${graphic_2d_root}/rosen/modules/composer/vsync/test/fuzztest/vsyncgenerator_fuzzer"
module_out_path = module_output_path
include_dirs = [
"//foundation/graphic/graphic_2d/interfaces/inner_api/common",
"//foundation/graphic/graphic_2d/rosen/modules/composer/vsync/include",
"$graphic_2d_root/interfaces/inner_api/common",
"$graphic_2d_root/rosen/modules/composer/vsync/include",
]
cflags = [
"-g",
@ -34,9 +35,7 @@ ohos_fuzztest("VsyncGeneratorFuzzTest") {
"-Dprotected=public",
]
sources = [ "vsyncgenerator_fuzzer.cpp" ]
deps = [
"//foundation/graphic/graphic_2d/rosen/modules/composer/vsync:libvsync",
]
deps = [ "$graphic_2d_root/rosen/modules/composer/vsync:libvsync" ]
external_deps = [ "c_utils:utils" ]
}

View File

@ -84,25 +84,18 @@ namespace OHOS {
sptr<Rosen::VSyncController> vsyncController = new Rosen::VSyncController(vsyncGenerator, offset);
sptr<Rosen::VSyncDistributor> vsyncDistributor = new Rosen::VSyncDistributor(vsyncController, "Fuzz");
vsyncController->SetEnable(enable, enable);
//vsyncGenerator->ListenerVsyncEventCB(occurTimestamp, nextTimestamp, occurReferenceTime, isWakeup);
//vsyncGenerator->WaitForTimeout(occurTimestamp, nextTimestamp, occurReferenceTime);
vsyncGenerator->ChangeListenerOffsetInternal();
vsyncGenerator->ChangeListenerRefreshRatesInternal();
vsyncGenerator->UpdateWakeupDelay(occurReferenceTime,nextTimestamp);
//vsyncGenerator->CheckTimingCorrect(occurTimestamp, occurReferenceTime, nextTimestamp);
//vsyncGenerator->UpdateChangeDataLocked(occurReferenceTime, occurReferenceTime, nextTimestamp);
vsyncGenerator->UpdateWakeupDelay(occurReferenceTime, nextTimestamp);
vsyncGenerator->SetPendingMode(period, occurTimestamp);
vsyncGenerator->SetVSyncMode(GetData<OHOS::VSyncMode>());
vsyncGenerator->UpdateVSyncModeLocked();
Rosen::impl::VSyncGenerator::Listener listener= {
Rosen::impl::VSyncGenerator::Listener listener = {
.phase_ = phase,
.callback_ = vsyncController,
.lastTime_ = lastTime,
.lastTimeRecord_ = lastTimeRecord
};
//vsyncGenerator->ComputeListenerNextVSyncTimeStamp(listener, occurTimestamp, occurReferenceTime);
//vsyncGenerator->GetListenerTimeouted(now, occurTimestamp, occurReferenceTime);
//vsyncGenerator->GetListenerTimeoutedLTPO(now, occurReferenceTime);
vsyncGenerator->UpdatePeriodLocked(period);
vsyncGenerator->JudgeRefreshRateLocked(period);
vsyncGenerator->SetExpectNextVsyncTimeInternal(now);

View File

@ -134,9 +134,6 @@ namespace OHOS {
int64_t timestamp = GetData<int64_t>();
bool isThreadShared = GetData<bool>();
int64_t now = GetData<int64_t>();
// int64_t datas[3] = {GetData<int64_t>(), GetData<int64_t>(), GetData<int64_t>()};
// ssize_t dataCount = 3;
// int32_t fd = GetData<int32_t>();
// test
sptr<Rosen::VSyncGenerator> vsyncGenerator = Rosen::CreateVSyncGenerator();
@ -166,10 +163,8 @@ namespace OHOS {
vsyncCallBackListener->GetPeriodShared();
vsyncCallBackListener->GetTimeStampShared();
vsyncCallBackListener->AddCallback(fcb);
// vsyncCallBackListener->HandleVsyncCallbacks(datas, dataCount);
vsyncCallBackListener->CalculateExpectedEndLocked(now);
// vsyncCallBackListener->OnReadable(fd);
// vsyncCallBackListener->ReadFdInternal(fd, datas, dataCount);
GraphicCommonTest();
vsyncReceiver->SetVsyncCallBackForEveryFrame(fcb, isOpen);
@ -177,7 +172,6 @@ namespace OHOS {
vsyncReceiver->IsRequestedNextVSync();
//tearDown
//vsyncCallBackListener->closeFd(fd);
vsyncReceiver->CloseVsyncReceiverFd();
return true;
}