Rev 4350 | Rev 4743 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4350 | Rev 4588 | ||
---|---|---|---|
Line 45... | Line 45... | ||
45 | #include "include/crc.h" |
45 | #include "include/crc.h" |
46 | #include "structures/int_map.h" |
46 | #include "structures/int_map.h" |
47 | #include "structures/char_map.h" |
47 | #include "structures/char_map.h" |
48 | #include "structures/generic_char_map.h" |
48 | #include "structures/generic_char_map.h" |
49 | #include "structures/measured_strings.h" |
49 | #include "structures/measured_strings.h" |
- | 50 | #include "structures/dynamic_fifo.h" |
|
50 | 51 | ||
51 | #include "self_test.h" |
52 | #include "self_test.h" |
52 | 53 | ||
53 | /** Tests the function, compares the result and remembers if the result differs. |
54 | /** Tests the function, compares the result and remembers if the result differs. |
54 | * @param name The test name. Input parameter. |
55 | * @param name The test name. Input parameter. |
Line 56... | Line 57... | ||
56 | * @param result The expected result. Input parameter. |
57 | * @param result The expected result. Input parameter. |
57 | */ |
58 | */ |
58 | #define TEST( name, function_call, result ); { \ |
59 | #define TEST( name, function_call, result ); { \ |
59 | printf( "\n\t%s", ( name )); \ |
60 | printf( "\n\t%s", ( name )); \ |
60 | if(( function_call ) != ( result )){ \ |
61 | if(( function_call ) != ( result )){ \ |
61 | printf( "\tERROR" ); \ |
62 | printf( "\tERROR\n" ); \ |
62 | error = 1; \ |
63 | error = 1; \ |
63 | }else{ \ |
64 | }else{ \ |
64 | printf( "\tOK" ); \ |
65 | printf( "\tOK\n" ); \ |
65 | } \ |
66 | } \ |
66 | } |
67 | } |
67 | 68 | ||
68 | #if NET_SELF_TEST_INT_MAP |
69 | #if NET_SELF_TEST_INT_MAP |
69 | 70 | ||
Line 326... | Line 327... | ||
326 | 327 | ||
327 | if( error ) return EINVAL; |
328 | if( error ) return EINVAL; |
328 | 329 | ||
329 | #endif |
330 | #endif |
330 | 331 | ||
- | 332 | #if NET_SELF_TEST_DYNAMIC_FIFO |
|
- | 333 | dyn_fifo_t fifo; |
|
- | 334 | ||
- | 335 | printf( "\nDynamic fifo test" ); |
|
- | 336 | TEST( "add 1 einval", dyn_fifo_push( & fifo, 1, 0 ), EINVAL ); |
|
- | 337 | TEST( "initialize", dyn_fifo_initialize( & fifo, 1 ), EOK ); |
|
- | 338 | TEST( "add 1 eok", dyn_fifo_push( & fifo, 1, 0 ), EOK ); |
|
- | 339 | TEST( "pop 1", dyn_fifo_pop( & fifo ), 1 ); |
|
- | 340 | TEST( "pop enoent", dyn_fifo_pop( & fifo ), ENOENT ); |
|
- | 341 | TEST( "add 2 eok", dyn_fifo_push( & fifo, 2, 1 ), EOK ); |
|
- | 342 | TEST( "add 3 enomem", dyn_fifo_push( & fifo, 3, 1 ), ENOMEM ); |
|
- | 343 | TEST( "add 3 eok", dyn_fifo_push( & fifo, 3, 0 ), EOK ); |
|
- | 344 | TEST( "pop 2", dyn_fifo_pop( & fifo ), 2 ); |
|
- | 345 | TEST( "pop 3", dyn_fifo_pop( & fifo ), 3 ); |
|
- | 346 | TEST( "add 4 eok", dyn_fifo_push( & fifo, 4, 2 ), EOK ); |
|
- | 347 | TEST( "add 5 eok", dyn_fifo_push( & fifo, 5, 2 ), EOK ); |
|
- | 348 | TEST( "add 6 enomem", dyn_fifo_push( & fifo, 6, 2 ), ENOMEM ); |
|
- | 349 | TEST( "add 6 eok", dyn_fifo_push( & fifo, 6, 5 ), EOK ); |
|
- | 350 | TEST( "add 7 eok", dyn_fifo_push( & fifo, 7, 5 ), EOK ); |
|
- | 351 | TEST( "pop 4", dyn_fifo_pop( & fifo ), 4 ); |
|
- | 352 | TEST( "pop 5", dyn_fifo_pop( & fifo ), 5 ); |
|
- | 353 | TEST( "add 8 eok", dyn_fifo_push( & fifo, 8, 5 ), EOK ); |
|
- | 354 | TEST( "add 9 eok", dyn_fifo_push( & fifo, 9, 5 ), EOK ); |
|
- | 355 | TEST( "add 10 eok", dyn_fifo_push( & fifo, 10, 6 ), EOK ); |
|
- | 356 | TEST( "add 11 eok", dyn_fifo_push( & fifo, 11, 6 ), EOK ); |
|
- | 357 | TEST( "pop 6", dyn_fifo_pop( & fifo ), 6 ); |
|
- | 358 | TEST( "pop 7", dyn_fifo_pop( & fifo ), 7 ); |
|
- | 359 | TEST( "add 12 eok", dyn_fifo_push( & fifo, 12, 6 ), EOK ); |
|
- | 360 | TEST( "add 13 eok", dyn_fifo_push( & fifo, 13, 6 ), EOK ); |
|
- | 361 | TEST( "add 14 enomem", dyn_fifo_push( & fifo, 14, 6 ), ENOMEM ); |
|
- | 362 | TEST( "add 14 eok", dyn_fifo_push( & fifo, 14, 8 ), EOK ); |
|
- | 363 | TEST( "pop 8", dyn_fifo_pop( & fifo ), 8 ); |
|
- | 364 | TEST( "pop 9", dyn_fifo_pop( & fifo ), 9 ); |
|
- | 365 | TEST( "pop 10", dyn_fifo_pop( & fifo ), 10 ); |
|
- | 366 | TEST( "pop 11", dyn_fifo_pop( & fifo ), 11 ); |
|
- | 367 | TEST( "pop 12", dyn_fifo_pop( & fifo ), 12 ); |
|
- | 368 | TEST( "pop 13", dyn_fifo_pop( & fifo ), 13 ); |
|
- | 369 | TEST( "pop 14", dyn_fifo_pop( & fifo ), 14 ); |
|
- | 370 | TEST( "destroy", dyn_fifo_destroy( & fifo ), EOK ); |
|
- | 371 | TEST( "add 15 einval", dyn_fifo_push( & fifo, 1, 0 ), EINVAL ); |
|
- | 372 | if( error ) return EINVAL; |
|
- | 373 | ||
- | 374 | #endif |
|
- | 375 | ||
331 | return EOK; |
376 | return EOK; |
332 | } |
377 | } |
333 | 378 | ||
334 | #endif |
379 | #endif |
335 | 380 |