Changes in uspace/srv/net/self_test.c [21580dd:aadf01e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/self_test.c
r21580dd raadf01e 57 57 * @param[in] result The expected result. 58 58 */ 59 #define TEST( name, function_call, result); { \60 printf( "\n\t%s", ( name)); \61 if(( function_call ) != ( result)){ \62 printf( "\tERROR\n"); \59 #define TEST(name, function_call, result); { \ 60 printf("\n\t%s", (name)); \ 61 if((function_call) != (result)){ \ 62 printf("\tERROR\n"); \ 63 63 error = 1; \ 64 64 }else{ \ 65 printf( "\tOK\n"); \65 printf("\tOK\n"); \ 66 66 } \ 67 67 } … … 69 69 #if NET_SELF_TEST_INT_MAP 70 70 71 INT_MAP_DECLARE( int_map, int);72 73 INT_MAP_IMPLEMENT( int_map, int);71 INT_MAP_DECLARE(int_map, int); 72 73 INT_MAP_IMPLEMENT(int_map, int); 74 74 75 75 #endif … … 77 77 #if NET_SELF_TEST_GENERIC_FIELD 78 78 79 GENERIC_FIELD_DECLARE( int_field, int)80 81 GENERIC_FIELD_IMPLEMENT( int_field, int)79 GENERIC_FIELD_DECLARE(int_field, int) 80 81 GENERIC_FIELD_IMPLEMENT(int_field, int) 82 82 83 83 #endif … … 85 85 #if NET_SELF_TEST_GENERIC_CHAR_MAP 86 86 87 GENERIC_CHAR_MAP_DECLARE( int_char_map, int ) 88 89 GENERIC_CHAR_MAP_IMPLEMENT( int_char_map, int ) 90 91 #endif 92 93 int self_test( void ){ 94 int error = 0; 95 int * x, * y, * z, * u, * v, * w; 87 GENERIC_CHAR_MAP_DECLARE(int_char_map, int) 88 89 GENERIC_CHAR_MAP_IMPLEMENT(int_char_map, int) 90 91 #endif 92 93 int self_test(void){ 94 int error; 95 int * x; 96 int * y; 97 int * z; 98 int * u; 99 int * v; 100 int * w; 101 102 error = 0; 96 103 97 104 #if NET_SELF_TEST_MEASURED_STRINGS 98 measured_string_ref 99 100 printf( "\nMeasured strings test");101 string = measured_string_create_bulk( "I am a measured string!", 0);102 printf( "\n%x, %s at %x of %d", string, string->value, string->value, string->length);103 printf( "\nOK");105 measured_string_ref string; 106 107 printf("\nMeasured strings test"); 108 string = measured_string_create_bulk("I am a measured string!", 0); 109 printf("\n%x, %s at %x of %d", string, string->value, string->value, string->length); 110 printf("\nOK"); 104 111 #endif 105 112 106 113 #if NET_SELF_TEST_CHAR_MAP 107 char_map_t cm; 108 109 printf( "\nChar map test" ); 110 TEST( "update ucho 3 einval", char_map_update( & cm, "ucho", 0, 3 ), EINVAL ); 111 TEST( "initialize", char_map_initialize( & cm ), EOK ); 112 TEST( "exclude bla null", char_map_exclude( & cm, "bla", 0 ), CHAR_MAP_NULL ); 113 TEST( "find bla null", char_map_find( & cm, "bla", 0 ), CHAR_MAP_NULL ); 114 TEST( "add bla 1 eok", char_map_add( & cm, "bla", 0, 1 ), EOK ); 115 TEST( "find bla 1", char_map_find( & cm, "bla", 0 ), 1 ); 116 TEST( "add bla 10 eexists", char_map_add( & cm, "bla", 0, 10 ), EEXISTS ); 117 TEST( "update bla 2 eok", char_map_update( & cm, "bla", 0, 2 ), EOK ); 118 TEST( "find bla 2", char_map_find( & cm, "bla", 0 ), 2 ); 119 TEST( "update ucho 2 eok", char_map_update( & cm, "ucho", 0, 2 ), EOK ); 120 TEST( "exclude bla 2", char_map_exclude( & cm, "bla", 0 ), 2 ); 121 TEST( "exclude bla null", char_map_exclude( & cm, "bla", 0 ), CHAR_MAP_NULL ); 122 TEST( "find ucho 2", char_map_find( & cm, "ucho", 0 ), 2 ); 123 TEST( "update ucho 3 eok", char_map_update( & cm, "ucho", 0, 3 ), EOK ); 124 TEST( "find ucho 3", char_map_find( & cm, "ucho", 0 ), 3 ); 125 TEST( "add blabla 5 eok", char_map_add( & cm, "blabla", 0, 5 ), EOK ); 126 TEST( "find blabla 5", char_map_find( & cm, "blabla", 0 ), 5 ); 127 TEST( "add bla 6 eok", char_map_add( & cm, "bla", 0, 6 ), EOK ); 128 TEST( "find bla 6", char_map_find( & cm, "bla", 0 ), 6 ); 129 TEST( "exclude bla 6", char_map_exclude( & cm, "bla", 0 ), 6 ); 130 TEST( "find bla null", char_map_find( & cm, "bla", 0 ), CHAR_MAP_NULL ); 131 TEST( "find blabla 5", char_map_find( & cm, "blabla", 0 ), 5 ); 132 TEST( "add auto 7 eok", char_map_add( & cm, "auto", 0, 7 ), EOK ); 133 TEST( "find auto 7", char_map_find( & cm, "auto", 0 ), 7 ); 134 TEST( "add kara 8 eok", char_map_add( & cm, "kara", 0, 8 ), EOK ); 135 TEST( "find kara 8", char_map_find( & cm, "kara", 0 ), 8 ); 136 TEST( "add nic 9 eok", char_map_add( & cm, "nic", 0, 9 ), EOK ); 137 TEST( "find nic 9", char_map_find( & cm, "nic", 0 ), 9 ); 138 TEST( "find blabla 5", char_map_find( & cm, "blabla", 0 ), 5 ); 139 TEST( "add micnicnic 5 9 eok", char_map_add( & cm, "micnicnic", 5, 9 ), EOK ); 140 TEST( "find micni 9", char_map_find( & cm, "micni", 0 ), 9 ); 141 TEST( "find micnicn 5 9", char_map_find( & cm, "micnicn", 5 ), 9 ); 142 TEST( "add 10.0.2.2 4 15 eok", char_map_add( & cm, "\x10\x0\x2\x2", 4, 15 ), EOK ); 143 TEST( "find 10.0.2.2 4 15", char_map_find( & cm, "\x10\x0\x2\x2", 4 ), 15 ); 144 printf( "\n\tdestroy" ); 145 char_map_destroy( & cm ); 146 TEST( "update ucho 3 einval", char_map_update( & cm, "ucho", 0, 3 ), EINVAL ); 147 printf( "\nOK" ); 148 149 if( error ) return EINVAL; 114 char_map_t cm; 115 116 printf("\nChar map test"); 117 TEST("update ucho 3 einval", char_map_update(&cm, "ucho", 0, 3), EINVAL); 118 TEST("initialize", char_map_initialize(&cm), EOK); 119 TEST("exclude bla null", char_map_exclude(&cm, "bla", 0), CHAR_MAP_NULL); 120 TEST("find bla null", char_map_find(&cm, "bla", 0), CHAR_MAP_NULL); 121 TEST("add bla 1 eok", char_map_add(&cm, "bla", 0, 1), EOK); 122 TEST("find bla 1", char_map_find(&cm, "bla", 0), 1); 123 TEST("add bla 10 eexists", char_map_add(&cm, "bla", 0, 10), EEXISTS); 124 TEST("update bla 2 eok", char_map_update(&cm, "bla", 0, 2), EOK); 125 TEST("find bla 2", char_map_find(&cm, "bla", 0), 2); 126 TEST("update ucho 2 eok", char_map_update(&cm, "ucho", 0, 2), EOK); 127 TEST("exclude bla 2", char_map_exclude(&cm, "bla", 0), 2); 128 TEST("exclude bla null", char_map_exclude(&cm, "bla", 0), CHAR_MAP_NULL); 129 TEST("find ucho 2", char_map_find(&cm, "ucho", 0), 2); 130 TEST("update ucho 3 eok", char_map_update(&cm, "ucho", 0, 3), EOK); 131 TEST("find ucho 3", char_map_find(&cm, "ucho", 0), 3); 132 TEST("add blabla 5 eok", char_map_add(&cm, "blabla", 0, 5), EOK); 133 TEST("find blabla 5", char_map_find(&cm, "blabla", 0), 5); 134 TEST("add bla 6 eok", char_map_add(&cm, "bla", 0, 6), EOK); 135 TEST("find bla 6", char_map_find(&cm, "bla", 0), 6); 136 TEST("exclude bla 6", char_map_exclude(&cm, "bla", 0), 6); 137 TEST("find bla null", char_map_find(&cm, "bla", 0), CHAR_MAP_NULL); 138 TEST("find blabla 5", char_map_find(&cm, "blabla", 0), 5); 139 TEST("add auto 7 eok", char_map_add(&cm, "auto", 0, 7), EOK); 140 TEST("find auto 7", char_map_find(&cm, "auto", 0), 7); 141 TEST("add kara 8 eok", char_map_add(&cm, "kara", 0, 8), EOK); 142 TEST("find kara 8", char_map_find(&cm, "kara", 0), 8); 143 TEST("add nic 9 eok", char_map_add(&cm, "nic", 0, 9), EOK); 144 TEST("find nic 9", char_map_find(&cm, "nic", 0), 9); 145 TEST("find blabla 5", char_map_find(&cm, "blabla", 0), 5); 146 TEST("add micnicnic 5 9 eok", char_map_add(&cm, "micnicnic", 5, 9), EOK); 147 TEST("find micni 9", char_map_find(&cm, "micni", 0), 9); 148 TEST("find micnicn 5 9", char_map_find(&cm, "micnicn", 5), 9); 149 TEST("add 10.0.2.2 4 15 eok", char_map_add(&cm, "\x10\x0\x2\x2", 4, 15), EOK); 150 TEST("find 10.0.2.2 4 15", char_map_find(&cm, "\x10\x0\x2\x2", 4), 15); 151 printf("\n\tdestroy"); 152 char_map_destroy(&cm); 153 TEST("update ucho 3 einval", char_map_update(&cm, "ucho", 0, 3), EINVAL); 154 printf("\nOK"); 155 156 if(error){ 157 return EINVAL; 158 } 150 159 151 160 #endif 152 161 153 162 #if NET_SELF_TEST_INT_MAP 154 int_map_t 155 156 x = ( int * ) malloc( sizeof( int));157 y = ( int * ) malloc( sizeof( int));158 z = ( int * ) malloc( sizeof( int));159 u = ( int * ) malloc( sizeof( int));160 v = ( int * ) malloc( sizeof( int));161 w = ( int * ) malloc( sizeof( int));163 int_map_t im; 164 165 x = (int *) malloc(sizeof(int)); 166 y = (int *) malloc(sizeof(int)); 167 z = (int *) malloc(sizeof(int)); 168 u = (int *) malloc(sizeof(int)); 169 v = (int *) malloc(sizeof(int)); 170 w = (int *) malloc(sizeof(int)); 162 171 163 172 im.magic = 0; 164 printf( "\nInt map test" ); 165 TEST( "add 1 x einval", int_map_add( & im, 1, x ), EINVAL ); 166 TEST( "count -1", int_map_count( & im ), -1 ); 167 TEST( "initialize", int_map_initialize( & im ), EOK ); 168 TEST( "count 0", int_map_count( & im ), 0 ); 169 TEST( "find 1 null", int_map_find( & im, 1 ), NULL ); 170 TEST( "add 1 x 0", int_map_add( & im, 1, x ), 0 ); 171 TEST( "find 1 x", int_map_find( & im, 1 ), x ); 172 int_map_exclude( & im, 1 ); 173 TEST( "find 1 null", int_map_find( & im, 1 ), NULL ); 174 TEST( "add 1 y 1", int_map_add( & im, 1, y ), 1 ); 175 TEST( "find 1 y", int_map_find( & im, 1 ), y ); 176 TEST( "add 4 z 2", int_map_add( & im, 4, z ), 2 ); 177 TEST( "get 2 z", int_map_get_index( & im, 2 ), z ); 178 TEST( "find 4 z", int_map_find( & im, 4 ), z ); 179 TEST( "find 1 y", int_map_find( & im, 1 ), y ); 180 TEST( "count 3", int_map_count( & im ), 3 ); 181 TEST( "add 2 u 3", int_map_add( & im, 2, u ), 3 ); 182 TEST( "find 2 u", int_map_find( & im, 2 ), u ); 183 TEST( "add 3 v 4", int_map_add( & im, 3, v ), 4 ); 184 TEST( "find 3 v", int_map_find( & im, 3 ), v ); 185 TEST( "get 4 v", int_map_get_index( & im, 4 ), v ); 186 TEST( "add 6 w 5", int_map_add( & im, 6, w ), 5 ); 187 TEST( "find 6 w", int_map_find( & im, 6 ), w ); 188 TEST( "count 6", int_map_count( & im ), 6 ); 189 int_map_exclude( & im, 1 ); 190 TEST( "find 1 null", int_map_find( & im, 1 ), NULL ); 191 TEST( "find 2 u", int_map_find( & im, 2 ), u ); 192 int_map_exclude( & im, 7 ); 193 TEST( "find 2 u", int_map_find( & im, 2 ), u ); 194 TEST( "find 6 w", int_map_find( & im, 6 ), w ); 195 int_map_exclude_index( & im, 4 ); 196 TEST( "get 4 null", int_map_get_index( & im, 4 ), NULL ); 197 TEST( "find 3 null", int_map_find( & im, 3 ), NULL ); 198 printf( "\n\tdestroy" ); 199 int_map_destroy( & im ); 200 TEST( "count -1", int_map_count( & im ), -1 ); 201 printf( "\nOK" ); 202 203 if( error ) return EINVAL; 173 printf("\nInt map test"); 174 TEST("add 1 x einval", int_map_add(&im, 1, x), EINVAL); 175 TEST("count -1", int_map_count(&im), -1); 176 TEST("initialize", int_map_initialize(&im), EOK); 177 TEST("count 0", int_map_count(&im), 0); 178 TEST("find 1 null", int_map_find(&im, 1), NULL); 179 TEST("add 1 x 0", int_map_add(&im, 1, x), 0); 180 TEST("find 1 x", int_map_find(&im, 1), x); 181 int_map_exclude(&im, 1); 182 TEST("find 1 null", int_map_find(&im, 1), NULL); 183 TEST("add 1 y 1", int_map_add(&im, 1, y), 1); 184 TEST("find 1 y", int_map_find(&im, 1), y); 185 TEST("add 4 z 2", int_map_add(&im, 4, z), 2); 186 TEST("get 2 z", int_map_get_index(&im, 2), z); 187 TEST("find 4 z", int_map_find(&im, 4), z); 188 TEST("find 1 y", int_map_find(&im, 1), y); 189 TEST("count 3", int_map_count(&im), 3); 190 TEST("add 2 u 3", int_map_add(&im, 2, u), 3); 191 TEST("find 2 u", int_map_find(&im, 2), u); 192 TEST("add 3 v 4", int_map_add(&im, 3, v), 4); 193 TEST("find 3 v", int_map_find(&im, 3), v); 194 TEST("get 4 v", int_map_get_index(&im, 4), v); 195 TEST("add 6 w 5", int_map_add(&im, 6, w), 5); 196 TEST("find 6 w", int_map_find(&im, 6), w); 197 TEST("count 6", int_map_count(&im), 6); 198 int_map_exclude(&im, 1); 199 TEST("find 1 null", int_map_find(&im, 1), NULL); 200 TEST("find 2 u", int_map_find(&im, 2), u); 201 int_map_exclude(&im, 7); 202 TEST("find 2 u", int_map_find(&im, 2), u); 203 TEST("find 6 w", int_map_find(&im, 6), w); 204 int_map_exclude_index(&im, 4); 205 TEST("get 4 null", int_map_get_index(&im, 4), NULL); 206 TEST("find 3 null", int_map_find(&im, 3), NULL); 207 printf("\n\tdestroy"); 208 int_map_destroy(&im); 209 TEST("count -1", int_map_count(&im), -1); 210 printf("\nOK"); 211 212 if(error){ 213 return EINVAL; 214 } 204 215 205 216 #endif 206 217 207 218 #if NET_SELF_TEST_GENERIC_FIELD 208 int_field_t 209 210 x = ( int * ) malloc( sizeof( int));211 y = ( int * ) malloc( sizeof( int));212 z = ( int * ) malloc( sizeof( int));213 u = ( int * ) malloc( sizeof( int));214 v = ( int * ) malloc( sizeof( int));215 w = ( int * ) malloc( sizeof( int));219 int_field_t gf; 220 221 x = (int *) malloc(sizeof(int)); 222 y = (int *) malloc(sizeof(int)); 223 z = (int *) malloc(sizeof(int)); 224 u = (int *) malloc(sizeof(int)); 225 v = (int *) malloc(sizeof(int)); 226 w = (int *) malloc(sizeof(int)); 216 227 217 228 gf.magic = 0; 218 printf( "\nGeneric field test" ); 219 TEST( "add x einval", int_field_add( & gf, x ), EINVAL ); 220 TEST( "count -1", int_field_count( & gf ), -1 ); 221 TEST( "initialize", int_field_initialize( & gf ), EOK ); 222 TEST( "count 0", int_field_count( & gf ), 0 ); 223 TEST( "get 1 null", int_field_get_index( & gf, 1 ), NULL ); 224 TEST( "add x 0", int_field_add( & gf, x ), 0 ); 225 TEST( "get 0 x", int_field_get_index( & gf, 0 ), x ); 226 int_field_exclude_index( & gf, 0 ); 227 TEST( "get 0 null", int_field_get_index( & gf, 0 ), NULL ); 228 TEST( "add y 1", int_field_add( & gf, y ), 1 ); 229 TEST( "get 1 y", int_field_get_index( & gf, 1 ), y ); 230 TEST( "add z 2", int_field_add( & gf, z ), 2 ); 231 TEST( "get 2 z", int_field_get_index( & gf, 2 ), z ); 232 TEST( "get 1 y", int_field_get_index( & gf, 1 ), y ); 233 TEST( "count 3", int_field_count( & gf ), 3 ); 234 TEST( "add u 3", int_field_add( & gf, u ), 3 ); 235 TEST( "get 3 u", int_field_get_index( & gf, 3 ), u ); 236 TEST( "add v 4", int_field_add( & gf, v ), 4 ); 237 TEST( "get 4 v", int_field_get_index( & gf, 4 ), v ); 238 TEST( "add w 5", int_field_add( & gf, w ), 5 ); 239 TEST( "get 5 w", int_field_get_index( & gf, 5 ), w ); 240 TEST( "count 6", int_field_count( & gf ), 6 ); 241 int_field_exclude_index( & gf, 1 ); 242 TEST( "get 1 null", int_field_get_index( & gf, 1 ), NULL ); 243 TEST( "get 3 u", int_field_get_index( & gf, 3 ), u ); 244 int_field_exclude_index( & gf, 7 ); 245 TEST( "get 3 u", int_field_get_index( & gf, 3 ), u ); 246 TEST( "get 5 w", int_field_get_index( & gf, 5 ), w ); 247 int_field_exclude_index( & gf, 4 ); 248 TEST( "get 4 null", int_field_get_index( & gf, 4 ), NULL ); 249 printf( "\n\tdestroy" ); 250 int_field_destroy( & gf ); 251 TEST( "count -1", int_field_count( & gf ), -1 ); 252 printf( "\nOK" ); 253 254 if( error ) return EINVAL; 229 printf("\nGeneric field test"); 230 TEST("add x einval", int_field_add(&gf, x), EINVAL); 231 TEST("count -1", int_field_count(&gf), -1); 232 TEST("initialize", int_field_initialize(&gf), EOK); 233 TEST("count 0", int_field_count(&gf), 0); 234 TEST("get 1 null", int_field_get_index(&gf, 1), NULL); 235 TEST("add x 0", int_field_add(&gf, x), 0); 236 TEST("get 0 x", int_field_get_index(&gf, 0), x); 237 int_field_exclude_index(&gf, 0); 238 TEST("get 0 null", int_field_get_index(&gf, 0), NULL); 239 TEST("add y 1", int_field_add(&gf, y), 1); 240 TEST("get 1 y", int_field_get_index(&gf, 1), y); 241 TEST("add z 2", int_field_add(&gf, z), 2); 242 TEST("get 2 z", int_field_get_index(&gf, 2), z); 243 TEST("get 1 y", int_field_get_index(&gf, 1), y); 244 TEST("count 3", int_field_count(&gf), 3); 245 TEST("add u 3", int_field_add(&gf, u), 3); 246 TEST("get 3 u", int_field_get_index(&gf, 3), u); 247 TEST("add v 4", int_field_add(&gf, v), 4); 248 TEST("get 4 v", int_field_get_index(&gf, 4), v); 249 TEST("add w 5", int_field_add(&gf, w), 5); 250 TEST("get 5 w", int_field_get_index(&gf, 5), w); 251 TEST("count 6", int_field_count(&gf), 6); 252 int_field_exclude_index(&gf, 1); 253 TEST("get 1 null", int_field_get_index(&gf, 1), NULL); 254 TEST("get 3 u", int_field_get_index(&gf, 3), u); 255 int_field_exclude_index(&gf, 7); 256 TEST("get 3 u", int_field_get_index(&gf, 3), u); 257 TEST("get 5 w", int_field_get_index(&gf, 5), w); 258 int_field_exclude_index(&gf, 4); 259 TEST("get 4 null", int_field_get_index(&gf, 4), NULL); 260 printf("\n\tdestroy"); 261 int_field_destroy(&gf); 262 TEST("count -1", int_field_count(&gf), -1); 263 printf("\nOK"); 264 265 if(error){ 266 return EINVAL; 267 } 255 268 256 269 #endif 257 270 258 271 #if NET_SELF_TEST_GENERIC_CHAR_MAP 259 int_char_map_t 260 261 x = ( int * ) malloc( sizeof( int));262 y = ( int * ) malloc( sizeof( int));263 z = ( int * ) malloc( sizeof( int));264 u = ( int * ) malloc( sizeof( int));265 v = ( int * ) malloc( sizeof( int));266 w = ( int * ) malloc( sizeof( int));272 int_char_map_t icm; 273 274 x = (int *) malloc(sizeof(int)); 275 y = (int *) malloc(sizeof(int)); 276 z = (int *) malloc(sizeof(int)); 277 u = (int *) malloc(sizeof(int)); 278 v = (int *) malloc(sizeof(int)); 279 w = (int *) malloc(sizeof(int)); 267 280 268 281 icm.magic = 0; 269 printf( "\nGeneric char map test" ); 270 TEST( "add ucho z einval", int_char_map_add( & icm, "ucho", 0, z ), EINVAL ); 271 TEST( "initialize", int_char_map_initialize( & icm ), EOK ); 272 printf( "\n\texclude bla null" ); 273 int_char_map_exclude( & icm, "bla", 0 ); 274 TEST( "find bla null", int_char_map_find( & icm, "bla", 0 ), NULL ); 275 TEST( "add bla x eok", int_char_map_add( & icm, "bla", 0, x ), EOK ); 276 TEST( "find bla x", int_char_map_find( & icm, "bla", 0 ), x ); 277 TEST( "add bla y eexists", int_char_map_add( & icm, "bla", 0, y ), EEXISTS ); 278 printf( "\n\texclude bla y" ); 279 int_char_map_exclude( & icm, "bla", 0 ); 280 printf( "\n\texclude bla null" ); 281 int_char_map_exclude( & icm, "bla", 0 ); 282 TEST( "add blabla v eok", int_char_map_add( & icm, "blabla", 0, v ), EOK ); 283 TEST( "find blabla v", int_char_map_find( & icm, "blabla", 0 ), v ); 284 TEST( "add bla w eok", int_char_map_add( & icm, "bla", 0, w ), EOK ); 285 TEST( "find bla w", int_char_map_find( & icm, "bla", 0 ), w ); 286 printf( "\n\texclude bla" ); 287 int_char_map_exclude( & icm, "bla", 0 ); 288 TEST( "find bla null", int_char_map_find( & icm, "bla", 0 ), NULL ); 289 TEST( "find blabla v", int_char_map_find( & icm, "blabla", 0 ), v ); 290 TEST( "add auto u eok", int_char_map_add( & icm, "auto", 0, u ), EOK ); 291 TEST( "find auto u", int_char_map_find( & icm, "auto", 0 ), u ); 292 printf( "\n\tdestroy" ); 293 int_char_map_destroy( & icm ); 294 TEST( "add ucho z einval", int_char_map_add( & icm, "ucho", 0, z ), EINVAL ); 295 printf( "\nOK" ); 296 297 if( error ) return EINVAL; 282 printf("\nGeneric char map test"); 283 TEST("add ucho z einval", int_char_map_add(&icm, "ucho", 0, z), EINVAL); 284 TEST("initialize", int_char_map_initialize(&icm), EOK); 285 printf("\n\texclude bla null"); 286 int_char_map_exclude(&icm, "bla", 0); 287 TEST("find bla null", int_char_map_find(&icm, "bla", 0), NULL); 288 TEST("add bla x eok", int_char_map_add(&icm, "bla", 0, x), EOK); 289 TEST("find bla x", int_char_map_find(&icm, "bla", 0), x); 290 TEST("add bla y eexists", int_char_map_add(&icm, "bla", 0, y), EEXISTS); 291 printf("\n\texclude bla y"); 292 int_char_map_exclude(&icm, "bla", 0); 293 printf("\n\texclude bla null"); 294 int_char_map_exclude(&icm, "bla", 0); 295 TEST("add blabla v eok", int_char_map_add(&icm, "blabla", 0, v), EOK); 296 TEST("find blabla v", int_char_map_find(&icm, "blabla", 0), v); 297 TEST("add bla w eok", int_char_map_add(&icm, "bla", 0, w), EOK); 298 TEST("find bla w", int_char_map_find(&icm, "bla", 0), w); 299 printf("\n\texclude bla"); 300 int_char_map_exclude(&icm, "bla", 0); 301 TEST("find bla null", int_char_map_find(&icm, "bla", 0), NULL); 302 TEST("find blabla v", int_char_map_find(&icm, "blabla", 0), v); 303 TEST("add auto u eok", int_char_map_add(&icm, "auto", 0, u), EOK); 304 TEST("find auto u", int_char_map_find(&icm, "auto", 0), u); 305 printf("\n\tdestroy"); 306 int_char_map_destroy(&icm); 307 TEST("add ucho z einval", int_char_map_add(&icm, "ucho", 0, z), EINVAL); 308 printf("\nOK"); 309 310 if(error){ 311 return EINVAL; 312 } 298 313 299 314 #endif 300 315 301 316 #if NET_SELF_TEST_CRC 302 uint32_t value; 303 304 printf( "\nCRC computation test" ); 305 value = ~ compute_crc32( ~ 0, "123456789", 8 * 9 ); 306 TEST( "123456789", value, 0xCBF43926 ); 307 printf( "\t=> %X", value ); 308 value = ~ compute_crc32( ~ 0, "1", 8 ); 309 TEST( "1", value, 0x83DCEFB7 ); 310 printf( "\t=> %X", value ); 311 value = ~ compute_crc32( ~ 0, "12", 8 * 2 ); 312 TEST( "12", value, 0x4F5344CD ); 313 printf( "\t=> %X", value ); 314 value = ~ compute_crc32( ~ 0, "123", 8 * 3 ); 315 TEST( "123", value, 0x884863D2 ); 316 printf( "\t=> %X", value ); 317 value = ~ compute_crc32( ~ 0, "1234", 8 * 4 ); 318 TEST( "1234", value, 0x9BE3E0A3 ); 319 printf( "\t=> %X", value ); 320 value = ~ compute_crc32( ~ 0, "12345678", 8 * 8 ); 321 TEST( "12345678", value, 0x9AE0DAAF ); 322 printf( "\t=> %X", value ); 323 value = ~ compute_crc32( ~ 0, "ahoj pane", 8 * 9 ); 324 TEST( "ahoj pane", value, 0x5FC3D706 ); 325 printf( "\t=> %X", value ); 326 327 if( error ) return EINVAL; 317 uint32_t value; 318 319 printf("\nCRC computation test"); 320 value = ~ compute_crc32(~ 0, "123456789", 8 * 9); 321 TEST("123456789", value, 0xCBF43926); 322 printf("\t=> %X", value); 323 value = ~ compute_crc32(~ 0, "1", 8); 324 TEST("1", value, 0x83DCEFB7); 325 printf("\t=> %X", value); 326 value = ~ compute_crc32(~ 0, "12", 8 * 2); 327 TEST("12", value, 0x4F5344CD); 328 printf("\t=> %X", value); 329 value = ~ compute_crc32(~ 0, "123", 8 * 3); 330 TEST("123", value, 0x884863D2); 331 printf("\t=> %X", value); 332 value = ~ compute_crc32(~ 0, "1234", 8 * 4); 333 TEST("1234", value, 0x9BE3E0A3); 334 printf("\t=> %X", value); 335 value = ~ compute_crc32(~ 0, "12345678", 8 * 8); 336 TEST("12345678", value, 0x9AE0DAAF); 337 printf("\t=> %X", value); 338 value = ~ compute_crc32(~ 0, "ahoj pane", 8 * 9); 339 TEST("ahoj pane", value, 0x5FC3D706); 340 printf("\t=> %X", value); 341 342 if(error){ 343 return EINVAL; 344 } 328 345 329 346 #endif 330 347 331 348 #if NET_SELF_TEST_DYNAMIC_FIFO 332 dyn_fifo_t fifo; 333 334 printf( "\nDynamic fifo test" ); 335 TEST( "add 1 einval", dyn_fifo_push( & fifo, 1, 0 ), EINVAL ); 336 TEST( "initialize", dyn_fifo_initialize( & fifo, 1 ), EOK ); 337 TEST( "add 1 eok", dyn_fifo_push( & fifo, 1, 0 ), EOK ); 338 TEST( "pop 1", dyn_fifo_pop( & fifo ), 1 ); 339 TEST( "pop enoent", dyn_fifo_pop( & fifo ), ENOENT ); 340 TEST( "add 2 eok", dyn_fifo_push( & fifo, 2, 1 ), EOK ); 341 TEST( "add 3 enomem", dyn_fifo_push( & fifo, 3, 1 ), ENOMEM ); 342 TEST( "add 3 eok", dyn_fifo_push( & fifo, 3, 0 ), EOK ); 343 TEST( "pop 2", dyn_fifo_pop( & fifo ), 2 ); 344 TEST( "pop 3", dyn_fifo_pop( & fifo ), 3 ); 345 TEST( "add 4 eok", dyn_fifo_push( & fifo, 4, 2 ), EOK ); 346 TEST( "add 5 eok", dyn_fifo_push( & fifo, 5, 2 ), EOK ); 347 TEST( "add 6 enomem", dyn_fifo_push( & fifo, 6, 2 ), ENOMEM ); 348 TEST( "add 6 eok", dyn_fifo_push( & fifo, 6, 5 ), EOK ); 349 TEST( "add 7 eok", dyn_fifo_push( & fifo, 7, 5 ), EOK ); 350 TEST( "pop 4", dyn_fifo_pop( & fifo ), 4 ); 351 TEST( "pop 5", dyn_fifo_pop( & fifo ), 5 ); 352 TEST( "add 8 eok", dyn_fifo_push( & fifo, 8, 5 ), EOK ); 353 TEST( "add 9 eok", dyn_fifo_push( & fifo, 9, 5 ), EOK ); 354 TEST( "add 10 eok", dyn_fifo_push( & fifo, 10, 6 ), EOK ); 355 TEST( "add 11 eok", dyn_fifo_push( & fifo, 11, 6 ), EOK ); 356 TEST( "pop 6", dyn_fifo_pop( & fifo ), 6 ); 357 TEST( "pop 7", dyn_fifo_pop( & fifo ), 7 ); 358 TEST( "add 12 eok", dyn_fifo_push( & fifo, 12, 6 ), EOK ); 359 TEST( "add 13 eok", dyn_fifo_push( & fifo, 13, 6 ), EOK ); 360 TEST( "add 14 enomem", dyn_fifo_push( & fifo, 14, 6 ), ENOMEM ); 361 TEST( "add 14 eok", dyn_fifo_push( & fifo, 14, 8 ), EOK ); 362 TEST( "pop 8", dyn_fifo_pop( & fifo ), 8 ); 363 TEST( "pop 9", dyn_fifo_pop( & fifo ), 9 ); 364 TEST( "pop 10", dyn_fifo_pop( & fifo ), 10 ); 365 TEST( "pop 11", dyn_fifo_pop( & fifo ), 11 ); 366 TEST( "pop 12", dyn_fifo_pop( & fifo ), 12 ); 367 TEST( "pop 13", dyn_fifo_pop( & fifo ), 13 ); 368 TEST( "pop 14", dyn_fifo_pop( & fifo ), 14 ); 369 TEST( "destroy", dyn_fifo_destroy( & fifo ), EOK ); 370 TEST( "add 15 einval", dyn_fifo_push( & fifo, 1, 0 ), EINVAL ); 371 if( error ) return EINVAL; 349 dyn_fifo_t fifo; 350 351 printf("\nDynamic fifo test"); 352 TEST("add 1 einval", dyn_fifo_push(&fifo, 1, 0), EINVAL); 353 TEST("initialize", dyn_fifo_initialize(&fifo, 1), EOK); 354 TEST("add 1 eok", dyn_fifo_push(&fifo, 1, 0), EOK); 355 TEST("pop 1", dyn_fifo_pop(&fifo), 1); 356 TEST("pop enoent", dyn_fifo_pop(&fifo), ENOENT); 357 TEST("add 2 eok", dyn_fifo_push(&fifo, 2, 1), EOK); 358 TEST("add 3 enomem", dyn_fifo_push(&fifo, 3, 1), ENOMEM); 359 TEST("add 3 eok", dyn_fifo_push(&fifo, 3, 0), EOK); 360 TEST("pop 2", dyn_fifo_pop(&fifo), 2); 361 TEST("pop 3", dyn_fifo_pop(&fifo), 3); 362 TEST("add 4 eok", dyn_fifo_push(&fifo, 4, 2), EOK); 363 TEST("add 5 eok", dyn_fifo_push(&fifo, 5, 2), EOK); 364 TEST("add 6 enomem", dyn_fifo_push(&fifo, 6, 2), ENOMEM); 365 TEST("add 6 eok", dyn_fifo_push(&fifo, 6, 5), EOK); 366 TEST("add 7 eok", dyn_fifo_push(&fifo, 7, 5), EOK); 367 TEST("pop 4", dyn_fifo_pop(&fifo), 4); 368 TEST("pop 5", dyn_fifo_pop(&fifo), 5); 369 TEST("add 8 eok", dyn_fifo_push(&fifo, 8, 5), EOK); 370 TEST("add 9 eok", dyn_fifo_push(&fifo, 9, 5), EOK); 371 TEST("add 10 eok", dyn_fifo_push(&fifo, 10, 6), EOK); 372 TEST("add 11 eok", dyn_fifo_push(&fifo, 11, 6), EOK); 373 TEST("pop 6", dyn_fifo_pop(&fifo), 6); 374 TEST("pop 7", dyn_fifo_pop(&fifo), 7); 375 TEST("add 12 eok", dyn_fifo_push(&fifo, 12, 6), EOK); 376 TEST("add 13 eok", dyn_fifo_push(&fifo, 13, 6), EOK); 377 TEST("add 14 enomem", dyn_fifo_push(&fifo, 14, 6), ENOMEM); 378 TEST("add 14 eok", dyn_fifo_push(&fifo, 14, 8), EOK); 379 TEST("pop 8", dyn_fifo_pop(&fifo), 8); 380 TEST("pop 9", dyn_fifo_pop(&fifo), 9); 381 TEST("pop 10", dyn_fifo_pop(&fifo), 10); 382 TEST("pop 11", dyn_fifo_pop(&fifo), 11); 383 TEST("pop 12", dyn_fifo_pop(&fifo), 12); 384 TEST("pop 13", dyn_fifo_pop(&fifo), 13); 385 TEST("pop 14", dyn_fifo_pop(&fifo), 14); 386 TEST("destroy", dyn_fifo_destroy(&fifo), EOK); 387 TEST("add 15 einval", dyn_fifo_push(&fifo, 1, 0), EINVAL); 388 if(error){ 389 return EINVAL; 390 } 372 391 373 392 #endif
Note:
See TracChangeset
for help on using the changeset viewer.