Navigation


Changeset 1088:1d1a20a0779d in freeDiameter for tests


Ignore:
Timestamp:
May 5, 2013, 4:25:27 AM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though

Location:
tests
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • tests/testcnx.c

    r974 r1088  
    715715                /* For debug: dump the object */
    716716                fd_log_debug("Dumping CER");
    717                 fd_msg_dump_walk(0, cer);
     717                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, cer, fd_g_config->cnf_dict, 0, 1));
    718718                #endif
    719719               
  • tests/testdict.c

    r788 r1088  
    192192                CHECK(1, obj ? 1 : 0 );
    193193#if 1
    194                 fd_dict_dump_object(obj);
     194                fd_log_debug("%s", fd_dict_dump_object(FD_DUMP_TEST_PARAMS, obj));
    195195#endif
    196196                CHECK( 0, fd_dict_delete(obj) );
  • tests/testdisp.c

    r1018 r1088  
    699699               
    700700                #if 0
    701                 fd_conf_dump();
     701                fd_log_debug("%s", fd_conf_dump(FD_DUMP_TEST_PARAMS));
    702702                #endif
    703703        }
  • tests/testfifo.c

    r1071 r1088  
    559559                CHECK( 14, iter );
    560560               
    561                 /* fd_fifo_dump(0, "test", queue, NULL); */
    562                
    563561                for (; i < td.nbr; i++) {
    564562                        CHECK( 0, fd_fifo_tryget(queue, &item) );
  • tests/testmesg.c

    r1047 r1088  
    6161                #if 0
    6262                /* For debug: dump the object */
    63                 fd_log_debug("Dumping Accounting-Request empty message");
    64                 fd_msg_dump_walk( 0, acr );
     63                fd_log_debug("Dumping Accounting-Request empty message:");
     64                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, acr, fd_g_config->cnf_dict, 0, 1));
    6565                #endif
    6666        }
     
    7979                /* For debug: dump the object */
    8080                fd_log_debug("Dumping Proxy-Info AVP");
    81                 fd_msg_dump_walk(0, pi);
     81                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, pi, fd_g_config->cnf_dict, 0, 1));
    8282                fd_log_debug("Dumping dictionary model");
    83                 fd_dict_dump_object(pi_model);
     83                fd_log_debug("%s", fd_dict_dump_object(FD_DUMP_TEST_PARAMS, pi_model));
    8484                #endif
    8585               
     
    107107                /* For debug: dump the object */
    108108                fd_log_debug("Dumping Accounting-Request with Proxy-Info AVP at the end");
    109                 fd_msg_dump_walk(0, acr);
     109                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, acr, fd_g_config->cnf_dict, 0, 1));
    110110                #endif
    111111        }
     
    306306                                                */
    307307                        #if 0
    308                         fd_dict_dump_object ( gavp );
     308                        fd_log_debug("%s", fd_dict_dump_object(FD_DUMP_TEST_PARAMS, gavp));
    309309                        #endif
    310310                }
    311311                #if 0
    312312                {
    313                         fd_dict_dump_object ( vendor );
     313                        fd_log_debug("%s", fd_dict_dump_object(FD_DUMP_TEST_PARAMS, vendor));
    314314                }
    315315                #endif
     
    365365                        #if 0
    366366                        fd_log_debug("AVP no vendor, value 3.1415:");
    367                         fd_msg_dump_one(0, avpi);
     367                        fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
    368368                        #endif
    369369                        CHECK( 0, fd_msg_avp_hdr ( avpi, &avpdata ) );
     
    382382                        #if 0
    383383                        fd_log_debug("AVP vendor, value 0x123456789abcdeL:");
    384                         fd_msg_dump_one(0, avpi);
     384                        fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
    385385                        #endif
    386386                        CHECK( 0, fd_msg_avp_hdr ( avpi, &avpdata ) );
     
    408408                                #if 0
    409409                                fd_log_debug("AVP enum i32, value 2 (from const):");
    410                                 fd_msg_dump_one(0, avpi);
     410                                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
    411411                                #endif
    412412                        }
     
    429429                                #if 0
    430430                                fd_log_debug("AVP enum i32, value -5 (from const):");
    431                                 fd_msg_dump_one(0, avpi);
     431                                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
    432432                                #endif
    433433                                /* Check the size is correct ( 12 for header + 4 for value ) */
     
    444444                        #if 0
    445445                        fd_log_debug("AVP vendor enum i32, value -10 (not const):");
    446                         fd_msg_dump_one(0, avpi);
     446                        fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
    447447                        #endif
    448448                       
     
    459459                                #if 0
    460460                                fd_log_debug("AVP octet string, 'This\\0 is a b...'");
    461                                 fd_msg_dump_one(0, avpi);
     461                                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
    462462                                #endif
    463463                                CHECK( 0, fd_msg_avp_hdr ( avpi, &avpdata ) );
     
    488488                                #if 0
    489489                                fd_log_debug("AVP Enumuerated OctetString (from const):");
    490                                 fd_msg_dump_one(0, avpi);
     490                                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
    491491                                #endif
    492492                                /* Check the size is correct ( 12 for header + 5 for value ) */
     
    513513                                #if 0
    514514                                fd_log_debug("AVP Enumuerated OctetString (from const):");
    515                                 fd_msg_dump_one(0, avpi);
     515                                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
    516516                                #endif
    517517                                /* Check the size is correct ( 12 for header + 3 for value ) */
     
    535535                                #if 0
    536536                                fd_log_debug("AVP octet string, '1234678'");
    537                                 fd_msg_dump_one(0, avpch);
     537                                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpch, fd_g_config->cnf_dict, 0, 0));
    538538                                #endif
    539539                                CHECK( 0, fd_msg_update_length ( avpch ) );
     
    548548                                #if 0
    549549                                fd_log_debug("AVP octet string, '12346789'");
    550                                 fd_msg_dump_one(0, avpch);
     550                                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpch, fd_g_config->cnf_dict, 0, 0));
    551551                                #endif
    552552                          }
     
    580580                        CHECK( 0, fd_msg_update_length ( msg ) );
    581581                        #if 0
    582                         fd_msg_dump_walk(0, msg);
     582                        fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
    583583                        #endif
    584584                        CHECK( 344, msgdata->msg_length );
     
    660660                        CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
    661661                        #if 0
    662                         fd_msg_dump_walk(0, msg);
     662                        fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
    663663                        #endif
    664664                       
     
    733733                               
    734734                                #if 0
    735                                 fd_msg_dump_walk(0, msg);
     735                                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
    736736                                #endif
    737737                               
     
    769769                                CHECK( 0, fd_msg_bufferize( msg, &buftmp, NULL ) );                             
    770770                               
    771                                 fd_msg_dump_walk(0, msg);
     771                                fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
    772772                               
    773773                                TODO("Check the Failed-AVP is as expected");
     
    783783                        CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
    784784                        #if 0
    785                         fd_msg_dump_walk(0, msg);
     785                        fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
    786786                        #endif
    787787                }
     
    13361336                        /* Okay, now delete the message and parse the buffer, then check we obtain the same values back */
    13371337                        #if 0
    1338                         fd_msg_dump_walk(0, msg);
     1338                        fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
    13391339                        #endif
    13401340                        CHECK( 0, fd_msg_free( msg ) );
     
    13431343                        CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
    13441344                        #if 0
    1345                         fd_msg_dump_walk(0, msg);
     1345                        fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
    13461346                        #endif
    13471347                       
  • tests/testmesg_stress.c

    r1076 r1088  
    197197                                < grouped >
    198198                                                */
    199                         #if 0
    200                         fd_dict_dump_object ( gavp );
    201                         #endif
    202                 }
    203                 #if 0
    204                 {
    205                         fd_dict_dump_object ( vendor );
    206                 }
    207                 #endif
     199                }
    208200        }
    209201       
  • tests/testpeers.c

    r748 r1088  
    5757                }
    5858        }
    59         fd_peer_dump_list(0);
     59        fd_log_debug("%s", fd_peer_dump_list(FD_DUMP_TEST_PARAMS, 0));
    6060        /* Check we are able to find again any of these */
    6161        {
  • tests/tests.h

    r1078 r1088  
    6868/* Define the macro to fail a test with a message */
    6969#define FAILTEST( message... ){                         \
    70         TRACE_ERROR(message);                           \
    71         TRACE_ERROR("FAILED: %s ", __STRIPPED_FILE__);  \
     70        LOG_F(message);                                 \
     71        LOG_F("FAILED: %s ", __STRIPPED_FILE__);        \
     72        free(tbuf);                                     \
    7273        exit(FAIL);                                     \
    7374}
     
    7576/* Define the macro to pass a test */
    7677#define PASSTEST( ){                                    \
    77         TRACE_NOTICE("PASS: %s", __STRIPPED_FILE__);    \
     78        LOG_N("PASS: %s", __STRIPPED_FILE__);           \
    7879        (void)fd_core_shutdown();                       \
    7980        (void)fd_core_wait_shutdown_complete();         \
    8081        (void)fd_thr_term(&signal_thr);                 \
     82        free(tbuf);                                     \
    8183        exit(PASS);                                     \
    8284}
    8385
    84 static int test_verbo = 0;
    8586static struct fd_config conf;
    8687extern struct fd_config * fd_g_config;
    8788
     89/* for dumps */
     90static char * tbuf = NULL; size_t tbuflen = 0;
     91#define FD_DUMP_TEST_PARAMS &tbuf, &tbuflen, NULL
     92
     93
    8894/* Define the standard check routines */
    8995#define CHECK( _val, _assert ){                         \
    90         if (test_verbo > 0) {                           \
    91                 TRACE_NOTICE("CHECK( %s == %s )",       \
     96        LOG_D("CHECK( %s == %s )",                      \
    9297                                #_assert,               \
    9398                                #_val);                 \
    94         }{                                              \
     99        {                                               \
    95100        __typeof__ (_val) __ret = (_assert);            \
    96101        if (__ret != (_val)) {                          \
     
    143148                switch (c) {
    144149                        case 'd':       /* Increase verbosity of debug messages.  */
    145                                 test_verbo++;
     150                                fd_g_debug_lvl--;
    146151                                break;
    147152                               
    148153                        case 'q':       /* Decrease verbosity.  */
    149                                 test_verbo--;
     154                                fd_g_debug_lvl++;
    150155                                break;
    151156                       
     
    178183                }
    179184        }
    180         fd_g_debug_lvl = (test_verbo > 0) ? (test_verbo - 1) : 0;
    181185        if (!no_timeout) {
    182186                alarm(TEST_TIMEOUT);
  • tests/testsess.c

    r888 r1088  
    4343
    4444#define TEST_EYEC       0x7e57e1ec
    45 struct mystate {
     45struct sess_state {
    4646        int     eyec;   /* TEST_EYEC */
    4747        os0_t   sid;    /* the session with which the data was registered */
     
    5050};
    5151
    52 static void mycleanup( struct mystate * data, os0_t sid, void * opaque )
     52static void mycleanup( struct sess_state * data, os0_t sid, void * opaque )
    5353{
    5454        /* sanity */
     
    6767}
    6868
    69 static __inline__ struct mystate * new_state(os0_t sid, int *freed)
     69static __inline__ struct sess_state * new_state(os0_t sid, int *freed)
    7070{
    71         struct mystate *new;
    72         new = malloc(sizeof(struct mystate));
     71        struct sess_state *new;
     72        new = malloc(sizeof(struct sess_state));
    7373        CHECK( 1, new ? 1 : 0 );
    74         memset(new, 0, sizeof(struct mystate));
     74        memset(new, 0, sizeof(struct sess_state));
    7575        new->eyec = TEST_EYEC;
    7676        new->sid = os0dup(sid, strlen((char *)sid));
     
    106106        {
    107107                void * testptr = NULL;
    108                 CHECK( 0, fd_sess_handler_create ( &hdl1, mycleanup, NULL ) );
    109                 CHECK( 0, fd_sess_handler_create ( &hdl2, mycleanup, NULL ) );
     108                CHECK( 0, fd_sess_handler_create ( &hdl1, mycleanup, NULL, NULL ) );
     109                CHECK( 0, fd_sess_handler_create ( &hdl2, mycleanup, NULL, NULL ) );
    110110                CHECK( 0, fd_sess_handler_destroy( &hdl2, &testptr ) );
    111111                CHECK( 1, testptr == NULL ? 1 : 0 );
    112                 CHECK( 0, fd_sess_handler_create ( &hdl2, mycleanup, g_opaque ) );
    113                 #if 0
    114                 fd_sess_dump_hdl(0, hdl1);
    115                 fd_sess_dump_hdl(0, hdl2);
     112                CHECK( 0, fd_sess_handler_create ( &hdl2, mycleanup, NULL, g_opaque ) );
     113                #if 0
     114                fd_log_debug("%s\n", fd_sess_dump_hdl(FD_DUMP_TEST_PARAMS, hdl1));
     115                fd_log_debug("%s\n", fd_sess_dump_hdl(FD_DUMP_TEST_PARAMS, hdl2));
    116116                #endif
    117117        }
     
    123123                CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, CONSTSTRLEN(TEST_DIAM_ID), NULL, 0 ) );
    124124                #if 0
    125                 fd_sess_dump(0, sess1);
    126                 fd_sess_dump(0, sess2);
     125                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
     126                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1));
    127127                #endif
    128128               
     
    141141                CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, CONSTSTRLEN(TEST_DIAM_ID), TEST_OPT, CONSTSTRLEN(TEST_OPT_IN) - 1 ) );
    142142                #if 0
    143                 fd_sess_dump(0, sess1);
    144                 fd_sess_dump(0, sess2);
     143                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
     144                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1));
    145145                #endif
    146146               
     
    165165                CHECK( 0, fd_sess_new( &sess2, NULL, 0, TEST_SID, CONSTSTRLEN(TEST_SID_IN) - 1 ) );
    166166                #if 0
    167                 fd_sess_dump(0, sess1);
    168                 fd_sess_dump(0, sess2);
     167                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
     168                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1));
    169169                #endif
    170170                CHECK( 0, fd_sess_getsid(sess1, &str1, &str1len) );
     
    211211        /* Test fd_sess_reclaim */
    212212        {
    213                 struct mystate *tms;
     213                struct sess_state *tms;
    214214               
    215215                CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess1, &new ) );
     
    271271        /* Test states operations */
    272272        {
    273                 struct mystate * ms[6], *tms;
     273                struct sess_state * ms[6], *tms;
    274274                int freed[6];
    275275                struct timespec timeout;
     
    295295               
    296296                #if 0
    297                 fd_sess_dump(0, sess1);
     297                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
    298298                #endif
    299299               
     
    332332               
    333333                #if 0
    334                 fd_sess_dump(0, sess1);
    335                 fd_sess_dump(0, sess2);
    336                 fd_sess_dump(0, sess3);
     334                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
     335                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1));
     336                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess3, 1));
    337337                #endif
    338338               
     
    357357               
    358358                #if 1
    359                 fd_sess_dump(0, sess1);
    360                 fd_sess_dump(0, sess2);
     359                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
     360                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1));
    361361                #endif
    362362               
     
    373373                CHECK( 0, fd_sess_settimeout( sess2, &timeout) );
    374374                #if 1
    375                 fd_sess_dump(0, sess1);
    376                 fd_sess_dump(0, sess2);
     375                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1));
     376                fd_log_debug("%s\n", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1));
    377377                #endif
    378378                timeout.tv_sec = 0;
Note: See TracChangeset for help on using the changeset viewer.