1
# Copyright (C) 2008-2009 Sun Microsystems, Inc. All rights reserved.
2
# Use is subject to license terms.
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.
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.
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
18
package GenTest::Incident;
27
# Those names are taken from an XML specification for a
28
# test result XML report (see XML/Report.pm). Not all of them will be used.
29
# See commented tags / statements for omitted stuff.
32
use constant INCIDENT_ID => 0;
33
use constant INCIDENT_TIMESTAMP => 1;
34
use constant INCIDENT_RESULT => 2;
35
use constant INCIDENT_DESCRIPTION => 3;
36
use constant INCIDENT_SIGNATURE => 4;
37
use constant INCIDENT_COREFILE => 5;
38
use constant INCIDENT_ANALYSIS => 6;
39
use constant INCIDENT_CLASS => 7;
40
use constant INCIDENT_BUG_ID => 8;
41
use constant INCIDENT_DEBUGS => 9;
43
use constant INCIDENT_DEBUG_TYPE => 0;
44
use constant INCIDENT_DEBUG_TEXT => 1;
53
my $incident = $class->SUPER::new({
55
timestamp => INCIDENT_TIMESTAMP,
56
result => INCIDENT_RESULT,
57
description => INCIDENT_DESCRIPTION,
58
signature => INCIDENT_SIGNATURE,
59
corefile => INCIDENT_COREFILE,
60
analysis => INCIDENT_ANALYSIS,
61
class => INCIDENT_CLASS,
62
bug_id => INCIDENT_BUG_ID,
63
debugs => INCIDENT_DEBUGS
66
$incident->[INCIDENT_TIMESTAMP] = isoTimestamp() if not defined $incident->[INCIDENT_TIMESTAMP];
67
$incident->[INCIDENT_ID] = $id++ if not defined $incident->[INCIDENT_ID];
78
my $writer = XML::Writer->new(
79
OUTPUT => \$incident_xml,
80
DATA_MODE => 1, # this and DATA_INDENT to have line breaks and indentation after each element
81
DATA_INDENT => 2, # number of spaces used for indentation
85
$writer->startTag('incident', 'id' => $incident->[INCIDENT_ID]);
87
# this is a sequence in the XML schema, so the order of elements is significant.
88
$writer->dataElement('timestamp', $incident->[INCIDENT_TIMESTAMP]) if defined $incident->[INCIDENT_TIMESTAMP];
89
$writer->dataElement('result', $incident->[INCIDENT_RESULT]) if defined $incident->[INCIDENT_RESULT];
90
$writer->dataElement('description', $incident->[INCIDENT_DESCRIPTION]) if defined $incident->[INCIDENT_DESCRIPTION];
91
$writer->cdataElement('signature', $incident->[INCIDENT_SIGNATURE]) if defined $incident->[INCIDENT_SIGNATURE];
92
$writer->dataElement('corefile', $incident->[INCIDENT_COREFILE]) if defined $incident->[INCIDENT_COREFILE];
93
$writer->dataElement('analysis', $incident->[INCIDENT_ANALYSIS]) if defined $incident->[INCIDENT_ANALYSIS];
94
$writer->dataElement('class', $incident->[INCIDENT_CLASS]) if defined $incident->[INCIDENT_CLASS];
95
$writer->dataElement('bug_id', $incident->[INCIDENT_BUG_ID]) if defined $incident->[INCIDENT_BUG_ID];
97
if (defined $incident->[INCIDENT_DEBUGS]) {
98
foreach my $debug (@{$incident->[INCIDENT_DEBUGS]}) {
99
$writer->startTag('debug');
100
$writer->dataElement('type', $debug->[INCIDENT_DEBUG_TYPE]);
101
$writer->cdataElement('text', $debug->[INCIDENT_DEBUG_TEXT]);
102
$writer->endTag('debug');
106
#$writer->dataElement('host', $incident->[INCIDENT_HOST]) if defined $incident->[INCIDENT_HOST]; # hostname
107
#$writer->dataElement('build_id', $incident->[INCIDENT_BUILD_ID]) if defined $incident->[INCIDENT_BUILD_ID]; # int
108
#$writer->dataElement('binary', $incident->[INCIDENT_BINARY]) if defined $incident->[INCIDENT_BINARY]; # string
109
#$writer->dataElement('role', $incident->[INCIDENT_ROLE]) if defined $incident->[INCIDENT_ROLE]; # string
111
$writer->endTag('incident');
115
return $incident_xml;
119
$_[0]->[INCIDENT_ID] = $_[1];
1
# Copyright (C) 2008-2009 Sun Microsystems, Inc. All rights reserved.
2
# Use is subject to license terms.
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.
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.
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
18
package GenTest::Incident;
27
# Those names are taken from an XML specification for a
28
# test result XML report (see XML/Report.pm). Not all of them will be used.
29
# See commented tags / statements for omitted stuff.
32
use constant INCIDENT_ID => 0;
33
use constant INCIDENT_TIMESTAMP => 1;
34
use constant INCIDENT_RESULT => 2;
35
use constant INCIDENT_DESCRIPTION => 3;
36
use constant INCIDENT_SIGNATURE => 4;
37
use constant INCIDENT_COREFILE => 5;
38
use constant INCIDENT_ANALYSIS => 6;
39
use constant INCIDENT_CLASS => 7;
40
use constant INCIDENT_BUG_ID => 8;
41
use constant INCIDENT_DEBUGS => 9;
43
use constant INCIDENT_DEBUG_TYPE => 0;
44
use constant INCIDENT_DEBUG_TEXT => 1;
53
my $incident = $class->SUPER::new({
55
timestamp => INCIDENT_TIMESTAMP,
56
result => INCIDENT_RESULT,
57
description => INCIDENT_DESCRIPTION,
58
signature => INCIDENT_SIGNATURE,
59
corefile => INCIDENT_COREFILE,
60
analysis => INCIDENT_ANALYSIS,
61
class => INCIDENT_CLASS,
62
bug_id => INCIDENT_BUG_ID,
63
debugs => INCIDENT_DEBUGS
66
$incident->[INCIDENT_TIMESTAMP] = isoTimestamp() if not defined $incident->[INCIDENT_TIMESTAMP];
67
$incident->[INCIDENT_ID] = $id++ if not defined $incident->[INCIDENT_ID];
78
my $writer = XML::Writer->new(
79
OUTPUT => \$incident_xml,
80
DATA_MODE => 1, # this and DATA_INDENT to have line breaks and indentation after each element
81
DATA_INDENT => 2, # number of spaces used for indentation
85
$writer->startTag('incident', 'id' => $incident->[INCIDENT_ID]);
87
# this is a sequence in the XML schema, so the order of elements is significant.
88
$writer->dataElement('timestamp', $incident->[INCIDENT_TIMESTAMP]) if defined $incident->[INCIDENT_TIMESTAMP];
89
$writer->dataElement('result', $incident->[INCIDENT_RESULT]) if defined $incident->[INCIDENT_RESULT];
90
$writer->dataElement('description', $incident->[INCIDENT_DESCRIPTION]) if defined $incident->[INCIDENT_DESCRIPTION];
91
$writer->cdataElement('signature', $incident->[INCIDENT_SIGNATURE]) if defined $incident->[INCIDENT_SIGNATURE];
92
$writer->dataElement('corefile', $incident->[INCIDENT_COREFILE]) if defined $incident->[INCIDENT_COREFILE];
93
$writer->dataElement('analysis', $incident->[INCIDENT_ANALYSIS]) if defined $incident->[INCIDENT_ANALYSIS];
94
$writer->dataElement('class', $incident->[INCIDENT_CLASS]) if defined $incident->[INCIDENT_CLASS];
95
$writer->dataElement('bug_id', $incident->[INCIDENT_BUG_ID]) if defined $incident->[INCIDENT_BUG_ID];
97
if (defined $incident->[INCIDENT_DEBUGS]) {
98
foreach my $debug (@{$incident->[INCIDENT_DEBUGS]}) {
99
$writer->startTag('debug');
100
$writer->dataElement('type', $debug->[INCIDENT_DEBUG_TYPE]);
101
$writer->cdataElement('text', $debug->[INCIDENT_DEBUG_TEXT]);
102
$writer->endTag('debug');
106
#$writer->dataElement('host', $incident->[INCIDENT_HOST]) if defined $incident->[INCIDENT_HOST]; # hostname
107
#$writer->dataElement('build_id', $incident->[INCIDENT_BUILD_ID]) if defined $incident->[INCIDENT_BUILD_ID]; # int
108
#$writer->dataElement('binary', $incident->[INCIDENT_BINARY]) if defined $incident->[INCIDENT_BINARY]; # string
109
#$writer->dataElement('role', $incident->[INCIDENT_ROLE]) if defined $incident->[INCIDENT_ROLE]; # string
111
$writer->endTag('incident');
115
return $incident_xml;
119
$_[0]->[INCIDENT_ID] = $_[1];