Skip to content

Commit

Permalink
Enable reproducable comparation in aqa-tests on windows (#3778)
Browse files Browse the repository at this point in the history
* Add Win reproducible comparing tests

Signed-off-by: Sophia Guo <[email protected]>

* Add reproducible win test

Signed-off-by: Sophia Guo <[email protected]>

* Add Reproducible.mk

Signed-off-by: Sophia Guo <[email protected]>

* Set copy and delelet failonerror="false"

Set copy and delelet failonerror="false" to support original repo name
openjdk-build.

Signed-off-by: Sophia Guo <[email protected]>

* Remove bootjdk suffix -LTS

Signed-off-by: Sophia Guo <[email protected]>

* Update makefile

Signed-off-by: Sophia Guo <[email protected]>

* Set JDK Tar/Zip file

Signed-off-by: Sophia Guo <[email protected]>

* Testing

Signed-off-by: Sophia Guo <[email protected]>

* Remove manually adding delimiter

Manually adding delimiter need to consistently update whenever parsing
parameters changes.

Signed-off-by: Sophia Guo <[email protected]>

* Update --user-openjdk-build-root-directory

Signed-off-by: Sophia Guo <[email protected]>

* Copy diff and reproduced JDK to reportDIR

Signed-off-by: Sophia Guo <[email protected]>

* Add report dir

Signed-off-by: Sophia Guo <[email protected]>

* Clean

Signed-off-by: Sophia Guo <[email protected]>

* Pass in $(REPORTDIR)

Signed-off-by: Sophia Guo <[email protected]>

* Add return code to show status

Signed-off-by: Sophia Guo <[email protected]>

* Manually handle return code

Signed-off-by: Sophia Guo <[email protected]>

* Remove window generated classes

Signed-off-by: Sophia Guo <[email protected]>

* Linter issue

Signed-off-by: Sophia Guo <[email protected]>

* Clean up

Signed-off-by: Sophia Guo <[email protected]>

---------

Signed-off-by: Sophia Guo <[email protected]>
  • Loading branch information
sophia-guo authored May 15, 2024
1 parent 01fe609 commit ad4a1c3
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 68 deletions.
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
101 changes: 35 additions & 66 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,29 +682,10 @@ 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

# Ensure Signtool Is In The Path
TOOLCOUNT=$(find "$SIGNTOOL_BASE" | grep $msvsArch | grep -ic "signtool.exe$")

Expand Down Expand Up @@ -760,20 +719,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 +797,4 @@ echo "---------------------------------------------"
Compare_JDK
echo "---------------------------------------------"
Clean_Up_Everything
exit $rc

0 comments on commit ad4a1c3

Please sign in to comment.