< prev index next >

test/jdk/tools/jpackage/run_tests.sh

Print this page


   1 #!/bin/bash
   2 
   3 #
   4 # Script to run jpackage tests.
   5 #
   6 
   7 
   8 # Fail fast
   9 set -e; set -o pipefail;
  10 
  11 

  12 workdir=/tmp/jpackage_jtreg_testing
  13 jtreg_jar=$workdir/jtreg/lib/jtreg.jar
  14 jpackage_test_selector=test/jdk/tools/jpackage
  15 
  16 
  17 find_packaging_tests ()
  18 {
  19   (cd "$open_jdk_with_jpackage_jtreg_tests" && \
  20     find "$jpackage_test_selector/$1" -type f -name '*.java' \
  21     | xargs grep -E -l '@key[[:space:]]+jpackagePlatformPackage')
  22 }
  23 
  24 
  25 find_all_packaging_tests ()
  26 {
  27   find_packaging_tests share
  28   case "$(uname -s)" in
  29     Darwin)
  30       find_packaging_tests macosx;;
  31     Linux)


 163   fatal_with_help_usage "Path to openjdk repo with jpackage jtreg tests not specified"
 164 fi
 165 
 166 if [ "$mode" = "print-default-tests" ]; then
 167   exec_command for t in ${tests[@]}";" do echo '$t;' done
 168   exit
 169 fi
 170 
 171 if [ -z "$test_jdk" ]; then
 172   fatal_with_help_usage Path to test JDK not specified
 173 fi
 174 
 175 if [ -z "$JAVA_HOME" ]; then
 176   echo JAVA_HOME environment variable not set, will use java from test JDK [$test_jdk] to run jtreg
 177   JAVA_HOME="$test_jdk"
 178 fi
 179 if [ ! -e "$JAVA_HOME/bin/java" ]; then
 180   fatal JAVA_HOME variable is set to [$JAVA_HOME] value, but $JAVA_HOME/bin/java not found.
 181 fi
 182 






 183 if [ -n "$runtime_dir" ]; then
 184   if [ ! -d "$runtime_dir" ]; then
 185     fatal 'Value of `-r` option is set to non-existing directory'.
 186   fi
 187   jtreg_args+=("-Djpackage.test.runtime-image=$(to_native_path "$(cd "$runtime_dir" && pwd)")")
 188 fi
 189 
 190 if [ -n "$logfile" ]; then
 191   if [ ! -d "$(dirname "$logfile")" ]; then
 192     fatal 'Value of `-l` option specified a file in non-existing directory'.
 193   fi
 194   logfile="$(cd "$(dirname "$logfile")" && pwd)/$(basename "$logfile")"
 195   jtreg_args+=("-Djpackage.test.logfile=$(to_native_path "$logfile")")
 196 fi
 197 
 198 if [ "$mode" = create ]; then
 199   true
 200 elif [ "$mode" = update ]; then
 201   true
 202 elif [ "$mode" = verify-install ]; then
 203   jtreg_args+=("-Djpackage.test.action=$mode")
 204 elif [ "$mode" = verify-uninstall ]; then
 205   jtreg_args+=("-Djpackage.test.action=$mode")
 206 else
 207   fatal_with_help_usage 'Invalid value of -m option:' [$mode]
 208 fi
 209 
 210 if [ -z "$run_all_tests" ]; then
 211   jtreg_args+=(-Djpackage.test.SQETest=yes)
 212 fi
 213 
 214 # All remaining command line arguments are tests to run that should override the defaults
 215 [ $# -eq 0 ] || tests=($@)
 216 
 217 
 218 installJtreg ()
 219 {
 220   # Install jtreg if missing

 221   if [ ! -f "$jtreg_jar" ]; then
 222     exec_command mkdir -p "$workdir"
 223     # TODO - restore code to download or copy jtreg.jar
 224     # to $workdir/jtreg/lib/jtreg.jar
 225     fatal "ERROR: All Tests Disabled until locating jtreg.jar implemented."




 226   fi








 227 }
 228 
 229 
 230 preRun ()
 231 {
 232   local xargs_args=(-t --no-run-if-empty rm)
 233   if [ -n "$dry_run" ]; then
 234     xargs_args=(--no-run-if-empty echo rm)
 235   fi
 236 
 237   if [ ! -d "$output_dir" ]; then
 238     exec_command mkdir -p "$output_dir"
 239   fi
 240   [ ! -d "$output_dir" ] || output_dir=$(cd "$output_dir" && pwd)
 241 
 242   # Clean output directory
 243   [ "$mode" != "create" ] || find $output_dir -maxdepth 1 -type f -name '*.exe' -or -name '*.msi' -or -name '*.rpm' -or -name '*.deb' | xargs "${xargs_args[@]}"
 244 }
 245 
 246 


   1 #!/bin/bash
   2 
   3 #
   4 # Script to run jpackage tests.
   5 #
   6 
   7 
   8 # Fail fast
   9 set -e; set -o pipefail;
  10 
  11 # $JTREG_BUNDLE_URL (Link can be obtained from https://openjdk.java.net/jtreg/ page)
  12 jtreg_bundle=$JTREG_BUNDLE_URL
  13 workdir=/tmp/jpackage_jtreg_testing
  14 jtreg_jar=$workdir/jtreg/lib/jtreg.jar
  15 jpackage_test_selector=test/jdk/tools/jpackage
  16 
  17 
  18 find_packaging_tests ()
  19 {
  20   (cd "$open_jdk_with_jpackage_jtreg_tests" && \
  21     find "$jpackage_test_selector/$1" -type f -name '*.java' \
  22     | xargs grep -E -l '@key[[:space:]]+jpackagePlatformPackage')
  23 }
  24 
  25 
  26 find_all_packaging_tests ()
  27 {
  28   find_packaging_tests share
  29   case "$(uname -s)" in
  30     Darwin)
  31       find_packaging_tests macosx;;
  32     Linux)


 164   fatal_with_help_usage "Path to openjdk repo with jpackage jtreg tests not specified"
 165 fi
 166 
 167 if [ "$mode" = "print-default-tests" ]; then
 168   exec_command for t in ${tests[@]}";" do echo '$t;' done
 169   exit
 170 fi
 171 
 172 if [ -z "$test_jdk" ]; then
 173   fatal_with_help_usage Path to test JDK not specified
 174 fi
 175 
 176 if [ -z "$JAVA_HOME" ]; then
 177   echo JAVA_HOME environment variable not set, will use java from test JDK [$test_jdk] to run jtreg
 178   JAVA_HOME="$test_jdk"
 179 fi
 180 if [ ! -e "$JAVA_HOME/bin/java" ]; then
 181   fatal JAVA_HOME variable is set to [$JAVA_HOME] value, but $JAVA_HOME/bin/java not found.
 182 fi
 183 
 184 if [ -z "$JTREG_HOME" ]; then
 185   if [ -z "$JTREG_BUNDLE_URL" ]; then
 186     fatal 'JTREG_HOME or JTREG_BUNDLE_URL environment variable is not set. Link to JTREG bundle can be found at https://openjdk.java.net/jtreg/'.
 187   fi
 188 fi
 189 
 190 if [ -n "$runtime_dir" ]; then
 191   if [ ! -d "$runtime_dir" ]; then
 192     fatal 'Value of `-r` option is set to non-existing directory'.
 193   fi
 194   jtreg_args+=("-Djpackage.test.runtime-image=$(to_native_path "$(cd "$runtime_dir" && pwd)")")
 195 fi
 196 
 197 if [ -n "$logfile" ]; then
 198   if [ ! -d "$(dirname "$logfile")" ]; then
 199     fatal 'Value of `-l` option specified a file in non-existing directory'.
 200   fi
 201   logfile="$(cd "$(dirname "$logfile")" && pwd)/$(basename "$logfile")"
 202   jtreg_args+=("-Djpackage.test.logfile=$(to_native_path "$logfile")")
 203 fi
 204 
 205 if [ "$mode" = create ]; then
 206   true
 207 elif [ "$mode" = update ]; then
 208   true
 209 elif [ "$mode" = verify-install ]; then
 210   jtreg_args+=("-Djpackage.test.action=$mode")
 211 elif [ "$mode" = verify-uninstall ]; then
 212   jtreg_args+=("-Djpackage.test.action=$mode")
 213 else
 214   fatal_with_help_usage 'Invalid value of -m option:' [$mode]
 215 fi
 216 
 217 if [ -z "$run_all_tests" ]; then
 218   jtreg_args+=(-Djpackage.test.SQETest=yes)
 219 fi
 220 
 221 # All remaining command line arguments are tests to run that should override the defaults
 222 [ $# -eq 0 ] || tests=($@)
 223 
 224 
 225 installJtreg ()
 226 {
 227   # Install jtreg if missing
 228   if [ -z "$JTREG_HOME" ]; then
 229     if [ ! -f "$jtreg_jar" ]; then
 230       exec_command mkdir -p "$workdir"
 231       if [[ ${jtreg_bundle: -7} == ".tar.gz" ]]; then
 232         exec_command "(" cd "$workdir" "&&" wget "$jtreg_bundle" "&&" tar -xzf "$(basename $jtreg_bundle)" ";" rm -f "$(basename $jtreg_bundle)" ")"
 233       else
 234         if [[ ${jtreg_bundle: -4} == ".zip" ]]; then
 235           exec_command "(" cd "$workdir" "&&" wget "$jtreg_bundle" "&&" unzip "$(basename $jtreg_bundle)" ";" rm -f "$(basename $jtreg_bundle)" ")"
 236         else
 237           fatal 'Unsupported extension of JREG bundle ['$JTREG_BUNDLE_URL']. Only *.zip or *.tar.gz is supported.'
 238         fi
 239       fi
 240     fi
 241   else
 242     # use jtreg provided via JTREG_HOME
 243     jtreg_jar=$JTREG_HOME/lib/jtreg.jar
 244   fi
 245 
 246   echo 'jtreg jar file: '$jtreg_jar
 247 }
 248 
 249 
 250 preRun ()
 251 {
 252   local xargs_args=(-t --no-run-if-empty rm)
 253   if [ -n "$dry_run" ]; then
 254     xargs_args=(--no-run-if-empty echo rm)
 255   fi
 256 
 257   if [ ! -d "$output_dir" ]; then
 258     exec_command mkdir -p "$output_dir"
 259   fi
 260   [ ! -d "$output_dir" ] || output_dir=$(cd "$output_dir" && pwd)
 261 
 262   # Clean output directory
 263   [ "$mode" != "create" ] || find $output_dir -maxdepth 1 -type f -name '*.exe' -or -name '*.msi' -or -name '*.rpm' -or -name '*.deb' | xargs "${xargs_args[@]}"
 264 }
 265 
 266 


< prev index next >