Skip to content

all-properties now shows results in an ordering #3241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions regression/cbmc/Multiple_Properties1/test.desc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
CORE
main.c
--property main.assertion.1 --property main.assertion.3
activate-multi-line-match
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED
^.*main.assertion.1.*SUCCESS
^.*main.assertion.3.*FAILURE
^VERIFICATION FAILED$
^main.c function main\n\[main\.assertion\.1\] .* SUCCESS\n\[main\.assertion\.3\] .* FAILURE$
--
^warning: ignoring
57 changes: 52 additions & 5 deletions src/cbmc/all_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Author: Daniel Kroening, [email protected]

#include "all_properties_class.h"

#include <algorithm>
#include <chrono>

#include <util/xml.h>
Expand Down Expand Up @@ -158,17 +159,63 @@ void bmc_all_propertiest::report(const cover_goalst &cover_goals)
{
result() << "\n** Results:" << eom;

for(const auto &goal_pair : goal_map)
// collect goals in a vector
std::vector<goal_mapt::const_iterator> goals;

for(auto g_it = goal_map.begin(); g_it != goal_map.end(); g_it++)
goals.push_back(g_it);

// now determine an ordering for those goals:
// 1. alphabetical ordering of file name
// 2. numerical ordering of line number
// 3. alphabetical ordering of goal ID
std::sort(
goals.begin(),
goals.end(),
[](goal_mapt::const_iterator git1, goal_mapt::const_iterator git2) {
const auto &g1 = git1->second.source_location;
const auto &g2 = git2->second.source_location;
if(g1.get_file() != g2.get_file())
return id2string(g1.get_file()) < id2string(g2.get_file());
else if(!g1.get_line().empty() && !g2.get_line().empty())
return std::stoul(id2string(g1.get_line())) <
std::stoul(id2string(g2.get_line()));
else
return id2string(git1->first) < id2string(git2->first);
});

// now show in the order we have determined

irep_idt previous_function;
for(const auto &g : goals)
{
result() << "[" << goal_pair.first << "] "
<< goal_pair.second.description << ": ";
const auto &l = g->second.source_location;

if(goal_pair.second.status == goalt::statust::SUCCESS)
if(l.get_function() != previous_function)
{
if(!previous_function.empty())
result() << '\n';
previous_function = l.get_function();
if(!previous_function.empty())
{
if(!l.get_file().empty())
result() << l.get_file() << ' ';
if(!l.get_function().empty())
result() << "function " << l.get_function();
result() << eom;
}
}

result() << faint << '[' << g->first << "] " << reset;

result() << g->second.description << ": ";

if(g->second.status == goalt::statust::SUCCESS)
result() << green;
else
result() << red;

result() << goal_pair.second.status_string() << reset << eom;
result() << g->second.status_string() << reset << eom;
}

if(bmc.options.get_bool_option("trace"))
Expand Down
2 changes: 2 additions & 0 deletions src/cbmc/all_properties_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class bmc_all_propertiest:
instancest;
instancest instances;
std::string description;
source_locationt source_location;

// if failed, we compute a goto_trace for the first failing instance
enum statust { UNKNOWN, FAILURE, SUCCESS, ERROR } status;
Expand All @@ -64,6 +65,7 @@ class bmc_all_propertiest:
const goto_programt::instructiont &instruction):
status(statust::UNKNOWN)
{
source_location = instruction.source_location;
description=id2string(instruction.source_location.get_comment());
}

Expand Down