On Tue, Mar 29, 2011 at 11:07:14AM -0400, Jeff Morriss wrote:
> Of course, the fact that they don't work does imply we might want to
> comment them out for the time being--unless someone wants to get them
> working.
Ok, I've fixed composite tests #0 and #2 :) Patch attached.
Other tests are imho broken, e.g. composite #1
composite is created by two tvb_smalls which are created by:
tvb_small[i] = tvb_new_real_data(small[i], 16, 17);
where small[i] is some random data -- lets assume 01234567890ABCDEF
so total reported_len is 34, and length is 32.
Data:
0 1 2 3 4 5 6 7 8 9 A B C D E F ? (packet truncated by 1 byte)
0 1 2 3 4 5 6 7 8 9 A B C D E F ? (packet truncated by 1 byte)
but expected data is set to: 01234567890ABCDEF01234567890ABCDEF,
and it doesn't care about truncated data.
Regards.
diff --git epan/tvbtest.c epan/tvbtest.c
index de1aeec..ae3aa8a 100644
--- epan/tvbtest.c
+++ epan/tvbtest.c
@@ -22,6 +22,10 @@
*
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -244,6 +248,13 @@ test(tvbuff_t *tvb, gchar* name,
return TRUE;
}
+gboolean
+skip(tvbuff_t *tvb _U_, gchar* name,
+ guint8* expected_data _U_, guint expected_length _U_)
+{
+ printf("Skipping TVB=%s\n", name);
+ return FALSE;
+}
void
@@ -259,12 +270,10 @@ run_tests(void)
guint8 *subset[6];
guint subset_length[6];
guint8 temp;
-#if 0
guint8 *comp[6];
tvbuff_t *tvb_comp[6];
guint comp_length[6];
int len;
-#endif
for (i = 0; i < 3; i++) {
small[i] = g_new(guint8, 16);
@@ -329,7 +338,6 @@ run_tests(void)
test(tvb_subset[4], "Subset 4", subset[4], subset_length[4]);
test(tvb_subset[5], "Subset 5", subset[5], subset_length[5]);
-#if 0
/* Composite tvbuffs don't work at the moment -- tests commented out until
* they do. */
@@ -408,12 +416,11 @@ run_tests(void)
/* Test the TVBUFF_COMPOSITE objects. */
test(tvb_comp[0], "Composite 0", comp[0], comp_length[0]);
- test(tvb_comp[1], "Composite 1", comp[1], comp_length[1]);
+ skip(tvb_comp[1], "Composite 1", comp[1], comp_length[1]);
test(tvb_comp[2], "Composite 2", comp[2], comp_length[2]);
- test(tvb_comp[3], "Composite 3", comp[3], comp_length[3]);
- test(tvb_comp[4], "Composite 4", comp[4], comp_length[4]);
- test(tvb_comp[5], "Composite 5", comp[5], comp_length[5]);
-#endif
+ skip(tvb_comp[3], "Composite 3", comp[3], comp_length[3]);
+ skip(tvb_comp[4], "Composite 4", comp[4], comp_length[4]);
+ skip(tvb_comp[5], "Composite 5", comp[5], comp_length[5]);
}
int
diff --git epan/tvbuff.c epan/tvbuff.c
index 32f8225..57b9580 100644
--- epan/tvbuff.c
+++ epan/tvbuff.c
@@ -604,6 +604,7 @@ tvb_composite_finalize(tvbuff_t* tvb)
DISSECTOR_ASSERT(tvb && !tvb->initialized);
DISSECTOR_ASSERT(tvb->type == TVBUFF_COMPOSITE);
DISSECTOR_ASSERT(tvb->length == 0);
+ DISSECTOR_ASSERT(tvb->reported_length == 0);
composite = &tvb->tvbuffs.composite;
num_members = g_slist_length(composite->tvbs);
@@ -616,6 +617,7 @@ tvb_composite_finalize(tvbuff_t* tvb)
member_tvb = slist->data;
composite->start_offsets[i] = tvb->length;
tvb->length += member_tvb->length;
+ tvb->reported_length += member_tvb->reported_length;
composite->end_offsets[i] = tvb->length - 1;
i++;
}