diff --git a/test/functional/reproducibleCompare/linux_repro_build_compare.sh b/test/functional/reproducibleCompare/linux_repro_build_compare.sh index 9b16ea5614..2568274e65 100755 --- a/test/functional/reproducibleCompare/linux_repro_build_compare.sh +++ b/test/functional/reproducibleCompare/linux_repro_build_compare.sh @@ -78,11 +78,11 @@ checkAllVariablesSet() { } originalJDKDir="" -testDir="$PWD" -ls /home/jenkins/jdkbinary +workDir="$PWD" + if [ $# -lt 1 ]; then if [ -d "/home/jenkins/jdkbinary" ]; then - find /home/jenkins/jdkbinary -type f -name '*sbom*.json' -exec cp {} "${testDir}" \; + find /home/jenkins/jdkbinary -type f -name '*sbom*.json' -exec cp {} "${workDir}" \; SBOM=$(find /home/jenkins/jdkbinary -type f -name '*sbom*.json' -exec basename {} \;) echo "SBOM is ${SBOM}" else @@ -107,7 +107,6 @@ LOCALGCCDIR=/usr/local/gcc$(echo "$GCCVERSION" | cut -d. -f1) TEMURIN_BUILD_SHA=$(jq -r '.components[] | .properties[] | select (.name == "Temurin Build Ref") | .value' "$SBOM" | awk -F/ '{print $NF}') TEMURIN_BUILD_ARGS=$(jq -r '.components[] | .properties[] | select (.name == "makejdk_any_platform_args") | .value' "$SBOM" | cut -d\" -f4 | sed -e "s/--disable-warnings-as-errors --enable-dtrace --without-version-pre --without-version-opt/'--disable-warnings-as-errors --enable-dtrace --without-version-pre --without-version-opt'/" -e "s/ --disable-warnings-as-errors --enable-dtrace/ '--disable-warnings-as-errors --enable-dtrace'/" -e 's/\\n//g' -e "s,--jdk-boot-dir [^ ]*,--jdk-boot-dir /usr/lib/jvm/jdk-$BOOTJDK_VERSION,g") TEMURIN_VERSION=$(jq -r '.metadata.component.version' "$SBOM" | sed 's/-beta//' | cut -f1 -d"-") - NATIVE_API_ARCH=$(uname -m) if [ "${NATIVE_API_ARCH}" = "x86_64" ]; then NATIVE_API_ARCH=x64; fi if [ "${NATIVE_API_ARCH}" = "armv7l" ]; then NATIVE_API_ARCH=arm; fi @@ -118,13 +117,13 @@ downloadTooling setEnvironment if [ $# -lt 1 ]; then - javacPath=$(find /home/jenkins/jdkbinary -name javac | egrep 'bin/javac$') + javacPath=$(find /home/jenkins/jdkbinary -name javac | grep -E 'bin/javac$') if [ "$javacPath" != "" ]; then - originalJDKDir=$(dirname ${javacPath})/../ + originalJDKDir=$(dirname "${javacPath}")/../ fi fi -if [ ! -n originalJDKDir ] && [ ! -d "jdk-${TEMURIN_VERSION}" ]; then +if [ -z "${originalJDKDir}" ] && [ ! -d "jdk-${TEMURIN_VERSION}" ]; then if [ -z "$TARBALL_URL" ]; then TARBALL_URL="https://api.adoptium.net/v3/binary/version/jdk-${TEMURIN_VERSION}/linux/${NATIVE_API_ARCH}/jdk/hotspot/normal/eclipse?project=jdk" fi @@ -137,16 +136,18 @@ echo " cd temurin-build && ./makejdk-any-platform.sh $TEMURIN_BUILD_ARGS 2>&1 | echo Comparing ... mkdir compare.$$ tar xpfz temurin-build/workspace/target/OpenJDK*-jdk_*tar.gz -C compare.$$ -ls -l compare.$$/jdk-$TEMURIN_VERSION/NOTICE cleanBuildInfo +rc=0 # shellcheck disable=SC2069 -if diff -r "${originalJDKDir}" "compare.$$/jdk-$TEMURIN_VERSION" 2>&1 > "reprotest.$(uname).$TEMURIN_VERSION.diff"; then - echo "Compare identical !" - exit 0 +diff -r "${originalJDKDir}" "compare.$$/jdk-$TEMURIN_VERSION" 2>&1 > "reprotest.$(uname).$TEMURIN_VERSION.diff" || rc=$? + +if [ $rc != 0 ]; then + cat "reprotest.$(uname).$TEMURIN_VERSION.diff" + echo "Differences found..., logged in: reprotest.$(uname).$TEMURIN_VERSION.diff" else - cat "reprotest.$(uname).$TEMURIN_VERSION.diff" - echo "Differences found..., logged in: reprotest.$(uname).$TEMURIN_VERSION.diff" - exit 1 + echo "Compare identical !" fi +cp reprotest.$(uname)."${TEMURIN_VERSION}".diff reprotest.diff +exit $rc \ No newline at end of file diff --git a/test/functional/reproducibleCompare/playlist.xml b/test/functional/reproducibleCompare/playlist.xml index 98d418862d..2874c31b8e 100644 --- a/test/functional/reproducibleCompare/playlist.xml +++ b/test/functional/reproducibleCompare/playlist.xml @@ -16,13 +16,13 @@ Reproducible_Comparison - docker run -v "$(TEST_RESROOT):/home/jenkins/test" -v "$(TEST_JDK_HOME)/..:/home/jenkins/jdkbinary" -w "/home/jenkins/test" --name reproducibleCompare adoptopenjdk/centos7_build_image /bin/bash test.sh; \ + docker run -v "$(TEST_RESROOT):/home/jenkins/test" -v "$(TEST_JDK_HOME)/..:/home/jenkins/jdkbinary" -w "/home/jenkins/" --name reproducibleCompare adoptopenjdk/centos7_build_image /bin/bash /home/jenkins/test/linux_repro_build_compare.sh; \ $(TEST_STATUS); \ - docker cp reproducibleCompare:/home/jenkins/test/reprotest.1.diff ./; - ls -l + docker cp reproducibleCompare:/home/jenkins/reprotest.diff ./; \ + docker container rm reproducibleCompare - extended + dev functional diff --git a/test/functional/reproducibleCompare/test.sh b/test/functional/reproducibleCompare/test.sh deleted file mode 100755 index ab2cb88f70..0000000000 --- a/test/functional/reproducibleCompare/test.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -################################################################################ - -# This script examines the given SBOM metadata file, and then builds the exact same binary -# and then compares with the Temurin JDK for the same build version, or the optionally supplied TARBALL_URL. - -echo "hello" > reprotest.1.diff -ls -l \ No newline at end of file