Skip to content

Commit 03da8b4

Browse files
chronos: add helper script for quickly testing run_test.sh (google#13533)
jsonnet: ``` ./infra/experimental/chronos/check_tests.sh jsonnet c++ ... ... Running tests... Test project /src/jsonnet/build Start 1: unicode_test 1/10 Test #1: unicode_test ..................... Passed 0.06 sec Start 2: lexer_test 2/10 Test #2: lexer_test ....................... Passed 0.01 sec Start 3: parser_test 3/10 Test #3: parser_test ...................... Passed 0.03 sec Start 4: libjsonnet_test 4/10 Test #4: libjsonnet_test .................. Passed 0.26 sec Start 5: libjsonnet_test_file 5/10 Test #5: libjsonnet_test_file ............. Passed 0.32 sec Start 6: libjsonnet_test_snippet 6/10 Test #6: libjsonnet_test_snippet .......... Passed 0.23 sec Start 7: jsonnet_test_snippet 7/10 Test #7: jsonnet_test_snippet ............. Passed 0.23 sec Start 8: libjsonnet++_test 8/10 Test #8: libjsonnet++_test ................ Passed 1.25 sec Start 9: libjsonnet_test_locale 9/10 Test #9: libjsonnet_test_locale ........... Passed 0.23 sec Start 10: regression_test 10/10 Test google#10: regression_test .................. Passed 121.20 sec 100% tests passed, 0 tests failed out of 10 Total Test time (real) = 123.82 sec ``` assimp: ``` ./infra/experimental/chronos/check_tests.sh assimp c++ ... ... [----------] 8 tests from ExtensionTests/ExtensionTest (0 ms total) [----------] Global test environment tear-down [==========] 591 tests from 117 test suites ran. (32219 ms total) [ PASSED ] 591 tests. ``` Signed-off-by: David Korczynski <david@adalogics.com>
1 parent aeb16cd commit 03da8b4

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
################################################################################
17+
18+
# Module for validating "run_tests.sh" of a given project. Before the run_tests.sh
19+
# script is run, a cached container image is first built. We assume here that the
20+
# replay is working for the target project.
21+
# (TODO): make sure this works for both replay_build.sh and ccached rebuilds.
22+
# currently the focus is on replay_build.sh.
23+
_PROJECT=$1
24+
_FUZZING_LANGUAGE=$2
25+
_SANITIZER=${3:-address}
26+
27+
BASE=$PWD
28+
29+
# Final image is either ccache or replay script, depending on which worked.
30+
FINAL_IMAGE_NAME=us-central1-docker.pkg.dev/oss-fuzz/oss-fuzz-gen/${_PROJECT}-ofg-cached-${_SANITIZER}
31+
32+
# Step 1: build the base image
33+
cd projects/${_PROJECT}
34+
docker build -t gcr.io/oss-fuzz/${_PROJECT} .
35+
36+
# Step 2: create a container where `compile` has run which enables ccaching
37+
# and also generates a replay build script.
38+
cd ${BASE}
39+
mkdir -p ccaches/${_PROJECT}
40+
mkdir -p build/out/${_PROJECT}
41+
42+
# Clean up existing images.
43+
docker container rm -f ${_PROJECT}-origin-${_SANITIZER}
44+
45+
docker run \
46+
--env=SANITIZER=${_SANITIZER} \
47+
--env=CCACHE_DIR=/workspace/ccache \
48+
--env=FUZZING_LANGUAGE=${_FUZZING_LANGUAGE} \
49+
--env=CAPTURE_REPLAY_SCRIPT=1 \
50+
--name=${_PROJECT}-origin-${_SANITIZER} \
51+
-v=$PWD/ccaches/${_PROJECT}/ccache:/workspace/ccache \
52+
-v=$PWD/build/out/${_PROJECT}/:/out/ \
53+
gcr.io/oss-fuzz/${_PROJECT} \
54+
/bin/bash -c \
55+
"export PATH=/ccache/bin:\$PATH && compile && cp -n /usr/local/bin/replay_build.sh \$SRC/"
56+
57+
58+
# Step 3: save (commit, locally) the cached container as an image
59+
docker container commit -c "ENV REPLAY_ENABLED=1" -c "ENV CAPTURE_REPLAY_SCRIPT=" ${_PROJECT}-origin-${_SANITIZER} $FINAL_IMAGE_NAME
60+
61+
# Step 4: run the actual run_tests.sh script in the container.
62+
docker run \
63+
--rm \
64+
-ti \
65+
us-central1-docker.pkg.dev/oss-fuzz/oss-fuzz-gen/${_PROJECT}-ofg-cached-address /bin/bash -c 'chmod +x /src/run_tests.sh && /src/run_tests.sh'

0 commit comments

Comments
 (0)