embedded IPsec source code documentation


main.c

Go to the documentation of this file.
00001 /*
00002  * embedded IPsec
00003  * Copyright (c) 2003 Niklaus Schild and Christian Scheurer, HTI Biel/Bienne
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without modification,
00007  * are permitted provided that the following conditions are met:
00008  *
00009  * 1. Redistributions of source code must retain the above copyright notice,
00010  *    this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright notice,
00012  *    this list of conditions and the following disclaimer in the documentation
00013  *    and/or other materials provided with the distribution.
00014  * 3. The name of the author may not be used to endorse or promote products
00015  *    derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00018  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00019  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
00020  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00021  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00022  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00023  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00024  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00025  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00026  * OF SUCH DAMAGE.
00027  *
00028  */
00029 
00063 #include "testing/structural/structural_test.h"
00064 #include "ipsec/debug.h"
00065 #include "ipsec/util.h"
00066 
00067 extern void serinit(void) ;
00068 
00069 /* declare all test functions here */
00070 extern void util_debug_test(test_result *);
00071 extern void des_test(test_result *);
00072 extern void md5_test(test_result *);
00073 extern void sha1_test(test_result *);
00074 extern void sa_test(test_result *) ;
00075 extern void ah_test(test_result *) ;
00076 extern void esp_test(test_result *) ;
00077 
00078 typedef struct test_set_struct
00079 {
00080         void (*function)(test_result *);        
00081         char *name ;                                            
00082 } test_set;
00083 
00084 test_set test_function_set[] = 
00085 {
00086                         { util_debug_test,      "util_debug_test"       },
00087                         { des_test,             "des_test"                      },
00088                         { md5_test,             "md5_test"                      }, 
00089                         { sha1_test,            "sha1_test"                     },
00090                         { sa_test,                      "sa_test"                       },
00091                         { ah_test,                      "ah_test"                       },
00092                         { esp_test,                     "esp_test"                      }
00093 } ;
00094 
00095 #define NR_OF_TESTFUNCTIONS sizeof(test_function_set)/sizeof(test_set) 
00103 void main(void)
00104 {
00105         int                     i ;
00106         float                   percents;
00107 
00108         test_result     global_results  = {0, 0, 0, 0};
00109         
00110 #ifdef SIMULATOR
00111         serinit();
00112 #endif
00113 
00114 
00115         IPSEC_LOG_MSG("main", (" ")) ;
00116         IPSEC_LOG_MSG("main", ("structural testing started")) ;
00117         IPSEC_LOG_MSG("main", ("compiled on %s at %s", __DATE__, __TIME__)) ;
00118         IPSEC_LOG_MSG("main", ("CVS ID: $Id: main_8c-source.html,v 1.4 2003/12/12 13:10:33 schec2 Exp $\n")) ;
00119 
00120         /* loop and execute all test functions */
00121         for (i = 0; i < NR_OF_TESTFUNCTIONS; i++)
00122         {
00123                 test_function_set[i].function((test_result *)&global_results);
00124                 printf("\n");
00125         }
00126 
00127         printf("\n");
00128         IPSEC_LOG_MSG("main", ("structural testing finished:")) ;
00129 
00130         percents = 100.00;
00131         if(global_results.tests > 0) {
00132                 percents = 100.00*(1.00-((float)global_results.errors/(float)global_results.tests));
00133         }
00134         IPSEC_LOG_MSG("main", (" o %6.2f%% correct  (%d of %d tests passed)", percents, (global_results.tests-global_results.errors), global_results.tests));
00135 
00136         percents = 100.00;
00137         if(global_results.functions > 0) {
00138                 percents = 100.00*(1.00-((float)global_results.notimplemented/(float)global_results.functions));
00139         }
00140         IPSEC_LOG_MSG("main", (" o %6.2f%% complete (%d of %d functions implemented)", percents, (global_results.functions-global_results.notimplemented), global_results.functions));
00141         
00142         while(1) ;
00143 
00144   return ;
00145 }
00146 
00147 

Copyright 2003 by Christian Scheurer and Niklaus Schild