Skip to content

Commit abead07

Browse files
committed
deploy: Fix jazzer not being executable
Since 4d0c74b, the Jazzer jar lacked a `Main-Class` attribute.
1 parent 0ffafcb commit abead07

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

deploy/BUILD.bazel

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,21 @@ java_export(
9090
],
9191
)
9292

93+
sh_test(
94+
name = "jazzer_version_test",
95+
srcs = ["jazzer_version_test.sh"],
96+
data = [
97+
":jazzer",
98+
"@bazel_tools//tools/jdk:current_java_runtime",
99+
],
100+
env = {
101+
"JAVA_EXECPATH": "$(JAVA)",
102+
"JAZZER_RLOCATIONPATH": "$(rlocationpath :jazzer)",
103+
},
104+
toolchains = ["@bazel_tools//tools/jdk:current_java_runtime"],
105+
deps = ["@bazel_tools//tools/bash/runfiles"],
106+
)
107+
93108
[
94109
sh_test(
95110
name = artifact + "_artifact_test",

deploy/jazzer_version_test.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2023 Code Intelligence GmbH
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+
# --- begin runfiles.bash initialization v3 ---
17+
# Copy-pasted from the Bazel Bash runfiles library v3.
18+
set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash
19+
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
20+
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
21+
source "$0.runfiles/$f" 2>/dev/null || \
22+
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
23+
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
24+
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
25+
# --- end runfiles.bash initialization v3 ---
26+
27+
# JAZZER_EXECPATH is a path of the form "external/remotejdk_17/bin/java". We need to strip of the
28+
# leading external to get a path we can pass to rlocation.
29+
java_rlocationpath=$(echo "$JAVA_EXECPATH" | cut -d/ -f2-)
30+
java=$(rlocation "$java_rlocationpath")
31+
jazzer=$(rlocation "$JAZZER_RLOCATIONPATH")
32+
[ -f "$jazzer" ] || exit 1
33+
jazzer_version_output=$("$java" -jar "$jazzer" --version 2>&1)
34+
echo "$jazzer_version_output"
35+
echo "$jazzer_version_output" | tr -d '\n' | grep -q '^Jazzer v[0-9.]*$' || exit 1

src/main/java/com/code_intelligence/jazzer/BUILD.bazel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ java_binary(
6363
"//src/main/java/com/code_intelligence/jazzer/api:api_deploy_env",
6464
"//src/main/java/com/code_intelligence/jazzer/runtime:jazzer_bootstrap_env",
6565
],
66-
main_class = "com.code_intelligence.jazzer.Jazzer",
66+
deploy_manifest_lines = [
67+
"Main-Class: com.code_intelligence.jazzer.Jazzer",
68+
],
6769
runtime_deps = [":jazzer_lib"],
6870
)
6971

0 commit comments

Comments
 (0)