Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable reproducable comparation in aqa-tests on windows #3778

Merged
merged 19 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions test/system/reproducibleCompare/playlist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,23 @@
</versions>
<platformRequirements>os.linux</platformRequirements>
</test>
<test>
<testCaseName>Rebuild_Same_JDK_Reproducibility_Test_win</testCaseName>
<command>$(TEST_ROOT)$(D)system$(D)reproducibleCompare$(D)windows_repro_build_compare.sh $(SBOM_FILE) $(JDK_FILE) $(REPORTDIR); \
$(TEST_STATUS)
</command>
<levels>
<level>dev</level>
</levels>
<groups>
<group>system</group>
</groups>
<vendors>
<vendor>eclipse</vendor>
</vendors>
<versions>
<version>21+</version>
</versions>
<platformRequirements>os.win</platformRequirements>
</test>
</playlist>
5 changes: 5 additions & 0 deletions test/system/reproducibleCompare/reproducible.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ ifndef SBOM_FILE
SBOM_FILE := $(shell ls $(TEST_ROOT)/../jdkbinary/ | grep "sbom" | grep -v "metadata")
SBOM_FILE := $(TEST_ROOT)/../jdkbinary/$(SBOM_FILE)
endif
ifndef JDK_FILE
ifneq (,$(findstring win,$(SPEC)))
JDK_FILE := $(shell find $(TEST_ROOT)/../jdkbinary/ -type f -name '*-jdk_*.zip')
endif
endif

ifneq (,$(findstring linux,$(SPEC)))
SBOM_FILE := $(subst $(TEST_ROOT)/../jdkbinary,/home/jenkins/test,$(SBOM_FILE))
Expand Down
11 changes: 11 additions & 0 deletions tooling/reproducible/repro_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,17 @@ function processModuleInfo() {
fi
}

# Remove windowns generate classes jdk/bin/server/classes.jsa & jdk/bin/server/classes_nocoops.jsa
function removeGeneratedClasses() {
local JDK_DIR="$1"
local OS="$2"

if [[ "$OS" =~ CYGWIN* ]]; then
rm -rf "$JDK_DIR/bin/server/classes.jsa"
rm -rf "$JDK_DIR/bin/server/classes_nocoops.jsa"
fi
}

