4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 /* testsuite for mm-radio library */
28 #include "mm_radio_test_type.h"
29 #include "mm_radio_rt_api_test.h"
31 #define DEFAULT_TEST_FREQ 107700
34 int __test_radio_init(void);
35 int __test_radio_listen_gorealra(void);
36 int __test_repeat_init_release(void);
37 int __test_repeat_start_stop(void);
38 int __test_repeat_seek(void);
39 int __test_repeat_whole(void);
40 int __test_manual_api_calling(void);
41 int __test_radio_hw_debug(void);
43 static int __msg_callback(int message, void *param, void *user_param);
46 static void __print_menu(void);
47 static void __run_test(int key);
50 test_item_t g_tests[100] = {
51 /* menu string : short string to be displayed to menu
52 description : detailed description
53 test function : a pointer to a actual test function
54 0 : to be filled with return value of test function
58 "check radio init function",
65 "let's listen to the gorealra!",
66 __test_radio_listen_gorealra,
71 "repeat_init_release",
72 "repeat init and release and check if it working and memory usage increment",
73 __test_repeat_init_release,
79 "repeat start and stop and check if it working and memory usage increment",
80 __test_repeat_start_stop,
86 "repeat seek and check if it working and memory usage increment",
93 "repeat whole radio sequence and check if it working and memory usage increment",
99 "manual api calling test",
100 "mapping each api to each test manu. just like other testsuite. try to reproduce the bugs with it.",
101 __test_manual_api_calling,
107 /* NOTE : do not remove this last item */
108 {"end", "", NULL, 0},
111 int g_num_of_tests = 0;
113 int main(int argc, char **argv)
123 if (key >= '0' && key <= '9') {
124 __run_test(key - '0');
126 } while (key == '\n');
127 } while (key != 'q' && key == 'Q');
129 printf("radio test client finished\n");
134 void __print_menu(void)
138 printf("\n\nFMRadio testing menu\n");
139 printf("------------------------------------------\n");
141 for (i = 0; g_tests[i].func; i++) {
142 printf("[%d] %s\n", i, g_tests[i].menu_string);
144 printf("[q] quit\n");
148 printf("Choose one : ");
151 void __run_test(int key)
156 printf("#tests : %d key : %d\n", g_num_of_tests, key);
157 if (key >= g_num_of_tests || key < 0) {
158 printf("unassigned key has pressed : %d\n", key);
162 /* display description*/
163 printf("excuting test : %s\n", g_tests[key].menu_string);
164 printf("description : %s\n", g_tests[key].description);
166 /* calling test function*/
167 ret = g_tests[key].func();
169 g_tests[key].result = ret;
172 printf("TEST FAILED. ret code : %d\n", g_tests[key].result);
174 printf("TEST SUCCEDED. ret code : %d\n", g_tests[key].result);
178 static int __msg_callback(int message, void *pParam, void *user_param)
180 MMMessageParamType *param = (MMMessageParamType *)pParam;
181 MMHandleType radio = (MMHandleType) user_param;
184 printf("incomming message : %d\n", message);
187 case MM_MESSAGE_STATE_CHANGED:
188 printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n"
189 , param->state.current, param->state.previous);
191 case MM_MESSAGE_RADIO_SCAN_START:
192 printf("MM_MESSAGE_RADIO_SCAN_START\n");
194 case MM_MESSAGE_RADIO_SCAN_INFO:
196 printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d KHz\n", param->radio_scan.frequency);
198 case MM_MESSAGE_RADIO_SCAN_STOP:
199 printf("MM_MESSAGE_RADIO_SCAN_STOP\n");
201 case MM_MESSAGE_RADIO_SCAN_FINISH:
202 printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n");
203 RADIO_TEST__(mm_radio_scan_stop(radio);)
205 case MM_MESSAGE_RADIO_SEEK_START:
206 printf("MM_MESSAGE_RADIO_SEEK_START\n");
208 case MM_MESSAGE_RADIO_SEEK_FINISH:
209 printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d KHz\n", param->radio_scan.frequency);
211 case MM_MESSAGE_STATE_INTERRUPTED:
212 printf("MM_MESSAGE_STATE_INTERRUPTED code - %d\n", param->code);
214 case MM_MESSAGE_READY_TO_RESUME:
215 printf("MM_MESSAGE_READY_TO_RESUME\n");
216 RADIO_TEST__(mm_radio_start(radio);)
219 printf("ERROR : unknown message received!\n");
227 int __test_radio_init(void)
229 printf("%s\n", __FUNCTION__);
231 int ret = MM_ERROR_NONE;
232 MMHandleType radio = 0;
234 RADIO_TEST__(mm_radio_create(&radio);)
235 RADIO_TEST__(mm_radio_set_message_callback(radio, (MMMessageCallback)__msg_callback, (void *)radio);)
236 RADIO_TEST__(mm_radio_realize(radio);)
237 RADIO_TEST__(mm_radio_unrealize(radio);)
238 RADIO_TEST__(mm_radio_destroy(radio);)
242 int __test_radio_listen_gorealra(void)
244 printf("%s\n", __FUNCTION__);
246 int ret = MM_ERROR_NONE;
247 MMHandleType radio = 0;
249 RADIO_TEST__(mm_radio_create(&radio);)
250 RADIO_TEST__(mm_radio_set_message_callback(radio, (MMMessageCallback)__msg_callback, (void *)radio);)
251 RADIO_TEST__(mm_radio_realize(radio);)
252 RADIO_TEST__(mm_radio_set_frequency(radio, DEFAULT_TEST_FREQ);)
253 RADIO_TEST__(mm_radio_start(radio);)
257 int __test_repeat_init_release(void)
259 printf("%s\n", __FUNCTION__);
261 int ret = MM_ERROR_NONE;
263 MMHandleType radio = 0;
266 RADIO_TEST__(mm_radio_create(&radio);)
267 RADIO_TEST__(mm_radio_set_message_callback(radio, (MMMessageCallback)__msg_callback, (void *)radio);)
268 RADIO_TEST__(mm_radio_realize(radio);)
269 RADIO_TEST__(mm_radio_unrealize(radio);)
270 RADIO_TEST__(mm_radio_destroy(radio);)
274 printf("%s : repeat count : %d\n", __FUNCTION__, cnt);
280 int __test_repeat_start_stop(void)
282 printf("%s\n", __FUNCTION__);
283 int ret = MM_ERROR_NONE;
285 MMHandleType radio = 0;
287 RADIO_TEST__(mm_radio_create(&radio);)
288 RADIO_TEST__(mm_radio_set_message_callback(radio, (MMMessageCallback)__msg_callback, (void *)radio);)
289 RADIO_TEST__(mm_radio_realize(radio);)
290 RADIO_TEST__(mm_radio_set_frequency(radio, DEFAULT_TEST_FREQ);)
293 RADIO_TEST__(mm_radio_start(radio);)
294 RADIO_TEST__(mm_radio_stop(radio);)
298 printf("%s : repeat count : %d\n", __FUNCTION__, cnt);
304 int __test_repeat_seek(void)
306 printf("__test_repeat_seek\n");
310 int __test_repeat_whole(void)
312 printf("__test_repeat_whole\n");
316 int __test_manual_api_calling(void)
319 mm_radio_rt_api_test();