comparison tests/testmesg.c @ 1438:7c60cb0ac8c8

testmesg: improve comments and msg cleanup
author Luke Mewburn <luke@mewburn.net>
date Fri, 21 Feb 2020 14:30:16 +1100
parents b09f1b4c9fad
children 566bb46cc73f
comparison
equal deleted inserted replaced
1437:0a80278df21f 1438:7c60cb0ac8c8
162 /* Now find the ACR dictionary object */ 162 /* Now find the ACR dictionary object */
163 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) ); 163 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) );
164 164
165 /* Create the instance, using the templates */ 165 /* Create the instance, using the templates */
166 CHECK( 0, fd_msg_new ( acr_model, 0, &acr ) ); 166 CHECK( 0, fd_msg_new ( acr_model, 0, &acr ) );
167
168 /* TODO: Do we need this recreated? acr is not used again . */
167 } 169 }
168 170
169 /* Now let's create some additional Dictionary objects for the test */ 171 /* Now let's create some additional Dictionary objects for the test */
170 { 172 {
171 /* The constant values used here are totally arbitrary chosen */ 173 /* The constant values used here are totally arbitrary chosen */
698 struct dict_object * avp_model; 700 struct dict_object * avp_model;
699 struct avp * found; 701 struct avp * found;
700 struct avp * grouped = NULL; 702 struct avp * grouped = NULL;
701 struct avp_hdr * avpdata = NULL; 703 struct avp_hdr * avpdata = NULL;
702 704
703 /* Now find the ACR dictionary object */ 705 /* Now find the Test f32 AVP dictionary object */
704 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "AVP Test - no vendor - f32", &avp_model, ENOENT ) ); 706 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "AVP Test - no vendor - f32", &avp_model, ENOENT ) );
705 707
706 CPYBUF(); 708 CPYBUF();
707 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) ); 709 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
708 CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) ); 710 CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
1113 CHECK( 0, fd_msg_rescode_set(msg, "DIAMETER_AVP_OCCURS_TOO_MANY_TIMES", NULL, pi1, 1) ); 1115 CHECK( 0, fd_msg_rescode_set(msg, "DIAMETER_AVP_OCCURS_TOO_MANY_TIMES", NULL, pi1, 1) );
1114 1116
1115 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1)); 1117 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
1116 1118
1117 TODO("Check the Failed-AVP is as expected"); 1119 TODO("Check the Failed-AVP is as expected");
1120
1121 CHECK( 0, fd_msg_free( msg ) );
1118 } 1122 }
1119 1123
1120 } 1124 }
1121 } 1125 }
1122 1126
1507 1511
1508 /* Create a message */ 1512 /* Create a message */
1509 CHECK( 0, fd_msg_new ( cmd_model, 0, &msg ) ); 1513 CHECK( 0, fd_msg_new ( cmd_model, 0, &msg ) );
1510 1514
1511 /* Add a session id */ 1515 /* Add a session id */
1512 CHECK( 0, fd_msg_new_session( msg, (os0_t)"tm2", strlen("tm2") ) ); 1516 CHECK( 0, fd_msg_new_session( msg, (os0_t)"testmsg", strlen("testmsg") ) );
1513 1517
1514 /* Find the DICT_TYPE Enumerated(Result-Code) */ 1518 /* Find the DICT_TYPE Enumerated(Result-Code) */
1515 struct dict_object * restype = NULL; 1519 struct dict_object * restype = NULL;
1516 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_TYPE, TYPE_BY_NAME, "Enumerated(Result-Code)", &restype, ENOENT ) ); 1520 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_TYPE, TYPE_BY_NAME, "Enumerated(Result-Code)", &restype, ENOENT ) );
1517 1521
1551 1555
1552 /* Create a message */ 1556 /* Create a message */
1553 CHECK( 0, fd_msg_new ( cmd_model, 0, &msg ) ); 1557 CHECK( 0, fd_msg_new ( cmd_model, 0, &msg ) );
1554 1558
1555 /* Add a session id */ 1559 /* Add a session id */
1556 CHECK( 0, fd_msg_new_session( msg, (os0_t)"tm2", strlen("tm2") ) ); 1560 CHECK( 0, fd_msg_new_session( msg, (os0_t)"testmsg", strlen("testmsg") ) );
1557 1561
1558 /* Find the DICT_TYPE Enumerated(73565/Experimental-Result-Code) */ 1562 /* Find the DICT_TYPE Enumerated(73565/Experimental-Result-Code) */
1559 struct dict_object * restype = NULL; 1563 struct dict_object * restype = NULL;
1560 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_TYPE, TYPE_BY_NAME, "Enumerated(73565/Experimental-Result-Code)", &restype, ENOENT ) ); 1564 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_TYPE, TYPE_BY_NAME, "Enumerated(73565/Experimental-Result-Code)", &restype, ENOENT ) );
1561 1565
"Welcome to our mercurial repository"