test/jdk/tools/jpackage/run_tests.sh
author herrick
Wed, 23 Oct 2019 10:10:34 -0400
branchJDK-8200758-branch
changeset 58761 88e2753a2334
parent 58301 e0efb29609bd
permissions -rw-r--r--
8231972: Build a stable list of jpackager tests for SQE Submitted-by: asemenyuk Reviewed-by: aherrick, almatvee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
     1
#!/bin/bash
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
     2
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
     3
#
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
     4
# Script to run jpackage tests.
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
     5
#
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
     6
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
     7
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
     8
# Fail fast
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
     9
set -e; set -o pipefail;
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    10
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    11
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    12
# Link obtained from https://openjdk.java.net/jtreg/ page
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    13
jtreg_bundle=https://ci.adoptopenjdk.net/view/Dependencies/job/jtreg/lastSuccessfulBuild/artifact/jtreg-4.2.0-tip.tar.gz
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    14
workdir=/tmp/jpackage_jtreg_testing
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    15
jtreg_jar=$workdir/jtreg/lib/jtreg.jar
58761
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    16
jpackage_test_selector=test/jdk/tools/jpackage
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    17
58761
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    18
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    19
find_packaging_tests ()
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    20
{
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    21
  (cd "$open_jdk_with_jpackage_jtreg_tests" && \
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    22
    find "$jpackage_test_selector/$1" -type f -name '*.java' \
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    23
    | xargs grep -E -l '@key[[:space:]]+jpackagePlatformPackage')
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    24
}
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    25
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    26
58761
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    27
find_all_packaging_tests ()
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    28
{
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    29
  find_packaging_tests share
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    30
  case "$(uname -s)" in
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    31
    Darwin)
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    32
      find_packaging_tests macosx;;
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    33
    Linux)
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    34
      find_packaging_tests linux;;
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    35
    CYGWIN*|MINGW32*|MSYS*)
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    36
      find_packaging_tests windows;;
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    37
    *)
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    38
      fatal Failed to detect OS type;;
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    39
  esac
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    40
}
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    41
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    42
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    43
help_usage ()
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    44
{
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    45
  echo "Usage: `basename $0` [options] [test_names]"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    46
  echo "Options:"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    47
  echo "  -h              - print this message"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    48
  echo "  -v              - verbose output"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    49
  echo "  -c              - keep jtreg cache"
58761
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    50
  echo "  -a              - run all, not only SQE tests"
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    51
  echo "  -d              - dry run. Print jtreg command line, but don't execute it"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    52
  echo "  -t <jdk>        - path to JDK to be tested [ mandatory ]"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    53
  echo "  -j <openjdk>    - path to local copy of openjdk repo with jpackage jtreg tests"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    54
  echo "                    Optional, default is openjdk repo where this script resides"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    55
  echo "  -o <outputdir>  - path to folder where to copy artifacts for testing."
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    56
  echo "                    Optional, default is the current directory."
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    57
  echo '  -r <runtimedir> - value for `jpackage.test.runtime-image` property.'
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    58
  echo "                    Optional, for jtreg tests debug purposes only."
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    59
  echo '  -l <logfile>    - value for `jpackage.test.logfile` property.'
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    60
  echo "                    Optional, for jtreg tests debug purposes only."
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    61
  echo "  -m <mode>       - mode to run jtreg tests."
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    62
  echo '                    Should be one of `create`, `update`, `verify-install` or `verify-uninstall`.'
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    63
  echo '                    Optional, default mode is `update`.'
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    64
  echo '                    - `create`'
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    65
  echo '                      Remove all package bundles from the output directory before running jtreg tests.'
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    66
  echo '                    - `update`'
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    67
  echo '                      Run jtreg tests and overrite existing package bundles in the output directory.'
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    68
  echo '                    - `verify-install`'
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    69
  echo '                      Verify installed packages created with the previous run of the script.'
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    70
  echo '                    - `verify-uninstall`'
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    71
  echo '                      Verify packages created with the previous run of the script were uninstalled cleanly.'
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    72
  echo '                    - `print-default-tests`'
58761
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
    73
  echo '                      Print default list of packaging tests and exit.'
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    74
}
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    75
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    76
error ()
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    77
{
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    78
  echo "$@" > /dev/stderr
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    79
}
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    80
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    81
fatal ()
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    82
{
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    83
  error "$@"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    84
  exit 1
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    85
}
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    86
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    87
fatal_with_help_usage ()
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    88
{
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    89
  error "$@"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    90
  help_usage
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    91
  exit 1
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    92
}
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    93
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    94
if command -v cygpath &> /dev/null; then
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    95
to_native_path ()
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    96
{
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    97
  cygpath -m "$@"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    98
}
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
    99
