00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00050 #include <string.h>
00051
00052 #include "ipsec/util.h"
00053 #include "ipsec/debug.h"
00054 #include "testing/structural/structural_test.h"
00055
00059 int test_ipsec_inet_addr(void)
00060 {
00061 int local_error_count = 0 ;
00062 unsigned long ipsec_inet_address ;
00063
00064 ipsec_inet_address = ipsec_inet_addr("192.168.100.100") ;
00065 if(ipsec_inet_address != 0x6464A8C0)
00066 {
00067 local_error_count++ ;
00068 IPSEC_LOG_TST("test_ipsec_inet_addr", "FAILURE", ("192.168.100.100 was not properly converted to network order")) ;
00069 }
00070
00071 ipsec_inet_address = ipsec_inet_addr("255.255.255.255") ;
00072 if(ipsec_inet_address != 0xFFFFFFFF)
00073 {
00074 local_error_count++ ;
00075 IPSEC_LOG_TST("test_ipsec_inet_addr", "FAILURE", ("255.255.255.255 was not properly converted to network order")) ;
00076 }
00077
00078
00079 ipsec_inet_address = ipsec_inet_addr("255.0.0.0") ;
00080 if(ipsec_inet_address != 0x000000FF)
00081 {
00082 local_error_count++ ;
00083 IPSEC_LOG_TST("test_ipsec_inet_addr", "FAILURE", ("255.255.0.0 was not properly converted to network order")) ;
00084 }
00085
00086
00087 ipsec_inet_address = ipsec_inet_addr("192.168.1.2") ;
00088 if(ipsec_inet_address != 0x0201A8C0)
00089 {
00090 local_error_count++ ;
00091 IPSEC_LOG_TST("test_ipsec_inet_addr", "FAILURE", ("192.168.1.2 was not properly converted to network order")) ;
00092 }
00093
00094
00095 ipsec_inet_address = ipsec_inet_addr("1.2.3.4") ;
00096 if(ipsec_inet_address != 0x04030201)
00097 {
00098 local_error_count++ ;
00099 IPSEC_LOG_TST("test_ipsec_inet_addr", "FAILURE", ("1.2.3.4 was not properly converted to network order")) ;
00100 }
00101
00102
00103 ipsec_inet_address = ipsec_inet_addr("1.2.3.100") ;
00104 if(ipsec_inet_address != 0x64030201)
00105 {
00106 local_error_count++ ;
00107 IPSEC_LOG_TST("test_ipsec_inet_addr", "FAILURE", ("1.2.3.100 was not properly converted to network order")) ;
00108 }
00109
00110 return local_error_count ;
00111 }
00112
00117 void util_debug_test(test_result *global_results)
00118 {
00119 test_result sub_results = {
00120 6,
00121 1,
00122 0,
00123 0,
00124 };
00125
00126 int retcode;
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 IPSEC_LOG_TST("test_debug", "NOTE", ("These text printing macros have no particular test"));
00144
00145 retcode = test_ipsec_inet_addr() ;
00146 IPSEC_TESTING_EVALUATE(retcode, sub_results, "test_util_ipsec_inet_addr()", (" "));
00147
00148
00149
00150 global_results->tests += sub_results.tests;
00151 global_results->functions += sub_results.functions;
00152 global_results->errors += sub_results.errors;
00153 global_results->notimplemented += sub_results.notimplemented;
00154 }
00155
00156
00157
00158
00159