| 1 |
--source include/not_embedded.inc |
| 2 |
|
| 3 |
--echo # |
| 4 |
--echo # MDEV-39126: Feedback plugin to use /etc/os-release |
| 5 |
--echo # |
| 6 |
|
| 7 |
if (`select count(*) = 0 from information_schema.plugins |
| 8 |
where plugin_name = 'feedback' and plugin_status='active'`) |
| 9 |
{ |
| 10 |
--skip Feedback plugin is not active |
| 11 |
} |
| 12 |
|
| 13 |
if (`select @@feedback_url = ""`) |
| 14 |
{ |
| 15 |
--skip Feedback plugin is not active |
| 16 |
} |
| 17 |
|
| 18 |
perl; |
| 19 |
if (! -f '/etc/os-release') { |
| 20 |
open(FILE, '>', $ENV{MYSQLTEST_VARDIR} . '/tmp/skip_mdev39126') or die; |
| 21 |
close(FILE); |
| 22 |
} else { |
| 23 |
open(my $fh, '<', '/etc/os-release') or die "Cannot open /etc/os-release: $!"; |
| 24 |
my $pretty_name = ''; |
| 25 |
while (my $line = <$fh>) { |
| 26 |
chomp $line; |
| 27 |
if ($line =~ /^PRETTY_NAME=(.+)$/) { |
| 28 |
$pretty_name = $1; |
| 29 |
$pretty_name =~ s/^"(.*)"$/$1/; |
| 30 |
last; |
| 31 |
} |
| 32 |
} |
| 33 |
close($fh); |
| 34 |
open(my $out, '>', $ENV{MYSQLTEST_VARDIR} . '/tmp/mdev39126_pretty_name') or die; |
| 35 |
print $out "os-release: $pretty_name"; |
| 36 |
close($out); |
| 37 |
} |
| 38 |
EOF |
| 39 |
|
| 40 |
# Skip if /etc/os-release was not found (written by perl block above) |
| 41 |
if (!`select LOAD_FILE('$MYSQLTEST_VARDIR/tmp/skip_mdev39126') IS NULL`) |
| 42 |
{ |
| 43 |
--skip /etc/os-release not available on this platform |
| 44 |
} |
| 45 |
|
| 46 |
let $plugin_val= `select variable_value from information_schema.feedback |
| 47 |
where variable_name = 'Uname_distribution'`; |
| 48 |
|
| 49 |
# Skip if plugin returned empty (e.g. FreeBSD with MTR_FEEDBACK_PLUGIN=0) |
| 50 |
if (`select '$plugin_val' = ''`) |
| 51 |
{ |
| 52 |
--skip Uname_distribution not available on this platform |
| 53 |
} |
| 54 |
|
| 55 |
let $expected_val= `select TRIM(LOAD_FILE('$MYSQLTEST_VARDIR/tmp/mdev39126_pretty_name'))`; |
| 56 |
|
| 57 |
if (`select '$plugin_val' != '$expected_val'`) |
| 58 |
{ |
| 59 |
--echo Mismatch! Plugin: '$plugin_val' |
| 60 |
--echo Expected: '$expected_val' |
| 61 |
--die Uname_distribution does not match /etc/os-release PRETTY_NAME |
| 62 |
} |
| 63 |
|
| 64 |
--echo Uname_distribution matches /etc/os-release |
| 65 |
|
| 66 |
--remove_file $MYSQLTEST_VARDIR/tmp/mdev39126_pretty_name |
| 67 |
|
| 68 |
--echo # End of 10.11 tests |