2 # Copyright (c) 2008 MySQL AB, 2008 Sun Microsystems, Inc.
3 # Use is subject to license terms.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 of the License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
39 # Return a unique key that can be used to
40 # identify this test in a hash
50 $value =~ s/([|\\\x{0a}\x{0d}])/sprintf('\%02X', ord($1))/eg;
56 $value =~ s/\\([0-9a-fA-F]{2})/chr(hex($1))/ge;
62 my $result= $self->{result
};
63 croak
"'is_failed' can't be called until test has been run!"
64 unless defined $result;
66 return ($result eq 'MTR_RES_FAILED');
71 my ($test, $sock, $header)= @_;
73 # Give the test a unique key before serializing it
74 $test->{key
}= "$test" unless defined $test->{key
};
76 print $sock $header, "\n";
77 while ((my ($key, $value)) = each(%$test)) {
78 print $sock $key, "= ";
79 if (ref $value eq "ARRAY") {
80 print $sock "[", _encode
(join(", ", @
$value)), "]";
82 print $sock _encode
($value);
92 my $test= My
::Test
->new();
93 # Read the : separated key value pairs until a
94 # single newline on it's own line
96 while (defined($line= <$sock>)) {
97 # List is terminated by newline on it's own
99 # Correctly terminated reply
100 # print "Got newline\n";
105 # Split key/value on the first "="
106 my ($key, $value)= split("= ", $line, 2);
108 if ($value =~ /^\[(.*)\]/){
109 my @values= split(", ", _decode
($1));
110 push(@
{$test->{$key}}, @values);
114 $test->{$key}= _decode
($value);
124 print "[", $self->{name
}, "]", "\n";
125 while ((my ($key, $value)) = each(%$self)) {
126 print " ", $key, "= ";
127 if (ref $value eq "ARRAY") {
128 print "[", join(", ", @
$value), "]";