Navigation


Changeset 1093:44f3e48dfe27 in freeDiameter for tests


Ignore:
Timestamp:
May 6, 2013, 5:33:22 PM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Align the behavior of all fd_*dump functions wrt final \n

Location:
tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tests/testdict.c

    r1088 r1093  
    204204        }
    205205       
     206        LOG_D( "Dictionary at the end of %s: %s", __FILE__, fd_dict_dump(FD_DUMP_TEST_PARAMS, fd_g_config->cnf_dict) ?: "error");
     207       
    206208        /* That's all for the tests yet */
    207209        PASSTEST();
  • tests/testmesg_stress.c

    r1090 r1093  
    374374                CHECK( 0, fd_msg_bufferize( msg, &buf, NULL ) );
    375375               
     376                LOG_D( "Test message: %s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, NULL, 0, 1));
     377               
    376378                /* Now free the message, we keep only the buffer. */
    377379                CHECK( 0, fd_msg_free( msg ) );
     
    390392                struct timespec start, end;
    391393               
    392                 unsigned char * buf_cpy = NULL;
    393394                struct msg * msg;
    394395               
    395                 #define CPYBUF() {                      \
    396                         buf_cpy = malloc(344);          \
    397                         CHECK( buf_cpy ? 1 : 0, 1);     \
    398                         memcpy(buf_cpy, buf, 344);      \
    399                 }
    400396               
    401397                /* Create the copies of the message buffer */
     
    404400               
    405401                for (i=0; i < test_parameter; i++) {
    406                         CPYBUF();
    407                         stress_array[i].b = buf_cpy;
    408                 }
     402                        stress_array[i].b = malloc(344);
     403                        if (!stress_array[i].b)
     404                                break;
     405                        memcpy(stress_array[i].b, buf, 344);
     406                }
     407                CHECK( test_parameter, i ); /* if false, a malloc failed */
    409408               
    410409        /* fd_msg_parse_buffer */
     
    414413                /* Test the msg_parse_buffer function */
    415414                for (i=0; i < test_parameter; i++) {
    416                         CHECK( 0, fd_msg_parse_buffer( &stress_array[i].b, 344, &stress_array[i].m) );
    417                 }
     415                        if (0 != fd_msg_parse_buffer( &stress_array[i].b, 344, &stress_array[i].m) )
     416                                break;
     417                }
     418                CHECK( test_parameter, i ); /* if false, a call failed */
    418419               
    419420                CHECK( 0, clock_gettime(CLOCK_REALTIME, &end) );
     
    426427                /* Test the fd_msg_parse_dict function */
    427428                for (i=0; i < test_parameter; i++) {
    428                         CHECK( 0, fd_msg_parse_dict( stress_array[i].m, fd_g_config->cnf_dict, NULL ) );
    429                 }
     429                        if (0 != fd_msg_parse_dict( stress_array[i].m, fd_g_config->cnf_dict, NULL ) )
     430                                break;
     431                }
     432                CHECK( test_parameter, i ); /* if false, a call failed */
    430433               
    431434                CHECK( 0, clock_gettime(CLOCK_REALTIME, &end) );
     
    439442                /* Test the fd_msg_parse_rules function */
    440443                for (i=0; i < test_parameter; i++) {
    441                         CHECK( 0, fd_msg_parse_rules( stress_array[i].m, fd_g_config->cnf_dict, NULL ) );
    442                 }
     444                        if (0 != fd_msg_parse_rules( stress_array[i].m, fd_g_config->cnf_dict, NULL ) )
     445                                break;
     446                }
     447                CHECK( test_parameter, i ); /* if false, a call failed */
    443448               
    444449                CHECK( 0, clock_gettime(CLOCK_REALTIME, &end) );
     
    452457                /* Test the fd_msg_new_answer_from_req function */
    453458                for (i=0; i < test_parameter; i++) {
    454                         CHECK( 0, fd_msg_new_answer_from_req( fd_g_config->cnf_dict, &stress_array[i].m, 0 ) );
    455                 }
     459                        if (0 != fd_msg_new_answer_from_req( fd_g_config->cnf_dict, &stress_array[i].m, 0 ) )
     460                                break;
     461                }
     462                CHECK( test_parameter, i ); /* if false, a call failed */
    456463               
    457464                CHECK( 0, clock_gettime(CLOCK_REALTIME, &end) );
     
    461468                for (i=0; i < test_parameter; i++) {
    462469                        struct msg * ans = stress_array[i].m;
    463                         CHECK( 0, fd_msg_answ_getq( ans, &stress_array[i].m ) );
    464                         CHECK( 0, fd_msg_answ_detach( ans ) );
     470                        if (0 != fd_msg_answ_getq( ans, &stress_array[i].m ) )
     471                                break;
     472                        if (0 != fd_msg_answ_detach( ans ) )
     473                                break;
    465474                        fd_msg_free( ans );
    466475                }
     476                CHECK( test_parameter, i ); /* if false, a call failed */
    467477               
    468478               
     
    473483                /* Test the fd_msg_new_answer_from_req function */
    474484                for (i=0; i < test_parameter; i++) {
    475                         CHECK( 0, fd_msg_new_answer_from_req( fd_g_config->cnf_dict, &stress_array[i].m, MSGFL_ANSW_ERROR ) );
    476                 }
     485                        if ( 0 != fd_msg_new_answer_from_req( fd_g_config->cnf_dict, &stress_array[i].m, MSGFL_ANSW_ERROR ) )
     486                                break;
     487                }
     488                CHECK( test_parameter, i ); /* if false, a call failed */
    477489               
    478490                CHECK( 0, clock_gettime(CLOCK_REALTIME, &end) );
     
    482494                for (i=0; i < test_parameter; i++) {
    483495                        struct msg * ans = stress_array[i].m;
    484                         CHECK( 0, fd_msg_answ_getq( ans, &stress_array[i].m ) );
    485                         CHECK( 0, fd_msg_answ_detach( ans ) );
     496                        if (0 != fd_msg_answ_getq( ans, &stress_array[i].m ) )
     497                                break;
     498                        if (0 != fd_msg_answ_detach( ans ) )
     499                                break;
    486500                        fd_msg_free( ans );
    487501                }
     
    496510                for (i=0; i < test_parameter; i++) {
    497511                        size_t len = 0;
    498                         CHECK( 0, fd_msg_bufferize( stress_array[i].m, &stress_array[i].b, &len ) );
    499                 }
     512                        if (0 != fd_msg_bufferize( stress_array[i].m, &stress_array[i].b, &len ) )
     513                                break;
     514                }
     515                CHECK( test_parameter, i ); /* if false, a call failed */
    500516               
    501517                CHECK( 0, clock_gettime(CLOCK_REALTIME, &end) );
Note: See TracChangeset for help on using the changeset viewer.