# Remove all Signatures
function removeSignatures() {
local JDK_DIR="$1"
Expand Down
2 changes: 1 addition & 1 deletion tooling/reproducible/repro_compare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ done
files1=$(find "${JDK_DIR1}" -type f | wc -l)
echo "Number of files: ${files1}"
rc=0
output="repro_diff.out"
output="reprotest.diff"
echo "Comparing ${JDK_DIR1} with ${JDK_DIR2} ... output to file: ${output}"
diff -r -q "${JDK_DIR1}" "${JDK_DIR2}" > "${output}" || rc=$?

Expand Down
3 changes: 2 additions & 1 deletion tooling/reproducible/repro_process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ OS="$2"

expandJDK "$JDK_DIR" "$OS"


removeGeneratedClasses "$JDK_DIR" "$OS"
if [[ "$OS" =~ CYGWIN* ]] || [[ "$OS" =~ Darwin* ]]; then

# Remove existing signature
removeSignatures "$JDK_DIR" "$OS"

Expand Down
99 changes: 36 additions & 63 deletions tooling/reproducible/windows_repro_build_compare.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ fi
# Read Parameters
SBOM_URL="$1"
TARBALL_URL="$2"
REPORT_DIR="$3"

# Constants Required By This Script
# These Values Should Be Updated To Reflect The Build Environment
# The Defaults Below Are Suitable For An Adoptium Windows Build Environment
# Which Has Been Created Via The Ansible Infrastructure Playbooks

WORK_DIR="/cygdrive/c/comp-jdk-build"
ANT_VERSION="1.10.5"
ANT_CONTRIB_VERSION="1.0b3"
Expand All @@ -62,8 +62,8 @@ NOTUSE_ARGS=("--assemble-exploded-image" "--configure-args")
# Addiitonal Working Variables Defined For Use By This Script
SBOMLocalPath="$WORK_DIR/src_sbom.json"
DISTLocalPath="$WORK_DIR/src_jdk_dist.zip"
ScriptPath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

ScriptPath=$(dirname "$(realpath "$0")")
rc=0
# Function to check if a string is a valid URL
is_url() {
local url=$1
Expand Down Expand Up @@ -172,9 +172,6 @@ Install_PreReqs() {
apt-cyg install jq libjq1 libonig5
fi
fi

# Install JQ Where Not Already Installed

}

Get_SBOM_Values() {
Expand Down Expand Up @@ -203,7 +200,7 @@ Get_SBOM_Values() {
msvsCCompiler=$(echo "$sbomContent" | jq -r '.metadata.tools[] | select(.name == "MSVS C Compiler Version").version')
msvsCppCompiler=$(echo "$sbomContent" | jq -r '.metadata.tools[] | select(.name == "MSVS C++ Compiler Version").version')
msvsSDKver=$(echo "$sbomContent" | jq -r '.metadata.tools[] | select(.name == "MS Windows SDK Version").version')
bootJDK=$(echo "$sbomContent" | jq -r '.metadata.tools[] | select(.name == "BOOTJDK").version')
bootJDK=$(echo "$sbomContent" | jq -r '.metadata.tools[] | select(.name == "BOOTJDK").version' | sed -e 's#-LTS$##')
buildArch=$(echo "$sbomContent" | jq -r '.metadata.properties[] | select(.name == "OS architecture").value')
buildSHA=$(echo "$sbomContent" | jq -r '.components[0].properties[] | select(.name == "Temurin Build Ref").value' | awk -F'/' '{print $NF}')
buildStamp=$(echo "$sbomContent" | jq -r '.components[0].properties[] | select(.name == "Build Timestamp").value')
Expand Down Expand Up @@ -557,13 +554,13 @@ Clone_Build_Repo() {
Prepare_Env_For_Build() {
echo "Setting Variables"
export BOOTJDK_HOME=$WORK_DIR/jdk-${bootJDK}

echo "Parsing Make JDK Any Platform ARGS For Build"
# Split the string into an array of words
IFS=' ' read -ra words <<< "$buildArgs"

# Add The Build Time Stamp In Case It Wasnt In The SBOM ARGS
words+=( "--build-reproducible-date \"$buildStamp\"" )
words+=("--build-reproducible-date")
words+=("\"$buildStamp\"")

# Initialize variables
param=""
Expand All @@ -582,12 +579,12 @@ Prepare_Env_For_Build() {
param="$word"
value=""
else
value+=" $word"
value+="$word "
fi
done

# Add the last parameter to the array
params+=("$param = $value")
params+=("$param=$value")

# Read the separated parameters and values into a new array
export fixed_param=""
Expand All @@ -604,16 +601,12 @@ Prepare_Env_For_Build() {
fixed_param="${prefixed_param%%[[:space:]]}"
prepped_value=${parts[1]}
fixed_value=$(echo "$prepped_value" | awk '{$1=$1};1')

# Handle Special parameters
if [ "$fixed_param" == "-b" ]; then fixed_value="$fixed_value " ; fi
if [ "$fixed_param" == "--jdk-boot-dir" ]; then fixed_value="$BOOTJDK_HOME " ; fi
if [ "$fixed_param" == "--freetype-dir" ]; then fixed_value="$fixed_value " ; fi
if [ "$fixed_param" == "--with-toolchain-version" ]; then fixed_value="$visualStudioVersion " ; fi
if [ "$fixed_param" == "--jdk-boot-dir" ]; then fixed_value="$BOOTJDK_HOME" ; fi
if [ "$fixed_param" == "--with-toolchain-version" ]; then fixed_value="$visualStudioVersion" ; fi
if [ "$fixed_param" == "--with-ucrt-dll-dir" ]; then fixed_value="temporary_speech_mark_placeholder${UCRT_PARAM_PATH}temporary_speech_mark_placeholder " ; fi
if [ "$fixed_param" == "--target-file-name" ]; then target_file="$fixed_value" ; fixed_value="$fixed_value " ; fi
if [ "$fixed_param" == "--tag" ]; then fixed_value="$fixed_value " ; fi

if [ "$fixed_param" == "--target-file-name" ]; then target_file="$fixed_value" ; fi
if [ "$fixed_param" == "--user-openjdk-build-root-directory" ]; then fixed_value="$WORK_DIR/temurin-build/workspace/build/openjdkbuild" ; fi

# Fix Build Variant Parameter To Strip JDK Version

Expand Down Expand Up @@ -654,15 +647,9 @@ Prepare_Env_For_Build() {
fi
done

for element in "${BUILD_ARRAY[@]}"; do
build_string+="$element"
done

for element in "${CONFIG_ARRAY[@]}"; do
config_string+="$element"
done

final_params="$build_string--configure-args \"$config_string\" $jdk"
IFS=' ' build_string="${BUILD_ARRAY[*]}"
IFS=' ' config_string=$"${CONFIG_ARRAY[*]}"
final_params="$build_string --configure-args \"$config_string\" $jdk"

echo "Make JDK Any Platform Argument List = "
echo "$final_params"
Expand All @@ -677,23 +664,14 @@ Build_JDK() {
cd "$WORK_DIR"
echo "cd temurin-build && ./makejdk-any-platform.sh $final_params 2>&1 | tee build.$$.log" | sh
# Copy The Built JDK To The Working Directory
cp "$WORK_DIR/temurin-build/workspace/target/$target_file" "$WORK_DIR/built_jdk.zip"
cp "$WORK_DIR/temurin-build/workspace/target/$target_file" "$WORK_DIR/reproJDK.zip"
}

Compare_JDK() {
echo "Comparing JDKs"
echo ""
mkdir "$WORK_DIR/compare"
cp "$WORK_DIR/src_jdk_dist.zip" "$WORK_DIR/compare"
cp "$WORK_DIR/built_jdk.zip" "$WORK_DIR/compare"

# Get The Current Versions Of The Reproducible Build Scripts
wget -O "$WORK_DIR/compare/repro_common.sh" "https://raw.githubusercontent.com/adoptium/temurin-build/master/tooling/reproducible/repro_common.sh"
wget -O "$WORK_DIR/compare/repro_compare.sh" "https://raw.githubusercontent.com/adoptium/temurin-build/master/tooling/reproducible/repro_compare.sh"
wget -O "$WORK_DIR/compare/repro_process.sh" "https://raw.githubusercontent.com/adoptium/temurin-build/master/tooling/reproducible/repro_process.sh"

# Set Permissions
chmod +x "$WORK_DIR/compare/"*sh
cp "$WORK_DIR/reproJDK.zip" "$WORK_DIR/compare"
cd "$WORK_DIR/compare"

# Unzip And Rename The Source JDK
Expand All @@ -704,28 +682,13 @@ Compare_JDK() {

#Unzip And Rename The Target JDK
echo "Unzip Target"
unzip -q -o built_jdk.zip
unzip -q -o reproJDK.zip
original_directory_name=$(find . -maxdepth 1 -type d | grep -v src_jdk | tail -1)
mv "$original_directory_name" tar_jdk

# These Two Files Are Generate Classes And Should Be Removed Prior To Running The Comparison
# jdk/bin/server/classes.jsa & jdk/bin/server/classes_nocoops.jsa

if [ -f "$WORK_DIR/compare/src_jdk/bin/server/classes.jsa" ] ; then
rm -rf "$WORK_DIR/compare/src_jdk/bin/server/classes.jsa"
fi

if [ -f "$WORK_DIR/compare/tar_jdk/bin/server/classes.jsa" ] ; then
rm -rf "$WORK_DIR/compare/tar_jdk/bin/server/classes.jsa"
fi

if [ -f "$WORK_DIR/compare/src_jdk/bin/server/classes_nocoops.jsa" ] ; then
rm -rf "$WORK_DIR/compare/src_jdk/bin/server/classes_nocoops.jsa"
fi

if [ -f "$WORK_DIR/compare/tar_jdk/bin/server/classes_nocoops.jsa" ] ; then
rm -rf "$WORK_DIR/compare/tar_jdk/bin/server/classes_nocoops.jsa"
fi
# should move to repro_common.sh

# Ensure Signtool Is In The Path
TOOLCOUNT=$(find "$SIGNTOOL_BASE" | grep $msvsArch | grep -ic "signtool.exe$")
Expand Down Expand Up @@ -760,20 +723,29 @@ Compare_JDK() {
export PATH="$PATH:$CPW"

# Run Comparison Script
echo "cd $WORK_DIR/compare && ./repro_compare.sh temurin src_jdk temurin tar_jdk CYGWIN 2>&1" | sh &
wait
set +e
cd "$ScriptPath" || exit 1
./repro_compare.sh temurin $WORK_DIR/compare/src_jdk temurin $WORK_DIR/compare/tar_jdk CYGWIN 2>&1 &
pid=$!
wait $pid

# Display The Content Of repro_diff.out
rc=$?
set -e
cd "$WORK_DIR"
# Display The Content Of reprotest.diff
echo ""
echo "---------------------------------------------"
echo "Output From JDK Comparison Script"
echo "---------------------------------------------"
cat "$WORK_DIR/compare/repro_diff.out"
cat "$ScriptPath/reprotest.diff"
echo ""
echo "---------------------------------------------"
echo "Copying Output To $(dirname "$0")"
cp "$WORK_DIR/compare/repro_diff.out" "$ScriptPath"

if [ -n "$REPORT_DIR" ]; then
echo "Copying Output To $REPORT_DIR"
cp "$ScriptPath/reprotest.diff" "$REPORT_DIR"
cp "$WORK_DIR/reproJDK.zip" "$REPORT_DIR"
fi
}

Clean_Up_Everything() {
Expand Down Expand Up @@ -829,3 +801,4 @@ echo "---------------------------------------------"
Compare_JDK
echo "---------------------------------------------"
Clean_Up_Everything
exit $rc