unit.c

Go to the documentation of this file.
00001 
00007 #include <stdlib.h>
00008 #include <stdio.h>
00009 
00010 #define PROFILE
00011 #include "unit.h"
00012 #include "ctl/mstime.h"
00013 #include "ctl/dir.h"
00014 #include "ctl/mmap.h"
00015 #include "ctl/ctlstring.h"
00016 
00017 int error_count = 0;    
00018 static int mArgc;
00019 static const char* const * mArgv;
00020 
00021 /* Bring in extern unit definitions */
00022 void Test_Dir(void);
00023 void Test_UnitShifts(void);
00024 void Test_Malloc(void);
00025 void Test_strings(void);
00026 void Test_sconst(void);
00027 void Test_mstring(void);
00028 void Test_FIFO(void);
00029 void Test_LIFO(void);
00030 void Test_BLIB(void);
00031 void Test_SLL(void);
00032 void Test_DLL(void);
00033 void Test_Tree(void);
00034 void Test_MMAp(void);
00035 void Test_XMLReader(void);
00036 void Test_ppRand(void);
00037 void Test_DatagenContainers(void);
00038 void Test_DatagenCopy(void);
00039 void Test_DatagenSerial(void);
00040 void Test_DatagenRecord(void);
00041 void Test_DatagenXML(void);
00042 void Test_OPC(void);
00043 void Test_RingBuff(void);
00044 void Test_Except(void);
00045 
00046 int main( int argc, const char** argv )
00047 {
00048     int repeat = 1;
00049     int crepeat;
00050     srand(ctl_ustime());
00051     ctl_profile_begin(Total,"All Tests");
00052     atexit(ctl_profiles_dump);
00053     mArgc = argc;
00054     mArgv = argv;
00055     {
00056         int found = arg_find( "-r", 2 );
00057         if( found )
00058         {
00059             repeat = atoi(arg_get(found)+2);
00060             if( !repeat )
00061                 repeat = atoi(arg_get(found+1));
00062             if( !repeat )
00063                 repeat = 2;
00064         }
00065     }
00066     crepeat = repeat;
00067     while( crepeat-- )
00068     {
00069         ctl_profile_counter_begin(ItsPerSecond,"Average test set loops per second",0);
00070 
00071         /* Invoke units - comment some out for profiling */
00072         UNIT_TEST(Test_UnitShifts);
00073         UNIT_TEST(Test_Dir);
00074         UNIT_TEST(Test_Malloc);
00075         UNIT_TEST(Test_strings);
00076         UNIT_TEST(Test_sconst);
00077         UNIT_TEST(Test_mstring);
00078         UNIT_TEST(Test_FIFO);
00079         UNIT_TEST(Test_LIFO);
00080         UNIT_TEST(Test_BLIB);
00081         UNIT_TEST(Test_SLL);
00082         UNIT_TEST(Test_DLL);
00083         UNIT_TEST(Test_Tree);
00084         UNIT_TEST(Test_MMAp);
00085         UNIT_TEST(Test_XMLReader);
00086         UNIT_TEST(Test_ppRand);
00087         UNIT_TEST(Test_OPC);
00088         UNIT_TEST(Test_RingBuff);
00089         UNIT_TEST(Test_Except);
00090         UNIT_TEST(Test_DatagenContainers);
00091         UNIT_TEST(Test_DatagenCopy);
00092         UNIT_TEST(Test_DatagenSerial);
00093         UNIT_TEST(Test_DatagenRecord);
00094         UNIT_TEST(Test_DatagenXML);
00095         ctl_profile_counter_end(ItsPerSecond);
00096     }
00097     ctl_profile_end(Total);
00098     ctl_destroy_all_pools();
00099     Test_Error( 0 == ctl_pool_dump(LOG_ERROR) );
00100     Test_Error( 0 == ctl_memory_dump(LOG_ERROR) );
00101     return 0 != error_count;
00102 }
00103 
00110 int arg_find( const char* sz, size_t len )
00111 {
00112     int curr;
00113     for ( curr = 1; curr < mArgc; ++curr )
00114     {
00115         if ( 0 == len )
00116         {
00117             if( !cstrcmp(char)( mArgv[curr], sz ) )
00118                 return curr;
00119         }
00120         else 
00121         {
00122             if ( !cstrncmp(char)( mArgv[curr], sz, len ) )
00123                 return curr;
00124         }
00125     }
00126     return 0;
00127 }
00128 
00134 int arg_count( void )
00135 {
00136     return mArgc;
00137 }
00138 
00144 const char* arg_get( int index )
00145 {
00146     if( index < 0 || index > mArgc )
00147         return "";
00148     return mArgv[index];
00149 }

Generated on Fri Jan 2 15:28:35 2009 for Squat by  doxygen 1.5.6