Skip to content

Commit 396d31e

Browse files
Add result_to_exit_code
Enable consistent result-dependent exit codes across all driver programs.
1 parent 440fc64 commit 396d31e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/goto-checker/properties.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Author: Daniel Kroening, Peter Schrammel
1111

1212
#include "properties.h"
1313

14+
#include <util/exit_codes.h>
1415
#include <util/invariant.h>
1516
#include <util/json.h>
1617
#include <util/xml.h>
@@ -116,6 +117,22 @@ json(const irep_idt &property_id, const property_infot &property_info)
116117
return result;
117118
}
118119

120+
int result_to_exit_code(resultt result)
121+
{
122+
switch(result)
123+
{
124+
case resultt::PASS:
125+
return CPROVER_EXIT_VERIFICATION_SAFE;
126+
case resultt::FAIL:
127+
return CPROVER_EXIT_VERIFICATION_UNSAFE;
128+
case resultt::ERROR:
129+
return CPROVER_EXIT_INTERNAL_ERROR;
130+
case resultt::UNKNOWN:
131+
return CPROVER_EXIT_VERIFICATION_INCONCLUSIVE;
132+
}
133+
UNREACHABLE;
134+
}
135+
119136
std::size_t
120137
count_properties(const propertiest &properties, property_statust status)
121138
{

src/goto-checker/properties.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ xmlt xml(const irep_idt &property_id, const property_infot &property_info);
8484
json_objectt
8585
json(const irep_idt &property_id, const property_infot &property_info);
8686

87+
int result_to_exit_code(resultt result);
88+
8789
/// Return the number of properties with given \p status
8890
std::size_t count_properties(const propertiest &, property_statust);
8991

0 commit comments

Comments
 (0)