Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LARA
inox
Commits
045ce441
Commit
045ce441
authored
9 years ago
by
Lars Hupel
Browse files
Options
Downloads
Patches
Plain Diff
VerificationSuite: allow testing for errors and inconclusive results
parent
e3bf8ee0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/scala/leon/regression/verification/VerificationSuite.scala
+35
-15
35 additions, 15 deletions
...cala/leon/regression/verification/VerificationSuite.scala
with
35 additions
and
15 deletions
src/test/scala/leon/regression/verification/VerificationSuite.scala
+
35
−
15
View file @
045ce441
...
@@ -19,17 +19,18 @@ trait VerificationSuite extends LeonRegressionSuite {
...
@@ -19,17 +19,18 @@ trait VerificationSuite extends LeonRegressionSuite {
val
optionVariants
:
List
[
List
[
String
]]
val
optionVariants
:
List
[
List
[
String
]]
val
testDir
:
String
val
testDir
:
String
private
var
counter
:
Int
=
0
private
var
counter
:
Int
=
0
private
def
nextInt
()
:
Int
=
{
private
def
nextInt
()
:
Int
=
{
counter
+=
1
counter
+=
1
counter
counter
}
}
private
[
verification
]
case
class
Output
(
report
:
VerificationReport
,
reporter
:
Reporter
)
private
[
verification
]
case
class
Output
(
report
:
VerificationReport
,
reporter
:
Reporter
)
val
pipeFront
:
Pipeline
[
Program
,
Program
]
val
pipeFront
:
Pipeline
[
Program
,
Program
]
val
pipeBack
:
Pipeline
[
Program
,
VerificationReport
]
val
pipeBack
:
Pipeline
[
Program
,
VerificationReport
]
private
def
mkTest
(
files
:
List
[
String
],
cat
:
String
)(
block
:
Output
=>
Unit
)
=
{
private
def
mkTest
(
files
:
List
[
String
],
cat
:
String
,
forError
:
Boolean
)(
block
:
Output
=>
Unit
)
=
{
val
extraction
=
val
extraction
=
ExtractionPhase
andThen
ExtractionPhase
andThen
PreprocessingPhase
andThen
PreprocessingPhase
andThen
...
@@ -46,15 +47,22 @@ trait VerificationSuite extends LeonRegressionSuite {
...
@@ -46,15 +47,22 @@ trait VerificationSuite extends LeonRegressionSuite {
for
((
id
,
p
)
<-
programs
;
options
<-
optionVariants
)
{
for
((
id
,
p
)
<-
programs
;
options
<-
optionVariants
)
{
test
(
f
"${nextInt()}%3d: ${id.name} ${options.mkString("
")}"
)
{
test
(
f
"${nextInt()}%3d: ${id.name} ${options.mkString("
")}"
)
{
val
ctx
=
createLeonContext
(
options
:
_
*
)
val
ctx
=
createLeonContext
(
options
:
_
*
)
val
report
=
pipeBack
.
run
(
ctx
)(
p
)
if
(
forError
)
{
block
(
Output
(
report
,
ctx
.
reporter
))
intercept
[
LeonFatalError
]
{
pipeBack
.
run
(
ctx
)(
p
)
}
}
else
{
val
report
=
pipeBack
.
run
(
ctx
)(
p
)
block
(
Output
(
report
,
ctx
.
reporter
))
}
}
}
}
}
}
catch
{
}
catch
{
case
_:
LeonFatalError
=>
case
_:
LeonFatalError
=>
ctx
.
reporter
match
{
ctx
.
reporter
match
{
case
sr
:
TestSilentReporter
=>
case
sr
:
TestSilentReporter
=>
println
(
"Un
n
expected
F
atal error:"
)
println
(
"Unexpected
f
atal error:"
)
for
(
e
<-
sr
.
lastErrors
)
{
for
(
e
<-
sr
.
lastErrors
)
{
println
(
" "
+
e
)
println
(
" "
+
e
)
}
}
...
@@ -64,8 +72,8 @@ trait VerificationSuite extends LeonRegressionSuite {
...
@@ -64,8 +72,8 @@ trait VerificationSuite extends LeonRegressionSuite {
}
}
}
}
private
[
verification
]
def
forEachFileIn
(
cat
:
String
)(
block
:
Output
=>
Unit
)
{
private
[
verification
]
def
forEachFileIn
(
cat
:
String
,
forError
:
Boolean
)(
block
:
Output
=>
Unit
)
{
val
fs
=
filesInResourceDir
(
testDir
+
cat
,
_
.
endsWith
(
".scala"
)).
toList
val
fs
=
filesInResourceDir
(
testDir
+
cat
,
_
.
endsWith
(
".scala"
)).
toList
fs
foreach
{
file
=>
fs
foreach
{
file
=>
assert
(
file
.
exists
&&
file
.
isFile
&&
file
.
canRead
,
assert
(
file
.
exists
&&
file
.
isFile
&&
file
.
canRead
,
...
@@ -74,30 +82,42 @@ trait VerificationSuite extends LeonRegressionSuite {
...
@@ -74,30 +82,42 @@ trait VerificationSuite extends LeonRegressionSuite {
val
files
=
fs
map
{
_
.
getPath
}
val
files
=
fs
map
{
_
.
getPath
}
mkTest
(
files
,
cat
)(
block
)
mkTest
(
files
,
cat
,
forError
)(
block
)
}
}
override
def
run
(
testName
:
Option
[
String
],
args
:
Args
)
:
Status
=
{
override
def
run
(
testName
:
Option
[
String
],
args
:
Args
)
:
Status
=
{
forEachFileIn
(
"valid"
)
{
output
=>
forEachFileIn
(
"valid"
,
false
)
{
output
=>
val
Output
(
report
,
reporter
)
=
output
val
Output
(
report
,
reporter
)
=
output
for
((
vc
,
vr
)
<-
report
.
vrs
if
(
vr
.
isInvalid
)
)
{
for
((
vc
,
vr
)
<-
report
.
vrs
if
vr
.
isInvalid
)
{
fail
(
s
"The following verification condition was invalid: $vc @${vc.getPos}"
)
fail
(
s
"The following verification condition was invalid: $vc @${vc.getPos}"
)
}
}
for
((
vc
,
vr
)
<-
report
.
vrs
if
(
vr
.
isInconclusive
)
)
{
for
((
vc
,
vr
)
<-
report
.
vrs
if
vr
.
isInconclusive
)
{
fail
(
s
"The following verification condition was inconclusive: $vc @${vc.getPos}"
)
fail
(
s
"The following verification condition was inconclusive: $vc @${vc.getPos}"
)
}
}
reporter
.
terminateIfError
()
reporter
.
terminateIfError
()
}
}
forEachFileIn
(
"invalid"
)
{
output
=>
forEachFileIn
(
"invalid"
,
false
)
{
output
=>
val
Output
(
report
,
reporter
)
=
output
val
Output
(
report
,
_
)
=
output
assert
(
report
.
totalUnknown
===
0
,
assert
(
report
.
totalUnknown
===
0
,
"There should not be unknown verification conditions."
)
"There should not be unknown verification conditions."
)
assert
(
report
.
totalInvalid
>
0
,
assert
(
report
.
totalInvalid
>
0
,
"There should be at least one invalid verification condition."
)
"There should be at least one invalid verification condition."
)
}
forEachFileIn
(
"unknown"
,
false
)
{
output
=>
val
Output
(
report
,
reporter
)
=
output
for
((
vc
,
vr
)
<-
report
.
vrs
if
vr
.
isInvalid
)
{
fail
(
s
"The following verification condition was invalid: $vc @${vc.getPos}"
)
}
assert
(
report
.
totalUnknown
>
0
,
"There should be at least one unknown verification conditions."
)
reporter
.
terminateIfError
()
}
}
forEachFileIn
(
"error"
,
true
)
{
_
=>
()
}
super
.
run
(
testName
,
args
)
super
.
run
(
testName
,
args
)
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment