Skip to content
Snippets Groups Projects
Commit c73e95e6 authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Logs of unsuccessful union matchings are now properly cleaned up (bug 567844)


Signed-off-by: default avatarBotond Baranyi <botond.baranyi@ericsson.com>
Change-Id: I723f69311554c3010add93c4833e5f6f85cf7747
parent a82e0f51
No related branches found
No related tags found
No related merge requests found
......@@ -3216,12 +3216,14 @@ void defUnionTemplate(const struct_def *sdef, output_struct *output)
"}\n"
"if (template_selection == SPECIFIC_VALUE && "
"single_value.union_selection == match_value.get_selection()) {\n"
"size_t previous_size = TTCN_Logger::get_logmatch_buffer_len();\n"
"switch (single_value.union_selection) {\n", name, name);
for (i = 0; i < sdef->nElements; i++) {
src = mputprintf(src, "case %s_%s:\n"
"if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){\n"
"TTCN_Logger::log_logmatch_info(\".%s\");\n"
"single_value.field_%s->log_match(match_value.%s%s(), legacy);\n"
"TTCN_Logger::set_logmatch_buffer_len(previous_size);\n"
"} else {\n"
"TTCN_Logger::log_event_str(\"{ %s := \");\n"
"single_value.field_%s->log_match(match_value.%s%s(), legacy);\n"
......
......@@ -200,6 +200,27 @@ testcase tc_record_withWildCard3E() runs on templateUnion_mycomp {
if(ispresent(vtl_rec2.u.i)){setverdict(fail)}else {setverdict(pass)};
}
testcase tc_logmatch_cleanup() runs on templateUnion_mycomp {
// bug 567844
// When logging the result of an unsuccessful matching operation with a union template,
// the matching info is not properly cleaned up, and can cause future logged matchings
// of the same type to also display leftover data.
var charstring log2_exp := " matched";
for (var integer i := 0; i < 5; i := i + 1) {
var templateUnion_myunion x := { f1 := i };
var charstring log1 := log2str(match(x, templateUnion_myunion: { f1 := 10 }));
var charstring log1_exp := ".f1 := " & int2str(i) & " with 10 unmatched";
if (log1 != log1_exp) {
setverdict(fail, "log1: ", log1, ", expected: ", log1_exp);
}
var charstring log2 := log2str(match(x, templateUnion_myunion: { f1 := ? }));
if (log2 != log2_exp) {
setverdict(fail, "log2: ", log2, ", expected: ", log2_exp);
}
}
setverdict(pass);
}
control {
execute(templateUnionSpec());
execute(templateUnionList());
......@@ -209,5 +230,6 @@ control {
execute(templateUnionAnyorNone());
// execute(templateUnionIfpresent());
execute(tc_record_withWildCard3E());
execute(tc_logmatch_cleanup());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment