8 /****************************************************************************/
9 int main( int argc, char **argv )
13 show_error_flag = LOWERED,
14 show_help_flag = LOWERED,
15 show_version_flag = LOWERED;
23 memory_in_megabytes = DEFAULT_TEST_MEMORY_IN_MEGABYTES;
25 struct lfds700_list_asu_state
26 list_of_logical_processors;
28 struct util_cmdline_state
31 union util_cmdline_arg_data
35 assert( argv != NULL );
37 lfds700_misc_library_init_valid_on_current_logical_core();
39 util_cmdline_init( &cs );
41 util_cmdline_add_arg( &cs, 'h', LIBCOMMON_CMDLINE_ARG_TYPE_FLAG );
42 util_cmdline_add_arg( &cs, 'i', LIBCOMMON_CMDLINE_ARG_TYPE_INTEGER );
43 util_cmdline_add_arg( &cs, 'm', LIBCOMMON_CMDLINE_ARG_TYPE_INTEGER );
44 util_cmdline_add_arg( &cs, 'r', LIBCOMMON_CMDLINE_ARG_TYPE_FLAG );
45 util_cmdline_add_arg( &cs, 'v', LIBCOMMON_CMDLINE_ARG_TYPE_FLAG );
47 rv = util_cmdline_process_args( &cs, argc, argv );
50 show_error_flag = RAISED;
54 util_cmdline_get_arg_data( &cs, 'h', &arg_data );
55 if( arg_data != NULL )
56 show_help_flag = RAISED;
58 util_cmdline_get_arg_data( &cs, 'i', &arg_data );
59 if( arg_data != NULL )
60 iterations = (lfds700_pal_uint_t) arg_data->integer.integer;
62 util_cmdline_get_arg_data( &cs, 'm', &arg_data );
63 if( arg_data != NULL )
64 memory_in_megabytes = (lfds700_pal_uint_t) arg_data->integer.integer;
66 util_cmdline_get_arg_data( &cs, 'r', &arg_data );
67 if( arg_data != NULL )
70 util_cmdline_get_arg_data( &cs, 'v', &arg_data );
71 if( arg_data != NULL )
72 show_version_flag = RAISED;
75 util_cmdline_cleanup( &cs );
77 if( argc == 1 or (run_flag == LOWERED and show_version_flag == LOWERED) )
78 show_help_flag = RAISED;
80 if( show_error_flag == RAISED )
82 printf( "\nInvalid arguments. Sorry - it's a simple parser, so no clues.\n"
83 "-h or run with no args to see the help text.\n" );
85 return( EXIT_SUCCESS );
88 if( show_help_flag == RAISED )
90 printf( "test -h -i [n] -m [n] -r -v\n"
92 " -i [n] : number of iterations (default : 1)\n"
93 " -m [n] : memory for tests, in mb (default : %u)\n"
94 " -r : run (causes test to run; present so no args gives help)\n"
95 " -v : version\n", DEFAULT_TEST_MEMORY_IN_MEGABYTES );
97 return( EXIT_SUCCESS );
100 if( show_version_flag == RAISED )
102 internal_show_version();
103 return( EXIT_SUCCESS );
106 if( run_flag == RAISED )
108 test_pal_get_logical_core_ids( &list_of_logical_processors );
110 for( loop = 0 ; loop < (lfds700_pal_uint_t) iterations ; loop++ )
113 "Test Iteration %02llu\n"
114 "=================\n", (int long long unsigned) (loop+1) );
116 test_lfds700_pal_atomic( &list_of_logical_processors, memory_in_megabytes );
117 test_lfds700_btree_au( &list_of_logical_processors, memory_in_megabytes );
118 test_lfds700_freelist( &list_of_logical_processors, memory_in_megabytes );
119 test_lfds700_hash_a( &list_of_logical_processors, memory_in_megabytes );
120 test_lfds700_list_aos( &list_of_logical_processors, memory_in_megabytes );
121 test_lfds700_list_asu( &list_of_logical_processors, memory_in_megabytes );
122 test_lfds700_queue( &list_of_logical_processors, memory_in_megabytes );
123 test_lfds700_queue_bss( &list_of_logical_processors );
124 test_lfds700_ringbuffer( &list_of_logical_processors, memory_in_megabytes );
125 test_lfds700_stack( &list_of_logical_processors, memory_in_megabytes );
128 lfds700_list_asu_cleanup( &list_of_logical_processors, internal_logical_core_id_element_cleanup_callback );
131 lfds700_misc_library_cleanup();
133 return( EXIT_SUCCESS );