Skip to content

Commit afd55ac

Browse files
author
owen-jones-diffblue
authored
Merge pull request diffblue#453 from diffblue/MODELS_LIB_merge-2018-06-14
SEC-441: Models-lib merge 2018-06-14
2 parents bace8c1 + b7e2eda commit afd55ac

File tree

1,271 files changed

+83510
-5088
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,271 files changed

+83510
-5088
lines changed
+5-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
/jdk-original
2+
13
/model/target
2-
/model/jdk-original
4+
/model-simple/target
35

46
*.txt
57
*.d
68
*.o
79
*.a
810
/.project
11+
/scripts/generalize-java-method/GeneralizeJavaMethod.class
12+
/scripts/generalize-java-method/Specialization.class

benchmarks/LIBRARIES/models/.travis.yml

+22-4
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,22 @@ before_install:
3333
- sudo pip install google_compute_engine --upgrade
3434

3535
install:
36+
# Check that modelling utilities are building and run unit tests
37+
- mvn -f scripts/modelling-utils/pom.xml install
38+
# First build simple models.
39+
- cd model-simple
40+
- mvn package
41+
- cd ..
42+
# Now build the "ordinary" models, and run the tests for both.
3643
- cd model
3744
- mvn package
3845
- cd modelTests
3946
- gsutil cp gs://travis-artifacts/test-gen/${TEST_GEN_BUILD:-"latest-develop-ubuntu"}.tar.gz cbmc-testgen-latest.tar.gz
4047
- tar -zxvf cbmc-testgen-latest.tar.gz -C under_test
41-
- mvn install:install-file -Dfile=under_test/deeptestutils-1.0.0.jar -DpomFile=under_test/pom.xml
4248
- mv ../target/models.jar under_test
49+
- mv ../../model-simple/target/models-simple-overlay.jar under_test
4350
# Setup gauge
44-
- sudo apt-key add keys/023EDB0B.asc || sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net --recv-keys 023EDB0B
51+
- sudo apt-key add ${TRAVIS_BUILD_DIR}/keys/023EDB0B.asc || sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net --recv-keys 023EDB0B
4552
- echo deb https://dl.bintray.com/gauge/gauge-deb stable main | sudo tee -a /etc/apt/sources.list
4653
- sudo apt-get update
4754
- sudo apt-get install gauge
@@ -54,7 +61,7 @@ install:
5461
- export DIFFBLUE_MODEL_TESTS_PROCESS_TIMEOUT="500"
5562

5663
script:
57-
- mvn test -Dtags='!known-bug,!future,!long' -Dflags='--verbose' -DspecsDir='specs'
64+
- mvn test -Dtags='!known-bug,!future' -Dflags='--verbose' -DspecsDir='specs'
5865

