Debian Codegraph @

mysql-test/suite/ndb/include/run_ndbapitest.inc

raw
1 # All test using run_ndbapitest.inc should automatically be
2 # skipped (by mtr_cases.pm) unless the NDB test programs are available
3 if (!$NDBT_BINARIES_AVAILABLE) {
4 die Should be autoskipped when NDB test binaries not available;
5 }
6
7 source include/full_result_diff.inc;
8
9 --perl
10 use strict;
11 use lib "lib/";
12 use My::Find;
13 use My::Exec;
14 use File::Basename;
15 use IO::File;
16
17 my $name = $ENV{NDBAPITEST_NAME} or die "Need NDBAPITEST_NAME";
18 my $defaults;
19 if (defined $ENV{NDBAPITEST_DEFAULTS}) {
20 $defaults = $ENV{NDBAPITEST_DEFAULTS};
21 }
22 else {
23 if (defined $ENV{PATH_CONFIG_FILE}) {
24 $defaults = "--defaults-file=".$ENV{PATH_CONFIG_FILE};
25 }
26 }
27 my $args = $ENV{NDBAPITEST_ARGS};
28 my $max_lines = $ENV{NDBAPITEST_MAXLINES} || 200;
29
30 my $mysql_test_dir = $ENV{MYSQL_TEST_DIR} or die "Need MYSQL_TEST_DIR";
31 my $basedir = dirname($mysql_test_dir);
32 my $bindir = $ENV{MTR_BINDIR} || $basedir; # Out of source set MTR_BINDIR
33 my $test_bin = my_find_bin($bindir,
34 ["runtime_output_directory", "bin"],
35 $name, NOT_REQUIRED);
36
37 my $vardir = $ENV{MYSQLTEST_VARDIR} or die "Need MYSQLTEST_VARDIR";
38 my $F = IO::File->new("$vardir/tmp/run_ndbapitest_result.inc", "w") or die;
39 unless($test_bin)
40 {
41 print $F "--let \$skip_test = 1\n";
42 print $F "--let \$skip_reason = skip Could not find $name\n";
43 exit(0);
44 }
45
46 if ($ENV{'MYSQL_TMP_DIR'})
47 {
48 $ENV{'NDBT_TMP_DIR'} = $ENV{'MYSQL_TMP_DIR'};
49 }
50
51 my $cmd = $test_bin;
52 $cmd .= " $defaults" if $defaults;
53 $cmd .= " $args" if $args;
54 my $res = exec_print_on_error($cmd, $max_lines);
55 if (!$res)
56 {
57 # No need to remove run_ndbapitest_result.inc when test case dies. Because,
58 # when it dies MTR fails and returns without executing check-testcase.test.
59
60 print $F "die Test program failed!;\n";
61 }
62 $F->close();
63
64 EOF
65
66 if ($NDBAPITEST_CLEANUP_QUERY != '')
67 {
68 eval $NDBAPITEST_CLEANUP_QUERY;
69 }
70
71 --source $MYSQLTEST_VARDIR/tmp/run_ndbapitest_result.inc
72 --remove_file $MYSQLTEST_VARDIR/tmp/run_ndbapitest_result.inc
73
74 # When we --source run_ndbapitest_result.inc, if test is skipped,
75 # test case will return immediately and will not execute other commands
76 # after --source. So, remove file will not get executed and check test
77 # case will fail. Hence, moving --skip outside run_ndbapitest_result.inc.
78
79 if ($skip_test)
80 {
81 --skip $skip_reason
82 }
83
84 --echo Test program success!
85