blob: b62663e729d905169c9dedbcaae2aafc52ca1be3 [file] [log] [blame]
b.liud440f9f2025-04-18 10:44:31 +08001/*-----------------------------------------------------------------------------------------------*/
2/**
3 @file test_utils.h
4 @brief Test related interface definition
5*/
6/*-----------------------------------------------------------------------------------------------*/
7
8/*-------------------------------------------------------------------------------------------------
9 Copyright (c) 2018 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
10 Quectel Wireless Solution Proprietary and Confidential.
11-------------------------------------------------------------------------------------------------*/
12
13/*-------------------------------------------------------------------------------------------------
14 EDIT HISTORY
15 This section contains comments describing changes made to the file.
16 Notice that changes are listed in reverse chronological order.
17 $Header: $
18 when who what, where, why
19 -------- --- ----------------------------------------------------------
20 20190508 tyler.kuang Created .
21-------------------------------------------------------------------------------------------------*/
22
23#ifndef __TEST_UTILS_H__
24#define __TEST_UTILS_H__
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#include <stdint.h>
31
32typedef void (*item_handler_f)(void);
33
34#define T_ARRAY_SIZE(items) (sizeof(items)/sizeof(items[0]))
35
36typedef struct
37{
38 const char *name;
39 item_handler_f handle;
40} t_item_t;
41
42typedef struct
43{
44 const char *name;
45 int item_len;
46 t_item_t *item_list;
47} t_module_t;
48
49/*-----------------------------------------------------------------------------------------------*/
50/**
51 @brief Read a int value from stdin
52 @param[out] val, Return read data
53 @return
54 0 - successful
55 1 - read an enter
56 -1 - invalid input
57 */
58/*-----------------------------------------------------------------------------------------------*/
59int t_get_int(int *val);
60
61/*-----------------------------------------------------------------------------------------------*/
62/**
63 @brief Read a uint32 value from stdin
64 @param[out] val, Return read data
65 @return
66 0 - successful
67 1 - read an enter
68 -1 - invalid input
69 */
70/*-----------------------------------------------------------------------------------------------*/
71int t_get_hex(uint32_t *val);
72
73/*-----------------------------------------------------------------------------------------------*/
74/**
75 @brief Read a char value from stdin
76 @param[out] val, Return read data
77 @return
78 0 - successful
79 1 - read an enter
80 -1 - invalid input
81 */
82/*-----------------------------------------------------------------------------------------------*/
83int t_get_char(int *val);
84
85/*-----------------------------------------------------------------------------------------------*/
86/**
87 @brief Read a string value from stdin
88 @param[out] val, Return read data
89 @return
90 0 - successful
91 1 - read an enter
92 -1 - invalid input
93 */
94/*-----------------------------------------------------------------------------------------------*/
95int t_get_string(char *str_buf, int str_len);
96
97/*-----------------------------------------------------------------------------------------------*/
98/**
99 @brief Read a list of int values from stdin
100 @param[out] val, Return read datas
101 @param[out&in] val, Input buffer length, output the number of read
102 @return
103 0 - successful
104 1 - read an enter
105 -1 - invalid input
106 */
107/*-----------------------------------------------------------------------------------------------*/
108int t_get_int_list(int *dat_buf, int *dat_len);
109
110/*-----------------------------------------------------------------------------------------------*/
111/**
112 @brief Read a list of float values from stdin
113 @param[out] val, Return read datas
114 @param[out&in] val, Input buffer length, output the number of read
115 @return
116 0 - successful
117 1 - read an enter
118 -1 - invalid input
119 */
120/*-----------------------------------------------------------------------------------------------*/
121int t_get_float_list(float *dat_buf, int *dat_len);
122
123
124#ifdef __cplusplus
125}
126#endif
127
128#endif
129