forked from osmocom/wireshark
Add a test to verify we pre-allocated enough hf entries.
This way we'll know as soon as we drop below the pre-allocated limit. As suggested by Graham on https://code.wireshark.org/review/10601 Change-Id: Ieeb14bdcf991d7a67c30787c97ca24ebb35d1763 Reviewed-on: https://code.wireshark.org/review/10627 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
This commit is contained in:
parent
66de69aeae
commit
3ff5afd541
28
epan/proto.c
28
epan/proto.c
|
@ -7809,8 +7809,11 @@ proto_registrar_dump_values(void)
|
|||
/* Prints the number of registered fields.
|
||||
* Useful for determining an appropriate value for
|
||||
* PROTO_PRE_ALLOC_HF_FIELDS_MEM.
|
||||
*
|
||||
* Returns FALSE if PROTO_PRE_ALLOC_HF_FIELDS_MEM is larger than or equal to
|
||||
* the number of fields, TRUE otherwise.
|
||||
*/
|
||||
void
|
||||
gboolean
|
||||
proto_registrar_dump_fieldcount(void)
|
||||
{
|
||||
guint32 i;
|
||||
|
@ -7834,17 +7837,24 @@ proto_registrar_dump_fieldcount(void)
|
|||
same_name_count++;
|
||||
}
|
||||
|
||||
printf("There are %d header fields registered, of which:\n"
|
||||
"\t%d are deregistered\n"
|
||||
"\t%d are protocols\n"
|
||||
"\t%d have the same name as another field\n\n",
|
||||
printf ("There are %d header fields registered, of which:\n"
|
||||
"\t%d are deregistered\n"
|
||||
"\t%d are protocols\n"
|
||||
"\t%d have the same name as another field\n\n",
|
||||
gpa_hfinfo.len, deregistered_count, protocol_count,
|
||||
same_name_count);
|
||||
|
||||
printf("The header field table consumes %d KiB of memory.\n",
|
||||
(int)(gpa_hfinfo.allocated_len * sizeof(header_field_info *) / 1024));
|
||||
printf("The fields themselves consume %d KiB of memory.\n",
|
||||
(int)(gpa_hfinfo.len * sizeof(header_field_info) / 1024));
|
||||
printf ("%d fields were pre-allocated.\n%s", PROTO_PRE_ALLOC_HF_FIELDS_MEM,
|
||||
(gpa_hfinfo.allocated_len > PROTO_PRE_ALLOC_HF_FIELDS_MEM) ?
|
||||
"* * Please increase PROTO_PRE_ALLOC_HF_FIELDS_MEM (in epan/proto.c)! * *\n\n" :
|
||||
"\n");
|
||||
|
||||
printf ("The header field table consumes %d KiB of memory.\n",
|
||||
(int)(gpa_hfinfo.allocated_len * sizeof(header_field_info *) / 1024));
|
||||
printf ("The fields themselves consume %d KiB of memory.\n",
|
||||
(int)(gpa_hfinfo.len * sizeof(header_field_info) / 1024));
|
||||
|
||||
return (gpa_hfinfo.allocated_len > PROTO_PRE_ALLOC_HF_FIELDS_MEM);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2251,8 +2251,9 @@ WS_DLL_PUBLIC void proto_registrar_dump_protocols(void);
|
|||
/** Dumps a glossary of the field value strings or true/false strings to STDOUT */
|
||||
WS_DLL_PUBLIC void proto_registrar_dump_values(void);
|
||||
|
||||
/** Dumps the number of protocol and field registrations to STDOUT. */
|
||||
WS_DLL_PUBLIC void proto_registrar_dump_fieldcount(void);
|
||||
/** Dumps the number of protocol and field registrations to STDOUT.
|
||||
@return FALSE if we pre-allocated enough fields, TRUE otherwise. */
|
||||
WS_DLL_PUBLIC gboolean proto_registrar_dump_fieldcount(void);
|
||||
|
||||
/** Dumps a glossary of the protocol and field registrations to STDOUT. */
|
||||
WS_DLL_PUBLIC void proto_registrar_dump_fields(void);
|
||||
|
|
|
@ -100,6 +100,12 @@ unittests_step_ftsanity() {
|
|||
unittests_step_test
|
||||
}
|
||||
|
||||
unittests_step_fieldcount() {
|
||||
check_dut tshark
|
||||
ARGS="-G fieldcount"
|
||||
unittests_step_test
|
||||
}
|
||||
|
||||
unittests_cleanup_step() {
|
||||
rm -f ./testout.txt
|
||||
}
|
||||
|
@ -113,6 +119,7 @@ unittests_suite() {
|
|||
test_step_add "tvbtest" unittests_step_tvbtest
|
||||
test_step_add "wmem_test" unittests_step_wmem_test
|
||||
test_step_add "ftsanity.py" unittests_step_ftsanity
|
||||
test_step_add "field count" unittests_step_fieldcount
|
||||
}
|
||||
#
|
||||
# Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
|
|
7
tshark.c
7
tshark.c
|
@ -1276,9 +1276,10 @@ DIAG_ON(cast-qual)
|
|||
write_prefs(NULL);
|
||||
else if (strcmp(argv[2], "dissector-tables") == 0)
|
||||
dissector_dump_dissector_tables();
|
||||
else if (strcmp(argv[2], "fieldcount") == 0)
|
||||
proto_registrar_dump_fieldcount();
|
||||
else if (strcmp(argv[2], "fields") == 0)
|
||||
else if (strcmp(argv[2], "fieldcount") == 0) {
|
||||
/* return value for the test suite */
|
||||
return proto_registrar_dump_fieldcount();
|
||||
} else if (strcmp(argv[2], "fields") == 0)
|
||||
proto_registrar_dump_fields();
|
||||
else if (strcmp(argv[2], "ftypes") == 0)
|
||||
proto_registrar_dump_ftypes();
|
||||
|
|
Loading…
Reference in New Issue