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

Changes for Pull Request bench#85: Automatic Generation of Test Cases for Incremental Static Analysis #1096

Closed
wants to merge 142 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
15f3dfd
upload files
May 4, 2023
9de3f7a
sync
J2000A May 4, 2023
e8cf76c
update gitignore
J2000A May 4, 2023
5b03ce8
update build instructions
May 5, 2023
6091f1d
Adjust evalAssert to offer __goblint_check(exp) with the option trans…
J2000A May 5, 2023
1111331
Change number of jobs to improve build speed
May 5, 2023
acd5e06
Merge remote-tracking branch 'refs/remotes/origin/master'
May 5, 2023
2ea12fc
Add build target option for further speedup
J2000A May 5, 2023
a0ca99c
Adding index to matched functionDecl
May 9, 2023
922dd23
Adopt evalAssert.ml so the option is checked correctly at runtime
May 10, 2023
5f16ec1
Index mutations with -line-filter option
May 16, 2023
ad9f0d9
Fix Goblint Option Retrieving by adding Unit to constant
May 16, 2023
eba6d46
Move Check Creation Info to md
J2000A May 18, 2023
1592efe
Bugfix
J2000A May 18, 2023
03868cb
Add Unary Operator Inversion Mutation
J2000A May 18, 2023
4f0299b
Add [MUTATION] to comments
J2000A May 18, 2023
dd69c3a
Add test files
J2000A May 18, 2023
c63a024
Add ROR Mutation
J2000A May 18, 2023
1e71c0b
Remove function body in one line
J2000A May 18, 2023
ac053d8
Remove unnecesary comments
J2000A May 18, 2023
5958abb
Add Logical Connector Mutation
J2000A May 18, 2023
6702b56
Add Constant Replacement Check
J2000A May 19, 2023
5583a91
Add Mutation Type to Brackets
J2000A May 19, 2023
7875a58
New sample file for pthreads
J2000A May 19, 2023
7d41ae4
Bugfix
J2000A May 19, 2023
a2d4bee
Add Remove Thread Mutation
J2000A May 22, 2023
e5483b0
Documentation of Mutations
J2000A May 22, 2023
507fe12
Bugfix
J2000A May 22, 2023
31d39cf
Add ML Heuristic
J2000A May 22, 2023
f55aebe
Delete APIKEY.yaml
J2000A May 22, 2023
d35ef36
Update .gitignore
J2000A May 22, 2023
28f5976
Bugfix
May 23, 2023
453da2c
Testing ML
May 23, 2023
f99fc76
Script for adding SUCCESS or UNDEFINED to checks
May 23, 2023
36a2b21
Use argparser
May 24, 2023
6c1ae58
Add gitignore
May 24, 2023
09d91ca
Refactoring
May 24, 2023
aea65aa
Implementing add-check
May 24, 2023
11fb212
Refactoring
May 25, 2023
213ee8d
Create generate mutations
May 25, 2023
d3cf3ef
Add new check to create wrapper for remove thread
May 25, 2023
ab3b973
Bugfix
May 25, 2023
5a78a05
Add handling of thread function wrapping
May 25, 2023
ca13c9e
Refactor file name
May 25, 2023
540565b
Added gitignore
May 25, 2023
13875a1
Bugfixes
May 25, 2023
d0760eb
Add vervose option
May 25, 2023
5d06a6d
Add Script for generating programs
May 25, 2023
539ae63
Move sample files
J2000A May 26, 2023
488519f
Add gitignore
J2000A May 26, 2023
0742b4f
Add comment with run command
J2000A May 26, 2023
0e2dd7e
Writing of generate tests script
J2000A May 30, 2023
d9e25e7
Use common util constants
J2000A May 30, 2023
9cc1e8c
Add main to test programs
J2000A May 30, 2023
c9f5e6e
Fix imports
J2000A May 30, 2023
1821e93
Implement script for running tests
J2000A May 30, 2023
112850d
Implemente base cli
J2000A May 30, 2023
b7252e1
Make name of tests unique
May 31, 2023
d7a3dd8
Fix Logo
May 31, 2023
d2cb173
Fix comment name
May 31, 2023
e1887da
Generate Minimal Test for "nothing" problem
J2000A Jun 1, 2023
0bdda1f
Implementation of ML
J2000A Jun 2, 2023
26917ca
Run multiple requests for ML in parallel
J2000A Jun 2, 2023
d2cc0c3
documentation of llvm version
J2000A Jun 6, 2023
a6368ee
Trying around with git
J2000A Jun 6, 2023
7bb727b
Bugfix
J2000A Jun 7, 2023
5295752
Fix imports
J2000A Jun 7, 2023
46405f5
Update gitignore
J2000A Jun 7, 2023
b64399d
Update gitignore
J2000A Jun 7, 2023
1068617
Add Repositories to sample files
J2000A Jun 7, 2023
09553e8
Add Shell Script for Git Repositories
J2000A Jun 8, 2023
edda276
Add Shell Script for processing git repos
J2000A Jun 8, 2023
402edb3
Seperate User Input and script itself
J2000A Jun 8, 2023
ae67de8
Add option for output directory
J2000A Jun 8, 2023
545a8dc
Remove superfluous argument
J2000A Jun 8, 2023
7718a50
Seperate parts of the script with options
J2000A Jun 8, 2023
a1f9eed
integration of generateGit into whole script TODOs
J2000A Jun 9, 2023
0708341
Add coloring to terminal output
J2000A Jun 9, 2023
ce1e0d4
Rename script
J2000A Jun 9, 2023
ea3edf8
Consider not compiling programs
J2000A Jun 9, 2023
3d7be0f
Print template script and ask for sh path
J2000A Jun 9, 2023
134a17d
Add exception printing for comilation errors
J2000A Jun 9, 2023
d0ea8c2
Update gitignore
J2000A Jun 12, 2023
79b953c
Remove obsolete files
J2000A Jun 12, 2023
7f63d28
Fix and document files
J2000A Jun 12, 2023
fe961f7
Fixes and Readme files
J2000A Jun 12, 2023
d845082
Do not overwrite direcotroy
J2000A Jun 12, 2023
304d289
Add cfg option
J2000A Jun 12, 2023
8db02d2
Pass option for dir names and test creation
J2000A Jun 15, 2023
83144bf
Pass git start and end hash
J2000A Jun 15, 2023
df9ad70
Add options for ml
J2000A Jun 15, 2023
16c8b9e
Add passing of goblint config file
J2000A Jun 16, 2023
3e86606
Interpret //PARAM from input file
J2000A Jun 16, 2023
9ff18ed
Add option for gpt 16k model vs 4k
J2000A Jun 16, 2023
5671ed4
Update CLI for individual files
J2000A Jun 16, 2023
8873ab2
Fix
J2000A Jun 16, 2023
feade93
Allow multiple directories
J2000A Jun 16, 2023
de00d79
Update gitignore
J2000A Jun 16, 2023
44932c8
Give temp name only in CLI
J2000A Jun 17, 2023
b7f33e6
move test-generation up
J2000A Jun 17, 2023
4bac14d
move to bench repo
J2000A Jun 17, 2023
49d71b1
Add gitignore for temp test files
J2000A Jun 19, 2023
7a96981
Read always the PARMs from the first line
Jun 20, 2023
6633ada
Revert passing params with -p
Jun 20, 2023
8ea7618
Schreibe keine assertions für dead code
Jun 21, 2023
cc64c2d
Do not interpret cil __SC_TRACE as RACE
J2000A Jun 23, 2023
9d33c22
Merge remote-tracking branch 'upstream/master'
J2000A Jun 24, 2023
9001024
Only consider annotations not part of a word
J2000A Jun 26, 2023
764482c
Add nowarn annotation
Jun 27, 2023
bbbfaf7
Update documentation
Jun 27, 2023
075c1a8
In case of exception print content of warnfile
Jun 27, 2023
b4c84b0
Add warn and nothing to results for NOFAIL
Jun 28, 2023
63fb6bf
change accepted results to not fail
Jun 28, 2023
7e2491a
Fix depreciated option
Jun 29, 2023
52ee2f8
Check files with linter
J2000A Jun 29, 2023
3ba9149
Fix
J2000A Jun 29, 2023
b942b21
Merge branch 'goblint:master' into master
J2000A Jun 29, 2023
e11b135
Fix << for nil error
J2000A Jul 7, 2023
4bc1729
Revive removed comment
J2000A Jul 7, 2023
73011a8
Merge branch 'master' into master
J2000A Jul 7, 2023
1c5871f
Add annotation not imprecise
Jul 11, 2023
184e900
Add annotation not imprecise to documentation
Jul 11, 2023
5de6d6c
Rephrase documentation
Jul 11, 2023
757b85c
Remove ignoring of nothing
J2000A Jul 18, 2023
f8cbdb3
Merge branch 'goblint:master' into master
J2000A Jul 25, 2023
fddcfb1
Change MAYFAIL to MAY FAIL
Jul 25, 2023
1c5c355
Update name to IATT
Jul 25, 2023
8aabe2d
Update name to IATT
Jul 25, 2023
d3835f2
Update paths in readme
Jul 25, 2023
cb0ddb6
Change MAYFAIL to MAY FAIL
Jul 25, 2023
558b68e
Correct description
Jul 25, 2023
f11f84e
Merge branch 'master' into master
J2000A Jul 25, 2023
097a42a
Merge remote-tracking branch 'upstream/master'
Jul 25, 2023
15e1896
Merge branch 'master' of https://github.com/J2000A/analyzer
Jul 25, 2023
840d587
Update Name to TAIA
Jul 25, 2023
7e8e216
Merge branch 'goblint:master' into master
J2000A Aug 3, 2023
9bf2959
Ignore extern definitions
J2000A Aug 4, 2023
698111f
Merge branch 'master' of https://github.com/J2000A/analyzer
J2000A Aug 4, 2023
692e8a0
remove notinprecise annotation
stilscher Dec 8, 2023
474010b
change may fail to fail annotation
stilscher Dec 8, 2023
40a9f80
rename option
stilscher Dec 8, 2023
f4412f8
Merge branch 'master' into jonas-master
stilscher Dec 8, 2023
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
4 changes: 4 additions & 0 deletions docs/developer-guide/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Comments at the end of other lines indicate the behavior on that line:
| `DEADLOCK` | Deadlock warning | Deadlock is possible | Soundness |
| `NOWARN` | No warning | — | Precision |
| `WARN` | Some warning | — | Soundness |
| `NOFAIL` | Assertion is unknown <br> or succeeds | Everything except fail | Incremental analysis |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the meaning of "Everything except fail" as concrete semantics? Isn't that just "Assertion succeeds"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may succeed or be unknown. It is what one expects for an incremental run if the assert was proven in a from-scratch run.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's in our abstract semantics, but in the concrete the assertion either fails or it succeeds. So it should be "Assertion may both succeed or fail"?


