• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3  * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this list of
9  * conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12  * of conditions and the following disclaimer in the documentation and/or other materials
13  * provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16  * to endorse or promote products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 #ifndef IT_POSIX_QUEUE_H
32 #define IT_POSIX_QUEUE_H
33 
34 #include <stdlib.h>
35 #include <mqueue.h>
36 #include <los_typedef.h>
37 #include <fcntl.h>
38 #include <errno.h>
39 #include <limits.h>
40 #include <sched.h>
41 #include <signal.h>
42 #include <osTest.h>
43 #include <sys/utsname.h>
44 
45 #define MAXMSG5 5
46 #define MSGLEN 10
47 #define MAXMSG 10
48 
49 const int MQUEUE_SHORT_ARRAY_LENGTH  = 10; // = strlen(MQUEUE_SEND_STRING_TEST)
50 const int MQUEUE_STANDARD_NAME_LENGTH  = 50;
51 
52 #define MQUEUE_NO_ERROR 0
53 #define MQUEUE_IS_ERROR (-1)
54 #define MQUEUE_PTHREAD_PRIORITY_TEST1 3
55 #define MQUEUE_PTHREAD_PRIORITY_TEST2 4
56 #define MQUEUE_PATH_MAX_TEST PATH_MAX
57 #define MQUEUE_NAME_MAX_TEST NAME_MAX
58 #define MQUEUE_SEND_STRING_TEST "0123456789"
59 #define MQUEUE_PTHREAD_NUM_TEST 5
60 #define MQUEUE_PRIORITY_TEST 0
61 #define MQUEUE_TIMEOUT_TEST 7
62 #define MQUEUE_PRIORITY_NUM_TEST 3
63 #define MQUEUE_MAX_NUM_TEST (LOSCFG_BASE_IPC_QUEUE_CONFIG - QUEUE_EXISTED_NUM)
64 #define MQ_MAX_MSG_NUM 16
65 #define MQ_MAX_MSG_LEN 64
66 #define HWI_NUM_TEST 1
67 #define HWI_NUM_TEST1 2
68 #define LOS_WAIT_FOREVER 0XFFFFFFFF
69 
70 typedef VOID (*HWI_PROC_FUNC)(VOID *pParm);
71 
72 #define MQ_VALID_MAGIC 0x6db256c1
73 const int  LOSCFG_BASE_IPC_QUEUE_CONFIG = 1024;
74 
75 #ifdef __LP64__
76 #define PER_ADDED_VALUE 8
77 #else
78 #define PER_ADDED_VALUE 4
79 #endif
80 
81 typedef UINT32 TSK_HANDLE_T;
82 using SEM_HANDLE_T = UINT32;
83 extern SEM_HANDLE_T g_mqueueSem;
84 
85 static TSK_HANDLE_T g_mqueueTaskPID;
86 extern CHAR g_gqname[MQUEUE_STANDARD_NAME_LENGTH];
87 extern CHAR g_mqueueName[LOSCFG_BASE_IPC_QUEUE_CONFIG + 1][MQUEUE_STANDARD_NAME_LENGTH];
88 extern mqd_t g_mqueueId[LOSCFG_BASE_IPC_QUEUE_CONFIG + 1];
89 
90 extern CHAR *g_mqueueMsessage[MQUEUE_SHORT_ARRAY_LENGTH];
91 extern mqd_t g_messageQId;
92 extern mqd_t g_gqueue;
93 
94 extern unsigned long MsecsToJiffies(const unsigned int m);
95 
96 extern VOID ItSuite_Posix_Mqueue(VOID);
97 extern UINT32 LosCurTaskIDGet();
98 extern int LOS_AtomicInc(const volatile unsigned int *num);
99 extern int LosSemDelete(SEM_HANDLE_T num);
100 extern int LosSemCreate(int num, const SEM_HANDLE_T *hdl);
101 extern UINT32 PosixPthreadInit(pthread_attr_t *attr, int pri);
102 extern void LOS_TaskUnlock();
103 extern void LOS_TaskLock();
104 extern int LosSemPost(SEM_HANDLE_T);
105 extern int LosSemPend(SEM_HANDLE_T hdl, int num);
106 extern int SemPost(SEM_HANDLE_T);
107 extern int SemPend(SEM_HANDLE_T hdl, int num);
108 extern int LOS_HwiCreate(int hwiNum, int hwiPrio, int hwiMode, HWI_PROC_FUNC hwiHandler, int *irqParam);
109 extern UINT64 JiffiesToTick(unsigned long j);
110 extern int HalIrqMask(int num);
111 extern UINT32 PosixPthreadDestroy(pthread_attr_t *attr, pthread_t thread);
112 
113 #define LOS_TaskLock()
114 #define LOS_TaskUnlock()
115 #define LOS_AtomicInc(a) (++*(a))
116 #define TEST_TEST_HwiDelete(ID, NULL)
117 
118 #if defined(LOSCFG_USER_TEST_SMOKE)
119 VOID ItPosixQueue001(VOID);
120 VOID ItPosixQueue003(VOID);
121 VOID ItPosixQueue028(VOID);
122 VOID ItPosixQueue062(VOID);
123 VOID ItPosixQueue053(VOID);
124 VOID ItPosixQueue144(VOID);
125 #endif
126 
127 #if defined(LOSCFG_USER_TEST_FULL)
128 VOID ItPosixQueue002(VOID);
129 VOID ItPosixQueue004(VOID);
130 VOID ItPosixQueue005(VOID);
131 VOID ItPosixQueue007(VOID);
132 VOID ItPosixQueue008(VOID);
133 VOID ItPosixQueue010(VOID);
134 VOID ItPosixQueue011(VOID);
135 VOID ItPosixQueue012(VOID);
136 VOID ItPosixQueue013(VOID);
137 VOID ItPosixQueue014(VOID);
138 VOID ItPosixQueue015(VOID);
139 VOID ItPosixQueue016(VOID);
140 VOID ItPosixQueue017(VOID);
141 VOID ItPosixQueue018(VOID);
142 VOID ItPosixQueue019(VOID);
143 VOID ItPosixQueue020(VOID);
144 VOID ItPosixQueue021(VOID);
145 VOID ItPosixQueue025(VOID);
146 VOID ItPosixQueue026(VOID);
147 VOID ItPosixQueue027(VOID);
148 VOID ItPosixQueue030(VOID);
149 VOID ItPosixQueue031(VOID);
150 VOID ItPosixQueue032(VOID);
151 VOID ItPosixQueue033(VOID);
152 VOID ItPosixQueue036(VOID);
153 VOID ItPosixQueue037(VOID);
154 VOID ItPosixQueue038(VOID);
155 VOID ItPosixQueue039(VOID);
156 VOID ItPosixQueue040(VOID);
157 VOID ItPosixQueue041(VOID);
158 VOID ItPosixQueue042(VOID);
159 VOID ItPosixQueue044(VOID);
160 VOID ItPosixQueue046(VOID);
161 VOID ItPosixQueue047(VOID);
162 VOID ItPosixQueue048(VOID);
163 VOID ItPosixQueue049(VOID);
164 VOID ItPosixQueue050(VOID);
165 VOID ItPosixQueue052(VOID);
166 VOID ItPosixQueue054(VOID);
167 VOID ItPosixQueue055(VOID);
168 VOID ItPosixQueue056(VOID);
169 VOID ItPosixQueue057(VOID);
170 VOID ItPosixQueue058(VOID);
171 VOID ItPosixQueue060(VOID);
172 VOID ItPosixQueue061(VOID);
173 VOID ItPosixQueue063(VOID);
174 VOID ItPosixQueue064(VOID);
175 VOID ItPosixQueue065(VOID);
176 VOID ItPosixQueue066(VOID);
177 VOID ItPosixQueue067(VOID);
178 VOID ItPosixQueue069(VOID);
179 VOID ItPosixQueue070(VOID);
180 VOID ItPosixQueue071(VOID);
181 VOID ItPosixQueue072(VOID);
182 VOID ItPosixQueue073(VOID);
183 VOID ItPosixQueue074(VOID);
184 VOID ItPosixQueue075(VOID);
185 VOID ItPosixQueue076(VOID);
186 VOID ItPosixQueue077(VOID);
187 VOID ItPosixQueue078(VOID);
188 VOID ItPosixQueue079(VOID);
189 VOID ItPosixQueue080(VOID);
190 VOID ItPosixQueue081(VOID);
191 VOID ItPosixQueue082(VOID);
192 VOID ItPosixQueue083(VOID);
193 VOID ItPosixQueue084(VOID);
194 VOID ItPosixQueue085(VOID);
195 VOID ItPosixQueue086(VOID);
196 VOID ItPosixQueue087(VOID);
197 VOID ItPosixQueue088(VOID);
198 VOID ItPosixQueue089(VOID);
199 VOID ItPosixQueue090(VOID);
200 VOID ItPosixQueue091(VOID);
201 VOID ItPosixQueue093(VOID);
202 VOID ItPosixQueue094(VOID);
203 VOID ItPosixQueue095(VOID);
204 VOID ItPosixQueue096(VOID);
205 VOID ItPosixQueue097(VOID);
206 VOID ItPosixQueue098(VOID);
207 VOID ItPosixQueue100(VOID);
208 VOID ItPosixQueue101(VOID);
209 VOID ItPosixQueue102(VOID);
210 VOID ItPosixQueue103(VOID);
211 VOID ItPosixQueue104(VOID);
212 VOID ItPosixQueue106(VOID);
213 VOID ItPosixQueue108(VOID);
214 VOID ItPosixQueue109(VOID);
215 VOID ItPosixQueue110(VOID);
216 VOID ItPosixQueue111(VOID);
217 VOID ItPosixQueue112(VOID);
218 VOID ItPosixQueue113(VOID);
219 VOID ItPosixQueue114(VOID);
220 VOID ItPosixQueue115(VOID);
221 VOID ItPosixQueue116(VOID);
222 VOID ItPosixQueue117(VOID);
223 VOID ItPosixQueue118(VOID);
224 VOID ItPosixQueue119(VOID);
225 VOID ItPosixQueue120(VOID);
226 VOID ItPosixQueue121(VOID);
227 VOID ItPosixQueue122(VOID);
228 VOID ItPosixQueue123(VOID);
229 VOID ItPosixQueue124(VOID);
230 VOID ItPosixQueue125(VOID);
231 VOID ItPosixQueue126(VOID);
232 VOID ItPosixQueue127(VOID);
233 VOID ItPosixQueue128(VOID);
234 VOID ItPosixQueue129(VOID);
235 VOID ItPosixQueue130(VOID);
236 VOID ItPosixQueue133(VOID);
237 VOID ItPosixQueue134(VOID);
238 VOID ItPosixQueue136(VOID);
239 VOID ItPosixQueue143(VOID);
240 VOID ItPosixQueue145(VOID);
241 VOID ItPosixQueue146(VOID);
242 VOID ItPosixQueue147(VOID);
243 VOID ItPosixQueue148(VOID);
244 VOID ItPosixQueue149(VOID);
245 VOID ItPosixQueue150(VOID);
246 VOID ItPosixQueue151(VOID);
247 VOID ItPosixQueue152(VOID);
248 VOID ItPosixQueue153(VOID);
249 VOID ItPosixQueue154(VOID);
250 VOID ItPosixQueue155(VOID);
251 VOID ItPosixQueue156(VOID);
252 VOID ItPosixQueue160(VOID);
253 VOID ItPosixQueue161(VOID);
254 VOID ItPosixQueue162(VOID);
255 VOID ItPosixQueue163(VOID);
256 VOID ItPosixQueue164(VOID);
257 VOID ItPosixQueue165(VOID);
258 VOID ItPosixQueue166(VOID);
259 VOID ItPosixQueue168(VOID);
260 VOID ItPosixQueue169(VOID);
261 VOID ItPosixQueue173(VOID);
262 VOID ItPosixQueue175(VOID);
263 VOID ItPosixQueue176(VOID);
264 VOID ItPosixQueue187(VOID);
265 
266 VOID ItPosixQueue200(VOID);
267 VOID ItPosixQueue201(VOID);
268 VOID ItPosixQueue202(VOID);
269 VOID ItPosixQueue203(VOID);
270 VOID ItPosixQueue204(VOID);
271 
272 VOID ItPosixQueue205(VOID);
273 VOID ItPosixQueue206(VOID);
274 VOID ItPosixQueue207(VOID);
275 VOID ItPosixQueue208(VOID);
276 VOID ItPosixQueue209(VOID);
277 #endif
278 #endif
279