else
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   100
to_native_path ()
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   101
{
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   102
  echo "$@"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   103
}
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   104
fi
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   105
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   106
exec_command ()
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   107
{
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   108
  if [ -n "$dry_run" ]; then
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   109
    echo "$@"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   110
  else
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   111
    eval "$@"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   112
  fi
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   113
}
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   114
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   115
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   116
# Path to JDK to be tested.
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   117
test_jdk=
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   118
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   119
# Path to local copy of open jdk repo with jpackage jtreg tests
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   120
# hg clone http://hg.openjdk.java.net/jdk/sandbox
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   121
# cd sandbox; hg update -r JDK-8200758-branch
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   122
open_jdk_with_jpackage_jtreg_tests=$(dirname $0)/../../../../
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   123
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   124
# Directory where to save artifacts for testing.
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   125
output_dir=$PWD
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   126
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   127
# Script and jtreg debug.
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   128
verbose=
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   129
jtreg_verbose="-verbose:fail,error,summary"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   130
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   131
keep_jtreg_cache=
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   132
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   133
# Mode in which to run jtreg tests
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   134
mode=update
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   135
58761
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
   136
# jtreg extra arguments
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
   137
declare -a jtreg_args
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   138
58761
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
   139
# Run all tests
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
   140
run_all_tests=
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
   141
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
   142
mapfile -t tests < <(find_all_packaging_tests)
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
   143
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
   144
while getopts "vahdct:j:o:r:m:l:" argname; do
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   145
  case "$argname" in
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   146
    v) verbose=yes;;
58761
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
   147
    a) run_all_tests=yes;;
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   148
    d) dry_run=yes;;
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   149
    c) keep_jtreg_cache=yes;;
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   150
    t) test_jdk="$OPTARG";;
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   151
    j) open_jdk_with_jpackage_jtreg_tests="$OPTARG";;
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   152
    o) output_dir="$OPTARG";;
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   153
    r) runtime_dir="$OPTARG";;
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   154
    l) logfile="$OPTARG";;
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   155
    m) mode="$OPTARG";;
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   156
    h) help_usage; exit 0;;
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   157
    ?) help_usage; exit 1;;
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   158
  esac
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   159
done
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   160
shift $(( OPTIND - 1 ))
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   161
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   162
[ -z "$verbose" ] || { set -x; jtreg_verbose=-va; }
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   163
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   164
if [ -z "$open_jdk_with_jpackage_jtreg_tests" ]; then
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   165
  fatal_with_help_usage "Path to openjdk repo with jpackage jtreg tests not specified"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   166
fi
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   167
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   168
if [ "$mode" = "print-default-tests" ]; then
58761
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
   169
  exec_command for t in ${tests[@]}";" do echo '$t;' done
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   170
  exit
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   171
fi
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   172
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   173
if [ -z "$test_jdk" ]; then
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   174
  fatal_with_help_usage Path to test JDK not specified
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   175
fi
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   176
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   177
if [ -z "$JAVA_HOME" ]; then
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   178
  echo JAVA_HOME environment variable not set, will use java from test JDK [$test_jdk] to run jtreg
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   179
  JAVA_HOME="$test_jdk"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   180
fi
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   181
if [ ! -e "$JAVA_HOME/bin/java" ]; then
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   182
  fatal JAVA_HOME variable is set to [$JAVA_HOME] value, but $JAVA_HOME/bin/java not found.
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   183
fi
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   184
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   185
if [ -n "$runtime_dir" ]; then
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   186
  if [ ! -d "$runtime_dir" ]; then
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   187
    fatal 'Value of `-r` option is set to non-existing directory'.
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   188
  fi
