@@ -18,19 +18,21 @@ interfaces of objects, avoiding reflection.
18
18
19
19
### Getting started
20
20
21
+ - See the documentation in ` scripts ` for initial setup scripts.
21
22
- Install Gauge from [ here] ( https://getgauge.io/get-started.html ) .
22
- - Install the required Gauge plugins :
23
+ - Install the required Gauge plugin :
23
24
```
24
25
gauge install java
26
+ ```
27
+ - To generate HTML reports locally, you might also want to run
28
+ ```
25
29
gauge install html-report
26
30
```
31
+ This plugin generally works well on single spec files but is unreliable and
32
+ may freeze randomly when used on the whole test suite.
27
33
- Navigate to the ` model ` subdirectory (` cd model ` ).
28
34
- Run ` mvn package ` from the ` model ` directory to build a new copy of the
29
35
` models.jar ` , which will be placed in ` model/target ` .
30
- - Run ` get-original-jdk.sh ` to download a copy of the real jdk classes.
31
- - Use ` add-new-file.sh ` to copy a java class from the 'real' directory to our
32
- directory of models. For example, to copy the jdk implementation of
33
- java.lang.Long, run ` add-new-file.sh java/lang/Long.java ` .
34
36
- Create a branch using the scheme ` yourname/classname ` . where ` classname ` is
35
37
the class for which you're creating a model.
36
38
- Commit the file you just copied.
@@ -61,13 +63,34 @@ interfaces of objects, avoiding reflection.
61
63
```
62
64
return CProver.nondetInt();
63
65
```
64
- Methods that are not currently modelled should include the line
66
+ To generate a non-deterministic object of type ` T ` , use
67
+ ` CProver.nondetWithNull(T) ` or ` CProver.nondetWithoutNull(T) ` , providing an
68
+ instance of that class. Giving a non-null argument ensures the class ` T `
69
+ gets loaded.
70
+ - Methods that are not currently modelled should include the line
65
71
```
66
72
CProver.notModelled();
67
73
```
68
74
in the method body. Deeptest will discard any tests that depend on any such
69
- method.
70
- - More information about CProver's assume functionality can be found in [ the
75
+ method. If a method which is not modelled returns an object, the return
76
+ statement should be:
77
+ ```
78
+ return CProver.nondetWithNullForNotModelled();
79
+ ```
80
+ or
81
+ ```
82
+ return CProver.nondetWithoutNullForNotModelled();
83
+ ```
84
+ - Methods that are mocked and return an object of a class that is not modelled
85
+ should also use the return statements:
86
+ ```
87
+ return CProver.nondetWithNullForNotModelled();
88
+ ```
89
+ or
90
+ ```
91
+ return CProver.nondetWithoutNullForNotModelled();
92
+ ```
93
+ - More information about CProver's assume functionality can be found in [ the
71
94
manual] ( http://www.cprover.org/cprover-manual/modeling-assertions.shtml ) .
72
95
- CBMC is smart about strings. Most of the ` java.lang.String ` methods are
73
96
intercepted and handled natively by CBMC. Therefore, it should be fine to
@@ -138,16 +161,9 @@ non-deterministic.
138
161
139
162
### Running Tests
140
163
141
- To test models with test-gen, you'll need an up-to-date copy of the
142
- test-generator binary. If you're developing models-library from the test-gen
143
- submodule, you can ` cd model/modelTests ` and run ` setup.sh "build" ` to symlink
144
- ` test-generator ` and ` models.jar ` into the ` under_test ` directory.
145
- ` setup.sh "build" ` will link ` test-generator ` from the outer test-gen repo, and
146
- ` models.jar ` from the ` target ` directory, so it's important that these files
147
- are in the expected locations, and have been built against the current branch
148
- of the models repo. The argument to ` setup.sh ` is the directory passed to cmake
149
- when building ` test-generator ` , so if you ran ` cmake -H. -B$DIR ` , you should
150
- run ` setup.sh $DIR ` .
164
+ Before using the Gauge TestRunner, you need to set up the
165
+ ` modelTests/under_test ` folder using the ` setup-under-test-dir.sh ` script. For
166
+ detailed instructions, see ` scripts/README.md ` .
151
167
152
168
Once you've set up the tests, you can run them using Gauge through Maven. Run
153
169
the following command from the modelTests directory. It will get all the
@@ -219,9 +235,14 @@ verify that they pass, or throw an error.
219
235
220
236
#### Gauge spec files
221
237
222
- You will probably want to supply test specifications alongside any new models.
238
+ You should supply test specifications alongside any new models.
223
239
First, you should probably familiarise yourself with how Gauge works, using the
224
240
official documentation [ here] ( https://docs.getgauge.io/using.html ) .
241
+
242
+ Gauge specs can be automatically generated for a given set of tests using the
243
+ ` generate-specs.sh ` script in ` scripts/modelling-utils ` . See the ` scripts `
244
+ readme for more information.
245
+
225
246
Generally, test specifications will look like this:
226
247
227
248
```
@@ -366,12 +387,6 @@ The important points:
366
387
- End with ` ; `
367
388
- Use ` / ` instead of ` . ` to separate class paths
368
389
369
- ### Misc
370
-
371
- ` create-small-rt-jar.sh ` can be used to create a jar file which contains the
372
- original jdk classes, rather than models, but does not contain any jdk clasess
373
- for which models don't exist. This might be useful in A-B testing.
374
-
375
390
#### Model Stats
376
391
377
392
The overall progress of the library modelling effort can be tracked using
0 commit comments