Skip to content

Commit

Permalink
Merge pull request #49 from cbm-fles/fix_checker
Browse files Browse the repository at this point in the history
Fixes in checkers
  • Loading branch information
cuveland committed Mar 22, 2019
2 parents 1e42350 + 5280f4d commit 4ed5947
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
31 changes: 23 additions & 8 deletions lib/fles_core/FlibPatternChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,34 @@ bool FlibPatternChecker::check(const fles::Microslice& m) {
++flib_pgen_packet_number_;
}

// Do not check last word size and last word if ms was truncated
// Last word check will be skipped because last_word_size = 0
if (m.desc().size >= 1 &&
((m.desc().flags &
static_cast<uint16_t>(fles::MicrosliceFlags::OverflowFlim)) == 0)) {
if (m.desc().size >= 1) {
last_word_size = m.content()[0];
if ((m.desc().size & 0x7) != (last_word_size & 0x7)) {
std::cerr << "Flib pgen: error in last word size" << std::endl;
std::cerr << "desc.size " << m.desc().size << std::endl;
// Assert last word size is in valid range form 0 to 8 bytes
if (last_word_size > 8) {
std::cerr << "Flib pgen: error in last word size: out of bounds"
<< std::endl;
std::cerr << "last word " << static_cast<uint32_t>(last_word_size)
<< std::endl;
last_word_size = 0;
return false;
}
// Do not check last word size consistency and last word content if ms was
// truncated
if ((m.desc().flags &
static_cast<uint16_t>(fles::MicrosliceFlags::OverflowFlim)) == 0) {
if ((m.desc().size & 0x7) != (last_word_size & 0x7)) {
std::cerr
<< "Flib pgen: error in last word size: inconsistent with desc.size"
<< std::endl;
std::cerr << "desc.size " << m.desc().size << std::endl;
std::cerr << "last word " << static_cast<uint32_t>(last_word_size)
<< std::endl;
return false;
}
} else {
// if truncated set to 0 to skip last word content check at the end
last_word_size = 0;
}
}

if (m.desc().size >= 4) {
Expand Down
2 changes: 1 addition & 1 deletion lib/fles_core/MicrosliceAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ bool MicrosliceAnalyzer::check_microslice(const fles::Microslice& ms) {
out_verbosity_ >= 3) { // full dump for first error
out_ << "microslice content:\n"
<< MicrosliceDescriptorDump(ms.desc())
<< BufferDump(ms.content(), ms.desc().size);
<< BufferDump(ms.content(), ms.desc().size) << std::flush;
}
++microslice_error_count_;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/fles_core/TimesliceAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ bool TimesliceAnalyzer::check_timeslice(const fles::Timeslice& ts) {
out_ << "microslice content:\n"
<< MicrosliceDescriptorDump(ts.get_microslice(c, m).desc())
<< BufferDump(ts.get_microslice(c, m).content(),
ts.get_microslice(c, m).desc().size);
ts.get_microslice(c, m).desc().size)
<< std::flush;
}
++timeslice_error_count_;
return false;
Expand Down

0 comments on commit 4ed5947

Please sign in to comment.