feat: 增加内核queue在中断中进行读写操作的接口

方案描述:
1,基于 OsQueueOperate增加支持queue在中断中进行读写操作的接口。
BREAKING CHANGE:
增加支持queue在中断中进行读写操作的接口,需要适配接口描述:
适配API:

新增API:
UINT32 LOS_QueueReadCopyIsr(UINT32 queueID,   VOID *bufferAddr, UINT32 *bufferSize);
UINT32 LOS_QueueWriteCopyIsr(UINT32 queueID, VOID *bufferAddr, UINT32 bufferSize);
UINT32 LOS_QueueReadIsr(UINT32 queueID,VOID *bufferAddr,  UINT32 bufferSize);
UINT32 LOS_QueueWriteIsr(UINT32 queueID, VOID *bufferAddr,  UINT32 bufferSize);
UINT32 LOS_QueueWriteHeadIsr(UINT32 queueID, VOID *bufferAddr,UINT32 bufferSize);
UINT32 LOS_QueueWriteHeadCopyIsr(UINT32 queueID,  VOID *bufferAddr,UINT32 bufferSize);

Signed-off-by: zengwenlong <zengwenlong@openvalley.net>
This commit is contained in:
zengwenlong
2023-09-11 20:47:44 -07:00
parent d2bf535696
commit 1b778c4267
22 changed files with 1469 additions and 3 deletions
+16
View File
@@ -164,6 +164,22 @@ static_library("test_queue") {
"It_los_queue_head_040.c",
"It_los_queue_head_041.c",
"It_los_queue_head_042.c",
"It_los_queue_isr_001.c",
"It_los_queue_isr_002.c",
"It_los_queue_isr_003.c",
"It_los_queue_isr_004.c",
"It_los_queue_isr_005.c",
"It_los_queue_isr_006.c",
"It_los_queue_isr_007.c",
"It_los_queue_isr_008.c",
"It_los_queue_isr_009.c",
"It_los_queue_isr_010.c",
"It_los_queue_isr_011.c",
"It_los_queue_isr_012.c",
"It_los_queue_isr_013.c",
"It_los_queue_isr_014.c",
"It_los_queue_isr_015.c",
"It_los_queue_isr_016.c",
"It_los_queue_static_001.c",
"It_los_queue_static_002.c",
"It_los_queue_static_003.c",
+16 -1
View File
@@ -151,7 +151,22 @@ VOID ItSuiteLosQueue(VOID)
ItLosQueueHead040();
ItLosQueueHead041();
ItLosQueueHead042();
ItLosQueueIsr001();
ItLosQueueIsr002();
ItLosQueueIsr003();
ItLosQueueIsr004();
ItLosQueueIsr005();
ItLosQueueIsr006();
ItLosQueueIsr007();
ItLosQueueIsr008();
ItLosQueueIsr009();
ItLosQueueIsr010();
ItLosQueueIsr011();
ItLosQueueIsr012();
ItLosQueueIsr013();
ItLosQueueIsr014();
ItLosQueueIsr015();
ItLosQueueIsr016();
#if (LOS_KERNEL_TEST_FULL == 1)
#if (LOS_KERNEL_HWI_TEST == 1)
ItLosQueue044();
+16 -1
View File
@@ -183,7 +183,22 @@ extern VOID ItLosQueueHead039(VOID);
extern VOID ItLosQueueHead040(VOID);
extern VOID ItLosQueueHead041(VOID);
extern VOID ItLosQueueHead042(VOID);
extern VOID ItLosQueueIsr001(VOID);
extern VOID ItLosQueueIsr002(VOID);
extern VOID ItLosQueueIsr003(VOID);
extern VOID ItLosQueueIsr004(VOID);
extern VOID ItLosQueueIsr005(VOID);
extern VOID ItLosQueueIsr006(VOID);
extern VOID ItLosQueueIsr007(VOID);
extern VOID ItLosQueueIsr008(VOID);
extern VOID ItLosQueueIsr009(VOID);
extern VOID ItLosQueueIsr010(VOID);
extern VOID ItLosQueueIsr011(VOID);
extern VOID ItLosQueueIsr012(VOID);
extern VOID ItLosQueueIsr013(VOID);
extern VOID ItLosQueueIsr014(VOID);
extern VOID ItLosQueueIsr015(VOID);
extern VOID ItLosQueueIsr016(VOID);
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
extern VOID ItLosQueueStatic001(VOID);
extern VOID ItLosQueueStatic002(VOID);
+60
View File
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR *buff2 = NULL;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr001(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr001", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}
+59
View File
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR *buff2 = NULL;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_PARA_ISZERO, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret);
return LOS_OK;
}
VOID ItLosQueueIsr002(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr002", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}
+60
View File
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, 0);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR *buff2 = NULL;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, 1);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
ret = LOS_QueueRead(g_testQueueID01, &buff2, 1, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr003(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr003", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}
+59
View File
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, 0);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR *buff2 = NULL;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, 4);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
ret = LOS_QueueRead(g_testQueueID01, &buff2, 1, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr004(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr004", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}
+63
View File
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR *buff2 = NULL;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
TestHwiTrigger(HWI_NUM_TEST);
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr005(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr005", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}
+66
View File
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 "It_los_queue.h"
CHAR buff1[QUEUE_BASE_MSGSIZE] = "UniDSP";
static VOID HwiF01(VOID)
{
UINT32 ret;
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR *buff2 = NULL;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
ICUNIT_GOTO_EQUAL(*((CHAR *)(intptr_t)buff2 + index), buff1[index],
*((CHAR *)(intptr_t)buff2 + index), EXIT);
}
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr006(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr006", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}
+63
View File
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
ret = LOS_QueueWriteIsr((UINT32)-1, &buff1, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_INVALID, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR *buff2 = NULL;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr007(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr007", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}
+62
View File
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
ret = LOS_QueueWriteIsr(OS_ALL_IPC_QUEUE_LIMIT + 1, &buff1, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_INVALID, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR *buff2 = NULL;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr008(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr008", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}
+60
View File
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR *buff2 = NULL;
ret = LOS_QueueReadIsr(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
ret = LOS_QueueWrite(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
TestHwiTrigger(HWI_NUM_TEST);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr009(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr009", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}
+77
View File
@@ -0,0 +1,77 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR *buff2 = NULL;
ret = LOS_QueueReadIsr(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret);
}
static VOID HwiF02(VOID)
{
UINT32 ret;
CHAR *buff2 = NULL;
ret = LOS_QueueReadIsr(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST0, hwiPrio, mode, (HWI_PROC_FUNC)HwiF02, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
ret = LOS_QueueWrite(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
TestHwiTrigger(HWI_NUM_TEST0);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
TestHwiDelete(HWI_NUM_TEST0);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr010(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr010", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}
+65
View File
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 "It_los_queue.h"
static CHAR g_buff[QUEUE_BASE_MSGSIZE] = "UniDSP";
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR *buff2 = NULL;
ret = LOS_QueueReadIsr(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
ICUNIT_ASSERT_EQUAL_VOID(*((CHAR *)(intptr_t)buff2 + index), g_buff[index],
*((CHAR *)(intptr_t)buff2 + index));
}
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
ret = LOS_QueueWrite(g_testQueueID01, &g_buff, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
TestHwiTrigger(HWI_NUM_TEST);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr011(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr011", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}
+81
View File
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
}
static VOID TaskF01(VOID)
{
UINT32 ret;
CHAR *buff2 = NULL;
g_testCount++;
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE,LOS_WAIT_FOREVER);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
g_testCount++;
return;
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TSK_INIT_PARAM_S task1 = { 0 };
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
task1.uwStackSize = TASK_STACK_SIZE_TEST;
task1.pcName = "Tsk001A";
task1.usTaskPrio = TASK_PRIO_TEST - 1;
task1.uwResved = LOS_TASK_STATUS_DETACHED;
g_testCount = 0;
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr012(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr012", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}
+87
View File
@@ -0,0 +1,87 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
}
static VOID TaskF01(VOID)
{
UINT32 ret;
CHAR *buff2 = NULL;
g_testCount++;
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE,LOS_WAIT_FOREVER);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
g_testCount++;
return;
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TSK_INIT_PARAM_S task1 = { 0 };
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
task1.uwStackSize = TASK_STACK_SIZE_TEST;
task1.pcName = "Tsk001A";
task1.usTaskPrio = TASK_PRIO_TEST + 1;
task1.uwResved = LOS_TASK_STATUS_DETACHED;
g_testCount = 0;
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
LOS_TaskDelay(1);
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
TestHwiTrigger(HWI_NUM_TEST);
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
LOS_TaskDelay(1);
ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr013(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr013", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}
+84
View File
@@ -0,0 +1,84 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
ret = LOS_QueueWriteCopyIsr(g_testQueueID01, buff1, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
}
static VOID TaskF01(VOID)
{
UINT32 ret;
UINT32 msgSize = (UINT32)QUEUE_BASE_MSGSIZE;
CHAR buff[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
CHAR buff2[QUEUE_SHORT_BUFFER_LENGTH] = " ";
ret = LOS_QueueReadCopy(g_testQueueID01, buff2, &msgSize, LOS_WAIT_FOREVER);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
ICUNIT_GOTO_EQUAL(*((CHAR *)(intptr_t)buff2 + index), buff[index],
*((CHAR *)(intptr_t)buff2 + index), EXIT);
}
EXIT:
return;
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TSK_INIT_PARAM_S task1 = { 0 };
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
task1.uwStackSize = TASK_STACK_SIZE_TEST;
task1.pcName = "Tsk001A";
task1.usTaskPrio = TASK_PRIO_TEST - 1;
task1.uwResved = LOS_TASK_STATUS_DETACHED;
g_testCount = 0;
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr014(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr014", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}
+109
View File
@@ -0,0 +1,109 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 "It_los_queue.h"
static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = "DOPRA";
static CHAR g_buff3[QUEUE_SHORT_BUFFER_LENGTH] = "TEST";
static VOID HwiF01(VOID)
{
UINT32 ret;
ret = LOS_QueueWriteHeadIsr(g_testQueueID01, &g_buff1, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
ret = LOS_QueueWriteHeadIsr(g_testQueueID01, &g_buff2, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
ret = LOS_QueueWriteHeadIsr(g_testQueueID01, &g_buff3, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
}
static VOID TaskF01(VOID)
{
UINT32 ret;
CHAR buffA[QUEUE_SHORT_BUFFER_LENGTH] = "TEST";
CHAR buffB[QUEUE_SHORT_BUFFER_LENGTH] = "DOPRA";
CHAR buffC[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
CHAR *buff = NULL;
ret = LOS_QueueRead(g_testQueueID01, &buff, QUEUE_BASE_MSGSIZE, LOS_WAIT_FOREVER);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
ICUNIT_GOTO_EQUAL(*((CHAR *)(intptr_t)buff + index), buffA[index],
*((CHAR *)(intptr_t)buff + index), EXIT);
}
ret = LOS_QueueRead(g_testQueueID01, &buff, QUEUE_BASE_MSGSIZE, LOS_WAIT_FOREVER);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
ICUNIT_GOTO_EQUAL(*((CHAR *)(intptr_t)buff + index), buffB[index],
*((CHAR *)(intptr_t)buff + index), EXIT);
}
ret = LOS_QueueRead(g_testQueueID01, &buff, QUEUE_BASE_MSGSIZE, LOS_WAIT_FOREVER);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
ICUNIT_GOTO_EQUAL(*((CHAR *)(intptr_t)buff + index), buffC[index],
*((CHAR *)(intptr_t)buff + index), EXIT);
}
EXIT:
return;
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TSK_INIT_PARAM_S task1 = { 0 };
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
task1.uwStackSize = TASK_STACK_SIZE_TEST;
task1.pcName = "Tsk001A";
task1.usTaskPrio = TASK_PRIO_TEST - 1;
task1.uwResved = LOS_TASK_STATUS_DETACHED;
g_testCount = 0;
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr015(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr015", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}
+108
View File
@@ -0,0 +1,108 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
CHAR buff2[QUEUE_SHORT_BUFFER_LENGTH] = "DOPRA";
CHAR buff3[QUEUE_SHORT_BUFFER_LENGTH] = "TEST";
ret = LOS_QueueWriteHeadCopyIsr(g_testQueueID01, buff1, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
ret = LOS_QueueWriteHeadCopyIsr(g_testQueueID01, buff2, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
ret = LOS_QueueWriteHeadCopyIsr(g_testQueueID01, buff3, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
}
static VOID TaskF01(VOID)
{
UINT32 ret;
UINT32 msgSize = (UINT32)QUEUE_BASE_MSGSIZE;
CHAR buffA[QUEUE_SHORT_BUFFER_LENGTH] = "TEST";
CHAR buffB[QUEUE_SHORT_BUFFER_LENGTH] = "DOPRA";
CHAR buffC[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
CHAR buff[QUEUE_SHORT_BUFFER_LENGTH] = " ";
ret = LOS_QueueReadCopy(g_testQueueID01, buff, &msgSize, LOS_WAIT_FOREVER);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
ICUNIT_GOTO_EQUAL(*((CHAR *)(intptr_t)buff + index), buffA[index],
*((CHAR *)(intptr_t)buff + index), EXIT);
}
ret = LOS_QueueReadCopy(g_testQueueID01, buff, &msgSize, LOS_WAIT_FOREVER);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
ICUNIT_GOTO_EQUAL(*((CHAR *)(intptr_t)buff + index), buffB[index],
*((CHAR *)(intptr_t)buff + index), EXIT);
}
ret = LOS_QueueReadCopy(g_testQueueID01, buff, &msgSize, LOS_WAIT_FOREVER);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
ICUNIT_GOTO_EQUAL(*((CHAR *)(intptr_t)buff + index), buffC[index],
*((CHAR *)(intptr_t)buff + index), EXIT);
}
EXIT:
return;
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TSK_INIT_PARAM_S task1 = { 0 };
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
task1.uwStackSize = TASK_STACK_SIZE_TEST;
task1.pcName = "Tsk001A";
task1.usTaskPrio = TASK_PRIO_TEST - 1;
task1.uwResved = LOS_TASK_STATUS_DETACHED;
g_testCount = 0;
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr016(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr016", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}