| 1 |
# The inc file ensures that the the test which it sources |
| 2 |
# runs on linux and that the programs 'mysqld', 'mysql' and |
| 3 |
# 'mysqlxtest' have the 'cap_sys_admin' capability granted. |
| 4 |
# It also checks whether a couple of network namespaces |
| 5 |
# named 'red' and 'blue' are configured on the machine. |
| 6 |
|
| 7 |
--perl |
| 8 |
use strict; |
| 9 |
use File::Basename; |
| 10 |
|
| 11 |
my $osname = $^O; |
| 12 |
my $mysqld_cap_set = 0; |
| 13 |
my $mysql_cap_set = 0; |
| 14 |
my $mysqlxtest_cap_set = 0; |
| 15 |
my $red_netns_set = 0; |
| 16 |
my $blue_netns_set = 0; |
| 17 |
my $platform_support = 0; |
| 18 |
my $exe_mysqlxtest; |
| 19 |
|
| 20 |
if( $osname eq 'linux') |
| 21 |
{ |
| 22 |
$platform_support = 1; |
| 23 |
|
| 24 |
`/sbin/getcap $ENV{'MYSQLD'} | grep -F -q cap_sys_admin`; |
| 25 |
$mysqld_cap_set = 1 if $? == 0; |
| 26 |
|
| 27 |
`/sbin/getcap $ENV{'EXE_MYSQL'} | grep -F -q cap_sys_admin`; |
| 28 |
$mysql_cap_set = 1 if $? == 0; |
| 29 |
|
| 30 |
($exe_mysqlxtest) = split (/\s/, $ENV{'MYSQLXTEST'}); |
| 31 |
`/sbin/getcap $exe_mysqlxtest | grep -F -q cap_sys_admin`; |
| 32 |
$mysqlxtest_cap_set = 1 if $? == 0; |
| 33 |
|
| 34 |
`/sbin/ip netns list | grep -F -q red`; |
| 35 |
$red_netns_set = 1 if $? == 0; |
| 36 |
|
| 37 |
`/sbin/ip netns list | grep -F -q blue`; |
| 38 |
$blue_netns_set = 1 if $? == 0; |
| 39 |
} |
| 40 |
|
| 41 |
open(FH, ">$ENV{MYSQL_TMP_DIR}/netns_vars.inc") or |
| 42 |
die("Unable to open file: $!\n"); |
| 43 |
print FH "let \$mysqld_cap_set= $mysqld_cap_set;\n"; |
| 44 |
print FH "let \$mysql_cap_set= $mysql_cap_set;\n"; |
| 45 |
print FH "let \$mysqlxtest_cap_set= $mysqlxtest_cap_set;\n"; |
| 46 |
print FH "let \$exe_mysqlxtest= $exe_mysqlxtest;\n"; |
| 47 |
print FH "let \$red_netns_set= $red_netns_set;\n"; |
| 48 |
print FH "let \$blue_netns_set= $blue_netns_set;\n"; |
| 49 |
close FH; |
| 50 |
EOF |
| 51 |
|
| 52 |
--source $MYSQL_TMP_DIR/netns_vars.inc |
| 53 |
--remove_file $MYSQL_TMP_DIR/netns_vars.inc |
| 54 |
|
| 55 |
if ($platform_support == 0) |
| 56 |
{ |
| 57 |
--skip Test is not supported on the platform |
| 58 |
} |
| 59 |
|
| 60 |
if ($mysqld_cap_set == 0) |
| 61 |
{ |
| 62 |
--skip Test requires that mysqld has cap_sys_admin |
| 63 |
} |
| 64 |
|
| 65 |
if ($mysql_cap_set == 0) |
| 66 |
{ |
| 67 |
--skip Test requires that mysql client has cap_sys_admin |
| 68 |
} |
| 69 |
|
| 70 |
if ($mysqlxtest_cap_set == 0) |
| 71 |
{ |
| 72 |
--skip Test requires that mysqlxtest client has cap_sys_admin |
| 73 |
} |
| 74 |
|
| 75 |
if ($red_netns_set == 0) |
| 76 |
{ |
| 77 |
--skip Test requires that network namespace 'red' is present |
| 78 |
} |
| 79 |
|
| 80 |
if ($blue_netns_set == 0) |
| 81 |
{ |
| 82 |
--skip Test requires that network namespace 'blue' is present |
| 83 |
} |