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