2
# Originally created by John Embretsen, 2011-01-26.
4
# Checks for the existence of Perl modules DBI and DBD::mysql as seen from the
5
# perl installation used by "external" executable perl scripts, i.e. scripts
6
# that are executed as standalone scripts interpreted by the perl installation
7
# specified by the "shebang" line in the top of these scripts.
9
# If either module is not found, the test will be skipped.
11
# For use in tests that call perl scripts that require these modules.
13
# This file is intended to work on Unix. Windows may need different treatment.
15
# - "shebangs" are not relevant on Windows, but need to be handled here.
16
# - Perl scripts cannot be made executable on Windows, interpreter must be
19
# Note that if there are multiple perl installations and not all have the
20
# required modules, this check may fail even if the perl in path does have
21
# the modules available. This may happen if the perl specified by the script's
22
# shebang (e.g. #!/usr/bin/perl) does not have these modules, and script is
23
# called without specifying the perl interpreter. However, this will be
24
# a correct result in cases where a test calls a script with a similar shebang.
26
################################################################################
28
--source include/not_windows.inc
30
# We jump through some hoops since there is no direct way to check if an
31
# external command went OK or not from a mysql-test file:
33
# - In theory, we could do as simple as "exec perl -MDBI -MDBD::mysql -e 1",
34
# however we cannot check the result (exit code) from within a test script.
35
# Also, this may not yield the same result as other uses of perl due to the
36
# shebang issue mentioned above.
37
# - Instead we use a separate helper perl script that checks for the modules.
38
# - If the modules are found, the perl script leaves a file which sets a
39
# variable that can be read by this file.
40
# If the modules are not found, the perl script does not set this variable,
41
# but leaves an empty file instead.
43
# This is done because there is apparently no direct way to transfer
44
# information from perl to the test script itself.
50
# We do not use embedded perl in this script because that would not have yielded
51
# correct results for a situation where an external Perl script is called like
52
# "scriptname" instead of "perl scriptname" and the shebang in the script points
53
# to a specific perl that may be different than the perl in PATH.
55
# Instead, we call a separate helper script which checks for the modules in its
56
# own environment. We call it without "perl" in front.
58
--let $perlChecker= $MYSQLTEST_VARDIR/std_data/checkDBI_DBD-mysql.pl
59
--let $resultFile= $MYSQL_TMP_DIR/dbidbd-mysql.txt
61
# Make the script executable and execute it.
62
--chmod 0755 $perlChecker
65
# Source the resulting temporary file and look for a variable being set.
69
--skip Test needs Perl modules DBI and DBD::mysql
73
--remove_file $resultFile