Changeset 961f687


Ignore:
Timestamp:
05/25/06 14:59:28 (15 years ago)
Author:
Perry Lorier <perry@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, 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:
f57715c8
Parents:
64444f9
Message:

Validate conversions actually worked.

Location:
test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • test/Makefile

    rcd7eec7 r961f687  
    3434# Not all types are convertable, for instance libtrace doesn't
    3535# do rtclient output, and erf doesn't support 802.11
     36        @echo \* Conversions
     37        @echo " * erf -> erf"
    3638        @LD_LIBRARY_PATH=$(libdir) ./test-convert erf erf
     39        @echo " * erf -> pcap"
    3740        @LD_LIBRARY_PATH=$(libdir) ./test-convert erf pcap
     41        @echo " * pcap -> erf"
    3842        @LD_LIBRARY_PATH=$(libdir) ./test-convert pcap erf
     43        @echo " * pcapfile -> erf"
    3944        @LD_LIBRARY_PATH=$(libdir) ./test-convert pcapfile erf
    40         #@LD_LIBRARY_PATH=$(libdir) ./test-convert rtclient erf
    41         #@LD_LIBRARY_PATH=$(libdir) ./test-convert rtclient pcap
     45        @#LD_LIBRARY_PATH=$(libdir) ./test-convert rtclient erf
     46        @#LD_LIBRARY_PATH=$(libdir) ./test-convert rtclient pcap
     47        @echo " * wtf -> pcap"
    4248        @LD_LIBRARY_PATH=$(libdir) ./test-convert wtf pcap
     49        @echo " * wtf -> wtf"
    4350        @LD_LIBRARY_PATH=$(libdir) ./test-convert wtf wtf
     51        @echo " * duck -> duck"
    4452        @LD_LIBRARY_PATH=$(libdir) ./test-convert duck duck
    4553 
  • test/test-convert.c

    rcd7eec7 r961f687  
    103103        int level = 0;
    104104        int expected = 100;
    105         libtrace_t *trace;
     105        libtrace_t *trace,*trace2;
    106106        libtrace_out_t *outtrace;
    107         libtrace_packet_t *packet;
     107        libtrace_packet_t *packet,*packet2;
    108108
    109109        trace = trace_create(lookup_uri(argv[1]));
     
    143143        trace_destroy_packet(&packet);
    144144        if (error == 0) {
    145                 if (count == expected) {
    146                         printf("success: %d packets read\n",expected);
    147                 } else {
     145                if (count != expected) {
    148146                        printf("failure: %d packets expected, %d seen\n",expected,count);
    149147                        error = 1;
     
    154152        trace_destroy(trace);
    155153        trace_destroy_output(outtrace);
     154
     155        if (error)
     156                return error;
     157
     158        /* Now read it back in again and check it's all kosher */
     159        trace = trace_create(lookup_uri(argv[1]));
     160        iferr(trace);
     161        trace_start(trace);
     162        trace2 = trace_create(lookup_out_uri(argv[2]));
     163        iferr(trace2);
     164        trace_start(trace2);
     165        iferr(trace2);
     166        packet=trace_create_packet();
     167        packet2=trace_create_packet();
     168        count=0;
     169        while(trace_read_packet(trace,packet)>0) {
     170                int err;
     171                ++count;
     172                if ((err=trace_read_packet(trace2,packet2))<1) {
     173                        printf("premature EOF on destination, %i from %s, %i from %s\n",count,lookup_uri(argv[1]),count-1,lookup_out_uri(argv[2]));
     174                        iferr(trace2);
     175                        error=1;
     176                        break;
     177                }
     178                assert(trace_get_capture_length(packet)
     179                                == trace_get_capture_length(packet2));
     180                assert(trace_get_wire_length(packet)
     181                                == trace_get_wire_length(packet2));
     182        }
     183        if (trace_read_packet(trace2,packet2)>0) {
     184                printf("Extra packets after EOF\n");
     185                error=1;
     186        }
     187        trace_destroy(trace);
     188        trace_destroy(trace2);
     189        trace_destroy_packet(&packet);
     190
    156191        return error;
    157192}
Note: See TracChangeset for help on using the changeset viewer.