Skip to content

Commit

Permalink
trashing some of the legacy code, extending readme and overall polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
jandrlik committed Feb 20, 2024
1 parent 7d5dd7a commit 9777c12
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 38 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# TestHeadlessComponents
Test of correct behavior of swing components in a headless jre environment.

## Running TestHeadlessComponents locally

### Setting up the environment:
Nothing special is required, just install the java package or unpack the portable you want the test.

### ENV variables:
The test utilizes *JAVA_HOME variable, so if it is not set it will not work correctly! In case of testing portable packages please set it up first.
BOOTJDK_DIR - directory to store bootjdk which is used to compile the code in case we are testing jre only installation. Uses ~/bootjdk by default and uses Adoptium latest build of relevant jdk for this purpose.
BOOTJDK_ARCHIVE_DIR - In case the user wants to use arbitrary jdk build, he can provide path to its archive's dir and it will be used in jre execution.. Creates and downloads to $WORKSPACE/bootjdkarchive if unset.
WORKSPACE - directory where the testsuite is going to execute all the tests. ~/workspace by default
TMPRESULTS - this is a location where the logfiles will be after the testsuite finishes. Same as WORKSPACE by default.
*JREJDK - This tells the testsuite whether we are testing jre or jdk.
ARCH - architecture of our system. The suite detects this automatically if left blank.
*OJDK_VERSION_NUMBER - number of jdk we are testing - this is used for downloading corresponding JDK from adoptium site.

Variables marked with "*" are mandatory and the testsuite wont run without them.

### Executing the testsuite

Now it is as simple as running bash script testHeadlessComponents.sh.
27 changes: 0 additions & 27 deletions genericRunner.sh

This file was deleted.

16 changes: 5 additions & 11 deletions testHeadlessComponents.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ function installAlternativeJDK() {
if [ "x$BOOTJDK_DIR" == "x" ]; then
BOOTJDK_DIR=~/bootjdk
fi
if [ ! "x$ALTERNATE_BOOT_JDK" == "x" ] ; then
ALTERNATIVE_JDK_DIR=$ALTERNATE_BOOT_JDK
return 0
fi
if [ "x$BOOTJDK_ARCHIVE_DIR" == "x" ]; then
BOOTJDK_ARCHIVE_DIR=$WORKSPACE/bootjdkarchive
mkdir -p $BOOTJDK_ARCHIVE_DIR
Expand All @@ -84,7 +80,7 @@ function installAlternativeJDK() {

function run_java_with_headless {
COMPONENTS_TO_TEST=$2
$JAVA -cp $cp -Djava.awt.headless=$1 MainRunner -test=$COMPONENTS_TO_TEST -jreSdkHeadless=$JRESDK -displayValue=$DISPLAY
$JAVA -cp $cp -Djava.awt.headless=$1 MainRunner -test=$COMPONENTS_TO_TEST -jreSdkHeadless=$JREJDK -displayValue=$DISPLAY
}

function run_swing_component_test_unset {
Expand Down Expand Up @@ -189,26 +185,24 @@ $JAVAC_BINARY `find . -type f -name "*.java"` -d $cp
declare -A resArray
set +e

if [[ -z "${OTOOL_ARCH}" ]] ; then
if [[ -z "${ARCH}" ]] ; then
RUN_ARCH=$(uname -m)
else
RUN_ARCH=$OTOOL_ARCH
fi

for testOption in compatible incompatible; do
for headless in true false; do
if [[ "$JRESDK" == "jre" || "$JRESDK" == "jdk" && (("${testOption}${headless}" == "compatibletrue") || ("${testOption}${headless}" == "incompatiblefalse")) ]] ; then
if [[ "$JREJDK" == "jre" || "$JREJDK" == "jdk" && (("${testOption}${headless}" == "compatibletrue") || ("${testOption}${headless}" == "incompatiblefalse")) ]] ; then
run_swing_component_test_unset ${testOption} ${headless} >> $LOGFILE 2>&1
resArray["jre_headless_${testOption}_${headless}_display_unset"]=$?
fi

if [[ "x$XDISPLAY" == *x* ]] ; then
if [[ "x$XDISPLAY" == "x" ]] ; then
echo "skipping tests with display set, as the default display was not defined"
else
run_swing_component_test_set ${testOption} ${headless} >> $LOGFILE 2>&1
resArray["jre_headless_${testOption}_${headless}_display_set"]=$?
fi
if [[ "$JRESDK" == "jre" || "$JRESDK" == "jdk" && (("${testOption}${headless}" == "compatibletrue") || ("${testOption}${headless}" == "incompatiblefalse")) ]] ; then
if [[ "$JREJDK" == "jre" || "$JREJDK" == "jdk" && (("${testOption}${headless}" == "compatibletrue") || ("${testOption}${headless}" == "incompatiblefalse")) ]] ; then
run_swing_component_test_fake ${testOption} ${headless} >> $LOGFILE 2>&1
resArray["jre_headless_${testOption}_${headless}_display_fake"]=$?
fi
Expand Down

0 comments on commit 9777c12

Please sign in to comment.