Navigation


Changeset 890:19a261c9a2e1 in freeDiameter for tests


Ignore:
Timestamp:
Nov 18, 2012, 6:54:24 AM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/testmesg.c

    r740 r890  
    186186                }
    187187               
     188                {
     189                        struct dict_avp_data avp_data = { 139103, 0, "AVP Test - no vendor - f64", 0, 0, AVP_TYPE_FLOAT64 };
     190                        CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) );
     191                }
     192               
    188193                {
    189194                        struct dict_object  * type = NULL;
     
    269274                        ADD_RULE(command, 73565, "AVP Test - enumos",           RULE_OPTIONAL,   -1, -1,  0);
    270275                        ADD_RULE(command, 73565, "AVP Test - grouped",          RULE_OPTIONAL,   -1, -1,  0);
     276                }
     277               
     278                {
     279                        struct dict_object  * application = NULL;
     280                        struct dict_object  * command = NULL;
     281                        struct dict_cmd_data  cmd_data = { 73573, "Test-Command-Answer", CMD_FLAG_REQUEST, 0 };
     282                       
     283                        CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Application test", &application, ENOENT ) );
     284                        CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_COMMAND, &cmd_data , application, &command ) );
    271285                }
    272286               
     
    725739                                CHECK( 0, fd_msg_free ( msg ) );
    726740                        }
     741                       
     742                        /* Test with an invalid AVP (definition mismatch with the dictionary) */
     743                        {
     744                                CPYBUF();
     745                               
     746                                buf_cpy[21] = 0x02;     /* New AVP code = 0x00021F5F, f64 type in the dictionary */
     747                               
     748                               
     749                                /* Check that we cannot support this message now */
     750                                CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
     751                                CHECK( EBADMSG, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
     752                               
     753                                /* reset */
     754                                CHECK( 0, fd_msg_free ( msg ) );
     755                        }
     756                       
     757#if 1
     758                        {
     759                                /* Check the parse or error works as expected */
     760                                CPYBUF();
     761                               
     762                                buf_cpy[21] = 0x02;     /* New AVP code = 0x00021F5F, f64 type in the dictionary */
     763                               
     764                                /* Check that we cannot support this message now */
     765                                CHECK( 0, fd_msg_init() );
     766                                CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
     767                                CHECK( EBADMSG, fd_msg_parse_or_error( &msg ) );
     768                               
     769                                /* Check the Failed-AVP is as expected */
     770                               
     771                                fd_msg_dump_walk(0, msg);
     772                               
     773                                /* reset */
     774                                CHECK( 0, fd_msg_free ( msg ) );
     775                               
     776                                ASSERT(0);
     777                        }
     778#endif                 
     779                       
    727780                       
    728781                        CHECK( 0, fd_msg_parse_buffer( &buf, 344, &msg) );
Note: See TracChangeset for help on using the changeset viewer.