~ubuntu-branches/ubuntu/vivid/drizzle/vivid-proposed

« back to all changes in this revision

Viewing changes to tests/test_tools/randgen/lib/GenTest/Constants.pm

  • Committer: Package Import Robot
  • Author(s): Tobias Frost
  • Date: 2013-08-22 20:18:31 UTC
  • mto: (20.1.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20130822201831-gn3ozsh7o7wmc5tk
Tags: upstream-7.2.3
ImportĀ upstreamĀ versionĀ 7.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2008,2011 Oracle and/or its affiliates. All rights reserved.
 
2
# Use is subject to license terms.
 
3
#
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; version 2 of the License.
 
7
#
 
8
# This program is distributed in the hope that it will be useful, but
 
9
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
11
# General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
 
16
# USA
 
17
 
 
18
package GenTest::Constants;
 
19
 
 
20
use Carp;
 
21
 
 
22
require Exporter;
 
23
 
 
24
@ISA = qw(Exporter);
 
25
 
 
26
@EXPORT = qw(
 
27
        STATUS_OK
 
28
        STATUS_UNKNOWN_ERROR
 
29
        STATUS_ANY_ERROR
 
30
 
 
31
        STATUS_EOF
 
32
        STATUS_ENVIRONMENT_FAILURE
 
33
        STATUS_PERL_FAILURE
 
34
 
 
35
        STATUS_CUSTOM_OUTCOME
 
36
 
 
37
        STATUS_WONT_HANDLE
 
38
        STATUS_SKIP
 
39
 
 
40
        STATUS_SYNTAX_ERROR
 
41
        STATUS_SEMANTIC_ERROR
 
42
        STATUS_TRANSACTION_ERROR
 
43
 
 
44
        STATUS_TEST_FAILURE
 
45
 
 
46
        STATUS_ERROR_MISMATCH_SELECT
 
47
        STATUS_LENGTH_MISMATCH_SELECT
 
48
        STATUS_CONTENT_MISMATCH_SELECT
 
49
        STATUS_SELECT_REDUCTION
 
50
 
 
51
        STATUS_ERROR_MISMATCH
 
52
        STATUS_LENGTH_MISMATCH
 
53
        STATUS_CONTENT_MISMATCH
 
54
 
 
55
        STATUS_CRITICAL_FAILURE
 
56
        STATUS_SERVER_CRASHED
 
57
        STATUS_SERVER_KILLED
 
58
        STATUS_REPLICATION_FAILURE
 
59
        STATUS_BACKUP_FAILURE
 
60
        STATUS_RECOVERY_FAILURE
 
61
        STATUS_DATABASE_CORRUPTION
 
62
        STATUS_SERVER_DEADLOCKED
 
63
        STATUS_VALGRIND_FAILURE
 
64
        STATUS_ALARM
 
65
 
 
66
        ORACLE_ISSUE_STILL_REPEATABLE
 
67
        ORACLE_ISSUE_NO_LONGER_REPEATABLE
 
68
        ORACLE_ISSUE_STATUS_UNKNOWN
 
69
 
 
70
        DB_UNKNOWN
 
71
        DB_DUMMY
 
72
        DB_MYSQL
 
73
        DB_POSTGRES
 
74
        DB_JAVADB
 
75
        DB_DRIZZLE
 
76
 
 
77
        DEFAULT_MTR_BUILD_THREAD
 
78
 
 
79
        constant2text
 
80
        status2text
 
81
);
 
82
 
 
83
use strict;
 
84
 
 
85
use constant STATUS_OK                          => 0; ## Suitable for exit code
 
86
use constant STATUS_UNKNOWN_ERROR               => 2;
 
87
 
 
88
use constant STATUS_ANY_ERROR                   => 3;   # Used in util/simplify* to not differentiate based on error code
 
89
 
 
90
use constant STATUS_EOF                         => 4;   # A module requested that the test is terminated without failure
 
91
 
 
92
use constant STATUS_WONT_HANDLE                 => 5;   # A module, e.g. a Validator refuses to handle certain query
 
93
use constant STATUS_SKIP                        => 6;   # A Filter specifies that the query should not be processed further
 
94
 
 
95
use constant STATUS_SYNTAX_ERROR                => 21;
 
96
use constant STATUS_SEMANTIC_ERROR              => 22;  # Errors caused by the randomness of the test, e.g. dropping a non-existing table
 
97
use constant STATUS_TRANSACTION_ERROR           => 23;  # Lock wait timeouts, deadlocks, duplicate keys, etc.
 
98
 
 
99
use constant STATUS_TEST_FAILURE                => 24;  # Boundary between genuine errors and false positives due to randomness
 
100
 
 
101
use constant STATUS_SELECT_REDUCTION            => 5;   # A coefficient to substract from error codes in order to make them non-fatal
 
102
 
 
103
use constant STATUS_ERROR_MISMATCH_SELECT       => 26;  # A SELECT query caused those erros, however the test can continue
 
104
use constant STATUS_LENGTH_MISMATCH_SELECT      => 27;  # since the database has not been modified
 
105
use constant STATUS_CONTENT_MISMATCH_SELECT             => 28;  # 
 
106
 
 
107
use constant STATUS_ERROR_MISMATCH              => 31;  # A DML statement caused those errors, and the test can not continue
 
108
use constant STATUS_LENGTH_MISMATCH             => 32;  # because the databases are in an unknown inconsistent state
 
109
use constant STATUS_CONTENT_MISMATCH            => 33;  #
 
110
 
 
111
# Higher-priority errors
 
112
 
 
113
use constant STATUS_CRITICAL_FAILURE            => 100; # Boundary between critical and non-critical errors
 
114
 
 
115
use constant STATUS_ENVIRONMENT_FAILURE         => 110; # A failure in the environment or the grammar file
 
116
use constant STATUS_PERL_FAILURE                => 255; # Perl died for some reason
 
117
 
 
118
use constant STATUS_CUSTOM_OUTCOME              => 36;  # Used for things such as signaling an EXPLAIN hit from the ExplainMatch Validator
 
119
 
 
120
use constant STATUS_SERVER_CRASHED              => 101;
 
121
 
 
122
use constant STATUS_SERVER_KILLED               => 102; # Willfull killing of the server, will not be reported as a crash
 
123
 
 
124
use constant STATUS_REPLICATION_FAILURE         => 103;
 
125
use constant STATUS_RECOVERY_FAILURE            => 104;
 
126
use constant STATUS_DATABASE_CORRUPTION         => 105;
 
127
use constant STATUS_SERVER_DEADLOCKED           => 106;
 
128
use constant STATUS_BACKUP_FAILURE              => 107;
 
129
use constant STATUS_VALGRIND_FAILURE            => 108;
 
130
use constant STATUS_ALARM                       => 109; # A module, e.g. a Reporter, raises an alarm with critical severity
 
131
 
 
132
use constant ORACLE_ISSUE_STILL_REPEATABLE      => 2;
 
133
use constant ORACLE_ISSUE_NO_LONGER_REPEATABLE  => 3;
 
134
use constant ORACLE_ISSUE_STATUS_UNKNOWN        => 4;
 
135
 
 
136
use constant DB_UNKNOWN         => 0;
 
137
use constant DB_DUMMY        => 1;
 
138
use constant DB_MYSQL           => 2;
 
139
use constant DB_POSTGRES        => 3;
 
140
use constant DB_JAVADB          => 4;
 
141
use constant DB_DRIZZLE         => 5;
 
142
 
 
143
use constant DEFAULT_MTR_BUILD_THREAD => 930; ## Legacy...
 
144
 
 
145
#
 
146
# The part below deals with constant value to constant name conversions
 
147
#
 
148
 
 
149
 
 
150
my %text2value;
 
151
 
 
152
sub BEGIN {
 
153
 
 
154
        # What we do here is open the Constants.pm file and parse the 'use constant' lines from it
 
155
        # The regexp is faily hairy in order to be more permissive.
 
156
 
 
157
        open (CONSTFILE, __FILE__) or croak "Unable to read constants from ".__FILE__;
 
158
        read(CONSTFILE, my $constants_text, -s __FILE__);
 
159
        %text2value = $constants_text =~ m{^\s*use\s+constant\s+([A-Z_0-9]*?)\s*=>\s*(\d+)\s*;}mgio;
 
160
}
 
161
 
 
162
sub constant2text {
 
163
        my ($constant_value, $prefix) = @_;
 
164
 
 
165
        foreach my $constant_text (keys %text2value) {
 
166
                return $constant_text if $text2value{$constant_text} == $constant_value && $constant_text =~ m{^$prefix}si;
 
167
        }
 
168
        carp "Unable to obtain constant text for constant_value = $constant_value; prefix = $prefix";
 
169
        return undef;
 
170
}
 
171
 
 
172
sub status2text {
 
173
        return constant2text($_[0], 'STATUS_');
 
174
}
 
175
 
 
176
1;