58761
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
   189
  jtreg_args+=("-Djpackage.test.runtime-image=$(to_native_path "$(cd "$runtime_dir" && pwd)")")
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   190
fi
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   191
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   192
if [ -n "$logfile" ]; then
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   193
  if [ ! -d "$(dirname "$logfile")" ]; then
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   194
    fatal 'Value of `-l` option specified a file in non-existing directory'.
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   195
  fi
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   196
  logfile="$(cd "$(dirname "$logfile")" && pwd)/$(basename "$logfile")"
58761
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
   197
  jtreg_args+=("-Djpackage.test.logfile=$(to_native_path "$logfile")")
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   198
fi
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   199
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   200
if [ "$mode" = create ]; then
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   201
  true
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   202
elif [ "$mode" = update ]; then
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   203
  true
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   204
elif [ "$mode" = verify-install ]; then
58761
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
   205
  jtreg_args+=("-Djpackage.test.action=$mode")
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   206
elif [ "$mode" = verify-uninstall ]; then
58761
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
   207
  jtreg_args+=("-Djpackage.test.action=$mode")
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   208
else
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   209
  fatal_with_help_usage 'Invalid value of -m option:' [$mode]
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   210
fi
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   211
58761
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
   212
if [ -z "$run_all_tests" ]; then
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
   213
  jtreg_args+=(-Djpackage.test.SQETest=yes)
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
   214
fi
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   215
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   216
# All remaining command line arguments are tests to run that should override the defaults
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   217
[ $# -eq 0 ] || tests=($@)
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   218
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   219
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   220
installJtreg ()
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   221
{
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   222
  # Install jtreg if missing
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   223
  if [ ! -f "$jtreg_jar" ]; then
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   224
    exec_command mkdir -p "$workdir"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   225
    exec_command "(" cd "$workdir" "&&" wget "$jtreg_bundle" "&&" tar -xzf "$(basename $jtreg_bundle)" ";" rm -f "$(basename $jtreg_bundle)" ")"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   226
  fi
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   227
}
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   228
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   229
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   230
preRun ()
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   231
{
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   232
  local xargs_args=(-t --no-run-if-empty rm)
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   233
  if [ -n "$dry_run" ]; then
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   234
    xargs_args=(--no-run-if-empty echo rm)
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   235
  fi
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   236
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   237
  if [ ! -d "$output_dir" ]; then
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   238
    exec_command mkdir -p "$output_dir"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   239
  fi
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   240
  [ ! -d "$output_dir" ] || output_dir=$(cd "$output_dir" && pwd)
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   241
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   242
  # Clean output directory
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   243
  [ "$mode" != "create" ] || find $output_dir -maxdepth 1 -type f -name '*.exe' -or -name '*.msi' -or -name '*.rpm' -or -name '*.deb' | xargs "${xargs_args[@]}"
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   244
}
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   245
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   246
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   247
run ()
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   248
{
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   249
  local jtreg_cmdline=(\
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   250
    $JAVA_HOME/bin/java -jar $(to_native_path "$jtreg_jar") \
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   251
    "-Djpackage.test.output=$(to_native_path "$output_dir")" \
58761
88e2753a2334 8231972: Build a stable list of jpackager tests for SQE
herrick
parents: 58301
diff changeset
   252
    "${jtreg_args[@]}" \
58301
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   253
    -nr \
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   254
    "$jtreg_verbose" \
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   255
    -retain:all \
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   256
    -automatic \
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   257
    -ignore:run \
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   258
    -testjdk:"$(to_native_path $test_jdk)" \
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   259
    -dir:"$(to_native_path $open_jdk_with_jpackage_jtreg_tests)" \
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   260
    -reportDir:"$(to_native_path $workdir/run/results)" \
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   261
    -workDir:"$(to_native_path $workdir/run/support)" \
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   262
    "${tests[@]}" \
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   263
  )
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   264
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   265
  # Clear previous results
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   266
  [ -n "$keep_jtreg_cache" ] || exec_command rm -rf "$workdir"/run
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   267
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   268
  # Run jpackage jtreg tests to create artifacts for testing
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   269
  exec_command ${jtreg_cmdline[@]}
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   270
}
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   271
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   272
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   273
installJtreg
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   274
preRun
e0efb29609bd 8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff changeset
   275
run