Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate manual tests #847

Merged
merged 29 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2bc950b
Add yamlWitnessStrip testing utility
sim642 Oct 5, 2022
74477a4
Add cram witness test to 56-witness/05-prec-problem
sim642 Oct 5, 2022
d8b0c1e
Strip file hashes from YAML witness cram tests
sim642 Oct 5, 2022
d751c4c
Merge branch 'master' into yaml-witness-cram
sim642 Oct 5, 2022
9086c99
Add YAML witness privatized invariant tests
sim642 Oct 5, 2022
950cf9b
Fix variable counting with ana.apron.invariant.one-var
sim642 Oct 5, 2022
6023cbd
Add ana.apron.invariant.diff-box test
sim642 Oct 5, 2022
5959095
Add test for dead code messages (issue #94)
sim642 Oct 5, 2022
cd90dfe
Add test for synthetic YAML witness invariant locations (PR #758)
sim642 Oct 5, 2022
8cc3ff2
Automate 00-sanity/33-hoare-over-paths using cram
sim642 Oct 6, 2022
9f5c0e1
Print regression tests without any automatic checks
sim642 Oct 6, 2022
4705c30
Fix many regression tests without automatic checks
sim642 Oct 6, 2022
f1ca09d
Add cram tests for manual checks
sim642 Oct 6, 2022
7b3a3ec
Hide getdate_err from MacOS output
sim642 Oct 6, 2022
0542913
Add test for broken mutex contents hiding on MacOS
sim642 Oct 6, 2022
7d9de04
Fix 03-practical/28-base-mutex-macos
sim642 Oct 6, 2022
f49fd11
Add cram tests for CFG
sim642 Oct 7, 2022
d285260
Merge branch 'master' into cram-manual
sim642 Jul 16, 2024
8971af4
Add NOCHECK annotation to suppress missing automatic check warning
sim642 Jul 16, 2024
5946abc
Add NOCHECK and another annotations
sim642 Jul 16, 2024
5de8823
Add NOCHECK and CRAM annotations to incremental tests
sim642 Jul 16, 2024
205f058
Error on missing automatic checks in regression tests
sim642 Jul 16, 2024
8da7046
Document meta annotations for regression tests
sim642 Jul 16, 2024
50b7e14
Add yamlWitnessStripDiff for cram test
sim642 Jul 23, 2024
65d4c02
Add pretty-deterministic output for cram test
sim642 Jul 23, 2024
e5a103c
Merge branch 'master' into cram-manual
sim642 Sep 25, 2024
701f1ae
Document scope of regression test meta annotations
sim642 Sep 26, 2024
8cce1c9
Comment on negative line numbers in update_suite
sim642 Sep 26, 2024
54eb6f6
Add CRAM annotation to 00-sanity/33-hoare-over-paths
sim642 Sep 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions scripts/update_suite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ def compare_warnings
check.call warnings[idx] != "race"
when "nodeadlock"
check.call warnings[idx] != "deadlock"
when "nocrash", "fixpoint", "notimeout", "cram"
check.call true
end
end
end
Expand Down Expand Up @@ -281,6 +283,15 @@ def parse_tests (lines)
if obj =~ /#line ([0-9]+).*$/ then
i = $1.to_i - 1
end
if obj =~ /NOCRASH/ then
tests[-42] = "nocrash"
elsif obj =~ /FIXPOINT/ then
tests[-42] = "fixpoint"
elsif obj =~ /NOTIMEOUT/ then
tests[-42] = "notimeout"
elsif obj =~ /CRAM/ then
tests[-42] = "cram"
end
next if obj =~ /^\s*\/\// || obj =~ /^\s*\/\*([^*]|\*+[^*\/])*\*\/$/
todo << i if obj =~ /TODO|SKIP/
tests_line[i] = obj
Expand Down Expand Up @@ -312,6 +323,9 @@ def parse_tests (lines)
when /TERM/
tests[-1] = "term"
end
if tests.empty? then
puts "No automatic checks in #{@id} (maybe NOCRASH/FIXPOINT/NOTIMEOUT/CRAM?)"
end
Tests.new(self, tests, tests_line, todo)
end

Expand Down
2 changes: 1 addition & 1 deletion src/analyses/apron/apronAnalysis.apron.ml
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ struct
|> List.enum
|> Enum.filter_map (fun (lincons1: Lincons1.t) ->
(* filter one-vars *)
if one_var || Apron.Linexpr0.get_size lincons1.lincons0.linexpr0 >= 2 then
if one_var || Lincons1.num_vars lincons1 >= 2 then
CilOfApron.cil_exp_of_lincons1 lincons1
|> Option.map e_inv
|> Option.filter (fun exp -> not (InvariantCil.exp_contains_tmp exp) && InvariantCil.exp_is_in_scope scope exp)
Expand Down
10 changes: 5 additions & 5 deletions src/analyses/base.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2151,7 +2151,7 @@ struct
| _ -> ()
);
match lval with (* this section ensure global variables contain bottom values of the proper type before setting them *)
| (Var v, offs) when AD.is_definite lval_val && v.vglob ->
sim642 marked this conversation as resolved.
Show resolved Hide resolved
| (Var v, offs) when v.vglob ->
(* Optimization: In case of simple integral types, we not need to evaluate the old value.
v is not an allocated block, as v directly appears as a variable in the program;
so no explicit check is required here (unlike in set) *)
Expand All @@ -2163,14 +2163,14 @@ struct
in
begin match current_val with
| `Bot -> (* current value is VD `Bot *)
begin match Addr.to_var_offset (AD.choose lval_val) with
| Some (x,offs) ->
begin match AD.to_var_offset lval_val with
| [(x,offs)] ->
let t = v.vtype in
let iv = VD.bot_value t in (* correct bottom value for top level variable *)
if M.tracing then M.tracel "set" "init bot value: %a\n" VD.pretty iv;
if M.tracing then M.tracel "set" "init bot value (%a): %a\n" d_plaintype t VD.pretty iv;
let nv = VD.update_offset (Analyses.ask_of_ctx ctx) iv offs rval_val (Some (Lval lval)) lval t in (* do desired update to value *)
set_savetop ~ctx (Analyses.ask_of_ctx ctx) ctx.global ctx.local (AD.from_var v) lval_t nv ~lval_raw:lval ~rval_raw:rval (* set top-level variable to updated value *)
| None ->
| _ ->
set_savetop ~ctx (Analyses.ask_of_ctx ctx) ctx.global ctx.local lval_val lval_t rval_val ~lval_raw:lval ~rval_raw:rval
end
| _ ->
Expand Down
9 changes: 9 additions & 0 deletions src/cdomains/apron/apronDomain.apron.ml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ struct

let show = Format.asprintf "%a" print
let compare x y = String.compare (show x) (show y) (* HACK *)

let num_vars x =
(* Apron.Linexpr0.get_size returns some internal nonsense, so we count ourselves. *)
let size = ref 0 in
Lincons1.iter (fun coeff var ->
if not (Apron.Coeff.is_zero coeff) then
incr size
) x;
!size
end

module Lincons1Set =
Expand Down
1 change: 1 addition & 0 deletions src/framework/control.ml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ struct
let is_std = function
| {vname = ("__tzname" | "__daylight" | "__timezone"); _} (* unix time.h *)
| {vname = ("tzname" | "daylight" | "timezone"); _} (* unix time.h *)
| {vname = "getdate_err"; _} (* unix time.h (only on MacOS?) *)
| {vname = ("stdin" | "stdout" | "stderr"); _} -> (* standard stdio.h *)
true
| _ -> false
Expand Down
9 changes: 9 additions & 0 deletions src/witness/yamlWitnessType.ml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ struct
column: int;
function_: string;
}
[@@deriving ord]

