!614 Feat:Add pwm/watchdog/timer user interface performance test unittest

Merge pull request !614 from susha/PWM
This commit is contained in:
openharmony_ci
2022-02-12 10:16:51 +00:00
committed by Gitee
9 changed files with 121 additions and 6 deletions
@@ -122,3 +122,14 @@ HWTEST_F(HdfLitePwmTest, PwmDisableTest001, TestSize.Level1)
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
EXPECT_EQ(0, PwmTestExecute(PWM_DISABLE_TEST));
}
/**
* @tc.name: PwmIfPerformanceTest001
* @tc.desc: pwm user if performance test
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(HdfLitePwmTest, PwmIfPerformanceTest001, TestSize.Level1)
{
EXPECT_EQ(0, PwmTestExecute(PWM_IF_PERFORMANCE_TEST));
}
@@ -135,3 +135,14 @@ HWTEST_F(HdfLiteTimerTest, TimerTestReliability001, TestSize.Level1)
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
EXPECT_EQ(0, TimerTestExecute(TIMER_RELIABILITY_TEST));
}
/**
* @tc.name: TimerTestIfPerformance001
* @tc.desc: timer user if performance test
* @tc.type: FUNC
* @tc.require: NA
*/
HWTEST_F(HdfLiteTimerTest, TimerTestIfPerformance001, TestSize.Level1)
{
EXPECT_EQ(0, TimerTestExecute(TIMER_IF_PERFORMANCE_TEST));
}
@@ -97,3 +97,13 @@ HWTEST_F(HdfLiteWatchdogTest, HdfLiteWatchdogTestReliability001, TestSize.Level1
EXPECT_EQ(0, WatchdogTestExecute(WATCHDOG_TEST_RELIABILITY));
}
/**
* @tc.name: HdfLiteWatchdogTestIfPerformance001
* @tc.desc: watchdog user if performance test
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(HdfLiteWatchdogTest, HdfLiteWatchdogTestIfPerformance001, TestSize.Level1)
{
EXPECT_EQ(0, WatchdogTestExecute(WATCHDOG_IF_PERFORMANCE_TEST));
}
+26
View File
@@ -327,6 +327,31 @@ static int32_t PwmReliabilityTest(struct PwmTester *tester)
return HDF_SUCCESS;
}
static int32_t PwmIfPerformanceTest(struct PwmTester *tester)
{
#ifdef __LITEOS__
// liteos the accuracy of the obtained time is too large and inaccurate.
if (tester == NULL) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
#endif
struct PwmConfig cfg = {0};
uint64_t startMs;
uint64_t endMs;
uint64_t useTime; /*ms*/
startMs = OsalGetSysTimeMs();
PwmGetConfig(tester->handle, &cfg);
endMs = OsalGetSysTimeMs();
useTime = endMs - startMs;
HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n",
startMs, endMs, useTime, useTime < 1 ? true : false );
return HDF_SUCCESS;
}
struct PwmTestEntry {
int cmd;
int32_t (*func)(struct PwmTester *tester);
@@ -340,6 +365,7 @@ static struct PwmTestEntry g_entry[] = {
{ PWM_DISABLE_TEST, PwmDisableTest },
{ PWM_SET_GET_CONFIG_TEST, PwmSetGetConfigTest },
{ PWM_RELIABILITY_TEST, PwmReliabilityTest },
{ PWM_IF_PERFORMANCE_TEST, PwmIfPerformanceTest },
};
int32_t PwmTestExecute(int cmd)
+1
View File
@@ -25,6 +25,7 @@ enum PwmTestCmd {
PWM_DISABLE_TEST,
PWM_SET_GET_CONFIG_TEST,
PWM_RELIABILITY_TEST,
PWM_IF_PERFORMANCE_TEST,
PWM_TEST_CMD_MAX,
};
+28 -1
View File
@@ -338,6 +338,32 @@ struct TimerTest *TimerTestGet(void)
return &tester;
}
static int32_t TimerIfPerformanceTest(struct TimerTest *test)
{
#ifdef __LITEOS__
// liteos the accuracy of the obtained time is too large and inaccurate.
if (test == NULL) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
#endif
uint64_t startMs;
uint64_t endMs;
uint64_t useTime; /*ms*/
uint32_t uSecond;
bool isPeriod;
startMs = OsalGetSysTimeMs();
HwTimerGet(test->handle, &uSecond, &isPeriod);
endMs = OsalGetSysTimeMs();
useTime = endMs - startMs;
HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n",
startMs, endMs, useTime, useTime < 1 ? true : false );
return HDF_SUCCESS;
}
static struct TimerTestFunc g_timerTestFunc[] = {
{TIMER_TEST_SET, TimerSetTest},
{TIMER_TEST_SETONCE, TimerSetOnceTest},
@@ -346,6 +372,7 @@ static struct TimerTestFunc g_timerTestFunc[] = {
{TIMER_TEST_STOP, TimerStopTest},
{TIMER_MULTI_THREAD_TEST, TimerTestMultiThread},
{TIMER_RELIABILITY_TEST, TimerTestReliability},
{TIMER_IF_PERFORMANCE_TEST, TimerIfPerformanceTest},
};
int32_t TimerTestExecute(int cmd)
@@ -353,7 +380,7 @@ int32_t TimerTestExecute(int cmd)
uint32_t i;
int32_t ret = HDF_ERR_NOT_SUPPORT;
if (cmd > TIMER_RELIABILITY_TEST) {
if (cmd > TIMER_TEST_MAX_CMD) {
HDF_LOGE("%s: invalid cmd:%d", __func__, cmd);
return HDF_ERR_NOT_SUPPORT;
}
@@ -24,6 +24,8 @@ enum TimerTestCmd {
TIMER_TEST_STOP,
TIMER_MULTI_THREAD_TEST,
TIMER_RELIABILITY_TEST,
TIMER_IF_PERFORMANCE_TEST,
TIMER_TEST_MAX_CMD,
};
#define TIMER_TEST_STACK_SIZE (1024 * 100)
@@ -257,12 +257,38 @@ static int32_t TestCaseWatchdogReliability(struct WatchdogTester *tester)
return HDF_SUCCESS;
}
static int32_t TestCaseWatchdogIfPerformanceTest(struct WatchdogTester *tester)
{
#ifdef __LITEOS__
// liteos the accuracy of the obtained time is too large and inaccurate.
if (tester == NULL) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
#endif
uint32_t timeoutGet = 0;
uint64_t startMs;
uint64_t endMs;
uint64_t useTime; /*ms*/
startMs = OsalGetSysTimeMs();
WatchdogGetTimeout(tester->handle, &timeoutGet);
endMs = OsalGetSysTimeMs();
useTime = endMs - startMs;
HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n",
startMs, endMs, useTime, useTime < 1 ? true : false );
return HDF_SUCCESS;
}
static struct WatchdogTestEntry g_entry[] = {
{ WATCHDOG_TEST_SET_GET_TIMEOUT, TestCaseWatchdogSetGetTimeout},
{ WATCHDOG_TEST_START_STOP, TestCaseWatchdogStartStop},
{ WATCHDOG_TEST_FEED, TestCaseWatchdogFeed},
{ WATCHDOG_TEST_RELIABILITY, TestCaseWatchdogReliability},
{ WATCHDOG_TEST_BARK, TestCaseWatchdogBark},
{ WATCHDOG_IF_PERFORMANCE_TEST, TestCaseWatchdogIfPerformanceTest},
};
int32_t WatchdogTestExecute(int cmd)
@@ -17,11 +17,12 @@ extern "C" {
enum WatchdogTestCmd {
WATCHDOG_TEST_SET_GET_TIMEOUT = 0,
WATCHDOG_TEST_START_STOP = 1,
WATCHDOG_TEST_FEED = 2,
WATCHDOG_TEST_RELIABILITY = 3,
WATCHDOG_TEST_BARK = 4,
WATCHDOG_TEST_MAX = 5,
WATCHDOG_TEST_START_STOP,
WATCHDOG_TEST_FEED,
WATCHDOG_TEST_RELIABILITY,
WATCHDOG_TEST_BARK,
WATCHDOG_IF_PERFORMANCE_TEST,
WATCHDOG_TEST_MAX,
};
struct WatchdogTestConfig {