5966
before_cache:
6067
# To be able to update via pip
@@ -96,8 +103,19 @@ after_success:
96103
cp ${FILE} gs://diffblue-binaries/models-library/${BRANCH}/${FILE}
97104
# Generate signed URL for binary
98105
export SIGNED_URL
99-
SIGNED_URL=$(gsutil signurl -d 365d -m GET ${TRAVIS_BUILD_DIR}/.gcloud-travis-models-library.json \
106+
SIGNED_URL=$(gsutil signurl -d 7d -m GET ${TRAVIS_BUILD_DIR}/.gcloud-travis-models-library.json \
100107
gs://diffblue-binaries/models-library/${BRANCH}/${FILE} | awk '$5 ~ /https/ {print $5}')
101108
fi
102109
set +eu
103110
- echo ${SIGNED_URL}
111+
112+
notifications:
113+
webhooks:
114+
urls:
115+
- http://dashboard.diffblue.com/api/travis-webhooks
116+
on_success: always
117+
on_failure: always
118+
on_start: never
119+
on_cancel: never
120+
on_error: always
121+
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# These owners will be the default owners for everything in the repo.
2-
* @allredj @antlechner @romainbrenguier
2+
* @allredj @antlechner @romainbrenguier @jeannielynnmoulton

benchmarks/LIBRARIES/models/README.md

+40-25
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,21 @@ interfaces of objects, avoiding reflection.
1818

1919
### Getting started
2020

21+
- See the documentation in `scripts` for initial setup scripts.
2122
- Install Gauge from [here](https://getgauge.io/get-started.html).
22-
- Install the required Gauge plugins:
23+
- Install the required Gauge plugin:
2324
```
2425
gauge install java
26+
```
27+
- To generate HTML reports locally, you might also want to run
28+
```
2529
gauge install html-report
2630
```
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.
2733
- Navigate to the `model` subdirectory (`cd model`).
2834
- Run `mvn package` from the `model` directory to build a new copy of the
2935
`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`.
3436
- Create a branch using the scheme `yourname/classname`. where `classname` is
3537
the class for which you're creating a model.
3638
- Commit the file you just copied.
@@ -61,13 +63,34 @@ interfaces of objects, avoiding reflection.
6163
```
6264
return CProver.nondetInt();
6365
```
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
6571
```
6672
CProver.notModelled();
6773
```
6874
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
7194
manual](http://www.cprover.org/cprover-manual/modeling-assertions.shtml).
7295
- CBMC is smart about strings. Most of the `java.lang.String` methods are
7396
intercepted and handled natively by CBMC. Therefore, it should be fine to
@@ -138,16 +161,9 @@ non-deterministic.
138161

139162
### Running Tests
140163

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`.
151167

152168
Once you've set up the tests, you can run them using Gauge through Maven. Run
153169
the following command from the modelTests directory. It will get all the
@@ -219,9 +235,14 @@ verify that they pass, or throw an error.
219235

220236
#### Gauge spec files
221237

222-
You will probably want to supply test specifications alongside any new models.
238+
You should supply test specifications alongside any new models.
223239
First, you should probably familiarise yourself with how Gauge works, using the
224240
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+
225246
Generally, test specifications will look like this:
226247

227248
```
@@ -366,12 +387,6 @@ The important points:
366387
- End with `;`
367388
- Use `/` instead of `.` to separate class paths
368389

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-
375390
#### Model Stats
376391

377392
The overall progress of the library modelling effort can be tracked using
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-----BEGIN PGP PUBLIC KEY BLOCK-----
2+
3+
mQENBFZWldUBCADc/JVW1XhWdKSs1MbRNLxJPmLyHZ3b20T60KHtyPII9cWW2F3e
4+
x0IUNoLFpAjdreABI2rFSKdu+WrgCSHY21rfFmtgfWYTT6NYCyCq+A32d3U/ix9H
5+
N2v5KsS7QSQj7f8fkuahLPK5N3/QRYct+55lmGz8rh/t3rd8FR1WOeyKE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IwavII8CH
22+
WB2WhvrB0QARAQABiQEfBBgBCgAJBQJWVpXVAhsMAAoJECXM3BACPtsLS5MIALBq
23+
c50T1reLWNNs7/Reqom/O7Y7JPkFFdpBuqh8dOpDfdq1APsE65byYQwlcsBj1myv
24+
aTs6dK74MG22LC+5p/7TDLFe4gpcJ3aiPtltfE/6RdX9W8V1d/3zcxOgL/qRTeKK
25+
rwzk4GegauVKVkreJ+gj1MfvuHdCM37wyrQBanLqXfhQ1WhvmQL8UzoM3qd5i0ia
26+
ryQM6yZFkm8HN+J/3SSTbyhyYNyLVPVqi8CCiHKEWni2SXPWbqj5CgWEtzoDaBdp
27+
jKYpuGWO2YCweL0GszMXOCBHENaqp6Uh+cqR1sj5ALH5LAzJci/Z+oCGlUfJcr8/
28+
WaZm7oO4a/js7wX98TA=
29+
=frOr
30+
-----END PGP PUBLIC KEY BLOCK-----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.diffblue.models</groupId>
6+
<artifactId>models-simple-overlay</artifactId>
7+
<version>1.0-SNAPSHOT</version>
8+
<packaging>jar</packaging>
9+
10+
<properties>
11+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12+
</properties>
13+
14+
<name>DiffBlue JDK Models</name>
15+
16+
<!-- Tell javadoc plugin not to fail on warnings -->
17+
<profiles>
18+
<profile>
19+
<id>java8-doclint-disabled</id>
20+
<activation>
21+
<jdk>[1.8,)</jdk>
22+
</activation>
23+
<properties>
24+
<javadoc.opts>-Xdoclint:none</javadoc.opts>
25+
</properties>
26+
</profile>
27+
</profiles>
28+
29+
<build>
30+
<finalName>models-simple-overlay</finalName>
31+
<plugins>
32+
<plugin>
33+
<groupId>org.apache.maven.plugins</groupId>
34+
<artifactId>maven-compiler-plugin</artifactId>
35+
<version>3.6.1</version>
36+
<configuration>
37+
<compilerArguments>
38+
<classpath>${java.home}/lib/rt.jar</classpath>
39+
</compilerArguments>
40+
<source>1.8</source>
41+
<target>1.8</target>
42+
</configuration>
43+
</plugin>
44+
<plugin>
45+
<groupId>org.apache.maven.plugins</groupId>
46+
<artifactId>maven-javadoc-plugin</artifactId>
47+
<version>3.0.0-M1</version>
48+
<configuration>
49+
<outputDirectory>doc</outputDirectory>
50+
<quiet>true</quiet>
51+
<nosince>true</nosince>
52+
<sourcepath>src/main/java</sourcepath>
53+
<subpackages>java</subpackages>
54+
<overview>src/main/overview.html</overview>
55+
<windowtitle>Diffblue Library of Models</windowtitle>
56+
<doctitle>Diffblue Library of Models</doctitle>
57+
<tags>
58+
<tag>
59+
<name>diffblue.fullSupport</name>
60+
<placement>a</placement>
61+
<head>DIFFBLUE: Full support</head>
62+
</tag>
63+
<tag>
64+
<name>diffblue.limitedSupport</name>
65+
<placement>a</placement>
66+
<head>DIFFBLUE: Limited support</head>
67+
</tag>
68+
<tag>
69+
<name>diffblue.noSupport</name>
70+
<placement>a</placement>
71+
<head>DIFFBLUE: No support</head>
72+
</tag>
73+
<tag>
74+
<name>diffblue.untested</name>
75+
<placement>a</placement>
76+
<head>DIFFBLUE: Untested</head>
77+
</tag>
78+
<tag>
79+
<name>diffblue.todo</name>
80+
<placement>a</placement>
81+
<head>DIFFBLUE: To do</head>
82+
</tag>
83+
<tag>
84+
<name>diffblue.mock</name>
85+
<placement>a</placement>
86+
<head>DIFFBLUE: Intended for mocking</head>
87+
</tag>
88+
</tags>
89+
<!--No fail on warning-->
90+
<additionalparam>${javadoc.opts}</additionalparam>
91+
</configuration>
92+
</plugin>
93+
</plugins>
94+
</build>
95+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 1995, 1997, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
package java.awt;
27+
28+
/**
29+
* Thrown when a serious Abstract Window Toolkit error has occurred.
30+
*
31+
* @author Arthur van Hoff
32+
*/
33+
public class AWTError extends Error {
34+
35+
/*
36+
* JDK 1.1 serialVersionUID
37+
*/
38+
private static final long serialVersionUID = -1819846354050686206L;
39+
40+
/**
41+
* Constructs an instance of <code>AWTError</code> with the specified
42+
* detail message.
43+
* @param msg the detail message.
44+
* @since JDK1.0
45+
*/
46+
public AWTError(String msg) {
47+
super(msg);
48+
}
49+
50+
// DIFFBLUE MODEL LIBRARY
51+
// While Object.getClass() is not modelled, we can get the same
52+
// functionality by adding one toString() method per subclass of
53+
// Throwable.
54+
// @Override
55+
// public String toString() {
56+
// String message = getLocalizedMessage();
57+
// return (message != null)
58+
// ? ("java.awt.AWTError: " + message)
59+
// : "java.awt.AWTError";
60+
// }
61+
}

0 commit comments

Comments
 (0)