Navigation


Changeset 1071:6ca6cadf209c in freeDiameter for tests/testfifo.c


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

Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/testfifo.c

    r1060 r1071  
    217217        {
    218218                struct fifo * queue = NULL;
    219                 int count, max;
    220219                struct msg * msg  = NULL;
     220                int max;
     221                long long count;
    221222               
    222223                /* Create the queue */
     
    224225               
    225226                /* Check the count is 0 */
    226                 CHECK( 0, fd_fifo_length(queue, &count, &max) );
    227                 CHECK( 0, count);
    228                 CHECK( 0, max);
     227                CHECK( 0, fd_fifo_length(queue) );
    229228               
    230229                /* Now enqueue */
     
    237236               
    238237                /* Check the count is 3 */
    239                 CHECK( 0, fd_fifo_length(queue, &count, &max) );
    240                 CHECK( 3, count);
    241                 CHECK( 0, max);
     238                CHECK( 3, fd_fifo_length(queue) );
    242239               
    243240                /* Retrieve the first message using fd_fifo_get */
    244241                CHECK( 0, fd_fifo_get(queue, &msg) );
    245242                CHECK( msg1, msg);
    246                 CHECK( 0, fd_fifo_length(queue, &count, NULL) );
    247                 CHECK( 2, count);
     243                CHECK( 2, fd_fifo_length(queue) );
    248244               
    249245                /* Retrieve the second message using fd_fifo_timedget */
     
    252248                CHECK( 0, fd_fifo_timedget(queue, &msg, &ts) );
    253249                CHECK( msg2, msg);
    254                 CHECK( 0, fd_fifo_length(queue, &count, NULL) );
    255                 CHECK( 1, count);
     250                CHECK( 1, fd_fifo_length(queue) );
    256251               
    257252                /* Retrieve the third message using meq_tryget */
    258253                CHECK( 0, fd_fifo_tryget(queue, &msg) );
    259254                CHECK( msg3, msg);
    260                 CHECK( 0, fd_fifo_length(queue, &count, NULL) );
    261                 CHECK( 0, count);
     255                CHECK( 0, fd_fifo_length(queue) );
    262256               
    263257                /* Check that another meq_tryget does not block */
    264258                CHECK( EWOULDBLOCK, fd_fifo_tryget(queue, &msg) );
    265                 CHECK( 0, fd_fifo_length(queue, &count, NULL) );
    266                 CHECK( 0, count);
     259                CHECK( 0, fd_fifo_length(queue) );
    267260               
    268261                /* Check the timedget actually timesout */
     
    274267                }
    275268                CHECK( ETIMEDOUT, fd_fifo_timedget(queue, &msg, &ts) );
    276                 CHECK( 0, fd_fifo_length(queue, &count, NULL) );
    277                 CHECK( 0, count);
     269                CHECK( 0, fd_fifo_length(queue) );
     270               
     271                /* Post & get another message */
     272                msg = msg1;
     273                CHECK( 0, fd_fifo_post(queue, &msg) );
     274                CHECK( 0, fd_fifo_timedget(queue, &msg, &ts) );
     275                CHECK( msg1, msg);             
     276               
     277                /* Check some statistics */
     278                CHECK( 0, fd_fifo_getstats(queue, NULL, NULL, &max, &count, NULL, NULL, NULL) );
     279                CHECK( 3, max );
     280                CHECK( 4, count );     
    278281               
    279282                /* We're done for basic tests */
     
    292295                pthread_t                thr [NBR_THREADS * 2];
    293296                struct dict_object      *dwr_model = NULL;
    294                 int                      count;
    295297                int                      i;
    296298                int                      nbr_threads;
     
    363365               
    364366                /* Check the count of the queue is back to 0 */
    365                 CHECK( 0, fd_fifo_length(queue, &count, NULL) );
    366                 CHECK( 0, count);
     367                CHECK( 0, fd_fifo_length(queue) );
    367368               
    368369                /* Destroy this queue and the messages */
Note: See TracChangeset for help on using the changeset viewer.