#include <unistd.h>
#define DEFAULT_TEST_FREQ 107700
-#define MENU_ITEM_MAX 19
+#define MENU_ITEM_MAX 20
#define _MAX_INPUT_STRING_ 100
int radio_rt_api_test(void);
static int __menu(void);
-static void __call_api( int choosen );
+static void __call_api(int choosen);
void __radio_seek_completed_cb(int frequency, void *user_data);
void __radio_scan_updated_cb(int freq, void *user_data);
void __radio_scan_stop_cb(void *user_data);
/* list of tests*/
-test_item_t g_tests[100] =
-{
+test_item_t g_tests[100] = {
/* menu string : short string to be displayed to menu
description : detailed description
test function : a pointer to a actual test function
"init test",
"check radio init function",
__test_radio_init,
- 0
+ 0
},
{
"listening gorealra",
"let's listen to the gorealra!",
__test_radio_listen_gorealra,
- 0
+ 0
},
{
"repeat_init_release",
"repeat init and release and check if it working and memory usage increment",
__test_repeat_init_release,
- 0
+ 0
},
{
"repeat_start_stop",
"repeat start and stop and check if it working and memory usage increment",
__test_repeat_start_stop,
- 0
+ 0
},
{
"repeat_seek",
"repeat seek and check if it working and memory usage increment",
__test_repeat_seek,
- 0
+ 0
},
{
"repeat_whole",
"repeat whole radio sequence and check if it working and memory usage increment",
__test_repeat_whole,
- 0
+ 0
},
{
"manual api calling test",
"mapping each api to each test manu. just like other testsuite. try to reproduce the bugs with it.",
__test_manual_api_calling,
- 0
+ 0
},
/* add tests here*/
do {
key = getchar();
- if ( key >= '0' && key <= '9')
- {
- __run_test( key - '0' );
+ if (key >= '0' && key <= '9') {
+ __run_test(key - '0');
}
- }while ( key == '\n' );
- if(key == 'Q' || key == 'q')
+ } while (key == '\n');
+ if (key == 'Q' || key == 'q')
break;
- }while(1);
+ } while (1);
printf("radio test client finished\n");
printf("\n\nFMRadio testing menu\n");
printf("------------------------------------------\n");
- for ( i = 0; g_tests[i].func; i++ )
- {
- printf( "[%d] %s\n", i, g_tests[i].menu_string );
+ for (i = 0; g_tests[i].func; i++) {
+ printf("[%d] %s\n", i, g_tests[i].menu_string);
}
printf("[q] quit\n");
/* check index */
printf("#tests : %d key : %d\n", g_num_of_tests, key);
- if ( key >= g_num_of_tests || key < 0 )
- {
+ if (key >= g_num_of_tests || key < 0) {
printf("unassigned key has pressed : %d\n", key);
return;
}
/* display description*/
- printf( "excuting test : %s\n", g_tests[key].menu_string );
- printf( "description : %s\n", g_tests[key].description );
+ printf("excuting test : %s\n", g_tests[key].menu_string);
+ printf("description : %s\n", g_tests[key].description);
/* calling test function*/
ret = g_tests[key].func();
g_tests[key].result = ret;
- if ( ret )
- {
- printf( "TEST FAILED. ret code : %d\n", g_tests[key].result);
- }
- else
- {
- printf( "TEST SUCCEDED. ret code : %d\n", g_tests[key].result);
+ if (ret) {
+ printf("TEST FAILED. ret code : %d\n", g_tests[key].result);
+ } else {
+ printf("TEST SUCCEDED. ret code : %d\n", g_tests[key].result);
}
}
int ret = RADIO_ERROR_NONE;
radio_h radio;
- RADIO_TEST__( radio_create(&radio); )
- RADIO_TEST__( radio_destroy(radio); )
+ RADIO_TEST__(radio_create(&radio);)
+ RADIO_TEST__(radio_destroy(radio);)
return ret;
}
int ret = RADIO_ERROR_NONE;
radio_h radio;
- RADIO_TEST__( radio_create(&radio); )
- RADIO_TEST__( radio_set_frequency( radio, DEFAULT_TEST_FREQ ); )
- RADIO_TEST__( radio_start(radio); )
+ RADIO_TEST__(radio_create(&radio);)
+ RADIO_TEST__(radio_set_frequency(radio, DEFAULT_TEST_FREQ);)
+ RADIO_TEST__(radio_start(radio);)
usleep(5000 * 1000);
- RADIO_TEST__( radio_stop(radio); )
- RADIO_TEST__( radio_destroy(radio); )
+ RADIO_TEST__(radio_stop(radio);)
+ RADIO_TEST__(radio_destroy(radio);)
return ret;
}
int cnt = 0;
radio_h radio;
- while ( cnt < 1000 )
- {
- RADIO_TEST__( radio_create(&radio); )
- RADIO_TEST__( radio_destroy(radio); )
+ while (cnt < 1000) {
+ RADIO_TEST__(radio_create(&radio);)
+ RADIO_TEST__(radio_destroy(radio);)
cnt++;
int cnt = 0;
radio_h radio;
- RADIO_TEST__( radio_create(&radio); )
- RADIO_TEST__( radio_set_frequency( radio, DEFAULT_TEST_FREQ ); )
+ RADIO_TEST__(radio_create(&radio);)
+ RADIO_TEST__(radio_set_frequency(radio, DEFAULT_TEST_FREQ);)
- while(cnt < 10)
- {
- RADIO_TEST__( radio_start(radio); )
+ while (cnt < 10) {
+ RADIO_TEST__(radio_start(radio);)
usleep(2000 * 1000);
- RADIO_TEST__( radio_stop(radio); )
+ RADIO_TEST__(radio_stop(radio);)
cnt++;
int radio_rt_api_test(void)
{
- while(1)
- {
+ while (1) {
int choosen = 0;
choosen = __menu();
- if ( choosen == -1)
+ if (choosen == -1)
continue;
- if ( choosen == 0 )
+ if (choosen == 0)
break;
- __call_api( choosen );
+ __call_api(choosen);
}
printf("radio test client finished\n");
printf("[16] radio_unset_scan_completed_cb\n");
printf("[17] radio_set_interrupted_cb\n");
printf("[18] radio_unset_interrupted_cb\n");
+ printf("[19] radio_get_frequency_range\n");
+ printf("[20] radio_get_channel_spacing\n");
printf("[0] quit\n");
printf("---------------------------------------------------------\n");
printf("choose one : ");
- if ( scanf("%d", &menu_item) == 0)
- {
+ if (scanf("%d", &menu_item) == 0) {
char temp[_MAX_INPUT_STRING_];
- if (scanf("%s", temp) ==0)
- {
+ if (scanf("%s", temp) == 0) {
printf("Error while flushing the input buffer - but lets continue\n");
}
return -1;
}
- if ( menu_item > MENU_ITEM_MAX )
+ if (menu_item > MENU_ITEM_MAX)
menu_item = -1;
return menu_item;
}
-void __call_api( int choosen )
+void __call_api(int choosen)
{
int ret = RADIO_ERROR_NONE;
- switch( choosen )
- {
- case 1:
- {
- RADIO_TEST__( radio_create( &g_my_radio ); )
- }
- break;
+ switch (choosen) {
+ case 1: {
+ RADIO_TEST__(radio_create(&g_my_radio);)
+ }
+ break;
- case 2:
- {
- RADIO_TEST__( radio_destroy( g_my_radio ); )
- g_my_radio = 0;
- }
- break;
+ case 2: {
+ RADIO_TEST__(radio_destroy(g_my_radio);)
+ g_my_radio = 0;
+ }
+ break;
- case 3:
- {
- radio_state_e state;
- RADIO_TEST__( radio_get_state(g_my_radio, &state); )
+ case 3: {
+ radio_state_e state;
+ RADIO_TEST__(radio_get_state(g_my_radio, &state);)
- printf("state : %d\n", state);
- }
- break;
+ printf("state : %d\n", state);
+ }
+ break;
- case 4:
- {
- RADIO_TEST__( radio_start(g_my_radio); )
- }
- break;
+ case 4: {
+ RADIO_TEST__(radio_start(g_my_radio);)
+ }
+ break;
- case 5:
- {
- RADIO_TEST__( radio_stop(g_my_radio); )
- }
- break;
+ case 5: {
+ RADIO_TEST__(radio_stop(g_my_radio);)
+ }
+ break;
- case 6:
- {
- RADIO_TEST__( radio_seek_up(g_my_radio, __radio_seek_completed_cb, NULL); )
+ case 6: {
+ RADIO_TEST__(radio_seek_up(g_my_radio, __radio_seek_completed_cb, NULL);)
- }
- break;
+ }
+ break;
- case 7:
- {
- RADIO_TEST__( radio_seek_down(g_my_radio, __radio_seek_completed_cb, NULL); )
- }
- break;
+ case 7: {
+ RADIO_TEST__(radio_seek_down(g_my_radio, __radio_seek_completed_cb, NULL);)
+ }
+ break;
- case 8:
- {
- int freq = 0;
- printf("input freq : ");
- if (scanf("%d", &freq) == 0)
- return;
+ case 8: {
+ int freq = 0;
+ printf("input freq : ");
+ if (scanf("%d", &freq) == 0)
+ return;
- RADIO_TEST__( radio_set_frequency(g_my_radio, freq); )
- }
- break;
+ RADIO_TEST__(radio_set_frequency(g_my_radio, freq);)
+ }
+ break;
- case 9:
- {
- int freq = 0;
- RADIO_TEST__( radio_get_frequency(g_my_radio, &freq ); )
+ case 9: {
+ int freq = 0;
+ RADIO_TEST__(radio_get_frequency(g_my_radio, &freq);)
- printf("freq : %d\n", freq);
- }
- break;
+ printf("freq : %d\n", freq);
+ }
+ break;
- case 10:
- {
- int signal_strength = 0;
- RADIO_TEST__( radio_get_signal_strength(g_my_radio, &signal_strength); )
- printf("signal strength is : %d \n", signal_strength);
- }
- break;
+ case 10: {
+ int signal_strength = 0;
+ RADIO_TEST__(radio_get_signal_strength(g_my_radio, &signal_strength);)
+ printf("signal strength is : %d \n", signal_strength);
+ }
+ break;
- case 11:
- {
- RADIO_TEST__( radio_scan_start(g_my_radio, &__radio_scan_updated_cb, NULL); )
- }
- break;
+ case 11: {
+ RADIO_TEST__(radio_scan_start(g_my_radio, &__radio_scan_updated_cb, NULL);)
+ }
+ break;
- case 12:
- {
- RADIO_TEST__( radio_scan_stop(g_my_radio, &__radio_scan_stop_cb, NULL); )
- }
- break;
-
- case 13:
- {
- int muted = 0;
- printf("select one(0:UNMUTE/1:MUTE) : ");
- if ( scanf("%d", &muted) == 0)
- return;
- RADIO_TEST__( radio_set_mute(g_my_radio, muted); )
- }
- break;
+ case 12: {
+ RADIO_TEST__(radio_scan_stop(g_my_radio, &__radio_scan_stop_cb, NULL);)
+ }
+ break;
- case 14:
- {
- bool muted = 0;
- RADIO_TEST__( radio_is_muted(g_my_radio, &muted); )
- printf("muted : %d \n", muted);
- }
- break;
+ case 13: {
+ int muted = 0;
+ printf("select one(0:UNMUTE/1:MUTE) : ");
+ if (scanf("%d", &muted) == 0)
+ return;
+ RADIO_TEST__(radio_set_mute(g_my_radio, muted);)
+ }
+ break;
+ case 14: {
+ bool muted = 0;
+ RADIO_TEST__(radio_is_muted(g_my_radio, &muted);)
+ printf("muted : %d \n", muted);
+ }
+ break;
- case 15:
- {
- RADIO_TEST__( radio_set_scan_completed_cb(g_my_radio, &__radio_set_scan_completed_cb, NULL); )
- }
- break;
- case 16:
- {
- RADIO_TEST__( radio_unset_scan_completed_cb(g_my_radio); )
- }
- break;
+ case 15: {
+ RADIO_TEST__(radio_set_scan_completed_cb(g_my_radio, &__radio_set_scan_completed_cb, NULL);)
+ }
+ break;
- case 17:
- {
- RADIO_TEST__( radio_set_interrupted_cb(g_my_radio, &__radio_set_interrupted_cb, NULL ); )
- }
- break;
+ case 16: {
+ RADIO_TEST__(radio_unset_scan_completed_cb(g_my_radio);)
+ }
+ break;
- case 18:
- {
- RADIO_TEST__( radio_unset_interrupted_cb(g_my_radio); )
- }
- break;
+ case 17: {
+ RADIO_TEST__(radio_set_interrupted_cb(g_my_radio, &__radio_set_interrupted_cb, NULL);)
+ }
+ break;
+
+ case 18: {
+ RADIO_TEST__(radio_unset_interrupted_cb(g_my_radio);)
+ }
+ break;
+
+ case 19: {
+ int min = 0;
+ int max = 0;
+ RADIO_TEST__(radio_get_frequency_range(g_my_radio, &min, &max);)
+ printf("min : %d max: %d \n", min, max);
+ }
+ break;
+
+ case 20: {
+ int channel_spacing = 0;
+ RADIO_TEST__(radio_get_channel_spacing(g_my_radio, &channel_spacing);)
+ printf("channel_spacing : %d \n", channel_spacing);
+ }
+ break;
default:
break;