| 1 |
source include/full_result_diff.inc; |
| 2 |
|
| 3 |
--perl |
| 4 |
use strict; |
| 5 |
use lib "lib/"; |
| 6 |
use My::Exec; |
| 7 |
use My::Platform; |
| 8 |
|
| 9 |
## |
| 10 |
## run_java.inc - include script to run Java |
| 11 |
## |
| 12 |
## Parameters |
| 13 |
## $MTR_JAVA: Java which should be used |
| 14 |
## $JAVA_CLASS: Class file to run |
| 15 |
## $JAVA_CLASSPATH: Class path to use when running test |
| 16 |
## $JAVA_JVM_OPTS: Optional parameters to the JVM |
| 17 |
## |
| 18 |
## |
| 19 |
## Usage: |
| 20 |
## |
| 21 |
## --source suite/ndb/include/have_java.inc |
| 22 |
## |
| 23 |
## let JAVA_CLASSPATH=-classpath .:/some/path; |
| 24 |
## let JAVA_JVM_OPTS=-Dsome.setting=123 -ea -Xcheck:jni; |
| 25 |
## |
| 26 |
## let JAVA_CLASS=test/SomeTest.class; |
| 27 |
## --source suite/ndb/include/run_java.inc |
| 28 |
## |
| 29 |
## let JAVA_CLASS=test/SomeOtherTest.class; |
| 30 |
## --source suite/ndb/include/run_java.inc |
| 31 |
## |
| 32 |
|
| 33 |
# Check parameters |
| 34 |
my $java = $ENV{MTR_JAVA} || die "ERROR: Java not found, set MTR_JAVA"; |
| 35 |
my $java_classpath = $ENV{JAVA_CLASSPATH} || die "ERROR: Java classpath not set, please set JAVA_CLASSPATH"; |
| 36 |
my $java_class = $ENV{JAVA_CLASS} || die "ERROR: Java class to run not set, please set JAVA_CLASS"; |
| 37 |
my $java_args = $ENV{MTR_JAVA_ARGS} || ''; |
| 38 |
my $jvm_opts = $ENV{JAVA_JVM_OPTS} || ''; |
| 39 |
my $class_args = $ENV{JAVA_ARGUMENTS} || ''; |
| 40 |
my $vardir = $ENV{MYSQLTEST_VARDIR} || die "Need MYSQLTEST_VARDIR"; |
| 41 |
|
| 42 |
my $sep = ":"; |
| 43 |
if(IS_WINDOWS) |
| 44 |
{ |
| 45 |
$sep = ";"; |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
# The length of the variables that can be passed in environment variables are limited |
| 50 |
# (around 1024 characters) - this trick lets you plit the classpath in several variables to |
| 51 |
# be avle to pass longer classpaths |
| 52 |
for my $i (1..9) |
| 53 |
{ |
| 54 |
my $env = $ENV{"JAVA_CLASSPATH_$i"} || ''; |
| 55 |
if ($env) |
| 56 |
{ |
| 57 |
$java_classpath .= "$sep$env"; |
| 58 |
} |
| 59 |
my $jvm = $ENV{"JAVA_JVM_OPTS_$i"} || ''; |
| 60 |
if ($jvm) |
| 61 |
{ |
| 62 |
$jvm_opts .= " $jvm"; |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
# Tell the vm to put temporary files in $MYSQLTEST_VARDIR/tmp |
| 67 |
$jvm_opts .= " -Djava.io.tmpdir=$vardir/tmp"; |
| 68 |
|
| 69 |
if ($ENV{MTR_CLASSPATH}) |
| 70 |
{ |
| 71 |
$java_classpath .= "$sep$ENV{MTR_CLASSPATH}" |
| 72 |
} |
| 73 |
|
| 74 |
my $cmd = "\"$java\" $java_args $jvm_opts -classpath \"$java_classpath\" $java_class $class_args"; |
| 75 |
my $res = exec_print_on_error($cmd); |
| 76 |
|
| 77 |
my $F = IO::File->new("$vardir/tmp/run_java.result", "w") || die "Couldn't open varfile for writing"; |
| 78 |
if ($res) |
| 79 |
{ |
| 80 |
print $F "# Success\n"; |
| 81 |
} |
| 82 |
else |
| 83 |
{ |
| 84 |
# Rather than --die, we change the output |
| 85 |
# That will cause a result-content-mismatch giving more |
| 86 |
# visible context info |
| 87 |
print $F "--echo \'$cmd\' run failed;\n"; |
| 88 |
} |
| 89 |
$F->close(); |
| 90 |
|
| 91 |
EOF |
| 92 |
--source $MYSQLTEST_VARDIR/tmp/run_java.result |
| 93 |
--remove_file $MYSQLTEST_VARDIR/tmp/run_java.result |