forked from viperproject/silicon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request viperproject#853 from viperproject/meilers_cond_pe…
…rms_disable_for_perm_introspection Not pushing conditions using permission introspection further in, adding tests for conditionalizePermissions
- Loading branch information
Showing
7 changed files
with
122 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/test/resources/conditionalizePermissions/carbon_0179.vpr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
predicate P1(r$: Ref) | ||
|
||
predicate P3(r$: Ref) | ||
|
||
method test2() | ||
{ | ||
var b: Ref | ||
var k: Perm | ||
|
||
inhale acc(P1(b)) | ||
inhale acc(P3(b)) | ||
|
||
exhale perm(P3(b)) >= write ? acc(P3(b)) : (perm(P1(b)) > none ? acc(P1(b), write - perm(P3(b))) : true) | ||
|
||
assert perm(P1(b)) == write | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
field f: Int | ||
|
||
function ok(): Bool | ||
|
||
|
||
function val(): Ref | ||
requires ok() | ||
|
||
method test() | ||
{ | ||
// Test that the condition is not pushed inside the let expression to get e.g. | ||
// inhale let x == (val()) in acc(x.f, ok() ? write : none) | ||
// which would not be well-defined. | ||
inhale ok() ==> let x == (val()) in acc(x.f) | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/resources/conditionalizePermissions/silicon_0008.vpr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
|
||
field f: Int | ||
|
||
method deAlias(x: Ref, y: Ref, k: Perm) | ||
requires k >= none | ||
requires acc(x.f, k) && acc(y.f, k) | ||
// The following postcondition should fail in default greedy Silicon because --conditionalizePermissions creates a | ||
// situation where the two chunks may or may not alias in the same branch, so they cannot definitively be merged, | ||
// so greedy Silicon cannot prove the postcondition using any individual chunk. | ||
//:: ExpectedOutput(postcondition.violated:insufficient.permission) | ||
ensures x == y ==> acc(x.f, 2 * k) | ||
{} |
27 changes: 27 additions & 0 deletions
27
src/test/resources/conditionalizePermissions/silicon_0713.vpr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
|
||
field int: Int | ||
field unrelated: Int | ||
|
||
method conv_layer(a: Set[Ref]) | ||
requires (forall r: Ref :: r in a ==> acc(r.int, write)) | ||
{ | ||
label beforeFrame | ||
while (true) | ||
invariant true ==> | ||
(forall r: Ref :: r in a ==> acc(r.int, write)) && | ||
[ | ||
// on inhale | ||
(forperm | ||
obj: Ref [obj.unrelated] :: obj.unrelated == | ||
old[beforeFrame](obj.unrelated)) && | ||
(forperm | ||
obj: Ref [obj.int] :: obj.int == old[beforeFrame](obj.int)), | ||
|
||
// on exhale | ||
true | ||
] | ||
{ inhale false } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
field f: Int | ||
|
||
function ok(): Bool | ||
|
||
|
||
function val(): Ref | ||
requires ok() | ||
|
||
|
||
method test() | ||
{ | ||
inhale ok() ==> acc(val().f) | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/scala/SiliconTestsConditionalizePermissions.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) 2011-2022 ETH Zurich. | ||
|
||
package viper.silicon.tests | ||
|
||
class SiliconTestsConditionalizePermissions extends SiliconTests { | ||
override val testDirectories: Seq[String] = Seq("conditionalizePermissions") | ||
|
||
override val commandLineArguments: Seq[String] = Seq( | ||
"--timeout", "300" /* seconds */, | ||
"--conditionalizePermissions") | ||
} |