test/jdk/tools/jpackage/run_tests.sh
branchJDK-8200758-branch
changeset 58761 88e2753a2334
parent 58301 e0efb29609bd
equal deleted inserted replaced
58696:61c44899b4eb 58761:88e2753a2334
    11 
    11 
    12 # Link obtained from https://openjdk.java.net/jtreg/ page
    12 # Link obtained from https://openjdk.java.net/jtreg/ page
    13 jtreg_bundle=https://ci.adoptopenjdk.net/view/Dependencies/job/jtreg/lastSuccessfulBuild/artifact/jtreg-4.2.0-tip.tar.gz
    13 jtreg_bundle=https://ci.adoptopenjdk.net/view/Dependencies/job/jtreg/lastSuccessfulBuild/artifact/jtreg-4.2.0-tip.tar.gz
    14 workdir=/tmp/jpackage_jtreg_testing
    14 workdir=/tmp/jpackage_jtreg_testing
    15 jtreg_jar=$workdir/jtreg/lib/jtreg.jar
    15 jtreg_jar=$workdir/jtreg/lib/jtreg.jar
    16 
    16 jpackage_test_selector=test/jdk/tools/jpackage
    17 # Names of shared packaging tests to run
    17 
    18 share_package_test_names="
    18 
    19   FileAssociationsTest
    19 find_packaging_tests ()
    20   InstallDirTest
    20 {
    21   LicenseTest
    21   (cd "$open_jdk_with_jpackage_jtreg_tests" && \
    22   SimplePackageTest
    22     find "$jpackage_test_selector/$1" -type f -name '*.java' \
    23   RuntimePackageTest
    23     | xargs grep -E -l '@key[[:space:]]+jpackagePlatformPackage')
    24   AdditionalLaunchersTest
    24 }
    25   AppImagePackageTest
    25 
    26 "
    26 
    27 mapfile -t packaging_tests_share < <(for t in $share_package_test_names; do echo test/jdk/tools/jpackage/share/$t.java; done)
    27 find_all_packaging_tests ()
    28 packaging_tests_windows=test/jdk/tools/jpackage/windows
    28 {
    29 packaging_tests_linux=test/jdk/tools/jpackage/linux
    29   find_packaging_tests share
    30 packaging_tests_mac=test/jdk/tools/jpackage/macosx
    30   case "$(uname -s)" in
    31 
    31     Darwin)
    32 case "$(uname -s)" in
    32       find_packaging_tests macosx;;
    33   Darwin)
    33     Linux)
    34     tests=( "$packaging_tests_mac" );;
    34       find_packaging_tests linux;;
    35   Linux)
    35     CYGWIN*|MINGW32*|MSYS*)
    36     tests=( "$packaging_tests_linux" );;
    36       find_packaging_tests windows;;
    37   CYGWIN*|MINGW32*|MSYS*)
    37     *)
    38     tests=( "$packaging_tests_windows" );;
    38       fatal Failed to detect OS type;;
    39   *)
    39   esac
    40     fatal Failed to detect OS type;;
    40 }
    41 esac
       
    42 tests+=(${packaging_tests_share[@]})
       
    43 
    41 
    44 
    42 
    45 help_usage ()
    43 help_usage ()
    46 {
    44 {
    47   echo "Usage: `basename $0` [options] [test_names]"
    45   echo "Usage: `basename $0` [options] [test_names]"
    48   echo "Options:"
    46   echo "Options:"
    49   echo "  -h              - print this message"
    47   echo "  -h              - print this message"
    50   echo "  -v              - verbose output"
    48   echo "  -v              - verbose output"
    51   echo "  -c              - keep jtreg cache"
    49   echo "  -c              - keep jtreg cache"
       
    50   echo "  -a              - run all, not only SQE tests"
    52   echo "  -d              - dry run. Print jtreg command line, but don't execute it"
    51   echo "  -d              - dry run. Print jtreg command line, but don't execute it"
    53   echo "  -t <jdk>        - path to JDK to be tested [ mandatory ]"
    52   echo "  -t <jdk>        - path to JDK to be tested [ mandatory ]"
    54   echo "  -j <openjdk>    - path to local copy of openjdk repo with jpackage jtreg tests"
    53   echo "  -j <openjdk>    - path to local copy of openjdk repo with jpackage jtreg tests"
    55   echo "                    Optional, default is openjdk repo where this script resides"
    54   echo "                    Optional, default is openjdk repo where this script resides"
    56   echo "  -o <outputdir>  - path to folder where to copy artifacts for testing."
    55   echo "  -o <outputdir>  - path to folder where to copy artifacts for testing."
    69   echo '                    - `verify-install`'
    68   echo '                    - `verify-install`'
    70   echo '                      Verify installed packages created with the previous run of the script.'
    69   echo '                      Verify installed packages created with the previous run of the script.'
    71   echo '                    - `verify-uninstall`'
    70   echo '                    - `verify-uninstall`'
    72   echo '                      Verify packages created with the previous run of the script were uninstalled cleanly.'
    71   echo '                      Verify packages created with the previous run of the script were uninstalled cleanly.'
    73   echo '                    - `print-default-tests`'
    72   echo '                    - `print-default-tests`'
    74   echo '                      Print default tests list and exit.'
    73   echo '                      Print default list of packaging tests and exit.'
    75 }
    74 }
    76 
    75 
    77 error ()
    76 error ()
    78 {
    77 {
    79   echo "$@" > /dev/stderr
    78   echo "$@" > /dev/stderr
   111   else
   110   else
   112     eval "$@"
   111     eval "$@"
   113   fi
   112   fi
   114 }
   113 }
   115 
   114 
   116 expand_test_selector ()
       
   117 {
       
   118   if [ -d "$open_jdk_with_jpackage_jtreg_tests/$1" ]; then
       
   119     for java in $(find "$open_jdk_with_jpackage_jtreg_tests/$1" -maxdepth 1 -name '*.java'); do
       
   120       ! grep -q '@test' "$java" || echo "$1/$(basename "$java")"
       
   121     done
       
   122   else
       
   123     echo "$1"
       
   124   fi
       
   125 }
       
   126 
       
   127 
   115 
   128 # Path to JDK to be tested.
   116 # Path to JDK to be tested.
   129 test_jdk=
   117 test_jdk=
   130 
   118 
   131 # Path to local copy of open jdk repo with jpackage jtreg tests
   119 # Path to local copy of open jdk repo with jpackage jtreg tests
   143 keep_jtreg_cache=
   131 keep_jtreg_cache=
   144 
   132 
   145 # Mode in which to run jtreg tests
   133 # Mode in which to run jtreg tests
   146 mode=update
   134 mode=update
   147 
   135 
   148 # JVM extra arguments
   136 # jtreg extra arguments
   149 declare -a vm_args
   137 declare -a jtreg_args
   150 
   138 
   151 while getopts "vhdct:j:o:r:m:l:" argname; do
   139 # Run all tests
       
   140 run_all_tests=
       
   141 
       
   142 mapfile -t tests < <(find_all_packaging_tests)
       
   143 
       
   144 while getopts "vahdct:j:o:r:m:l:" argname; do
   152   case "$argname" in
   145   case "$argname" in
   153     v) verbose=yes;;
   146     v) verbose=yes;;
       
   147     a) run_all_tests=yes;;
   154     d) dry_run=yes;;
   148     d) dry_run=yes;;
   155     c) keep_jtreg_cache=yes;;
   149     c) keep_jtreg_cache=yes;;
   156     t) test_jdk="$OPTARG";;
   150     t) test_jdk="$OPTARG";;
   157     j) open_jdk_with_jpackage_jtreg_tests="$OPTARG";;
   151     j) open_jdk_with_jpackage_jtreg_tests="$OPTARG";;
   158     o) output_dir="$OPTARG";;
   152     o) output_dir="$OPTARG";;
   170 if [ -z "$open_jdk_with_jpackage_jtreg_tests" ]; then
   164 if [ -z "$open_jdk_with_jpackage_jtreg_tests" ]; then
   171   fatal_with_help_usage "Path to openjdk repo with jpackage jtreg tests not specified"
   165   fatal_with_help_usage "Path to openjdk repo with jpackage jtreg tests not specified"
   172 fi
   166 fi
   173 
   167 
   174 if [ "$mode" = "print-default-tests" ]; then
   168 if [ "$mode" = "print-default-tests" ]; then
   175   exec_command for t in ${tests[@]}";" do expand_test_selector '$t;' done
   169   exec_command for t in ${tests[@]}";" do echo '$t;' done
   176   exit
   170   exit
   177 fi
   171 fi
   178 
   172 
   179 if [ -z "$test_jdk" ]; then
   173 if [ -z "$test_jdk" ]; then
   180   fatal_with_help_usage Path to test JDK not specified
   174   fatal_with_help_usage Path to test JDK not specified
   190 
   184 
   191 if [ -n "$runtime_dir" ]; then
   185 if [ -n "$runtime_dir" ]; then
   192   if [ ! -d "$runtime_dir" ]; then
   186   if [ ! -d "$runtime_dir" ]; then
   193     fatal 'Value of `-r` option is set to non-existing directory'.
   187     fatal 'Value of `-r` option is set to non-existing directory'.
   194   fi
   188   fi
   195   vm_args+=("-Djpackage.test.runtime-image=$(to_native_path "$(cd "$runtime_dir" && pwd)")")
   189   jtreg_args+=("-Djpackage.test.runtime-image=$(to_native_path "$(cd "$runtime_dir" && pwd)")")
   196 fi
   190 fi
   197 
   191 
   198 if [ -n "$logfile" ]; then
   192 if [ -n "$logfile" ]; then
   199   if [ ! -d "$(dirname "$logfile")" ]; then
   193   if [ ! -d "$(dirname "$logfile")" ]; then
   200     fatal 'Value of `-l` option specified a file in non-existing directory'.
   194     fatal 'Value of `-l` option specified a file in non-existing directory'.
   201   fi
   195   fi
   202   logfile="$(cd "$(dirname "$logfile")" && pwd)/$(basename "$logfile")"
   196   logfile="$(cd "$(dirname "$logfile")" && pwd)/$(basename "$logfile")"
   203   vm_args+=("-Djpackage.test.logfile=$(to_native_path "$logfile")")
   197   jtreg_args+=("-Djpackage.test.logfile=$(to_native_path "$logfile")")
   204 fi
   198 fi
   205 
   199 
   206 if [ "$mode" = create ]; then
   200 if [ "$mode" = create ]; then
   207   true
   201   true
   208 elif [ "$mode" = update ]; then
   202 elif [ "$mode" = update ]; then
   209   true
   203   true
   210 elif [ "$mode" = verify-install ]; then
   204 elif [ "$mode" = verify-install ]; then
   211   vm_args+=("-Djpackage.test.action=$mode")
   205   jtreg_args+=("-Djpackage.test.action=$mode")
   212 elif [ "$mode" = verify-uninstall ]; then
   206 elif [ "$mode" = verify-uninstall ]; then
   213   vm_args+=("-Djpackage.test.action=$mode")
   207   jtreg_args+=("-Djpackage.test.action=$mode")
   214 else
   208 else
   215   fatal_with_help_usage 'Invalid value of -m option:' [$mode]
   209   fatal_with_help_usage 'Invalid value of -m option:' [$mode]
   216 fi
   210 fi
   217 
   211 
       
   212 if [ -z "$run_all_tests" ]; then
       
   213   jtreg_args+=(-Djpackage.test.SQETest=yes)
       
   214 fi
   218 
   215 
   219 # All remaining command line arguments are tests to run that should override the defaults
   216 # All remaining command line arguments are tests to run that should override the defaults
   220 [ $# -eq 0 ] || tests=($@)
   217 [ $# -eq 0 ] || tests=($@)
   221 
   218 
   222 
   219 
   250 run ()
   247 run ()
   251 {
   248 {
   252   local jtreg_cmdline=(\
   249   local jtreg_cmdline=(\
   253     $JAVA_HOME/bin/java -jar $(to_native_path "$jtreg_jar") \
   250     $JAVA_HOME/bin/java -jar $(to_native_path "$jtreg_jar") \
   254     "-Djpackage.test.output=$(to_native_path "$output_dir")" \
   251     "-Djpackage.test.output=$(to_native_path "$output_dir")" \
   255     "${vm_args[@]}" \
   252     "${jtreg_args[@]}" \
   256     -nr \
   253     -nr \
   257     "$jtreg_verbose" \
   254     "$jtreg_verbose" \
   258     -retain:all \
   255     -retain:all \
   259     -automatic \
   256     -automatic \
   260     -ignore:run \
   257     -ignore:run \