]> pd.if.org Git - liblfds/blob - liblfds/liblfds6.0.1/test/src/main.c
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds6.0.1 / test / src / main.c
1 #include "internal.h"\r
2 \r
3 \r
4 \r
5 \r
6 \r
7 /****************************************************************************/\r
8 int main( int argc, char **argv )\r
9 {\r
10   enum lfds601_test_operation\r
11     operation = UNKNOWN;\r
12 \r
13   unsigned int\r
14     loop,\r
15     iterations = 1;\r
16 \r
17   assert( argc >= 1 );\r
18   assert( argv != NULL );\r
19 \r
20   if( argc == 1 or argc >= 4 )\r
21     operation = HELP;\r
22 \r
23   if( operation == UNKNOWN )\r
24   {\r
25     if( 0 == strcmp(*(argv+1), "test") )\r
26     {\r
27       operation = TEST;\r
28 \r
29       // TRD : sscanf() may fail, but iterations is initialised to 1, so it's okay\r
30       if( argc == 3 )\r
31         sscanf( *(argv+2), "%u", &iterations );\r
32     }\r
33 \r
34     if( 0 == strcmp(*(argv+1), "benchmark") )\r
35       operation = BENCHMARK;\r
36   }\r
37 \r
38   switch( operation )\r
39   {\r
40     case UNKNOWN:\r
41     case HELP:\r
42       printf( "test [test|benchmark] [iterations]\n"\r
43               "  test       : run the test suite\n"\r
44               "  benchmark  : run the benchmark suite\n"\r
45               "  iterations : optional, only applies to tests, default is 1\n" );\r
46     break;\r
47 \r
48     case TEST:\r
49       for( loop = 1 ; loop < iterations+1 ; loop++ )\r
50       {\r
51         printf( "\n"\r
52                 "Test Iteration %02u\n"\r
53                 "=================\n", loop );\r
54 \r
55         test_lfds601_abstraction();\r
56         test_lfds601_freelist();\r
57         test_lfds601_queue();\r
58         test_lfds601_ringbuffer();\r
59         test_lfds601_slist();\r
60         test_lfds601_stack();\r
61       }\r
62     break;\r
63 \r
64     case BENCHMARK:\r
65       benchmark_lfds601_freelist();\r
66       benchmark_lfds601_queue();\r
67       benchmark_lfds601_ringbuffer();\r
68       benchmark_lfds601_stack();\r
69     break;\r
70   }\r
71 \r
72   return( EXIT_SUCCESS );\r
73 }\r
74 \r