#### Other
Other useful constructs are the following:
Expand Down Expand Up @@ -136,6 +137,9 @@ git diff --no-prefix relative/path/to/test.c relative/path/to/test.json > relati

The comparison input and the metadata in the patch headers are not necessary and can be removed.

### Test Automation for Incremental Analysis - TAIA
The "Test Automation for Incremental Analysis" in the bench repository (`bench/incremental-analysis-test-toolchain`) enables you to generate and run incremental tests based on one single c file as input. You find more details in the readme file in the repository (`bench/incremental-analysis-test-toolchain/README.md`).
Comment on lines +140 to +141
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This refers to the unmerged goblint/bench#58. If that isn't merged, our documentation probably shouldn't refer people to non-existent things.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plan would be to merge it. It is very self-contained, there are few things one would like to change before merging.


## Unit tests

### Running
Expand Down
58 changes: 36 additions & 22 deletions scripts/update_suite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ def compare_warnings
check.call warnings[idx] != "race"
when "nodeadlock"
check.call warnings[idx] != "deadlock"
when "nofail"
check.call(warnings[idx] != "fail")
end
end
end
Expand Down Expand Up @@ -300,33 +302,43 @@ def parse_tests (lines)
i = $1.to_i - 1
end
next if obj =~ /^\s*\/\// || obj =~ /^\s*\/\*([^*]|\*+[^*\/])*\*\/$/
todo << i if obj =~ /TODO|SKIP/
todo << i if obj =~ /(\b|\/)(TODO|SKIP)/
tests_line[i] = obj
if obj =~ /RACE/ then
tests[i] = if obj =~ /NORACE/ then "norace" else "race" end
elsif obj =~ /DEADLOCK/ then
tests[i] = if obj =~ /NODEADLOCK/ then "nodeadlock" else "deadlock" end
elsif obj =~ /WARN/ then
tests[i] = if obj =~ /NOWARN/ then "nowarn" else "warn" end
elsif obj =~ /SUCCESS/ then
if obj =~ /(\b|\/)NOFAIL/ then
tests[i] = "nofail"
elsif obj =~ /(\b|\/)RACE/ then
tests[i] = "race"
elsif obj =~ /(\b|\/)NORACE/ then
tests[i] = "norace"
elsif obj =~ /(\b|\/)DEADLOCK/ then
tests[i] = "deadlock"
elsif obj =~ /(\b|\/)NODEADLOCK/ then
tests[i] = "nodeadlock"
elsif obj =~ /(\b|\/)WARN/ then
tests[i] = "warn"
elsif obj =~ /(\b|\/)NOWARN/ then
tests[i] = "nowarn"
elsif obj =~ /(\b|\/)SUCCESS/ then
tests[i] = "success"
elsif obj =~ /FAIL/ then
elsif obj =~ /(\b|\/)FAIL/ then
tests[i] = "fail"
elsif obj =~ /NONTERMLOOP/ then
elsif obj =~ /(\b|\/)NONTERMLOOP/ then
tests[i] = "loop"
elsif obj =~ /NONTERMGOTO/ then
elsif obj =~ /(\b|\/)NONTERMGOTO/ then
tests[i] = "goto"
elsif obj =~ /NONTERMFUNDEC/ then
elsif obj =~ /(\b|\/)NONTERMFUNDEC/ then
tests[i] = "fundec"
elsif obj =~ /UNKNOWN/ then
elsif obj =~ /(\b|\/)UNKNOWN/ then
tests[i] = "unknown"
elsif obj =~ /(assert|__goblint_check).*\(/ then
if obj =~ /FAIL/ then
tests[i] = "fail"
elsif obj =~ /UNKNOWN/ then
tests[i] = "unknown"
else
tests[i] = "assert"
elsif obj =~ /(\b|\/)(assert|__goblint_check).*\(/ then
unless obj =~ /^\s*extern\b/
Comment on lines +333 to +334
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this extern about?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is about an extern definition of 'goblint_check', which would otherwise also be matched.

if obj =~ /(\b|\/)FAIL/ then
tests[i] = "fail"
elsif obj =~ /(\b|\/)UNKNOWN/ then
tests[i] = "unknown"
else
tests[i] = "assert"
end
end
end
end
Expand Down Expand Up @@ -376,6 +388,7 @@ def run_testset (testset, cmd, starttime)
lastline = (File.readlines testset.warnfile).last()
filename = File.basename(@path)
puts lastline.strip().sub filename, relpath(@path).to_s unless lastline.nil?
puts "Content of the warn-file: \n #{File.read(testset.warnfile)}"
puts stats[0..9].itemize
elsif status == 3 then
warn = File.readlines testset.warnfile
Expand Down Expand Up @@ -565,9 +578,10 @@ def run ()
config_path = File.expand_path(f[0..-3] + ".json", grouppath)
params = if cfg then "--conf #{config_path} --set incremental.compare cfg" else "--conf #{config_path}" end
else
lines[0] =~ /PARAM: (.*)$/
if $1 then params = $1 else params = "" end
params = ""
end
lines[0] =~ /PARAM: (.*)$/
if $1 then params << " #{$1}" else params << "" end
# always enable debugging so that the warnings would work
params << " --set warn.debug true"
p = if incremental then
Expand Down
14 changes: 14 additions & 0 deletions src/config/options.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,20 @@
"description": "Output filename for transformations that output a transformed file.",
"type":"string",
"default": "transformed.c"
},
"assert" : {
"title": "trans.assert",
"type": "object",
"properties": {
"goblint-check": {
"title": "trans.assert.goblint-check",
"description":
"Write __goblint_check(exp) in the file instead of __VERIFIER_assert(exp).",
"type": "boolean",
"default": false
}
},
"additionalProperties": false
}
},
"additionalProperties": false
Expand Down
9 changes: 6 additions & 3 deletions src/transform/evalAssert.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ module EvalAssert = struct
(* should asserts be surrounded by __VERIFIER_atomic_{begin,end}? *)
let surroundByAtomic = true

