• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "It_los_queue.h"
17 
18 
19 static CHAR g_buff[QUEUE_BASE_MSGSIZE] = "UniDSP";
20 
HwiF01(VOID)21 static VOID HwiF01(VOID)
22 {
23     UINT32 ret;
24     CHAR *buff2 = NULL;
25 
26     ret = LOS_QueueReadIsr(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE);
27     ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
28     for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
29         ICUNIT_ASSERT_EQUAL_VOID(*((CHAR *)(intptr_t)buff2 + index), g_buff[index],
30             *((CHAR *)(intptr_t)buff2 + index));
31     }
32 }
33 
Testcase(VOID)34 static UINT32 Testcase(VOID)
35 {
36     UINT32 ret;
37     HWI_PRIOR_T hwiPrio = 3;
38     HWI_MODE_T mode = 0;
39     HwiIrqParam irqParam;
40 
41     ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
42     ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
43 
44     (VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
45     irqParam.pDevId = 0;
46     ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
47     ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
48 
49     ret = LOS_QueueWrite(g_testQueueID01, &g_buff, QUEUE_BASE_MSGSIZE, 0);
50     ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
51 
52     TestHwiTrigger(HWI_NUM_TEST);
53 
54 EXIT:
55     TestHwiDelete(HWI_NUM_TEST);
56     ret = LOS_QueueDelete(g_testQueueID01);
57     ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
58     return LOS_OK;
59 }
60 
ItLosQueueIsr011(VOID)61 VOID ItLosQueueIsr011(VOID)
62 {
63     TEST_ADD_CASE("ItLosQueueIsr011", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
64 }
65 
66