| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package LEOCHARRE::Test; |
|
2
|
2
|
|
|
2
|
|
3921
|
eval { use lib './lib'; }; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
9
|
|
|
3
|
2
|
|
|
2
|
|
194
|
use strict 'vars'; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
50
|
|
|
4
|
2
|
|
|
2
|
|
1784
|
use Test::Builder::Module; |
|
|
2
|
|
|
|
|
29531
|
|
|
|
2
|
|
|
|
|
78
|
|
|
5
|
2
|
|
|
2
|
|
140
|
use vars qw(@EXPORT @ISA $VERSION $PART_NUMBER $ABS_MYSQLD); |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
317
|
|
|
6
|
|
|
|
|
|
|
@EXPORT = qw(ok_part ok test_is_interactive ok_mysqld spacer mysqld_running mysqld_exists stderr_spacer); |
|
7
|
|
|
|
|
|
|
$VERSION = sprintf "%d.%02d", q$Revision: 1.11 $ =~ /(\d+)/g; |
|
8
|
|
|
|
|
|
|
@ISA = qw(Test::Builder::Module); |
|
9
|
2
|
|
|
2
|
|
13
|
use Carp; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1905
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$ABS_MYSQLD ||= '/etc/init.d/mysqld'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $CLASS = __PACKAGE__; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub ok ($;$) { |
|
16
|
4
|
|
|
4
|
1
|
42
|
$CLASS->builder->ok(@_); |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
sub ok_part { |
|
19
|
2
|
|
|
2
|
1
|
12
|
my $msg = shift; |
|
20
|
2
|
|
50
|
|
|
7
|
$msg ||=''; |
|
21
|
2
|
|
|
|
|
13
|
my @arg= ('PART', $PART_NUMBER++, uc($msg)); |
|
22
|
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
531
|
carp("\n\n\n======================================\n@arg, "); |
|
24
|
2
|
|
|
|
|
10
|
return 1; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
1
|
50
|
sub stderr_spacer { print STDERR "\n\n" } |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
1
|
50
|
|
1
|
1
|
15
|
sub test_is_interactive { -t STDIN && -t STDOUT } |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub ok_mysqld { |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
0
|
0
|
1
|
|
my $host = $_[0] ||= 'localhost'; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
0
|
0
|
|
|
|
if ( $host eq 'localhost' and mysqld_exists() ){ |
|
38
|
0
|
|
|
|
|
|
return _ok_mysqld_via_daemon(); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
return _ok_mysqld_via_dbi($host); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _ok_mysqld_via_daemon { |
|
46
|
0
|
|
|
0
|
|
|
ok( mysqld_running(), "mysqld running on host, $ABS_MYSQLD is running") |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _ok_mysqld_via_dbi { |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
0
|
0
|
|
|
my $host = $_[0] ||= 'localhost'; |
|
52
|
0
|
|
|
|
|
|
require DBI; |
|
53
|
0
|
|
|
|
|
|
require DBD::mysql; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# make a bogus connect on purpose |
|
56
|
0
|
|
|
|
|
|
my $user = 'a'.time().( int rand(20) ); |
|
57
|
0
|
|
|
|
|
|
my $pass = 'b'.time().( int rand(20) ); |
|
58
|
0
|
|
|
|
|
|
my $name = 'c'.time().( int rand(20) ); |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my $h = "DBI:mysql:database=$name;host=$host"; |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my $dbh = DBI->connect($h, $user, $pass,{ RaiseError => 0, PrintError => 0}); |
|
63
|
0
|
|
|
|
|
|
my $err = $DBI::errstr; |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $result; |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
if($err=~/Unknown MySQL server host|Can\'t connect to local MySQL server/i){ |
|
|
|
0
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
$result = 0;; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
elsif ( $err=~/Access denied for user/i ){ |
|
71
|
0
|
|
|
|
|
|
$result = 1; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
else { |
|
74
|
0
|
|
|
|
|
|
warn("dont know how to interpret this error: '$err'"); |
|
75
|
0
|
|
|
|
|
|
$result = 0; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
ok($result, "[$result] mysql host '$host' is up ? " . ($result ? 'yes' : "no. |
|
79
|
|
|
|
|
|
|
Check your /etc/init.d/mysqld status or equivalent.")); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub mysqld_exists { |
|
84
|
0
|
0
|
|
0
|
1
|
|
my $path = ( $_[0] ? $_[0] : $ABS_MYSQLD ) or confess('missing ABS_MYSQLD or arg'); |
|
|
|
0
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
|
-e $path ? $path : 0 |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub mysqld_running { |
|
89
|
0
|
0
|
|
0
|
1
|
|
my $path = ( $_[0] ? $_[0] : $ABS_MYSQLD ) or confess('missing ABS_MYSQLD or arg'); |
|
|
|
0
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
|
91
|
0
|
0
|
0
|
|
|
|
mysqld_exists($path) or warn("daemon does not exist on disk: $path\n") and return; |
|
92
|
0
|
|
|
|
|
|
my $r = `$path status`; |
|
93
|
0
|
0
|
|
|
|
|
$r=~/stopped/i and return 0; |
|
94
|
0
|
0
|
|
|
|
|
$r=~/running/i and return 1; |
|
95
|
0
|
|
|
|
|
|
warn("dunno $path status '$r'"); |
|
96
|
0
|
|
|
|
|
|
return; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |