inputbenchmarktest

Signed-off-by: yanziyu <yanziyu1@huawei.com>
This commit is contained in:
yanziyu 2022-06-25 09:41:44 +08:00
parent 3a56add4a0
commit a1ef24b84e
9 changed files with 766 additions and 29 deletions

View File

@ -3,43 +3,21 @@
# 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
# 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.
# limitations under the License.
import("//build/ohos_var.gni")
import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni")
import("//test/xts/tools/build/suite.gni")
module_output_path = "hdf/input"
ohos_moduletest_suite("HatsHdfInputTest") {
module_out_path = module_output_path
include_dirs = [
"//drivers/peripheral/input/hal/include",
"//drivers/peripheral/input/interfaces/include",
group("HatsHdfInputTest") {
testonly = true
deps = [
"hdi_input:HatsHdfInputTest",
"inputBenchmarkTest:HatsHdfInputbenchmarkTest",
]
sources = [ "./common/hdi_input_test.cpp" ]
cflags = [
"-Wall",
"-Wextra",
"-Werror",
"-fsigned-char",
"-fno-common",
"-fno-strict-aliasing",
]
deps = [ "//drivers/peripheral/input/hal:hdi_input" ]
if (is_standard_system) {
external_deps = [
"hdf_core:libhdf_test_common",
"hdf_core:libhdf_utils",
"hiviewdfx_hilog_native:libhilog",
"utils_base:utils",
]
} else {
external_deps = [ "hilog:libhilog" ]
}
}

View File

@ -0,0 +1,45 @@
# Copyright (c) 2021-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.
import("//build/ohos_var.gni")
import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni")
import("//test/xts/tools/build/suite.gni")
module_output_path = "hdf/input"
ohos_moduletest_suite("HatsHdfInputTest") {
module_out_path = module_output_path
include_dirs = [
"//drivers/peripheral/input/hal/include",
"//drivers/peripheral/input/interfaces/include",
]
sources = [ "./common/hdi_input_test.cpp" ]
cflags = [
"-Wall",
"-Wextra",
"-Werror",
"-fsigned-char",
"-fno-common",
"-fno-strict-aliasing",
]
deps = [ "//drivers/peripheral/input/hal:hdi_input" ]
if (is_standard_system) {
external_deps = [
"hdf_core:libhdf_test_common",
"hdf_core:libhdf_utils",
"hiviewdfx_hilog_native:libhilog",
"utils_base:utils",
]
} else {
external_deps = [ "hilog:libhilog" ]
}
}

0
hdf/input/Test.json → hdf/input/hdi_input/Test.json Executable file → Normal file
View File

View File

@ -0,0 +1,50 @@
# Copyright (c) 2021-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.
import("//build/ohos_var.gni")
import("//build/test.gni")
import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni")
import("//test/xts/tools/build/suite.gni")
module_output_path = "hdf/input"
ohos_moduletest_suite("HatsHdfInputbenchmarkTest") {
module_out_path = module_output_path
include_dirs = [
"//drivers/peripheral/input/hal/include",
"//drivers/peripheral/input/interfaces/include",
]
sources = [ "./hdf_input_benchmark_test.cpp" ]
cflags = [
"-Wall",
"-Wextra",
"-Werror",
"-fsigned-char",
"-fno-common",
"-fno-strict-aliasing",
]
deps = [
"//drivers/peripheral/input/hal:hdi_input",
"//third_party/benchmark",
"//third_party/googletest:gmock_main",
"//third_party/googletest:gtest_main",
]
if (is_standard_system) {
external_deps = [
"hdf_core:libhdf_test_common",
"hdf_core:libhdf_utils",
"hiviewdfx_hilog_native:libhilog",
"utils_base:utils",
]
} else {
external_deps = [ "hilog:libhilog" ]
}
}

View File

@ -0,0 +1,18 @@
{
"kits": [
{
"push": [
"HatsHdfInputbenchmarkTest->/data/local/tmp/HatsHdfInputbenchmarkTest"
],
"type": "PushKit"
}
],
"driver": {
"native-test-timeout": "120000",
"type": "CppTest",
"module-name": "HatsHdfInputbenchmarkTest",
"runtime-hint": "1s",
"native-test-device-path": "/data/local/tmp"
},
"description": "Configuration for HatsHdfInputbenchmarkTest Tests"
}

View File

@ -0,0 +1,614 @@
/*
* Copyright (c) 2021-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 <benchmark/benchmark.h>
#include <string>
#include <vector>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <unistd.h>
#include <fcntl.h>
#include <gtest/gtest.h>
#include <securec.h>
#include "osal_time.h"
#include "hdf_log.h"
#include "input_manager.h"
#include "hdi_input_test.h"
using namespace std;
using namespace testing::ext;
IInputInterface *g_inputInterface;
InputEventCb g_callback;
InputHostCb g_hotplugCb;
bool g_HasDev = false;
static void ReportHotPlugEventPkgCallback(const InputHotPlugEvent *msg);
static void ReportEventPkgCallback(const InputEventPackage **pkgs, uint32_t count, uint32_t devIndex);
static void CloseOnlineDev(InputDevDesc *sta, int32_t len);
static void OpenOnlineDev(InputDevDesc *sta, int32_t len);
class inputBenchmarkTest : public benchmark::Fixture {
public:
void SetUp(const ::benchmark::State &state);
void TearDown(const ::benchmark::State &state);
};
void inputBenchmarkTest::SetUp(const ::benchmark::State &state)
{
int32_t ret;
InputDevDesc sta[MAX_DEVICES];
ret = memset_s(sta, MAX_DEVICES * sizeof(InputDevDesc), 0, MAX_DEVICES * sizeof(InputDevDesc));
if (ret != 0) {
HDF_LOGE("memset failed.\n");
return;
}
ret = GetInputInterface(&g_inputInterface);
if (ret != INPUT_SUCCESS) {
HDF_LOGE("%s: get input hdi failed, ret %d \n", __func__, ret);
}
g_callback.EventPkgCallback = ReportEventPkgCallback;
g_hotplugCb.HotPlugCallback = ReportHotPlugEventPkgCallback;
ret = g_inputInterface->iInputManager->ScanInputDevice(sta, MAX_DEVICES);
if (ret) {
HDF_LOGE("%s: scan device failed, ret %d \n", __func__, ret);
}
for (int32_t i = 0; i < MAX_DEVICES; i++) {
if (sta[i].devIndex == 0) {
break;
}
g_HasDev = true;
}
}
void inputBenchmarkTest::TearDown(const ::benchmark::State &state)
{
ReleaseInputInterface(g_inputInterface);
}
static void ReportEventPkgCallback(const InputEventPackage **pkgs, uint32_t count, uint32_t devIndex)
{
if (pkgs == nullptr) {
return;
}
for (int32_t i = 0; i < count; i++) {
printf("%s: pkgs[%d] = 0x%x, 0x%x, %d\n", __func__, i, pkgs[i]->type, pkgs[i]->code, pkgs[i]->value);
EXPECT_GE(pkgs[i]->type, 0);
EXPECT_GE(pkgs[i]->code, 0);
EXPECT_GE(pkgs[i]->value, 0);
}
}
static void ReportHotPlugEventPkgCallback(const InputHotPlugEvent *msg)
{
int32_t ret;
if (msg == nullptr) {
return;
}
HDF_LOGI("%s: status =%d devId=%d type =%d \n", __func__, msg->status, msg->devIndex, msg->devType);
EXPECT_GE(msg->status, 0);
EXPECT_GE(msg->devIndex, 0);
EXPECT_GE(msg->devType, 0);
if (msg->status == 0) {
ret = g_inputInterface->iInputManager->OpenInputDevice(msg->devIndex);
if (ret) {
HDF_LOGE("%s: open device[%u] failed, ret %d \n", __func__, msg->devIndex, ret);
}
ret = g_inputInterface->iInputReporter->RegisterReportCallback(msg->devIndex, &g_callback);
if (ret) {
HDF_LOGE("%s: register callback failed for device[%d], ret %d \n", __func__, msg->devIndex, ret);
}
} else {
ret = g_inputInterface->iInputReporter->UnregisterReportCallback(msg->devIndex);
if (ret) {
HDF_LOGE("%s: unregister callback failed, ret %d \n", __func__, ret);
}
ret = g_inputInterface->iInputManager->CloseInputDevice(msg->devIndex);
if (ret) {
HDF_LOGE("%s: close device failed, ret %d \n", __func__, ret);
}
}
}
static void OpenOnlineDev(InputDevDesc *sta, int32_t len)
{
int32_t ret = g_inputInterface->iInputManager->ScanInputDevice(sta, len);
if (ret) {
HDF_LOGE("%s: scan device failed, ret %d \n", __func__, ret);
}
ASSERT_EQ(ret, INPUT_SUCCESS);
for (int32_t i = 0; i < len; i++) {
if (sta[i].devIndex == 0) {
break;
}
ret = g_inputInterface->iInputManager->OpenInputDevice(sta[i].devIndex);
if (ret) {
HDF_LOGE("%s: open device[%d] failed, ret %d \n", __func__, sta[i].devIndex, ret);
}
ASSERT_EQ(ret, INPUT_SUCCESS);
ret = g_inputInterface->iInputReporter->RegisterReportCallback(sta[i].devIndex, &g_callback);
if (ret) {
HDF_LOGE("%s: register callback failed for device[%d], ret %d \n", __func__, sta[i].devIndex, ret);
}
ASSERT_EQ(ret, INPUT_SUCCESS);
}
}
static void CloseOnlineDev(InputDevDesc *sta, int32_t len)
{
int32_t ret = g_inputInterface->iInputManager->ScanInputDevice(sta, len);
if (ret) {
HDF_LOGE("%s: scan device failed, ret %d \n", __func__, ret);
}
ASSERT_EQ(ret, INPUT_SUCCESS);
for (int32_t i = 0; i < len; i++) {
if (sta[i].devIndex == 0) {
break;
}
ret = g_inputInterface->iInputReporter->UnregisterReportCallback(sta[i].devIndex);
if (ret) {
HDF_LOGE("%s: register callback failed for device[%d], ret %d \n", __func__, sta[i].devIndex, ret);
}
ASSERT_EQ(ret, INPUT_SUCCESS);
ret = g_inputInterface->iInputManager->CloseInputDevice(sta[i].devIndex);
if (ret) {
HDF_LOGE("%s: close device[%d] failed, ret %d \n", __func__, sta[i].devIndex, ret);
}
ASSERT_EQ(ret, INPUT_SUCCESS);
}
}
/**
* @tc.number: SUB_DriverSystem_HdiInput_0001
* @tc.name: open input device for ap mode benchmark test
* @tc.desc: [C- SOFTWARE -0010]
* @tc.size: Medium
* @tc.level: level 0
*/
BENCHMARK_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0001)(
benchmark::State &st)
{
InputDevDesc sta[MAX_DEVICES];
HDF_LOGI("%s: [Input] RegisterCallbackAndReportData001 enter \n", __func__);
int32_t ret;
INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
for (auto _ : st) {
ret = g_inputInterface->iInputManager->ScanInputDevice(sta, sizeof(sta)/sizeof(InputDevDesc));
}
EXPECT_EQ(HDF_SUCCESS, ret);
}
BENCHMARK_REGISTER_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0001)->Iterations(100)->
Repetitions(3)->ReportAggregatesOnly();
/**
* @tc.number: SUB_DriverSystem_HdiInput_0002
* @tc.name: open input device for ap mode benchmark test
* @tc.desc: [C- SOFTWARE -0010]
* @tc.size: Medium
* @tc.level: level 0
*/
BENCHMARK_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0002)(
benchmark::State &st)
{
HDF_LOGI("%s: [Input] HotPlugCallback Testcase enter\n", __func__);
InputDevDesc sta[MAX_DEVICES];
int32_t ret = memset_s(sta, sizeof(sta), 0, sizeof(sta));
if (ret != 0) {
HDF_LOGE("%s: memcpy failed, line %d\n", __func__, __LINE__);
}
INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputReporter, INPUT_NULL_PTR);
INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
for (auto _ : st) {
ret = g_inputInterface->iInputReporter->RegisterHotPlugCallback(&g_hotplugCb);
}
if (ret) {
HDF_LOGE("%s: register hotplug callback failed for device manager, ret %d\n", __func__, ret);
}
ASSERT_EQ(ret, INPUT_SUCCESS);
OpenOnlineDev(sta, MAX_DEVICES);
OsalMSleep(KEEP_ALIVE_TIME_MS);
ret = memset_s(sta, sizeof(sta), 0, sizeof(sta));
if (ret != 0) {
HDF_LOGE("%s: memcpy failed, line %d\n", __func__, __LINE__);
}
CloseOnlineDev(sta, MAX_DEVICES);
ret = g_inputInterface->iInputReporter->UnregisterHotPlugCallback();
if (ret) {
HDF_LOGE("%s: unregister hotplug callback failed for device manager, ret %d\n", __func__, ret);
}
EXPECT_EQ(ret, INPUT_SUCCESS);
}
BENCHMARK_REGISTER_F(inputBenchmarkTest,SUB_DriverSystem_HdiInput_0002)->Iterations(100)->
Repetitions(3)->ReportAggregatesOnly();
/**
* @tc.number: SUB_DriverSystem_HdiInput_0003
* @tc.name: open input device for ap mode benchmark test
* @tc.desc: [C- SOFTWARE -0010]
* @tc.size: Medium
* @tc.level: level 0
*/
BENCHMARK_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0003)(
benchmark::State &st)
{
ASSERT_EQ(g_HasDev, true);
INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
int32_t ret = g_inputInterface->iInputManager->OpenInputDevice(TOUCH_INDEX);
ASSERT_EQ(ret, INPUT_SUCCESS);
for (auto _ : st) {
ret = g_inputInterface->iInputManager->CloseInputDevice(TOUCH_INDEX);
}
}
BENCHMARK_REGISTER_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0003)->Iterations(100)->
Repetitions(3)->ReportAggregatesOnly();
/**
* @tc.number: SUB_DriverSystem_HdiInput_0004
* @tc.name: close input device for ap mode benchmark test
* @tc.desc: [C- SOFTWARE -0010]
* @tc.size: Medium
* @tc.level: level 0
*/
BENCHMARK_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0004)(
benchmark::State &st)
{
ASSERT_EQ(g_HasDev, true);
int32_t ret = 0;
g_inputInterface->iInputManager->OpenInputDevice(TOUCH_INDEX);
EXPECT_EQ(ret, INPUT_SUCCESS);
for (auto _ : st) {
ret = g_inputInterface->iInputManager->CloseInputDevice(TOUCH_INDEX);
}
}
BENCHMARK_REGISTER_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0004)->Iterations(100)->
Repetitions(3)->ReportAggregatesOnly();
/**
* @tc.number: SUB_DriverSystem_HdiInput_0005
* @tc.name: get input device id for ap mode benchmark test
* @tc.desc: [C- SOFTWARE -0010]
* @tc.size: Medium
* @tc.level: level 0
*/
BENCHMARK_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0005)(
benchmark::State &st)
{
ASSERT_EQ(g_HasDev, true);
int32_t ret = 0;
InputDeviceInfo *dev = nullptr;
INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
ret = g_inputInterface->iInputManager->OpenInputDevice(TOUCH_INDEX);
if (ret) {
HDF_LOGE("%s: open device1 failed, ret %d\n", __func__, ret);
}
ASSERT_EQ(ret, INPUT_SUCCESS);
for (auto _ : st) {
ret = g_inputInterface->iInputManager->GetInputDevice(TOUCH_INDEX, &dev);
}
EXPECT_EQ(ret, INPUT_SUCCESS);
EXPECT_EQ((uint32_t)TOUCH_INDEX, dev->devIndex);
HDF_LOGI("devindex = %u, devType = %u\n", dev->devIndex, dev->devType);
HDF_LOGI("chipInfo = %s, VendorName = %s,chipName = %s\n", dev->chipInfo, dev->vendorName, dev->chipName);
}
BENCHMARK_REGISTER_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0005)->Iterations(100)->
Repetitions(3)->ReportAggregatesOnly();
/**
* @tc.number: SUB_DriverSystem_HdiInput_0006
* @tc.name: get input device list info for ap mode benchmark test
* @tc.desc: [C- SOFTWARE -0010]
* @tc.size: Medium
* @tc.level: level 0
*/
BENCHMARK_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0006)(
benchmark::State &st)
{
ASSERT_EQ(g_HasDev, true);
int32_t ret;
uint32_t num = 0;
InputDeviceInfo *dev[MAX_INPUT_DEV_NUM] = {0};
for (auto _ : st) {
ret = g_inputInterface->iInputManager->GetInputDeviceList(&num, dev, MAX_INPUT_DEV_NUM);
}
EXPECT_EQ(ret, INPUT_SUCCESS);
ASSERT_LE(num, (uint32_t)MAX_INPUT_DEV_NUM);
for (uint32_t i = 0; i < num; i++) {
HDF_LOGI("num = %u,device[%d]'s info is :\n", num, i);
HDF_LOGI("index = %u, devType = %u\n", dev[i]->devIndex, dev[i]->devType);
HDF_LOGI("chipInfo = %s, VendorName = %s,chipName = %s\n", dev[i]->chipInfo, dev[i]->vendorName,
dev[i]->chipName);
EXPECT_LE(0, dev[i]->devType);
}
}
BENCHMARK_REGISTER_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0006)->Iterations(100)->
Repetitions(3)->ReportAggregatesOnly();
/**
* @tc.number: SUB_DriverSystem_HdiInput_0007
* @tc.name: get input device type test for ap mode benchmark test
* @tc.desc: [C- SOFTWARE -0010]
* @tc.size: Medium
* @tc.level: level 0
*/
BENCHMARK_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0007)(
benchmark::State &st)
{
ASSERT_EQ(g_HasDev, true);
int32_t ret;
uint32_t devType = INIT_DEFAULT_VALUE;
for (auto _ : st) {
ret = g_inputInterface->iInputController->GetDeviceType(TOUCH_INDEX, &devType);
}
}
BENCHMARK_REGISTER_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0007)->Iterations(100)->
Repetitions(3)->ReportAggregatesOnly();
/**
* @tc.number: SUB_DriverSystem_HdiInput_0008
* @tc.name: get input device chip info for ap mode benchmark test
* @tc.desc: [C- SOFTWARE -0010]
* @tc.size: Medium
* @tc.level: level 0
*/
BENCHMARK_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0008)(
benchmark::State &st)
{
ASSERT_EQ(g_HasDev, true);
int32_t ret;
char chipInfo[CHIP_INFO_LEN] = {0};
for (auto _ : st) {
ret = g_inputInterface->iInputController->GetChipInfo(TOUCH_INDEX, chipInfo, CHIP_INFO_LEN);
}
HDF_LOGI("device's chip info is %s\n", chipInfo);
}
BENCHMARK_REGISTER_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0008)->Iterations(100)->
Repetitions(3)->ReportAggregatesOnly();
/**
* @tc.number: SUB_DriverSystem_HdiInput_0009
* @tc.name: get input device info for ap mode benchmark test
* @tc.desc: [C- SOFTWARE -0010]
* @tc.size: Medium
* @tc.level: level 0
*/
BENCHMARK_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0009)(
benchmark::State &st)
{
ASSERT_EQ(g_HasDev, true);
int32_t ret;
char chipInfo[CHIP_INFO_LEN] = {0};
InputDeviceInfo *dev =NULL;
ret = g_inputInterface->iInputManager->GetInputDevice(TOUCH_INDEX, &dev);
for (auto _ : st) {
ret = g_inputInterface->iInputController->GetChipInfo(TOUCH_INDEX, chipInfo, CHIP_INFO_LEN);
}
HDF_LOGI("device1's chip info is %s? chipInfo = %s\n", chipInfo, dev->chipInfo);
}
BENCHMARK_REGISTER_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0009)->Iterations(100)->
Repetitions(3)->ReportAggregatesOnly();
/**
* @tc.number: SUB_DriverSystem_HdiInput_0010
* @tc.name: set device power status for ap mode benchmark test
* @tc.desc: [C- SOFTWARE -0010]
* @tc.size: Medium
* @tc.level: level 0
*/
BENCHMARK_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0010)(
benchmark::State &st)
{
ASSERT_EQ(g_HasDev, true);
int32_t ret;
uint32_t setStatus = INPUT_LOW_POWER;
uint32_t getStatus = 0;
ret = g_inputInterface->iInputController->SetPowerStatus(TOUCH_INDEX, setStatus);
for (auto _ : st) {
ret = g_inputInterface->iInputController->GetPowerStatus(TOUCH_INDEX, &getStatus);
}
}
BENCHMARK_REGISTER_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0010)->Iterations(100)->
Repetitions(3)->ReportAggregatesOnly();
/**
* @tc.number: SUB_DriverSystem_HdiInput_0011
* @tc.name: get device poewr status for ap mode benchmark test
* @tc.desc: [C- SOFTWARE -0010]
* @tc.size: Medium
* @tc.level: level 0
*/
BENCHMARK_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0011)(
benchmark::State &st)
{
ASSERT_EQ(g_HasDev, true);
int32_t ret;
uint32_t setStatus = INPUT_RESUME;
uint32_t getStatus = 0;
ret = g_inputInterface->iInputController->SetPowerStatus(TOUCH_INDEX, setStatus);
for (auto _ : st) {
ret = g_inputInterface->iInputController->GetPowerStatus(TOUCH_INDEX, &getStatus);
}
ASSERT_EQ(setStatus, getStatus);
}
BENCHMARK_REGISTER_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0011)->Iterations(100)->
Repetitions(3)->ReportAggregatesOnly();
/**
* @tc.number: SUB_DriverSystem_HdiInput_0012
* @tc.name: get device vendor name for ap mode benchmark test
* @tc.desc: [C- SOFTWARE -0010]
* @tc.size: Medium
* @tc.level: level 0
*/
BENCHMARK_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0012)(
benchmark::State &st)
{
ASSERT_EQ(g_HasDev, true);
int32_t ret;
char vendorName[VENDOR_NAME_LEN] = {0};
for (auto _ : st) {
ret = g_inputInterface->iInputController->GetVendorName(TOUCH_INDEX, vendorName, VENDOR_NAME_LEN);
}
HDF_LOGI("device1's vendor name is %s:\n", vendorName);
}
BENCHMARK_REGISTER_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0012)->Iterations(100)->
Repetitions(3)->ReportAggregatesOnly();
/**
* @tc.number: SUB_DriverSystem_HdiInput_0013
* @tc.name: get device chip name for ap mode benchmark test
* @tc.desc: [C- SOFTWARE -0010]
* @tc.size: Medium
* @tc.level: level 0
*/
BENCHMARK_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0013)(
benchmark::State &st)
{
ASSERT_EQ(g_HasDev, true);
int32_t ret;
char chipName[CHIP_NAME_LEN] = {0};
for (auto _ : st) {
ret = g_inputInterface->iInputController->GetChipName(TOUCH_INDEX, chipName, CHIP_NAME_LEN);
}
HDF_LOGI("device1's vendor name is %s:\n", chipName);
}
BENCHMARK_REGISTER_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0013)->Iterations(100)->
Repetitions(3)->ReportAggregatesOnly();
/**
* @tc.number: SUB_DriverSystem_HdiInput_0014
* @tc.name: set device gesture mode for ap mode benchmark test
* @tc.desc: [C- SOFTWARE -0010]
* @tc.size: Medium
* @tc.level: level 0
*/
BENCHMARK_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0014)(
benchmark::State &st)
{
ASSERT_EQ(g_HasDev, true);
int32_t ret;
uint32_t gestureMode = 1;
for (auto _ : st) {
ret = g_inputInterface->iInputController->SetGestureMode(TOUCH_INDEX, gestureMode);
}
}
BENCHMARK_REGISTER_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0014)->Iterations(100)->
Repetitions(3)->ReportAggregatesOnly();
/**
* @tc.number: SUB_DriverSystem_HdiInput_0015
* @tc.name: Run Capacitance for ap mode benchmark test
* @tc.desc: [C- SOFTWARE -0010]
* @tc.size: Medium
* @tc.level: level 0
*/
BENCHMARK_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0015)(
benchmark::State &st)
{
ASSERT_EQ(g_HasDev, true);
int32_t ret;
uint32_t testType = MMI_TEST;
char result[MAX_INPUT_DEV_NUM] = {0};
for (auto _ : st) {
ret = g_inputInterface->iInputController->RunCapacitanceTest(TOUCH_INDEX, testType, result, MAX_INPUT_DEV_NUM);
}
}
BENCHMARK_REGISTER_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0015)->Iterations(100)->
Repetitions(3)->ReportAggregatesOnly();
/**
* @tc.number: SUB_DriverSystem_HdiInput_0016
* @tc.name: Run Extra Command for ap mode benchmark test
* @tc.desc: [C- SOFTWARE -0010]
* @tc.size: Medium
* @tc.level: level 0
*/
BENCHMARK_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0016)(
benchmark::State &st)
{
ASSERT_EQ(g_HasDev, true);
int32_t ret;
InputExtraCmd extraCmd = {0};
extraCmd.cmdCode = "WakeUpMode";
extraCmd.cmdValue = "Enable";
for (auto _ : st) {
ret = g_inputInterface->iInputController->RunExtraCommand(TOUCH_INDEX, &extraCmd);
}
}
BENCHMARK_REGISTER_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0016)->Iterations(100)->
Repetitions(3)->ReportAggregatesOnly();
/**
* @tc.number: SUB_DriverSystem_HdiInput_0017
* @tc.name: Register Report Callback for ap mode benchmark test
* @tc.desc: [C- SOFTWARE -0010]
* @tc.size: Medium
* @tc.level: level 0
*/
BENCHMARK_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0017)(
benchmark::State &st)
{
ASSERT_EQ(g_HasDev, true);
int32_t ret;
g_callback.EventPkgCallback = ReportEventPkgCallback;
ret = g_inputInterface->iInputReporter->RegisterReportCallback(0, &g_callback);
EXPECT_NE(ret, INPUT_SUCCESS);
ret = g_inputInterface->iInputReporter->RegisterReportCallback(MAX_INPUT_DEV_NUM, &g_callback);
EXPECT_NE(ret, INPUT_SUCCESS);
for (auto _ : st) {
ret = g_inputInterface->iInputReporter->RegisterReportCallback(TOUCH_INDEX, nullptr);
EXPECT_NE(ret, INPUT_SUCCESS);
}
}
BENCHMARK_REGISTER_F(inputBenchmarkTest, SUB_DriverSystem_HdiInput_0017)->Iterations(100)->
Repetitions(3)->ReportAggregatesOnly();
BENCHMARK_MAIN();

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2021-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 INPUT_HDI_TEST_H
#define INPUT_HDI_TEST_H
const int INIT_DEFAULT_VALUE = 255;
const int KEEP_ALIVE_TIME_MS = 5000;
const int TOUCH_INDEX = 1;
const int MAX_DEVICES = 32;
const int INVALID_INDEX = 5;
#define INPUT_CHECK_NULL_POINTER(pointer, ret) do { \
if ((pointer) == nullptr) { \
printf("%s: null pointer", __func__); \
ASSERT_EQ ((ret), INPUT_SUCCESS); \
} \
} while (0)
#endif