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