(* variable for generating __goblint_check(exp) instead of __VERIFIER_assert(exp) *)
let goblintCheck () = GobConfig.get_bool "trans.assert.goblint-check"

(* Cannot use Cilfacade.name_fundecs as assert() is external and has no fundec *)
let ass = makeVarinfo true "__VERIFIER_assert" (TVoid [])
let ass () = if goblintCheck () then makeVarinfo true "__goblint_check" (TVoid []) else makeVarinfo true "__VERIFIER_assert" (TVoid [])
let atomicBegin = makeVarinfo true "__VERIFIER_atomic_begin" (TVoid [])
let atomicEnd = makeVarinfo true "__VERIFIER_atomic_end" (TVoid [])

Expand Down Expand Up @@ -59,8 +62,8 @@ module EvalAssert = struct
match (ask ~node loc).f (Queries.Invariant context) with
| `Lifted e ->
let es = WitnessUtil.InvariantExp.process_exp e in
let asserts = List.map (fun e -> cInstr ("%v:assert (%e:exp);") loc [("assert", Fv ass); ("exp", Fe e)]) es in
if surroundByAtomic then
let asserts = List.map (fun e -> cInstr ("%v:assert (%e:exp);") loc [("assert", Fv (ass ())); ("exp", Fe e)]) es in
if surroundByAtomic && not (goblintCheck ()) then
let abegin = (cInstr ("%v:__VERIFIER_atomic_begin();") loc [("__VERIFIER_atomic_begin", Fv atomicBegin)]) in
let aend = (cInstr ("%v:__VERIFIER_atomic_end();") loc [("__VERIFIER_atomic_end", Fv atomicEnd)]) in
abegin :: (asserts @ [aend])
Expand Down
2 changes: 2 additions & 0 deletions tests/incremental/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Do not consider temporary files for the running of the "Test Automation for Incremental Analysis"
99-temp
2 changes: 1 addition & 1 deletion tests/regression/36-apron/86-branched-thread-creation.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int main(void) {

if(!mt) {
pthread_mutex_lock(&mutex);
__goblint_check(g==h); //MAYFAIL
__goblint_check(g==h); //FAIL
pthread_mutex_unlock(&mutex);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/regression/46-apron2/26-autotune.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//SKIP PARAM: --enable ana.int.interval --sets sem.int.signed_overflow assume_none --set ana.activated[+] apron --enable ana.autotune.enabled
//SKIP PARAM: --enable ana.int.interval --set sem.int.signed_overflow assume_none --set ana.activated[+] apron --enable ana.autotune.enabled
// Check that autotuner disables context for apron as well for recursive calls
#include <goblint.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int main(void) {

if(!mt) {
pthread_mutex_lock(&mutex);
__goblint_check(g==h); //MAYFAIL
__goblint_check(g==h); //FAIL
pthread_mutex_unlock(&mutex);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int main(void) {

if(!mt) {
pthread_mutex_lock(&mutex);
__goblint_check(g==h); //MAYFAIL
__goblint_check(g==h); //FAIL
pthread_mutex_unlock(&mutex);
}

Expand Down
Loading