mirror of
https://github.com/openharmony/drivers_framework.git
synced 2026-07-20 19:27:49 -04:00
!621 Feat:add uart user interface performance test unittest and Fix: fix rtc code bug
Merge pull request !621 from 贾子扬/master
This commit is contained in:
@@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
#include "rtc_if.h"
|
||||
#include "hdf_log.h"
|
||||
#include "hdf_io_service_if.h"
|
||||
#include "hdf_log.h"
|
||||
#include "hdf_sbuf.h"
|
||||
#include "osal_mem.h"
|
||||
#include "securec.h"
|
||||
@@ -66,7 +66,7 @@ int32_t RtcReadTime(DevHandle handle, struct RtcTime *time)
|
||||
|
||||
host = (struct RtcHost *)handle;
|
||||
|
||||
reply = HdfSbufObtain(sizeof(*time) + sizeof(uint64_t));
|
||||
reply = HdfSbufObtainDefaultSize();
|
||||
if (reply == NULL) {
|
||||
HDF_LOGE("%s: fail to obtain reply!", __func__);
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
@@ -91,6 +91,12 @@ int32_t RtcReadTime(DevHandle handle, struct RtcTime *time)
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
if (len != sizeof(*time)) {
|
||||
HDF_LOGE("%s: read error, len: %u, size: %zu", __func__, len, sizeof(*time));
|
||||
ret = HDF_FAILURE;
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
if (memcpy_s(time, sizeof(*time), temp, len) != EOK) {
|
||||
HDF_LOGE("%s: memcpy time fail!", __func__);
|
||||
ret = HDF_ERR_IO;
|
||||
@@ -169,7 +175,7 @@ int32_t RtcReadAlarm(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct Rtc
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
reply = HdfSbufObtain(sizeof(*time) + sizeof(uint64_t));
|
||||
reply = HdfSbufObtainDefaultSize();
|
||||
if (reply == NULL) {
|
||||
HDF_LOGE("%s: fail to obtain reply!", __func__);
|
||||
HdfSbufRecycle(data);
|
||||
@@ -177,7 +183,7 @@ int32_t RtcReadAlarm(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct Rtc
|
||||
}
|
||||
|
||||
if (!HdfSbufWriteUint32(data, (uint32_t)alarmIndex)) {
|
||||
HDF_LOGE("%s: write rtc alarmIndex fail!", __func__);
|
||||
HDF_LOGE("%s: write alarmIndex fail!", __func__);
|
||||
ret = HDF_ERR_IO;
|
||||
goto EXIT;
|
||||
}
|
||||
@@ -201,6 +207,12 @@ int32_t RtcReadAlarm(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct Rtc
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
if (len != sizeof(*time)) {
|
||||
HDF_LOGE("%s: read error, len: %u, size: %zu", __func__, len, sizeof(*time));
|
||||
ret = HDF_FAILURE;
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
if (memcpy_s(time, sizeof(*time), temp, len) != EOK) {
|
||||
HDF_LOGE("%s: memcpy time fail!", __func__);
|
||||
ret = HDF_ERR_IO;
|
||||
@@ -267,7 +279,7 @@ int32_t RtcRegisterAlarmCallback(DevHandle handle, enum RtcAlarmIndex alarmIndex
|
||||
{
|
||||
(void)alarmIndex;
|
||||
if(handle == NULL || cb == NULL) {
|
||||
HDF_LOGE("%s: handle orcb is NULL.", __func__);
|
||||
HDF_LOGE("%s: handle or cb is NULL.", __func__);
|
||||
return HDF_ERR_INVALID_OBJECT;
|
||||
}
|
||||
|
||||
@@ -295,13 +307,13 @@ int32_t RtcAlarmInterruptEnable(DevHandle handle, enum RtcAlarmIndex alarmIndex,
|
||||
}
|
||||
|
||||
if (!HdfSbufWriteUint32(data, (uint32_t)alarmIndex)) {
|
||||
HDF_LOGE("%s: write rtc alarmIndex fail!", __func__);
|
||||
HDF_LOGE("%s: write alarmIndex fail!", __func__);
|
||||
HdfSbufRecycle(data);
|
||||
return HDF_ERR_IO;
|
||||
}
|
||||
|
||||
if (!HdfSbufWriteUint8(data, enable)) {
|
||||
HDF_LOGE("%s: write rtc time fail!", __func__);
|
||||
HDF_LOGE("%s: write enable fail!", __func__);
|
||||
HdfSbufRecycle(data);
|
||||
return HDF_ERR_IO;
|
||||
}
|
||||
@@ -338,7 +350,7 @@ int32_t RtcGetFreq(DevHandle handle, uint32_t *freq)
|
||||
|
||||
host = (struct RtcHost *)handle;
|
||||
|
||||
reply = HdfSbufObtain(sizeof(*freq) + sizeof(uint64_t));
|
||||
reply = HdfSbufObtainDefaultSize();
|
||||
if (reply == NULL) {
|
||||
HDF_LOGE("%s: fail to obtain data", __func__);
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
@@ -432,7 +444,7 @@ int32_t RtcReset(DevHandle handle)
|
||||
|
||||
ret = service->dispatcher->Dispatch(&service->object, RTC_IO_RESET, NULL, NULL);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: rtc close error, ret %d", __func__, ret);
|
||||
HDF_LOGE("%s: rtc reset fail, ret %d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -460,7 +472,7 @@ int32_t RtcReadReg(DevHandle handle, uint8_t usrDefIndex, uint8_t *value)
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
}
|
||||
|
||||
reply = HdfSbufObtain(sizeof(*value) + sizeof(uint64_t));
|
||||
reply = HdfSbufObtainDefaultSize();
|
||||
if (reply == NULL) {
|
||||
HDF_LOGE("%s: fail to obtain reply!", __func__);
|
||||
HdfSbufRecycle(data);
|
||||
@@ -519,13 +531,13 @@ int32_t RtcWriteReg(DevHandle handle, uint8_t usrDefIndex, uint8_t value)
|
||||
}
|
||||
|
||||
if (!HdfSbufWriteUint8(data, usrDefIndex)) {
|
||||
HDF_LOGE("%s: write rtc usrDefIndex fail!", __func__);
|
||||
HDF_LOGE("%s: write usrDefIndex fail!", __func__);
|
||||
HdfSbufRecycle(data);
|
||||
return HDF_ERR_IO;
|
||||
}
|
||||
|
||||
if (!HdfSbufWriteUint8(data, value)) {
|
||||
HDF_LOGE("%s: write rtc value fail!", __func__);
|
||||
HDF_LOGE("%s: write value fail!", __func__);
|
||||
HdfSbufRecycle(data);
|
||||
return HDF_ERR_IO;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ static int32_t RtcServiceIoReadTime(struct RtcHost *host, struct HdfSBuf *reply)
|
||||
|
||||
ret = RtcHostReadTime(host, &time);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: host is NULL!", __func__);
|
||||
HDF_LOGE("%s: host read time fail!", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ static int32_t RtcServiceIoWriteTime(struct RtcHost *host, struct HdfSBuf *data)
|
||||
|
||||
ret = RtcHostWriteTime(host, time);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: write time fail!", __func__);
|
||||
HDF_LOGE("%s: host write time fail!", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ static int32_t RtcServiceIoReadAlarm(struct RtcHost *host, struct HdfSBuf *data,
|
||||
struct RtcTime time;
|
||||
|
||||
if (!HdfSbufReadUint32(data, &alarmIndex)) {
|
||||
HDF_LOGE("%s: read rtc alarmIndex fail!", __func__);
|
||||
HDF_LOGE("%s: read alarmIndex fail!", __func__);
|
||||
return HDF_ERR_IO;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ static int32_t RtcServiceIoWriteAlarm(struct RtcHost *host, struct HdfSBuf *data
|
||||
struct RtcTime *time = NULL;
|
||||
|
||||
if (!HdfSbufReadUint32(data, &alarmIndex)) {
|
||||
HDF_LOGE("%s: read rtc alarmIndex fail!", __func__);
|
||||
HDF_LOGE("%s: read alarmIndex fail!", __func__);
|
||||
return HDF_ERR_IO;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ static int32_t RtcServiceIoWriteAlarm(struct RtcHost *host, struct HdfSBuf *data
|
||||
|
||||
ret = RtcHostWriteAlarm(host, (enum RtcAlarmIndex)alarmIndex, time);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: write alarm fail!", __func__);
|
||||
HDF_LOGE("%s: host write alarm fail!", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -118,18 +118,18 @@ static int32_t RtcServiceIoInterruptEnable(struct RtcHost *host, struct HdfSBuf
|
||||
uint8_t enable = 0;
|
||||
|
||||
if (!HdfSbufReadUint32(data, &alarmIndex)) {
|
||||
HDF_LOGE("%s: read rtc alarmIndex fail!", __func__);
|
||||
HDF_LOGE("%s: read alarmIndex fail!", __func__);
|
||||
return HDF_ERR_IO;
|
||||
}
|
||||
|
||||
if (!HdfSbufReadUint8(data, &enable)) {
|
||||
HDF_LOGE("%s: read rtc enable fail!", __func__);
|
||||
HDF_LOGE("%s: read enable fail!", __func__);
|
||||
return HDF_ERR_IO;
|
||||
}
|
||||
|
||||
ret = RtcHostAlarmInterruptEnable(host, (enum RtcAlarmIndex)alarmIndex, enable);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: host is NULL!", __func__);
|
||||
HDF_LOGE("%s: host alarm interrupt enable fail! ret :%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -139,16 +139,16 @@ static int32_t RtcServiceIoInterruptEnable(struct RtcHost *host, struct HdfSBuf
|
||||
static int32_t RtcServiceIoGetFreq(struct RtcHost *host, struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
uint32_t freq;
|
||||
uint32_t freq = 0;
|
||||
|
||||
ret = RtcHostGetFreq(host, &freq);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: get freq failde! ret :%d", __func__, ret);
|
||||
HDF_LOGE("%s: host get freq fail! ret :%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!HdfSbufWriteUint32(reply, freq)) {
|
||||
HDF_LOGE("%s: write rtc freq fail!", __func__);
|
||||
HDF_LOGE("%s: write freq fail!", __func__);
|
||||
return HDF_ERR_IO;
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ static int32_t RtcServiceIoSetFreq(struct RtcHost *host, struct HdfSBuf *data)
|
||||
|
||||
ret = RtcHostSetFreq(host, freq);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: set freq fail! ret :%d", __func__, ret);
|
||||
HDF_LOGE("%s: host set freq fail! ret :%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ static int32_t RtcServiceIoReset(struct RtcHost *host)
|
||||
|
||||
ret = RtcHostReset(host);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: host reset fail!", __func__);
|
||||
HDF_LOGE("%s: host reset fail! ret :%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ static int32_t RtcServiceIoReset(struct RtcHost *host)
|
||||
static int32_t RtcServiceIoReadReg(struct RtcHost *host, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
int32_t ret;
|
||||
uint8_t usrDefIndex;
|
||||
uint8_t usrDefIndex = 0;
|
||||
uint8_t value = 0;
|
||||
|
||||
if (!HdfSbufReadUint8(data, &usrDefIndex)) {
|
||||
@@ -200,11 +200,11 @@ static int32_t RtcServiceIoReadReg(struct RtcHost *host, struct HdfSBuf *data, s
|
||||
|
||||
ret = RtcHostReadReg(host, usrDefIndex, &value);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: read reg fail! ret :%d", __func__, ret);
|
||||
HDF_LOGE("%s: host read reg fail! ret :%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!HdfSbufWriteUint8(data, value)) {
|
||||
if (!HdfSbufWriteUint8(reply, value)) {
|
||||
HDF_LOGE("%s: write value fail!", __func__);
|
||||
return HDF_ERR_IO;
|
||||
}
|
||||
@@ -215,8 +215,8 @@ static int32_t RtcServiceIoReadReg(struct RtcHost *host, struct HdfSBuf *data, s
|
||||
static int32_t RtcServiceIoWriteReg(struct RtcHost *host, struct HdfSBuf *data)
|
||||
{
|
||||
int32_t ret;
|
||||
uint8_t usrDefIndex;
|
||||
uint8_t value;
|
||||
uint8_t usrDefIndex = 0;
|
||||
uint8_t value = 0;
|
||||
|
||||
if (!HdfSbufReadUint8(data, &usrDefIndex)) {
|
||||
HDF_LOGE("%s: read usrDefIndex fail!", __func__);
|
||||
@@ -224,13 +224,13 @@ static int32_t RtcServiceIoWriteReg(struct RtcHost *host, struct HdfSBuf *data)
|
||||
}
|
||||
|
||||
if (!HdfSbufReadUint8(data, &value)) {
|
||||
HDF_LOGE("%s: read usrDefIndex fail!", __func__);
|
||||
HDF_LOGE("%s: read value fail!", __func__);
|
||||
return HDF_ERR_IO;
|
||||
}
|
||||
|
||||
ret = RtcHostWriteReg(host, usrDefIndex, value);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: write reg fail! ret :%d", __func__, ret);
|
||||
HDF_LOGE("%s: host write reg fail! ret :%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,3 +172,14 @@ HWTEST_F(HdfLiteUartTest, UartReliabilityTest001, TestSize.Level1)
|
||||
EXPECT_EQ(0, UartTestExecute(UART_TEST_CMD_RELIABILITY));
|
||||
printf("%s: exit!\n", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UartIfPerformanceTest001
|
||||
* @tc.desc: uart user if performance test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(HdfLiteUartTest, UartIfPerformanceTest001, TestSize.Level1)
|
||||
{
|
||||
EXPECT_EQ(0, UartTestExecute(UART_TEST_CMD_PERFORMANCE));
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ static int32_t RtcTestGetConfig(struct RtcTestConfig *config)
|
||||
return HDF_ERR_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
reply = HdfSbufObtain(sizeof(*config) + sizeof(uint64_t));
|
||||
reply = HdfSbufObtainDefaultSize();
|
||||
if (reply == NULL) {
|
||||
HDF_LOGE("%s: Failed to obtain reply", __func__);
|
||||
HdfIoServiceRecycle(service);
|
||||
@@ -96,7 +96,7 @@ struct RtcTester *RtcTesterGet(void)
|
||||
static void RtcTesterPut(struct RtcTester *tester)
|
||||
{
|
||||
if (tester == NULL || tester->handle == NULL) {
|
||||
HDF_LOGE("%s: rtc handle is null", __func__);
|
||||
HDF_LOGE("%s: tester or handle is null", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ static int8_t g_rtcIrqCallback = HDF_FAILURE;
|
||||
int32_t RtcAlarmACallback(enum RtcAlarmIndex alarmIndex)
|
||||
{
|
||||
if (alarmIndex == RTC_ALARM_INDEX_A) {
|
||||
HDF_LOGE("RtcAlarmACallback: alarm a callback success");
|
||||
HDF_LOGI("%s: alarm a callback success", __func__);
|
||||
g_rtcIrqCallback = HDF_SUCCESS;
|
||||
} else {
|
||||
g_rtcIrqCallback = HDF_FAILURE;
|
||||
@@ -170,7 +170,7 @@ static int32_t RtcReadWriteTimeTest(struct RtcTester *tester)
|
||||
|
||||
ret = TestReadWriteTime(tester);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: test fail", __func__);
|
||||
HDF_LOGE("%s: test ReadWriteTime fail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ static int32_t TestReadWriteAlarm(struct RtcTester *tester) {
|
||||
|
||||
ret = RtcWriteAlarm(tester->handle, RTC_ALARM_INDEX_A, &tester->time);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: write alarm fail,ret:%d", __func__, ret);
|
||||
HDF_LOGE("%s: write alarm fail, ret :%d", __func__, ret);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ static int32_t TestReadWriteAlarm(struct RtcTester *tester) {
|
||||
|
||||
ret = RtcReadAlarm(tester->handle, RTC_ALARM_INDEX_A, &readTime);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: read alarm fail,ret:%d",__func__, ret);
|
||||
HDF_LOGE("%s: read alarm fail, ret :%d",__func__, ret);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
@@ -329,13 +329,13 @@ static int32_t RtcAlarmEnableTest(struct RtcTester *tester)
|
||||
|
||||
ret = TestReadWriteAlarm(tester);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s:read write alarm time fail.", __func__);
|
||||
HDF_LOGE("%s:read write alarm fail.", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
ret = RtcAlarmInterruptEnable(tester->handle, RTC_ALARM_INDEX_A, 1);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: alarm enable fail.", __func__);
|
||||
HDF_LOGE("%s: alarm interrupt enable fail.", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -356,13 +356,13 @@ static int32_t RtcAlarmIrqAttachConfig(struct RtcTester *tester)
|
||||
freq = tester->config.frequence;
|
||||
ret = RtcSetFreq(tester->handle, freq);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: rtc set freq fail, ret:%d", __func__, ret);
|
||||
HDF_LOGE("%s: set freq fail, ret :%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = RtcAlarmInterruptEnable(tester->handle, RTC_ALARM_INDEX_A, 1);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: alarm interrupt enable fail", __func__);
|
||||
HDF_LOGE("%s: alarm interrupt enable fail, ret :%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -387,13 +387,13 @@ static int32_t RtcAlarmIrqTest(struct RtcTester *tester)
|
||||
|
||||
ret = RtcAlarmIrqAttachConfig(tester);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: alarm irq attach config fail, ret:%d", __func__, ret);
|
||||
HDF_LOGE("%s: alarm irq attach config fail, ret :%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = RtcWriteTime(tester->handle, &tester->time);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: write time fail", __func__);
|
||||
HDF_LOGE("%s: write time fail, ret :%d", __func__, ret);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ static int32_t RtcAlarmIrqTest(struct RtcTester *tester)
|
||||
tester->time.second = tester->config.second + 1;
|
||||
ret = RtcWriteAlarm(tester->handle, RTC_ALARM_INDEX_A, &tester->time);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: write alarm fail, ret:%d", __func__, ret);
|
||||
HDF_LOGE("%s: write alarm fail, ret :%d", __func__, ret);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
@@ -423,7 +423,7 @@ static int32_t RtcRegisterCallbackTest(struct RtcTester *tester)
|
||||
|
||||
ret = RtcRegisterAlarmCallback(tester->handle, RTC_ALARM_INDEX_A, RtcAlarmACallback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: register alarm callback fail, ret:%d", __func__, ret);
|
||||
HDF_LOGE("%s: register alarm callback fail, ret :%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -449,7 +449,7 @@ static int32_t RtcSetNormalFreqTest(struct RtcTester *tester)
|
||||
|
||||
ret = RtcSetFreq(tester->handle, tester->config.frequence);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: set normal frequence fail,ret:%d", __func__, ret);
|
||||
HDF_LOGE("%s: set normal frequence fail, ret :%d", __func__, ret);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
@@ -498,12 +498,12 @@ static int32_t RtcReadWriteUserRegTest(struct RtcTester *tester)
|
||||
|
||||
ret = RtcReadReg(tester->handle, 0, &value);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: read min frequence fail, ret:%d", __func__, ret);
|
||||
HDF_LOGE("%s: read reg fail, ret :%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (value != tester->config.userValue) {
|
||||
HDF_LOGE("%s: value is not same.", __func__);
|
||||
HDF_LOGE("%s: value is not same. value :%u, userValue :%u", __func__, value, tester->config.userValue);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
@@ -518,16 +518,17 @@ static int32_t RtcReadWriteMaxUserIndexTest(struct RtcTester *tester)
|
||||
value = tester->config.userValue;
|
||||
ret = RtcWriteReg(tester->handle, tester->config.userMaxIndex, value);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: write reg max index test success", __func__);
|
||||
HDF_LOGI("%s: write reg max index test success", __func__);
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
ret = RtcReadReg(tester->handle, tester->config.userMaxIndex, &value);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: read reg max index test success", __func__);
|
||||
HDF_LOGI("%s: read reg max index test success", __func__);
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
HDF_LOGE("%s: read write reg max index test fail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
@@ -539,20 +540,20 @@ static int32_t RtcTestSample(struct RtcTester *tester)
|
||||
|
||||
ret = RtcRegisterAlarmCallback(tester->handle, RTC_ALARM_INDEX_A, RtcAlarmACallback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: register alarm callback fail, ret:%d", __func__, ret);
|
||||
HDF_LOGE("%s: register alarm callback fail, ret :%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
freq = tester->config.frequence;
|
||||
ret = RtcSetFreq(tester->handle, freq);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: set frequence fail, ret:%d", __func__, ret);
|
||||
HDF_LOGE("%s: set frequence fail, ret :%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = RtcAlarmInterruptEnable(tester->handle, RTC_ALARM_INDEX_A, 1);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: alarm interrupt enable fail, ret:%d", __func__, ret);
|
||||
HDF_LOGE("%s: alarm interrupt enable fail, ret :%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -566,14 +567,14 @@ static int32_t RtcTestSample(struct RtcTester *tester)
|
||||
|
||||
ret = RtcWriteTime(tester->handle, &tester->time);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: write time fail, ret:%d", __func__, ret);
|
||||
HDF_LOGE("%s: write time fail, ret :%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
tester->time.second = tester->config.second;
|
||||
ret = RtcWriteAlarm(tester->handle, RTC_ALARM_INDEX_A, &tester->time);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: write alarm fail, ret:%d", __func__, ret);
|
||||
HDF_LOGE("%s: write alarm fail, ret :%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -581,13 +582,13 @@ static int32_t RtcTestSample(struct RtcTester *tester)
|
||||
|
||||
ret = RtcReadAlarm(tester->handle, RTC_ALARM_INDEX_A, &readTime);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: read alarm fail, ret:%d", __func__, ret);
|
||||
HDF_LOGE("%s: read alarm fail, ret :%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = RtcReadTime(tester->handle, &tester->time);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: read time fail, ret:%d", __func__, ret);
|
||||
HDF_LOGE("%s: read time fail, ret :%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -601,7 +602,9 @@ static int32_t RtcReadWriteReliability(struct RtcTester *tester)
|
||||
for (i = 0; i < tester->config.time; i++) {
|
||||
(void)RtcReadWriteTimeTest(tester);
|
||||
(void)RtcReadWriteAlarmTimeTest(tester);
|
||||
#ifdef __LITEOS__
|
||||
(void)RtcSetNormalFreqTest(tester);
|
||||
#endif
|
||||
}
|
||||
|
||||
return HDF_SUCCESS;
|
||||
@@ -647,7 +650,7 @@ int32_t RtcTestExecute(int cmd)
|
||||
}
|
||||
|
||||
if (cmd > RTC_TEST_CMD_MAX) {
|
||||
HDF_LOGE("%s: invalid cmd:%d", __func__, cmd);
|
||||
HDF_LOGE("%s: invalid cmd :%d", __func__, cmd);
|
||||
ret = HDF_ERR_NOT_SUPPORT;
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
@@ -258,6 +258,29 @@ static int32_t UartReliabilityTest(struct UartTester *tester)
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t UartIfPerformanceTest(struct UartTester *tester)
|
||||
{
|
||||
#ifdef __LITEOS__
|
||||
if (tester == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
return HDF_SUCCESS;
|
||||
#endif
|
||||
uint32_t baudRate;
|
||||
uint64_t startMs;
|
||||
uint64_t endMs;
|
||||
uint64_t useTime; /*ms*/
|
||||
|
||||
startMs = OsalGetSysTimeMs();
|
||||
UartGetBaud(tester->handle, &baudRate);
|
||||
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 UartTestEntry {
|
||||
int cmd;
|
||||
int32_t (*func)(struct UartTester *tester);
|
||||
@@ -273,7 +296,7 @@ static struct UartTestEntry g_entry[] = {
|
||||
{ UART_TEST_CMD_GET_ATTRIBUTE, UartGetAttributeTest, "UartGetAttributeTest" },
|
||||
{ UART_TEST_CMD_SET_TRANSMODE, UartSetTransModeTest, "UartSetTransModeTest" },
|
||||
{ UART_TEST_CMD_RELIABILITY, UartReliabilityTest, "UartReliabilityTest" },
|
||||
{ UART_TEST_CMD_PERFORMANCE, NULL, "NULL" },
|
||||
{ UART_TEST_CMD_PERFORMANCE, UartIfPerformanceTest, "UartIfPerformanceTest" },
|
||||
};
|
||||
|
||||
int32_t UartTestExecute(int cmd)
|
||||
|
||||
Reference in New Issue
Block a user