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_CHANNEL_H 17 #define TEST_SUITE_CHANNEL_H 18 19 #include <stdint.h> 20 #include "common_def.h" 21 22 #ifdef __cplusplus 23 #if __cplusplus 24 extern "C" { 25 #endif /* __cplusplus */ 26 #endif /* __cplusplus */ 27 28 /** 29 * @defgroup test_common_testsuite_channel Channel 30 * @ingroup test_common_testsuite 31 * @{ 32 */ 33 34 /** 35 * @if Eng 36 * @brief Initialize channel for testsuite. 37 * @else 38 * @brief 通道层的初始化接口。 39 * @endif 40 */ 41 typedef void (*test_suite_channel_init_t)(void); 42 43 /** 44 * @if Eng 45 * @brief Initialize channel for testsuite. 46 * @else 47 * @brief 通道层的初始化接口。 48 * @endif 49 */ 50 typedef void (*test_suite_channel_deinit_t)(void); 51 52 /** 53 * @if Eng 54 * @brief Channel sends char interface. 55 * @param [in] c char to send. 56 * @else 57 * @brief 通道层的字节发送接口。 58 * @param [in] c 要发送的单个字节。 59 * @endif 60 */ 61 typedef void (*test_suite_channel_send_char_t)(char c); 62 63 /** 64 * @if Eng 65 * @brief Channel sends string interface. 66 * @param [in] str string to send. 67 * @else 68 * @brief 通道层的字符串发送接口。 69 * @param [in] str 要发送的字符串。 70 * @endif 71 */ 72 typedef void (*test_suite_channel_send_t)(const char *str); 73 74 /** 75 * @if Eng 76 * @brief Channel sends format string interface. 77 * @param [in] str string to send. 78 * @else 79 * @brief 通道层的格式化字符串发送接口。 80 * @param [in] str 要发送的字符串。 81 * @endif 82 */ 83 typedef void (*test_suite_channel_sendf_t)(const char *str, ...); 84 85 /** 86 * @if Eng 87 * @brief Channel sends string and "\r\n" interface. 88 * @param [in] str string to send. 89 * @else 90 * @brief 通道层的字符串发送并换行接口。 91 * @param [in] str 要发送的字符串。 92 * @endif 93 */ 94 typedef void (*test_suite_channel_send_line_t)(const char *str); 95 96 typedef struct { 97 test_suite_channel_init_t init; /*!< @if Eng Init channel interface. 98 @else 通道层的初始化接口。 @endif */ 99 test_suite_channel_deinit_t deinit; /*!< @if Eng Deinit channel interface. 100 @else 通道层的去初始化接口。 @endif */ 101 test_suite_channel_send_char_t send_char; /*!< @if Eng Channel sends char interface. 102 @else 通道层发送字节接口。 @endif */ 103 test_suite_channel_send_t send; /*!< @if Eng Channel sends string interface. 104 @else 通道层发送字符串接口。 @endif */ 105 test_suite_channel_sendf_t sendf; /*!< @if Eng Channel sends format string interface. 106 @else 通道层发送格式化字符串接口。 @endif */ 107 test_suite_channel_send_line_t send_line; /*!< @if Eng Channel sends string and "\r\n" interface. 108 @else 通道层发送字符串并换行接口。 @endif */ 109 } test_suite_channel_funcs_t; 110 111 /** 112 * @if Eng 113 * @brief Initialize test suite channel. 114 * @param [in] funcs test suite channel funtions. 115 * @else 116 * @brief 初始化测试套件的通道。 117 * @param [in] funcs 测试套件通道函数接口。 118 * @endif 119 */ 120 void test_suite_channel_init(test_suite_channel_funcs_t *funcs); 121 122 /** 123 * @if Eng 124 * @brief Deinit test suite channel. 125 * @else 126 * @brief 去初始化测试套件的逻辑通道。 127 * @endif 128 */ 129 void test_suite_channel_deinit(void); 130 131 /** 132 * @if Eng 133 * @brief Get test suite channel functions. 134 * @retval channel functions. 135 * @else 136 * @brief 获取逻辑通道的函数接口。 137 * @retval 通道函数接口。 138 * @endif 139 */ 140 test_suite_channel_funcs_t *test_suite_channel_get_funcs(void); 141 142 /** 143 * @} 144 */ 145 146 #ifdef __cplusplus 147 #if __cplusplus 148 } 149 #endif /* __cplusplus */ 150 #endif /* __cplusplus */ 151 152 #endif