8 ## run_java.inc - include script to run Java
11 ## $MTR_JAVA: Java which should be used
12 ## $JAVA_CLASS: Class file to run
13 ## $JAVA_CLASSPATH: Class path to use when running test
14 ## $JAVA_JVM_OPTS: Optional parameters to the JVM
19 ## --source suite/ndb/include/have_java.inc
21 ## let JAVA_CLASSPATH=-classpath .:/some/path;
22 ## let JAVA_JVM_OPTS=-Dsome.setting=123 -ea -Xcheck:jni;
24 ## let JAVA_CLASS=test/SomeTest.class;
25 ## --source suite/ndb/include/run_java.inc
27 ## let JAVA_CLASS=test/SomeOtherTest.class;
28 ## --source suite/ndb/include/run_java.inc
32 my $java = $ENV{MTR_JAVA} || die
"ERROR: Java not found, set MTR_JAVA";
33 my $java_classpath = $ENV{JAVA_CLASSPATH} || die
"ERROR: Java classpath not set, please set JAVA_CLASSPATH";
34 my $java_class = $ENV{JAVA_CLASS} || die
"ERROR: Java class to run not set, please set JAVA_CLASS";
35 my $java_args = $ENV{MTR_JAVA_ARGS} ||
'';
36 my $jvm_opts = $ENV{JAVA_JVM_OPTS} ||
'';
37 my $class_args = $ENV{JAVA_ARGUMENTS} ||
'';
46 # The length of the variables that can be passed in environment variables are limited
47 # (around 1024 characters) - this trick lets you plit the classpath in several variables to
48 # be avle to pass longer classpaths
51 my $env = $ENV{
"JAVA_CLASSPATH_$i"} ||
'';
54 $java_classpath .=
"$sep$env";
56 my $jvm = $ENV{
"JAVA_JVM_OPTS_$i"} ||
'';
63 if ($ENV{MTR_CLASSPATH})
65 $java_classpath .=
"$sep$ENV{MTR_CLASSPATH}"
68 my $cmd =
"$java $java_args $jvm_opts -classpath \"$java_classpath\" $java_class $class_args";
69 my $res = exec_print_on_error($cmd);
71 my $vardir = $ENV{MYSQLTEST_VARDIR} || die
"Need MYSQLTEST_VARDIR";
72 my $F = IO::File->new(
"$vardir/tmp/run_java.result",
"w") || die
"Couldn't open varfile for writing";
75 print $F
"# Success\n";
79 print $F
"die \'$cmd\' run failed;\n";
84 --source $MYSQLTEST_VARDIR/tmp/run_java.result