• 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 
HwiF01(VOID)19 static VOID HwiF01(VOID)
20 {
21     UINT32 ret;
22     CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
23 
24     ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE);
25     ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
26 }
27 
TaskF01(VOID)28 static VOID TaskF01(VOID)
29 {
30     UINT32 ret;
31     CHAR *buff2 = NULL;
32 
33     g_testCount++;
34     ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE,LOS_WAIT_FOREVER);
35     ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
36     g_testCount++;
37     return;
38 }
39 
Testcase(VOID)40 static UINT32 Testcase(VOID)
41 {
42     UINT32 ret;
43     HWI_PRIOR_T hwiPrio = 3;
44     HWI_MODE_T mode = 0;
45     HwiIrqParam irqParam;
46 
47     ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
48     ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
49 
50     (VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
51     irqParam.pDevId = 0;
52     ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
53     ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
54 
55     TSK_INIT_PARAM_S task1 = { 0 };
56     task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
57     task1.uwStackSize = TASK_STACK_SIZE_TEST;
58     task1.pcName = "Tsk001A";
59     task1.usTaskPrio = TASK_PRIO_TEST + 1;
60     task1.uwResved = LOS_TASK_STATUS_DETACHED;
61     g_testCount = 0;
62     ret = LOS_TaskCreate(&g_testTaskID01, &task1);
63     ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
64 
65     LOS_TaskDelay(1);
66 
67     ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
68 
69     TestHwiTrigger(HWI_NUM_TEST);
70 
71     ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
72 
73     LOS_TaskDelay(1);
74 
75     ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount);
76 EXIT:
77     TestHwiDelete(HWI_NUM_TEST);
78     ret = LOS_QueueDelete(g_testQueueID01);
79     ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
80     return LOS_OK;
81 }
82 
ItLosQueueIsr013(VOID)83 VOID ItLosQueueIsr013(VOID)
84 {
85     TEST_ADD_CASE("ItLosQueueIsr013", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
86 }
87 
88