• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
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 #ifndef TEST_SUITE_CONSOLE_H
17 #define TEST_SUITE_CONSOLE_H
18 
19 #include <stdint.h>
20 #include <stdbool.h>
21 #include "common_def.h"
22 #include "errcode.h"
23 
24 #ifdef __cplusplus
25 #if __cplusplus
26 extern "C" {
27 #endif /* __cplusplus */
28 #endif /* __cplusplus */
29 
30 /**
31  * @defgroup test_common_testsuite_console Console
32  * @ingroup  test_common_testsuite
33  * @{
34  */
35 
36 #define CONSOLE_CHAR_BACKSPACE (0x08)
37 #define CONSOLE_CHAR_ENTER     (0x0D)
38 #define CONSOLE_CHAR_ESC       (0x1B)
39 #define CONSOLE_CHAR_UP        (0x41)
40 #define CONSOLE_CHAR_DOWN      (0x42)
41 #define CONSOLE_CHAR_RIGHT     (0x43)
42 #define CONSOLE_CHAR_LEFT      (0x44)
43 #define CONSOLE_CHAR_CSI       (0x5B)
44 #define CONSOLE_CHAR_DELETE    (0x7F)
45 #define CONSOLE_CHAR_NONE      (0xFF)
46 
47 #define CONSOLE_CHAR_PAGE_HOME (0x31)
48 #define CONSOLE_CHAR_PAGE_END  (0x34)
49 #define CONSOLE_CHAR_PAGE_UP   (0x35)
50 #define CONSOLE_CHAR_PAGE_DOWN (0x36)
51 #define CONSOLE_CHAR_PAGE_7E   (0x7E)
52 
53 #define CONSOLE_COMMAND_CLEAR    ("[1J")
54 #define CONSOLE_COMMAND_MOVE_1_1 ("[11H")
55 
56 /**
57  * @if Eng
58  * @brief  Testsuite console color.
59  * @else
60  * @brief  测试套件控制台颜色。
61  * @endif
62  */
63 typedef enum {
64     TERM_COLOR_RESET = 0,
65     TERM_COLOR_BLACK = 30,
66     TERM_COLOR_RED,
67     TERM_COLOR_GREEN,
68     TERM_COLOR_BROWN,
69     TERM_COLOR_BLUE,
70     TERM_COLOR_PINK,
71     TERM_COLOR_CYAN,
72     TERM_COLOR_WHITE = 39
73 } term_color_t;
74 
75 /**
76  * @if Eng
77  * @brief  Initialize test suite console.
78  * @else
79  * @brief  初始化测试套件控制台。
80  * @endif
81  */
82 void test_suite_console_init(void);
83 
84 /**
85  * @if Eng
86  * @brief  Register console command buffer.
87  * @param  [in]  buffer_to_register the buffer register to console.
88  * @else
89  * @brief  注册控制台的命令输入缓存。
90  * @param  [in]  buffer_to_register 要注册给控制台的缓存。
91  * @endif
92  */
93 void test_suite_console_register_command_buffer(char *buffer_to_register);
94 
95 /**
96  * @if Eng
97  * @brief  Enable console command process,if enabled, allow receive buffer form channel.
98  * @else
99  * @brief  打开控制台的命令解析,打开状态下允许接收通道传来的命令。
100  * @endif
101  */
102 void test_suite_console_enable(void);
103 
104 /**
105  * @if Eng
106  * @brief  Disable console command  process,if disabled, not receive buffer form channel.
107  * @else
108  * @brief  关闭控制台的命令解析,关闭状态下不再接收通道传来的命令。
109  * @endif
110  */
111 void test_suite_console_disable(void);
112 
113 /**
114  * @if Eng
115  * @brief  Get test suite console status.
116  * @return  false:disabled; true:enable.
117  * @else
118  * @brief  获取测试套件控制台的状态。
119  * @return  false:关闭; true:打开。
120  * @endif
121  */
122 bool test_suite_console_is_enabled(void);
123 
124 /**
125  * @if Eng
126  * @brief  Process the char from the channel.
127  * @param  [in]  c the char to process.
128  * @else
129  * @brief  单字节处理通道传来的消息。
130  * @param  [in]  c 要处理的字节。
131  * @endif
132  */
133 void test_suite_console_process_char(char c);
134 
135 /**
136  * @if Eng
137  * @brief  Set test suite console background color.
138  * @param  [in]  color console color type.
139  * @else
140  * @brief  设置测试控制台背景色。
141  * @param  [in]  color 控制台颜色类型。
142  * @endif
143  */
144 void test_suite_console_set_color(term_color_t color);
145 
146 /**
147  * @if Eng
148  * @brief  Displat test suite test status over console.
149  * @param  [in]  status test suite test status.
150  * @else
151  * @brief  通过控制台显示测试套件当前的测试状态。
152  * @param  [in]  status 测试套件的测试状态。
153  * @endif
154  */
155 void test_suite_console_display_test_status(int status);
156 
157 /**
158  * @}
159  */
160 
161 #ifdef __cplusplus
162 #if __cplusplus
163 }
164 #endif /* __cplusplus */
165 #endif /* __cplusplus */
166 
167 #endif
168