Skip to content

Commit

Permalink
Records all SHAs
Browse files Browse the repository at this point in the history
  • Loading branch information
sophia-guo committed Dec 12, 2024
1 parent 67a6243 commit 1b19413
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 91 deletions.
11 changes: 0 additions & 11 deletions scripts/build_test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,6 @@
</if>
<echo> build.list is ${build.list} </echo>

<macrodef name="checkGitRepoSha">
<attribute name="repoDir" default="." />
<sequential>
<exec executable="bash" failonerror="true">
<arg line="${TEST_ROOT}/TKG/scripts/getSHA.sh" />
<arg line="--repo_dir @{repoDir}" />
<arg line="--output_file ${TEST_ROOT}/TKG/SHA.txt" />
</exec>
</sequential>
</macrodef>

<macrodef name="addTestenvProperties">
<attribute name="repoDir" default="." />
<attribute name="repoName" default="" />
Expand Down
71 changes: 0 additions & 71 deletions scripts/getSHA.sh

This file was deleted.

76 changes: 76 additions & 0 deletions scripts/getSHAs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env bash
#
# 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.

TEST_ROOT=""
SHAs_FILE=""
workDIR=$(pwd)

usage ()
{
echo 'This script use git command to get all shas in the provided TEST_ROOT and write the info into the SHAs file'
echo 'Usage : '
echo ' --test_root_dir: optional'
echo ' --shas_file: optianal, the file to write the sha info to. Default is to ../SHAs.txt'

}

parseCommandLineArgs()
{
while [[ $# -gt 0 ]] && [[ ."$1" = .-* ]] ; do
opt="$1";
shift;
case "$opt" in
"--test_root_dir" | "-d" )
TEST_ROOT="$1"; shift;;

"--shas_file" | "-f" )
SHAs_FILE="$1"; shift;;

"--help" | "-h" )
usage; exit 0;;

*) echo >&2 "Invalid option: ${opt}"; echo "This option was unrecognized."; usage; exit 1;
esac
done
if [ -z "$TEST_ROOT" ] || [ -z "$SHAs_FILE" ] || [ ! -d "$TEST_ROOT" ]; then
echo "Error, please see the usage and also check if $TEST_ROOT is existing"
usage
exit 1
fi
}

timestamp() {
date +"%Y%m%d-%H%M%S"
}

getSHAs()
{
echo "Check shas in $TEST_ROOT and store the info in $SHAs_FILE"
if [ ! -e "${SHAs_FILE}" ]; then
echo "touch $SHAs_FILE"
touch "$SHAs_FILE"
fi

cd "$TEST_ROOT" || exit
find "$TEST_ROOT" -type d -name ".git" | while read -r gitDir; do
repoDir=$(dirname "$gitDir")
cd "$repoDir" || continue
# append the info into $SHAs_FILR
{ echo "================================================"; echo "timestamp: $(timestamp)"; echo "repo dir: $repoDir"; echo "git repo: "; git remote show origin -n | grep "Fetch URL:"; echo "sha:"; git rev-parse HEAD; } 2>&1 | tee -a "$SHAs_FILE"
done
}
parseCommandLineArgs "$@"
getSHAs
cd "$workDIR" || exit

6 changes: 3 additions & 3 deletions scripts/resultsSum.pl
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,11 @@ sub resultReporter {
my $host = hostname;
print $fhOut "# Hostname: " . $host . "\n\n";

#add SHA.txt content in TAP file
my $SHAFile = $tapPath."../SHA.txt";
#add SHAs.txt content in TAP file
my $SHAFile = $tapPath."../SHAs.txt";
my $SHAContent = `cat $SHAFile`;
$SHAContent =~ s/\n/\n# /g;
print $fhOut "#SHA.txt content: \n# " . $SHAContent . "\n";
print $fhOut "#SHAs.txt content: \n# " . $SHAContent . "\n";

print $fhOut "# Timestamp: " . $timeStamp . " UTC \n";

Expand Down
15 changes: 9 additions & 6 deletions settings.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# limitations under the License.
##############################################################################

.PHONY: help rmResultFile resultsSummary
.PHONY: help rmResultFile shaInfor resultsSummary

help:
@echo "This makefile is used to build and execute JVM tests. You should specify the following"
Expand Down Expand Up @@ -364,7 +364,7 @@ $(SUBDIRS_TESTTARGET):

$(TESTTARGET): $(SUBDIRS_TESTTARGET)

_$(TESTTARGET): setup_$(TESTTARGET) rmResultFile $(TESTTARGET) resultsSummary teardown_$(TESTTARGET)
_$(TESTTARGET): setup_$(TESTTARGET) rmResultFile $(TESTTARGET) shaInfor resultsSummary teardown_$(TESTTARGET)
@$(ECHO) $@ done

.PHONY: _$(TESTTARGET) $(TESTTARGET) $(SUBDIRS) $(SUBDIRS_TESTTARGET)
Expand Down Expand Up @@ -443,13 +443,16 @@ endif
rmResultFile:
@$(RM) $(Q)$(TEMPRESULTFILE)$(Q)

shaInfor:
@$(ECHO_NEWLINE)
@$(ECHO_NEWLINE)
@$(ECHO) $(Q)Collect all REPOs sha $(Q)
$(CD) $(Q)$(TEST_ROOT)$(D)TKG$(D)scripts$(Q); \
bash $(Q)getSHAs.sh$(Q) --test_root_dir $(Q)$(TEST_ROOT)$(Q) --shas_file $(Q)$(TEST_ROOT)$(D)TKG$(D)SHAs.txt$(Q)

resultsSummary:
@$(ECHO_NEWLINE)
@$(ECHO_NEWLINE)
@$(ECHO) $(Q)All tests finished, run result summary:$(Q)
$(CD) $(Q)$(TEST_ROOT)$(D)TKG$(D)scripts$(Q); \
perl $(Q)resultsSum.pl$(Q) --failuremk=$(Q)$(FAILEDTARGETS)$(Q) --resultFile=$(Q)$(TEMPRESULTFILE)$(Q) --platFile=$(Q)$(PLATFROMFILE)$(Q) --diagnostic=$(DIAGNOSTICLEVEL) --jdkVersion=$(JDK_VERSION) --jdkImpl=$(JDK_IMPL) --jdkVendor=$(Q)$(JDK_VENDOR)$(Q) --spec=$(SPEC) --buildList=$(BUILD_LIST) --customTarget=$(Q)$(CUSTOM_TARGET)$(Q) --testTarget=$(TESTTARGET) --tapPath=$(TESTOUTPUT)$(D) --tapName=$(TAP_NAME) --comment=$(Q)$(RESULT_COMMENT)$(Q)

shaInfor:
$(CD) $(Q)$(TEST_ROOT)$(D)TKG$(D)scripts$(Q); \
bash $(Q)getSHA.sh$(Q) --repo_dir $(Q)$(TEST_ROOT)$(D)openjdk-jdk --output_file ${TEST_ROOT}$(D)TKG$(D)SHA.txt

0 comments on commit 1b19413

Please sign in to comment.