diff --git a/tests/value/backward_arith.i b/tests/value/backward_arith.i new file mode 100644 index 0000000000000000000000000000000000000000..a26120d37e80dcd688b619bc03df1b6913549a60 --- /dev/null +++ b/tests/value/backward_arith.i @@ -0,0 +1,33 @@ +/* run.config* +*/ + +/* Test the soundness of arithmetic backward propagators. */ + +volatile int nondet; + +void unsigned_neg () { + unsigned int x = nondet; + unsigned int minus_ten = -10; /* minus_ten = 4294967286. */ + if (-x == minus_ten) + Frama_C_show_each_ten(x); + else + Frama_C_show_each_not_ten(x); + if (-x < minus_ten) + Frama_C_show_each_greater_than_ten_or_zero(x); + else + Frama_C_show_each_smaller_than_ten_but_zero(x); + if (-x == 10) + Frama_C_show_each_minus_ten(x); /* 4294967286 */ + else + Frama_C_show_each_not_minus_ten(x); /* not 4294967286 */ + if (-x < 10) + Frama_C_show_each_greater_than_minus_ten_or_zero(x); /* > 4294967286 or 0 */ + else + Frama_C_show_each_smaller_than_minus_ten_but_zero(x); /* <= 4294967286 but 0 */ +} + + +int main () { + unsigned_neg (); + return 0; +} diff --git a/tests/value/oracle/backward_arith.res.oracle b/tests/value/oracle/backward_arith.res.oracle new file mode 100644 index 0000000000000000000000000000000000000000..fc69e93b267804f0f74ea0cb0b35963203f1fd0d --- /dev/null +++ b/tests/value/oracle/backward_arith.res.oracle @@ -0,0 +1,44 @@ +[kernel] Parsing tests/value/backward_arith.i (no preprocessing) +[eva] Analyzing a complete application starting at main +[eva] Computing initial state +[eva] Initial state computed +[eva:initial-state] Values of globals at initialization + nondet ∈ [--..--] +[eva] computing for function unsigned_neg <- main. + Called from tests/value/backward_arith.i:31. +[eva] tests/value/backward_arith.i:14: + Frama_C_show_each_not_ten: [0..4294967295] +[eva] tests/value/backward_arith.i:16: + Frama_C_show_each_greater_than_ten_or_zero: {0} +[eva] tests/value/backward_arith.i:22: Frama_C_show_each_not_minus_ten: {0} +[eva] tests/value/backward_arith.i:24: + Frama_C_show_each_greater_than_minus_ten_or_zero: {0} +[eva] Recording results for unsigned_neg +[eva] Done for function unsigned_neg +[eva] Recording results for main +[eva] done for function main +[eva] ====== VALUES COMPUTED ====== +[eva:final-states] Values at end of function unsigned_neg: + x ∈ {0} + minus_ten ∈ {4294967286} +[eva:final-states] Values at end of function main: + __retres ∈ {0} +[from] Computing for function unsigned_neg +[from] Done for function unsigned_neg +[from] Computing for function main +[from] Done for function main +[from] ====== DEPENDENCIES COMPUTED ====== + These dependencies hold at termination for the executions that terminate: +[from] Function unsigned_neg: + NO EFFECTS +[from] Function main: + \result FROM \nothing +[from] ====== END OF DEPENDENCIES ====== +[inout] Out (internal) for function unsigned_neg: + x; minus_ten +[inout] Inputs for function unsigned_neg: + nondet +[inout] Out (internal) for function main: + __retres +[inout] Inputs for function main: + nondet