ktest_interface.h
20.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* ktest_interface.h
*
* Project:
* --------
* Maui_Software
*
* Description:
* ------------
* This file expose the API or global varibles to test case files
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#ifndef __KTEST_INTERFACE_H
#define __KTEST_INTERFACE_H
#include "kal_release.h"
#include "syscomp_config.h"
#include "stack_common.h"
#include "stack_msgs.h"
#include "app_ltlcom.h"
#include "lcd_ip_cqueue.h"
#include "task_config.h"
#include "kal_public_defs.h"
#include "kal_internal_api.h"
#include "hisr_config.h"
/******************************************************************************
* Macros for KTEST adaptation layer
*****************************************************************************/
#ifdef KAL_ON_OSCAR
#define KTEST_FUNCTION_NAME __FUNCTION__
/* On Windows, createSemaphore accepts signed int as the count */
#define KTEST_MAX_SEM_CNT 0x7FFFFFFF
#define KAL_TIMER_ALLOWED_ERROR 2
#else /* not defined KAL_ON_OSCAR */
#define KTEST_FUNCTION_NAME __func__
#define KTEST_MAX_SEM_CNT 0xFFFFFFFF
#define KAL_TIMER_ALLOWED_ERROR 1
#endif /* KAL_ON_OSCAR */
/******************************************************************************
* Macros for error handling in KTEST
* KTEST_ASSERT_MAGIC: if we assign KTEST_ASSERT_MAGIC to KTEST_EXP_ASSERT_
* STR in test case, then no matter what the real assert expression is
* , KTEST will report this test case passed.
* KTEST_ASSERT_MAGIC_FAIL: if we assign KTEST_ASSERT_MAGIC_FAIL to KTEST_
* EXP_ASSERT_STR in test case, then no matter what the real assert
* expression is, KTEST will report this test case failed.
* KTEST_ALL_ERROR_CODE: if we assign KTEST_ALL_ERROR_CODE to KTEST_EXPECT_
* FATAL_ERROR in test case, then no matter what the real fatal error
* is, KTEST will report this test case passed.
*****************************************************************************/
#define KTEST_ASSERT_MAGIC "passassert"
#define KTEST_ASSERT_MAGIC_FAIL "failassert"
#define KTEST_ALL_ERROR_CODE 0x16789afe
/******************************************************************************
* KTEST will test KAL APIs automatically.
* It's exlusive with all tasks.
*****************************************************************************/
#ifdef __KTEST__
#define TASK_PRIORITY_KTEST KAL_PRIORITY_CLASS5
#endif
/******************************************************************************
* Simulate module id and task index mapping for ktest
*****************************************************************************/
typedef enum
{
MOD_KTEST_0,
MOD_KTEST,
MOD_KTEST1_1,
MOD_KTEST1_2,
MOD_KTEST2_1,
MOD_KTEST2_2,
MOD_KTEST3_1,
MOD_KTEST3_2,
MOD_KTEST4,
MOD_KTEST5,
MOD_KTEST6,
MOD_KTEST7,
KTEST_MOD_NUM,
} ktest_module_type;
typedef enum
{
INDX_KTEST_0,
INDX_KTEST,
INDX_KTEST1,
INDX_KTEST2,
INDX_KTEST3,
INDX_KTEST4,
INDX_KTEST5,
INDX_KTEST6,
INDX_KTEST7,
} ktest_task_index;
/******************************************************************************
* test case's result in KTEST:
* KTEST_PASS: the test case passes the test.
* KTEST_FAIL: the test case failed in the test.
* KTEST_DEP_FAIL: not used now.
*****************************************************************************/
typedef enum {
KTEST_PASS,
KTEST_FAIL,
KTEST_DEP_FAIL
} ktest_res;
/******************************************************************************
* entry sturcture for test case:
* argc: numbers of parameters
* argv: parameters
* tc_main_fn: entry function of each test case.
*****************************************************************************/
typedef kal_int32 (*ktest_tc_fn_ptr)( kal_uint32 argc, void *argv );
typedef struct
{
ktest_tc_fn_ptr tc_main_fn;
kal_uint32 argc;
void *argv;
} ktest_tc_struct;
/******************************************************************************
* Global variables exposed to test cases.
*****************************************************************************/
/******************************************************************************
* variables for test case table.
* tc_all_tbls:
* an array that contains test case tables in post-schedule stage of
* each module.
* pre_tc_all_tbls:
* an array that contains test case tables in pre-schedule stage of
* each module.
* tc_modules_num:
* an array that contains test cases number in post-schedule stage of
* each module.
* pre_tc_modules_num:
* an array that contains test cases number in pre-schedule stage of
* each module.
*****************************************************************************/
extern ktest_tc_struct const* tc_all_tbls[] ;
extern ktest_tc_struct const* pre_tc_all_tbls[];
extern kal_uint32 tc_modules_num[];
extern kal_uint32 pre_tc_modules_num[];
/******************************************************************************
* variables for test case related information.
* KTEST_TCID: the function name of a test case, it must be assigned the
* value of KTEST_FUNCTION_NAME in each test case.
* KTEST_BRIEF: brief description of a test case.
* KTEST_EXPECT_ERR_CODE: the fatal error that we expected in a test case.
* after we assigned a value to it, if the fatal error occured is just
* the one we expected, KTEST will report pass, instead of fail.
* KTEST_EXP_ASSERT_STR: the assert expression that we expected in a test
* case. its behavior is just like that of KTEST_EXPECT_ERR_CODE.
*****************************************************************************/
extern const kal_char *KTEST_TCID;
extern const kal_char *KTEST_BRIEF;
extern kal_uint32 KTEST_EXPECT_ERR_CODE;
extern kal_char *KTEST_EXP_ASSERT_STR;
/******************************************************************************
* APIs exposed to test cases.
*****************************************************************************/
/******************************************************************************
* Name:
* ktest_reset_target
* Functionality:
* reset the target.
* Parameters:
* void.
* Returns:
* void.
* Note:
* this function is designed to reset the target after a test case ends, in
* order to make a clean environment for next test case.
*****************************************************************************/
extern void ktest_reset_target( void );
/******************************************************************************
* Name:
* ktest_print
* Functionality:
* print some information.
* Parameters:
* fmt: a formatted string which determins the format of output.
* ...: real parameters that will be used in fmt.
* Returns:
* it always be KAL_TRUE.
* Note:
* this function supports variable parameter list just like printf in c
* standard library.
*****************************************************************************/
extern kal_uint32 ktest_print( kal_char *fmt, ... );
/******************************************************************************
* Name:
* internal_print
* Functionality:
* output some messages.
* Parameters:
* fmt: a formatted string that will be outputed.
* ap: a pointer to the variable argument list, it contains the real
* arguments that will be used in fmt.
* Returns:
* if successed, return 0.
* else, no return value.
* Note:
* the return value should be re-designed in the future.
*****************************************************************************/
extern kal_uint32 internal_print( kal_char *fmt, va_list ap );
/******************************************************************************
* Name:
* ktest_flush
* Functionality:
* flush test results to log file.
* Parameters:
* void.
* Returns:
* void.
*****************************************************************************/
extern void ktest_flush( void );
/******************************************************************************
* Name:
* ktest_report
* Functionality:
* report a test case result.
* Parameters:
* res: a value of KTEST_PASS, KTEST_FAIL or KTEST_DEP_FAIL.
* tcname: the function name of a test case.
* fmt: description of a test case, it's a formatted string.
* ...: real parameters that will be used in fmt.
* Returns:
* if report successfully, return KAL_TRUE.
* else, return KAL_FALSE.
* Note:
* you can use a variable parameter list in this function just like printf
* in c standard library.
*****************************************************************************/
extern kal_uint32 ktest_report( ktest_res res, const kal_char *tcname,
kal_char *fmt, ... );
/******************************************************************************
* Name:
* ktest_report_reset
* Functionality:
* report a test case result, then reset the target.
* Parameters:
* code: a value of KTEST_PASS, KTEST_FAIL or KTEST_DEP_FAIL.
* Returns:
* void.
*****************************************************************************/
extern void ktest_report_reset( kal_int32 code );
/******************************************************************************
* Name:
* ktest_report_reset3
* Functionality:
* report a test case result, then reset the target.
* Parameters:
* code: a value of KTEST_PASS, KTEST_FAIL, or KTEST_DEP_FAIL.
* tcname: the function name of a test case.
* msg: the description of a test case.
* Returns:
* void.
*****************************************************************************/
extern void ktest_report_reset3( kal_int32 code, const kal_char *tcname,
kal_char *msg );
/******************************************************************************
* Name:
* ktest_get_sys_tick
* Functionality:
* get current system tick.
* Parameters:
* void.
* Returns:
* if successful, return the system tick.
* else, return 0.
*****************************************************************************/
extern kal_uint32 ktest_get_sys_tick( void );
/******************************************************************************
* Name:
* ktest_set_sys_tick
* Functionality:
* set current system tick.
* Parameters:
* new_tick: new value that to be assigned to current system tick.
* Returns:
* void.
*****************************************************************************/
extern void ktest_set_sys_tick( kal_uint32 new_tick );
/******************************************************************************
* Name:
* ktest_delay_ticks
* Functionality:
* delay some ticks.
* Parameters:
* delay: how many ticks you want to dealy.
* Returns:
* void.
*****************************************************************************/
extern void ktest_delay_ticks( kal_uint32 delay );
/******************************************************************************
* Name:
* ktest_strncpy
* Functionality:
* copy some bytes from source to destination.
* Parameters:
* des: memory address of destination.
* src: memory address of source.
* len: how many bytes you want to copy.
* Returns:
* void.
* Note:
* its behavior is just like memcpy in c standard library, and I want to
* use memcpy instead of it.
*****************************************************************************/
extern void ktest_strncpy( kal_char *des, const kal_char *src, kal_uint32 len );
/******************************************************************************
* Name:
* ktest_strncmp
* Functionality:
* compair a string with another one.
* Parameters:
* s1: the first string to be compaired.
* s2: the second string to be compaired.
* len: how many bytes do you want to compair.
* Returns:
* if s1 equals with s2, return 0.
* else if s1 is in front of s2 in dictionary order, return a negative value.
* if s2 is in front of s1 in dictionary order, return a postive value.
* Note:
* its behavior is just like memcmp in c standard library, and I want to use
* memcmp instead of it.
*****************************************************************************/
extern kal_int32 ktest_strncmp( kal_char *s1, kal_char *s2, kal_uint32 len );
/******************************************************************************
* Name:
* ktest_strlen
* Functionality:
* caculate the length of a string.
* Parameters:
* str: the string whose length will be caculated.
* Returns:
* length of the string.
* Note:
* its behavior is just like strlen in c standard library, and I want to use
* strlen instead of it.
*****************************************************************************/
extern kal_uint32 ktest_strlen( const kal_char *str );
/******************************************************************************
* Name:
* ktest_strcmp
* Functionality:
* compair a string with another one.
* Parameters:
* s1: the first string you want to compair.
* s2: the second string you want to compair.
* Returns:
* if s1 equals with s2, return 0.
* else if s1 is in front of s2 in dictionary order, return a negative value.
* if s2 is in front of s1 in dictionary order, return a postive value.
* Note:
* its behavior is just like strcmp in c standard library, and I want to use
* strcmp intead of it.
*****************************************************************************/
extern kal_int32 ktest_strcmp( const kal_char *s1, const kal_char *s2 );
/******************************************************************************
* Name:
* ktest_start_gpt_timer
* Functionality:
* start a gpt timer.
* Parameters:
* time_count: time to expire ( in unit of 10ms ).
* gpttimer_func: callback function that will be called when timer expires.
* if it is null, default callback function will be called,
* it sends a message to host PC, then reset the target.
* cb_data: data that transferred to callback function.
* Returns:
* void.
*****************************************************************************/
void ktest_start_gpt_timer( kal_uint32 time_count,
void (*gpttimer_func)( void * ), void *cb_data );
/******************************************************************************
* Name:
* ktest_stop_gpt_timer
* Functionality:
* stop a gpt timer.
* Parameters:
* void.
* Returns:
* void.
*****************************************************************************/
void ktest_stop_gpt_timer( void );
/******************************************************************************
* Name:
* ktest_schedule
* Functionality:
* you can call this function in pre-schedule stage in order to run the
* created tasks.
* Parameters:
* void.
* Returns:
* void.
*****************************************************************************/
extern void ktest_schedule( void );
/******************************************************************************
* Name:
* ktest_sw_intr_handler
* Functionality:
* setup a handler for interrupt.
* Parameters:
* reg_lisr: the interrupt handler.
* Returns:
* void.
*****************************************************************************/
extern void ktest_sw_intr_handler( void (*reg_lisr)( void ) );
/******************************************************************************
* Name:
* ktest_active_sw_handler
* Functionality:
* activate the interrupt handler
* Parameters:
* void.
* Returns:
* void.
*****************************************************************************/
extern void ktest_active_sw_handler( void );
/******************************************************************************
* Name:
* ktest_deactive_sw_handler
* Functionality:
* de-activate the interrupt handler.
* Parameters:
* void.
* Returns:
* void.
*****************************************************************************/
extern void ktest_deactive_sw_handler( void );
/******************************************************************************
* Name:
* ktest_activate_hisr
* Functionality:
* activate a hisr.
* Parameters:
* hisr_routine: the routine of hisr.
* Returns:
* void.
*****************************************************************************/
extern void ktest_activate_hisr( void (*hisr_routine)( void ) );
/******************************************************************************
* Name:
* ktest_lib_createtask
* Functionality:
* create a task in KTEST
* Parameters:
* priority: the priority of task to be created.
* entry_func: entry function of task to be created.
* entry_param: parameters that will be transfered ti entry function.
* Returns:
* id of the created task.
*****************************************************************************/
extern kal_taskid ktest_lib_createtask( kal_uint8 priority,
kal_task_func_ptr entry_func,
void *entry_param );
/******************************************************************************
* Name:
* ktest_fake_test
* Functionality:
* a fake test case
* Parameters:
* argc: number of parameters
* argv: parameters of the function
* Returns:
* It always returns KAL_TRUE.
*****************************************************************************/
extern kal_int32 ktest_fake_test( kal_uint32 argc, void *argv );
#endif /* __KTEST_INTERFACE_H */