Changeset 19135af for test


Ignore:
Timestamp:
04/10/14 12:42:28 (6 years ago)
Author:
Richard Sanger <rsangerarj@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
60e8e86
Parents:
abda273
Message:

Fix type warnings in ring buffer test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/test-datastruct-ringbuffer.c

    rdf668eb r19135af  
    33#include <assert.h>
    44
    5 #define TEST_SIZE 1000000
    6 #define RINGBUFFER_SIZE 10000
     5#define TEST_SIZE ((char *) 1000000)
     6#define RINGBUFFER_SIZE ((char *) 10000)
    77
    88static void * producer(void * a) {
    99        libtrace_ringbuffer_t * rb = (libtrace_ringbuffer_t *) a;
    10         int i;
    11         void * value;
    12         for (i = 0; i < TEST_SIZE; i++) {
    13                 value = (void *) i;
    14                 libtrace_ringbuffer_write(rb, value);
     10        char * i;
     11        for (i = NULL; i < TEST_SIZE; i++) {
     12                libtrace_ringbuffer_write(rb, i);
    1513        }
    1614        return 0;
     
    1917static void * consumer(void * a) {
    2018        libtrace_ringbuffer_t * rb = (libtrace_ringbuffer_t *) a;
    21         int i;
    22         void * value;
    23         for (i = 0; i < TEST_SIZE; i++) {
     19        char *i;
     20        void *value;
     21        for (i = NULL; i < TEST_SIZE; i++) {
    2422                value = libtrace_ringbuffer_read(rb);
    25                 assert(value == (void *) i);
     23                assert(value == i);
    2624        }
    2725        return 0;
     
    3432 */
    3533int main() {
    36         int i;
     34        char *i;
    3735        void *value;
    3836        pthread_t t[4];
     
    4038        libtrace_ringbuffer_t rb_polling;
    4139
    42         libtrace_ringbuffer_init(&rb_block, RINGBUFFER_SIZE, LIBTRACE_RINGBUFFER_BLOCKING);
    43         libtrace_ringbuffer_init(&rb_polling, RINGBUFFER_SIZE, LIBTRACE_RINGBUFFER_BLOCKING);
     40        libtrace_ringbuffer_init(&rb_block, (size_t) RINGBUFFER_SIZE, LIBTRACE_RINGBUFFER_BLOCKING);
     41        libtrace_ringbuffer_init(&rb_polling, (size_t) RINGBUFFER_SIZE, LIBTRACE_RINGBUFFER_BLOCKING);
    4442        assert(libtrace_ringbuffer_is_empty(&rb_block));
    4543        assert(libtrace_ringbuffer_is_empty(&rb_polling));
    4644
    47         for (i = 0; i < RINGBUFFER_SIZE; i++) {
     45        for (i = NULL; i < RINGBUFFER_SIZE; i++) {
    4846                value = (void *) i;
    4947                libtrace_ringbuffer_write(&rb_block, value);
     
    6361
    6462        // Cycle the buffer a few times
    65         for (i = 0; i < TEST_SIZE; i++) {
     63        for (i = NULL; i < TEST_SIZE; i++) {
    6664                value = (void *) -1;
    6765                value = libtrace_ringbuffer_read(&rb_block);
     
    7068                value = libtrace_ringbuffer_read(&rb_polling);
    7169                assert(value == (void *) i);
    72                 value = (void *) (i + RINGBUFFER_SIZE);
     70                value = (void *) (i + (size_t) RINGBUFFER_SIZE);
    7371                libtrace_ringbuffer_write(&rb_block, value);
    7472                libtrace_ringbuffer_write(&rb_polling, value);
     
    7674
    7775        // Empty it completely
    78         for (i = TEST_SIZE; i < TEST_SIZE + RINGBUFFER_SIZE; i++) {
     76        for (i = TEST_SIZE; i < TEST_SIZE + (size_t) RINGBUFFER_SIZE; i++) {
    7977                value = libtrace_ringbuffer_read(&rb_block);
    8078                assert(value == (void *) i);
Note: See TracChangeset for help on using the changeset viewer.