You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: infra/experimental/chronos/README.md
+56-77Lines changed: 56 additions & 77 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,29 @@ and analysis of projects' testing infrastructure. This is used by projects,
5
5
e.g. [OSS-Fuzz-gen](https://github.com/google/oss-fuzz-gen) to help speed up
6
6
valuation processes during fuzzing harness generation.
7
7
8
-
Chronos is focused on two features, rebuilding projects fast and running the tests of a given project.
8
+
At the core, Chronos relies on caching containers after project build, in order
9
+
to enable fast rebuilding of a project following minor patches, and also enable
10
+
running of the tests in a given project. To support this, Chronos creates a snapshot
11
+
of a the docker container given project post build completion. This means that all `.o` files, generated
12
+
configuations etc. persist in the docker container. These artifacts are then
13
+
leverage for future "replay builds" where only a minor part of the project has changed,
14
+
e.g. due to some patching on the project. This patching could be e.g. minor adjustments
15
+
to the fuzzing harness source code e.g. by [oss-fuzz-gen](https://github.com/google/oss-fuzz-gen).
9
16
10
-
## Rebuilding projects fast
17
+
As such, at the core of Chronos are cached containers that are generated by taking a
18
+
snapshot of the container of a project post project build.
19
+
20
+
Chronos is focused on two features, rebuilding projects fast and running the
21
+
tests of a given project.
22
+
23
+
24
+
## Chronos features: fast rebuilding and running the tests of a project
25
+
26
+
### CLI interface for Chronos
27
+
28
+
The default route to validating Chronos is using the CLI available in `infra/experimental/chronos/manager.py`
29
+
30
+
### Chronos feature: Fast rebuilding
11
31
12
32
Chronos enables rebuilding projects efficiently in contexts where only a small patch
13
33
needs to be evalualted in the target. This is achieved by running a replay build script
@@ -17,24 +37,28 @@ of the original `build.sh`.
17
37
18
38
The replay build scripts are constructed in two ways: manually or automatically.
19
39
20
-
### Automated rebuilds
40
+
#### Option 1: Automated rebuilds
21
41
22
-
Chronos support automated rebuilding by:
42
+
Chronos support automated rebuilding. This is meant as a generic mechanism to enable Chronos support for projects by default. This is achieved by:
23
43
24
44
1. Calling into a `replay_build.sh` script during the building inside the container [here](https://github.com/google/oss-fuzz/blob/206656447b213fb04901d15122692d8dd4d45312/infra/base-images/base-builder/compile#L292-L296)
25
45
2. The `replay_build.sh` calls into `make_build_replayable.py`: [here](https://github.com/google/oss-fuzz/blob/master/infra/base-images/base-builder/replay_build.sh)
26
46
3.`make_build_replayable.py` adjusts the build environment to wrap around common commands, to avoid performing a complete run of `build.sh`: [here](https://github.com/google/oss-fuzz/blob/master/infra/base-images/base-builder/make_build_replayable.py).
27
47
28
-
### Manually provided replay builds
48
+
The automated rebuilding works in combination with [Ccache](https://ccache.dev/), in order to facilitate cachine of e.g. `.o` files.
49
+
This means that during rebuild mode as long as we have a cacche, we don't need to e.g. run `configure` again and will only have to
50
+
rebuild the changed source code.
51
+
52
+
#### Option 2: Manually provided replay builds
29
53
30
54
`replay_build.sh` above, is simply just a wrapper script around `build.sh` that aims to enable
31
55
fast rebuilding of the project. This `replay_build.sh` can, however, be overwritten in the Dockerfile
32
-
of the project's builder image. Examples of this is [php](https://github.com/google/oss-fuzz/blob/206656447b213fb04901d15122692d8dd4d45312/projects/php/replay_build.sh#L1) and [ffmpeg](https://github.com/google/oss-fuzz/blob/master/projects/ffmpeg/replay_build.sh#L1).
56
+
of the project's builder image to support a custom approach to fast rebuilding. Two examples of this is [php](https://github.com/google/oss-fuzz/blob/206656447b213fb04901d15122692d8dd4d45312/projects/php/replay_build.sh#L1) and [ffmpeg](https://github.com/google/oss-fuzz/blob/master/projects/ffmpeg/replay_build.sh#L1).
33
57
34
58
Providing a manual `replay_build.sh` is likely more efficient at build time and can help speed up the process. Automated replay build scripts can also be erroneous.
35
59
36
60
37
-
### Testing the validity of a replay build
61
+
####Testing the validity of a replay build
38
62
39
63
The Chronos manager can use the `manager.py` to validate the validity of a
If the above command fails for the relevant project, then the replay build feature
47
71
does not work for the given project.
48
72
49
-
## Running tests of a project
73
+
### Chronos feature: Running tests of a project
50
74
51
75
The second part of Chronos is a feature to enable running the tests of a given
52
76
project. This is done by way of a script `run_tests.sh`. Samples of
53
77
this script include [jsonnet](https://github.com/google/oss-fuzz/blob/master/projects/jsonnet/run_tests.sh#L1) and [tinyobjloader](https://github.com/google/oss-fuzz/blob/master/projects/tinyobjloader/run_tests.sh#L1).
54
78
55
79
56
-
### Testing the validity of run_tests.sh
80
+
#### Run tests constraints
81
+
82
+
1. The `run_tests.sh` main task is to run the tests of a project and return `0` upon success and non-null otherwise.
83
+
2. The `run_tests.sh` script must leave the main repository in the state as it was prior to the execution of `run_tests.sh` relative to `git diff` (or similar diff features of other version control systems).
84
+
85
+
#### Testing the validity of run_tests.sh
57
86
58
87
The Chronos manager can use the `manager.py` to validate the validity of a
0 commit comments