3 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 /* testsuite for radio api */
27 #include "radio_test_type.h"
30 #define DEFAULT_TEST_FREQ 107700
31 #define MENU_ITEM_MAX 20
32 #define _MAX_INPUT_STRING_ 100
36 int __test_radio_init(void);
37 int __test_radio_listen_gorealra(void);
38 int __test_repeat_init_release(void);
39 int __test_repeat_start_stop(void);
40 int __test_repeat_seek(void);
41 int __test_repeat_whole(void);
42 int __test_manual_api_calling(void);
43 int __test_radio_hw_debug(void);
47 static void __print_menu(void);
48 static void __run_test(int key);
50 int radio_rt_api_test(void);
51 static int __menu(void);
52 static void __call_api(int choosen);
53 void __radio_seek_completed_cb(int frequency, void *user_data);
54 void __radio_scan_updated_cb(int freq, void *user_data);
55 void __radio_scan_stop_cb(void *user_data);
56 void __radio_set_scan_completed_cb(void *user_param);
57 void __radio_set_interrupted_cb(radio_interrupted_code_e code, void *user_param);
62 test_item_t g_tests[100] = {
63 /* menu string : short string to be displayed to menu
64 description : detailed description
65 test function : a pointer to a actual test function
66 0 : to be filled with return value of test function
70 "check radio init function",
77 "let's listen to the gorealra!",
78 __test_radio_listen_gorealra,
83 "repeat_init_release",
84 "repeat init and release and check if it working and memory usage increment",
85 __test_repeat_init_release,
91 "repeat start and stop and check if it working and memory usage increment",
92 __test_repeat_start_stop,
98 "repeat seek and check if it working and memory usage increment",
105 "repeat whole radio sequence and check if it working and memory usage increment",
111 "manual api calling test",
112 "mapping each api to each test manu. just like other testsuite. try to reproduce the bugs with it.",
113 __test_manual_api_calling,
119 /* NOTE : do not remove this last item */
120 {"end", "", NULL, 0},
123 int g_num_of_tests = 0;
124 static radio_h g_my_radio = 0;
126 int main(int argc, char **argv)
136 if (key >= '0' && key <= '9') {
137 __run_test(key - '0');
139 } while (key == '\n');
140 if (key == 'Q' || key == 'q')
144 printf("radio test client finished\n");
149 void __print_menu(void)
153 printf("\n\nFMRadio testing menu\n");
154 printf("------------------------------------------\n");
156 for (i = 0; g_tests[i].func; i++) {
157 printf("[%d] %s\n", i, g_tests[i].menu_string);
159 printf("[q] quit\n");
163 printf("Choose one : ");
166 void __run_test(int key)
171 printf("#tests : %d key : %d\n", g_num_of_tests, key);
172 if (key >= g_num_of_tests || key < 0) {
173 printf("unassigned key has pressed : %d\n", key);
177 /* display description*/
178 printf("excuting test : %s\n", g_tests[key].menu_string);
179 printf("description : %s\n", g_tests[key].description);
181 /* calling test function*/
182 ret = g_tests[key].func();
184 g_tests[key].result = ret;
187 printf("TEST FAILED. ret code : %d\n", g_tests[key].result);
189 printf("TEST SUCCEDED. ret code : %d\n", g_tests[key].result);
195 int __test_radio_init(void)
197 printf("%s\n", __FUNCTION__);
199 int ret = RADIO_ERROR_NONE;
202 RADIO_TEST__(radio_create(&radio);)
203 RADIO_TEST__(radio_destroy(radio);)
207 int __test_radio_listen_gorealra(void)
209 printf("%s\n", __FUNCTION__);
211 int ret = RADIO_ERROR_NONE;
214 RADIO_TEST__(radio_create(&radio);)
215 RADIO_TEST__(radio_set_frequency(radio, DEFAULT_TEST_FREQ);)
216 RADIO_TEST__(radio_start(radio);)
218 RADIO_TEST__(radio_stop(radio);)
219 RADIO_TEST__(radio_destroy(radio);)
223 int __test_repeat_init_release(void)
225 printf("%s\n", __FUNCTION__);
227 int ret = RADIO_ERROR_NONE;
232 RADIO_TEST__(radio_create(&radio);)
233 RADIO_TEST__(radio_destroy(radio);)
237 printf("%s : repeat count : %d\n", __FUNCTION__, cnt);
243 int __test_repeat_start_stop(void)
245 printf("%s\n", __FUNCTION__);
246 int ret = RADIO_ERROR_NONE;
250 RADIO_TEST__(radio_create(&radio);)
251 RADIO_TEST__(radio_set_frequency(radio, DEFAULT_TEST_FREQ);)
254 RADIO_TEST__(radio_start(radio);)
256 RADIO_TEST__(radio_stop(radio);)
260 printf("%s : repeat count : %d\n", __FUNCTION__, cnt);
266 int __test_repeat_seek(void)
268 printf("__test_repeat_seek\n");
272 int __test_repeat_whole(void)
274 printf("__test_repeat_whole\n");
278 int __test_manual_api_calling(void)
287 int radio_rt_api_test(void)
303 printf("radio test client finished\n");
312 printf("---------------------------------------------------------\n");
313 printf("radio rt api test. try now!\n");
314 printf("---------------------------------------------------------\n");
315 printf("[1] radio_create\n");
316 printf("[2] radio_destroy\n");
317 printf("[3] radio_get_state\n");
318 printf("[4] radio_start\n");
319 printf("[5] radio_stop\n");
320 printf("[6] radio_seek_up\n");
321 printf("[7] radio_seek_down\n");
322 printf("[8] radio_set_frequency(ex.107700)\n");
323 printf("[9] radio_get_frequency\n");
324 printf("[10] radio_signal_strength\n");
325 printf("[11] radio_scan_start\n");
326 printf("[12] radio_scan_stop\n");
327 printf("[13] radio_set_mute\n");
328 printf("[14] radio_is_muted\n");
329 printf("[15] radio_set_scan_completed_cb\n");
330 printf("[16] radio_unset_scan_completed_cb\n");
331 printf("[17] radio_set_interrupted_cb\n");
332 printf("[18] radio_unset_interrupted_cb\n");
333 printf("[19] radio_get_frequency_range\n");
334 printf("[20] radio_get_channel_spacing\n");
336 printf("[0] quit\n");
337 printf("---------------------------------------------------------\n");
338 printf("choose one : ");
340 if (scanf("%d", &menu_item) == 0) {
341 char temp[_MAX_INPUT_STRING_];
342 if (scanf("%s", temp) == 0) {
343 printf("Error while flushing the input buffer - but lets continue\n");
349 if (menu_item > MENU_ITEM_MAX)
355 void __call_api(int choosen)
357 int ret = RADIO_ERROR_NONE;
361 RADIO_TEST__(radio_create(&g_my_radio);)
366 RADIO_TEST__(radio_destroy(g_my_radio);)
373 RADIO_TEST__(radio_get_state(g_my_radio, &state);)
375 printf("state : %d\n", state);
380 RADIO_TEST__(radio_start(g_my_radio);)
385 RADIO_TEST__(radio_stop(g_my_radio);)
390 RADIO_TEST__(radio_seek_up(g_my_radio, __radio_seek_completed_cb, NULL);)
396 RADIO_TEST__(radio_seek_down(g_my_radio, __radio_seek_completed_cb, NULL);)
402 printf("input freq : ");
403 if (scanf("%d", &freq) == 0)
406 RADIO_TEST__(radio_set_frequency(g_my_radio, freq);)
412 RADIO_TEST__(radio_get_frequency(g_my_radio, &freq);)
414 printf("freq : %d\n", freq);
419 int signal_strength = 0;
420 RADIO_TEST__(radio_get_signal_strength(g_my_radio, &signal_strength);)
421 printf("signal strength is : %d \n", signal_strength);
426 RADIO_TEST__(radio_scan_start(g_my_radio, &__radio_scan_updated_cb, NULL);)
431 RADIO_TEST__(radio_scan_stop(g_my_radio, &__radio_scan_stop_cb, NULL);)
437 printf("select one(0:UNMUTE/1:MUTE) : ");
438 if (scanf("%d", &muted) == 0)
440 RADIO_TEST__(radio_set_mute(g_my_radio, muted);)
446 RADIO_TEST__(radio_is_muted(g_my_radio, &muted);)
447 printf("muted : %d \n", muted);
453 RADIO_TEST__(radio_set_scan_completed_cb(g_my_radio, &__radio_set_scan_completed_cb, NULL);)
458 RADIO_TEST__(radio_unset_scan_completed_cb(g_my_radio);)
463 RADIO_TEST__(radio_set_interrupted_cb(g_my_radio, &__radio_set_interrupted_cb, NULL);)
468 RADIO_TEST__(radio_unset_interrupted_cb(g_my_radio);)
475 RADIO_TEST__(radio_get_frequency_range(g_my_radio, &min, &max);)
476 printf("min : %d max: %d \n", min, max);
481 int channel_spacing = 0;
482 RADIO_TEST__(radio_get_channel_spacing(g_my_radio, &channel_spacing);)
483 printf("channel_spacing : %d \n", channel_spacing);
493 void __radio_seek_completed_cb(int frequency, void *user_data)
495 printf("__radio_seek_completed_cb freq is %d\n" , frequency);
497 void __radio_scan_updated_cb(int frequency, void *user_param)
499 printf("__radio_scan_updated_cb freq is %d\n" , frequency);
502 void __radio_scan_stop_cb(void *user_param)
504 printf("__radio_scan_stop_cb\n");
507 void __radio_set_scan_completed_cb(void *user_param)
509 printf("__radio_scan_completed_cb\n");
512 void __radio_set_interrupted_cb(radio_interrupted_code_e code, void *user_param)
514 printf("__radio_set_interrupted_cb\n");