~drizzle-trunk/drizzle/development

0.67.738 by John H. Embretsen
New ErrorLogAlarm Reporter, and new status STATUS_ALARM (109).
1
# Copyright (c) 2008,2011 Oracle and/or its affiliates. All rights reserved.
0.67.305 by Bernt M. Johnsen
Copyright headres and license added
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
0.67.1 by Philip Stoev
initial import from internal tree
18
package GenTest::Constants;
19
20
require Exporter;
21
22
@ISA = qw(Exporter);
23
24
@EXPORT = qw(
25
	STATUS_OK
26
	STATUS_UNKNOWN_ERROR
0.67.9 by Philip Stoev
merge from internal tree
27
	STATUS_ANY_ERROR
28
0.67.1 by Philip Stoev
initial import from internal tree
29
	STATUS_EOF
30
	STATUS_ENVIRONMENT_FAILURE
0.67.521 by eve
provide textual exit codes for various scripts and not jus numbers
31
	STATUS_PERL_FAILURE
0.67.1 by Philip Stoev
initial import from internal tree
32
0.67.9 by Philip Stoev
merge from internal tree
33
	STATUS_CUSTOM_OUTCOME
34
0.67.1 by Philip Stoev
initial import from internal tree
35
	STATUS_WONT_HANDLE
0.67.9 by Philip Stoev
merge from internal tree
36
	STATUS_SKIP
0.67.1 by Philip Stoev
initial import from internal tree
37
38
	STATUS_SYNTAX_ERROR
39
	STATUS_SEMANTIC_ERROR
40
	STATUS_TRANSACTION_ERROR
41
42
	STATUS_TEST_FAILURE
43
44
	STATUS_ERROR_MISMATCH_SELECT
45
	STATUS_LENGTH_MISMATCH_SELECT
46
	STATUS_CONTENT_MISMATCH_SELECT
47
	STATUS_SELECT_REDUCTION
48
49
	STATUS_ERROR_MISMATCH
50
	STATUS_LENGTH_MISMATCH
51
	STATUS_CONTENT_MISMATCH
52
53
	STATUS_CRITICAL_FAILURE
54
	STATUS_SERVER_CRASHED
55
	STATUS_SERVER_KILLED
56
	STATUS_REPLICATION_FAILURE
57
	STATUS_BACKUP_FAILURE
58
	STATUS_RECOVERY_FAILURE
59
	STATUS_DATABASE_CORRUPTION
60
	STATUS_SERVER_DEADLOCKED
0.67.575 by eve
new --valgrind-xml option that reports Valgrind failures at the end of the test
61
	STATUS_VALGRIND_FAILURE
0.67.738 by John H. Embretsen
New ErrorLogAlarm Reporter, and new status STATUS_ALARM (109).
62
	STATUS_ALARM
0.67.1 by Philip Stoev
initial import from internal tree
63
64
	ORACLE_ISSUE_STILL_REPEATABLE
65
	ORACLE_ISSUE_NO_LONGER_REPEATABLE
0.67.9 by Philip Stoev
merge from internal tree
66
	ORACLE_ISSUE_STATUS_UNKNOWN
67
68
	DB_UNKNOWN
0.67.521 by eve
provide textual exit codes for various scripts and not jus numbers
69
	DB_DUMMY
0.67.9 by Philip Stoev
merge from internal tree
70
	DB_MYSQL
71
	DB_POSTGRES
72
	DB_JAVADB
0.67.10 by Philip Stoev
initial fixes for drizzle
73
	DB_DRIZZLE
0.73.1 by Bernt M. Johnsen
Changed STATUS_OK to 0. Changed default MTR_BUILD_THREAD to 930 for legacy reasons
74
0.67.521 by eve
provide textual exit codes for various scripts and not jus numbers
75
	DEFAULT_MTR_BUILD_THREAD
76
77
	constant2text
78
	status2text
0.67.1 by Philip Stoev
initial import from internal tree
79
);
80
0.67.521 by eve
provide textual exit codes for various scripts and not jus numbers
81
use strict;
82
0.73.1 by Bernt M. Johnsen
Changed STATUS_OK to 0. Changed default MTR_BUILD_THREAD to 930 for legacy reasons
83
use constant STATUS_OK				=> 0; ## Suitable for exit code
0.67.1 by Philip Stoev
initial import from internal tree
84
use constant STATUS_UNKNOWN_ERROR		=> 2;
85
0.67.9 by Philip Stoev
merge from internal tree
86
use constant STATUS_ANY_ERROR			=> 3;	# Used in util/simplify* to not differentiate based on error code
87
88
use constant STATUS_EOF				=> 4;	# A module requested that the test is terminated without failure
0.67.1 by Philip Stoev
initial import from internal tree
89
90
use constant STATUS_WONT_HANDLE			=> 5;	# A module, e.g. a Validator refuses to handle certain query
0.67.9 by Philip Stoev
merge from internal tree
91
use constant STATUS_SKIP			=> 6;	# A Filter specifies that the query should not be processed further
0.67.1 by Philip Stoev
initial import from internal tree
92
93
use constant STATUS_SYNTAX_ERROR		=> 21;
94
use constant STATUS_SEMANTIC_ERROR		=> 22;	# Errors caused by the randomness of the test, e.g. dropping a non-existing table
95
use constant STATUS_TRANSACTION_ERROR		=> 23;	# Lock wait timeouts, deadlocks, duplicate keys, etc.
96
0.67.9 by Philip Stoev
merge from internal tree
97
use constant STATUS_TEST_FAILURE		=> 24;	# Boundary between genuine errors and false positives due to randomness
0.67.1 by Philip Stoev
initial import from internal tree
98
99
use constant STATUS_SELECT_REDUCTION		=> 5;	# A coefficient to substract from error codes in order to make them non-fatal
100
101
use constant STATUS_ERROR_MISMATCH_SELECT	=> 26;	# A SELECT query caused those erros, however the test can continue
102
use constant STATUS_LENGTH_MISMATCH_SELECT	=> 27;	# since the database has not been modified
0.67.9 by Philip Stoev
merge from internal tree
103
use constant STATUS_CONTENT_MISMATCH_SELECT		=> 28;	# 
0.67.1 by Philip Stoev
initial import from internal tree
104
105
use constant STATUS_ERROR_MISMATCH		=> 31;	# A DML statement caused those errors, and the test can not continue
106
use constant STATUS_LENGTH_MISMATCH		=> 32;	# because the databases are in an unknown inconsistent state
107
use constant STATUS_CONTENT_MISMATCH		=> 33;	#
108
109
# Higher-priority errors
110
0.67.371 by Philip Stoev
better propragation of crashing error codes
111
use constant STATUS_CRITICAL_FAILURE		=> 100;	# Boundary between critical and non-critical errors
112
113
use constant STATUS_ENVIRONMENT_FAILURE		=> 110;	# A failure in the environment or the grammar file
0.67.521 by eve
provide textual exit codes for various scripts and not jus numbers
114
use constant STATUS_PERL_FAILURE		=> 255; # Perl died for some reason
0.67.371 by Philip Stoev
better propragation of crashing error codes
115
116
use constant STATUS_CUSTOM_OUTCOME		=> 36;	# Used for things such as signaling an EXPLAIN hit from the ExplainMatch Validator
0.67.9 by Philip Stoev
merge from internal tree
117
0.67.1 by Philip Stoev
initial import from internal tree
118
use constant STATUS_SERVER_CRASHED		=> 101;
119
120
use constant STATUS_SERVER_KILLED		=> 102;	# Willfull killing of the server, will not be reported as a crash
121
122
use constant STATUS_REPLICATION_FAILURE		=> 103;
123
use constant STATUS_RECOVERY_FAILURE		=> 104;
124
use constant STATUS_DATABASE_CORRUPTION		=> 105;
125
use constant STATUS_SERVER_DEADLOCKED		=> 106;
126
use constant STATUS_BACKUP_FAILURE		=> 107;
0.67.575 by eve
new --valgrind-xml option that reports Valgrind failures at the end of the test
127
use constant STATUS_VALGRIND_FAILURE		=> 108;
0.67.738 by John H. Embretsen
New ErrorLogAlarm Reporter, and new status STATUS_ALARM (109).
128
use constant STATUS_ALARM			=> 109; # A module, e.g. a Reporter, raises an alarm with critical severity
0.67.1 by Philip Stoev
initial import from internal tree
129
130
use constant ORACLE_ISSUE_STILL_REPEATABLE	=> 1;
131
use constant ORACLE_ISSUE_NO_LONGER_REPEATABLE	=> 0;
0.67.9 by Philip Stoev
merge from internal tree
132
use constant ORACLE_ISSUE_STATUS_UNKNOWN	=> 2;
133
0.67.10 by Philip Stoev
initial fixes for drizzle
134
use constant DB_UNKNOWN		=> 0;
0.67.49 by Bernt M. Johnsen
Refactored gendata.pl and gendata-old.pl to modules. The scripts are kept as wrappers
135
use constant DB_DUMMY        => 1;
136
use constant DB_MYSQL		=> 2;
137
use constant DB_POSTGRES	=> 3;
138
use constant DB_JAVADB		=> 4;
139
use constant DB_DRIZZLE		=> 5;
0.67.1 by Philip Stoev
initial import from internal tree
140
0.73.1 by Bernt M. Johnsen
Changed STATUS_OK to 0. Changed default MTR_BUILD_THREAD to 930 for legacy reasons
141
use constant DEFAULT_MTR_BUILD_THREAD => 930; ## Legacy...
142
0.67.521 by eve
provide textual exit codes for various scripts and not jus numbers
143
#
144
# The part below deals with constant value to constant name conversions
145
#
146
147
148
my %text2value;
149
150
sub BEGIN {
151
152
	# What we do here is open the Constants.pm file and parse the 'use constant' lines from it
153
	# The regexp is faily hairy in order to be more permissive.
154
155
	open (CONSTFILE, __FILE__) or die "Unable to read constants from ".__FILE__;
156
	read(CONSTFILE, my $constants_text, -s __FILE__);
157
	%text2value = $constants_text =~ m{^\s*use\s+constant\s+([A-Z_0-9]*?)\s*=>\s*(\d+)\s*;}mgio;
158
}
159
160
sub constant2text {
161
	my ($constant_value, $prefix) = @_;
162
163
	foreach my $constant_text (keys %text2value) {
164
		return $constant_text if $text2value{$constant_text} == $constant_value && $constant_text =~ m{^$prefix}si;
165
	}
166
	warn "Unable to obtain constant text for constant_value = $constant_value; prefix = $prefix";
167
	return undef;
168
}
169
170
sub status2text {
171
	return constant2text($_[0], 'STATUS_');
172
}
173
0.67.1 by Philip Stoev
initial import from internal tree
174
1;