Skip to content

Commit

Permalink
Two regresion tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-schwarz committed Sep 20, 2024
1 parent 33aee5a commit 3c0ff8c
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/regression/80-context_gas/23-per-fun.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// PARAM: --enable ana.int.interval_set --set ana.context.gas_value 3 --set ana.context.gas_scope function
int nr(int x, int y) {
// Non-recursive, but would fail with global scope as gas for f is exhausted
__goblint_check(x==y);
}

int f(int x, int y)
{
int top;
if (x == 0)
{
return y;
}

if(top) {
nr(5,5);
} else {
nr(6,6);
}

return f(x - 1, y - 1);
}

int main()
{
// main -> f(3,3) -> f(2,2) -> f(1,1) -> f(0,0) -> return 0
// 4 recursive calls -> boundary (excluded)
__goblint_check(f(3, 3) == 0); // UNKNOWN
}
44 changes: 44 additions & 0 deletions tests/regression/80-context_gas/24-per-fun-ex.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// PARAM: --enable ana.int.interval_set --set ana.context.gas_value 3 --set ana.context.gas_scope function
int nr(int x, int y) {
// Non-recursive, but would fail with global scope as gas for f is exhausted
__goblint_check(x==y);
}

// Checks that gas is also applied to further functions
int g(int x, int y)
{
int top;
if (x < -100000)
{
return y;
}

if(top) {
nr(5,5);
} else {
nr(6,6);
}

return g(x - 1, y - 1);
}

int f(int x, int y)
{
int top;

if (x == 0)
{
return y;
}

g(x,y);

return f(x - 1, y - 1);
}

int main()
{
// main -> f(3,3) -> f(2,2) -> f(1,1) -> f(0,0) -> return 0
// 4 recursive calls -> boundary (excluded)
__goblint_check(f(3, 3) == 0); // UNKNOWN
}

0 comments on commit 3c0ff8c

Please sign in to comment.