let to_yaml {file_name; file_hash; line; column; function_} =
`O [
Expand Down Expand Up @@ -132,6 +133,7 @@ struct
type_: string;
format: string;
}
[@@deriving ord]

let to_yaml {string; type_; format} =
`O [
Expand All @@ -154,6 +156,7 @@ struct
location: Location.t;
loop_invariant: Invariant.t;
}
[@@deriving ord]

let entry_type = "loop_invariant"

Expand All @@ -175,6 +178,7 @@ struct
type t = {
flow_insensitive_invariant: Invariant.t;
}
[@@deriving ord]

let entry_type = "flow_insensitive_invariant"

Expand All @@ -196,6 +200,7 @@ struct
loop_invariant: Invariant.t;
precondition: Invariant.t;
}
[@@deriving ord]

let entry_type = "precondition_loop_invariant"

Expand All @@ -221,6 +226,7 @@ struct
type_: string;
file_hash: string;
}
[@@deriving ord]

let to_yaml {uuid; type_; file_hash} =
`O [
Expand All @@ -244,6 +250,7 @@ struct
type_: string;
format: string;
}
[@@deriving ord]

let to_yaml {string; type_; format} =
`O [
Expand All @@ -266,6 +273,7 @@ struct
target: Target.t;
certification: Certification.t;
}
[@@deriving ord]

let entry_type = "loop_invariant_certificate"

Expand Down Expand Up @@ -297,6 +305,7 @@ struct
| PreconditionLoopInvariant of PreconditionLoopInvariant.t
| LoopInvariantCertificate of LoopInvariantCertificate.t
| PreconditionLoopInvariantCertificate of PreconditionLoopInvariantCertificate.t
[@@deriving ord]

let entry_type = function
| LoopInvariant _ -> LoopInvariant.entry_type
Expand Down
1 change: 1 addition & 0 deletions tests/regression/00-sanity/18-parse-empty-array.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Test for issue in https://github.com/goblint/cil/issues/19
// NOCRASH
static int a[];
static int a[] = {};
static int b[0] = {};
Expand Down
1 change: 1 addition & 0 deletions tests/regression/00-sanity/29-earlyglobs-insens.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// PARAM: --set ana.ctx_insens[+] base --enable exp.earlyglobs
// NOCRASH
int main() {}
4 changes: 2 additions & 2 deletions tests/regression/00-sanity/33-hoare-over-paths.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ int main() {
// NEW explanation:
// using SensitiveDomain correctly keeps both paths as path-sensitivity demands

// TODO: manually check final join node in HTML
// cannot be automated because concrete execution cannot check
// cram test checks internal result
sim642 marked this conversation as resolved.
Show resolved Hide resolved
// cannot be automated with annotations because concrete execution cannot check
// if _must_ lockset _may_ contain m on some path
return 0;
}
Loading