File: run_java.inc

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (93 lines) | stat: -rw-r--r-- 2,445 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
source include/full_result_diff.inc;

--perl
use strict;
use lib "lib/";
use My::Exec;
use My::Platform;

##
## run_java.inc - include script to run Java
##
## Parameters
##   $MTR_JAVA: Java which should be used
##   $JAVA_CLASS: Class file to run
##   $JAVA_CLASSPATH: Class path to use when running test
##   $JAVA_JVM_OPTS: Optional parameters to the JVM
##
##
## Usage:
##
## --source suite/ndb/include/have_java.inc
##
## let JAVA_CLASSPATH=-classpath .:/some/path;
## let JAVA_JVM_OPTS=-Dsome.setting=123 -ea -Xcheck:jni;
##
## let JAVA_CLASS=test/SomeTest.class;
## --source suite/ndb/include/run_java.inc
##
## let JAVA_CLASS=test/SomeOtherTest.class;
## --source suite/ndb/include/run_java.inc
##

# Check parameters
my $java = $ENV{MTR_JAVA} || die "ERROR: Java not found, set MTR_JAVA";
my $java_classpath = $ENV{JAVA_CLASSPATH} || die "ERROR: Java classpath not set, please set JAVA_CLASSPATH";
my $java_class = $ENV{JAVA_CLASS} || die "ERROR: Java class to run not set, please set JAVA_CLASS";
my $java_args = $ENV{MTR_JAVA_ARGS} || '';
my $jvm_opts = $ENV{JAVA_JVM_OPTS} || '';
my $class_args = $ENV{JAVA_ARGUMENTS} || '';
my $vardir = $ENV{MYSQLTEST_VARDIR} || die "Need MYSQLTEST_VARDIR";

my $sep = ":";
if(IS_WINDOWS)
{
  $sep = ";";
}


# The length of the variables that can be passed in environment variables are limited
# (around 1024 characters) - this trick lets you plit the classpath in several variables to
# be avle to pass longer classpaths
for my $i (1..9)
{
  my $env = $ENV{"JAVA_CLASSPATH_$i"} || '';
  if ($env)
  {
    $java_classpath .= "$sep$env";
  }
  my $jvm = $ENV{"JAVA_JVM_OPTS_$i"} || '';
  if ($jvm)
  {
    $jvm_opts .= " $jvm";
  }
}

# Tell the vm to put temporary files in $MYSQLTEST_VARDIR/tmp
$jvm_opts .= " -Djava.io.tmpdir=$vardir/tmp";

if ($ENV{MTR_CLASSPATH})
{
  $java_classpath .= "$sep$ENV{MTR_CLASSPATH}"
}

my $cmd = "\"$java\" $java_args $jvm_opts -classpath \"$java_classpath\" $java_class $class_args";
my $res = exec_print_on_error($cmd);

my $F = IO::File->new("$vardir/tmp/run_java.result", "w") || die "Couldn't open varfile for writing";
if ($res)
{
  print $F "# Success\n";
}
else
{
  # Rather than --die, we change the output
  # That will cause a result-content-mismatch giving more
  # visible context info
  print $F "--echo \'$cmd\' run failed;\n";
}
$F->close();

EOF
--source $MYSQLTEST_VARDIR/tmp/run_java.result
--remove_file $MYSQLTEST_VARDIR/tmp/run_java.result