forked from Kitware/CDash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
queryTests.php
228 lines (173 loc) · 6.09 KB
/
queryTests.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<?php
/*=========================================================================
Program: CDash - Cross-Platform Dashboard System
Module: $Id$
Language: PHP
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
// queryTests.php displays test results based on query parameters
//
$noforcelogin = 1;
include("cdash/config.php");
require_once("cdash/pdo.php");
include('login.php');
include_once("cdash/common.php");
include("cdash/version.php");
require_once("filterdataFunctions.php");
@$date = $_GET["date"];
if ($date != NULL)
{
$date = htmlspecialchars(pdo_real_escape_string($date));
}
@$projectname = $_GET["project"];
if ($projectname != NULL)
{
$projectname = htmlspecialchars(pdo_real_escape_string($projectname));
}
$start = microtime_float();
$db = pdo_connect("$CDASH_DB_HOST", "$CDASH_DB_LOGIN","$CDASH_DB_PASS");
pdo_select_db("$CDASH_DB_NAME",$db);
if ($projectname == '')
{
$project = pdo_single_row_query("SELECT * FROM project LIMIT 1");
}
else
{
$project = pdo_single_row_query("SELECT * FROM project WHERE name='$projectname'");
}
checkUserPolicy(@$_SESSION['cdash']['loginid'], $project['id']);
list ($previousdate, $currentstarttime, $nextdate) =
get_dates($date, $project['nightlytime']);
$xml = begin_XML_for_XSLT();
$xml .= "<title>CDash : ".$project['name']."</title>";
$xml .= get_cdash_dashboard_xml_by_name($project['name'], $date);
// Filters:
//
$filterdata = get_filterdata_from_request();
$filter_sql = $filterdata['sql'];
$limit_sql = '';
if ($filterdata['limit']>0)
{
$limit_sql = ' LIMIT '.$filterdata['limit'];
}
$xml .= $filterdata['xml'];
$xml .= "<menu>";
if ($date == '')
{
$back = "index.php?project=".urlencode($project['name']);
}
else
{
$back = "index.php?project=".urlencode($project['name'])."&date=".$date;
}
$xml .= add_XML_value("back",$back);
$limit_param = "&limit=".$filterdata['limit'];
$xml .= add_XML_value("previous",
"queryTests.php?project=".urlencode($project['name'])."&date=".$previousdate.$limit_param);
$xml .= add_XML_value("current",
"queryTests.php?project=".urlencode($project['name']).$limit_param);
if(has_next_date($date, $currentstarttime))
{
$xml .= add_XML_value("next",
"queryTests.php?project=".urlencode($project['name'])."&date=".$nextdate.$limit_param);
}
else
{
$xml .= add_XML_value("nonext","1");
}
$xml .= "</menu>";
$xml .= "<project>";
$xml .= add_XML_value("showtesttime", $project['showtesttime']);
$xml .= "</project>";
//get information about all the builds for the given date and project
$xml .= "<builds>\n";
$beginning_timestamp = $currentstarttime;
$end_timestamp = $currentstarttime + 3600*24;
$beginning_UTCDate = gmdate(FMT_DATETIME,$beginning_timestamp);
$end_UTCDate = gmdate(FMT_DATETIME,$end_timestamp);
// Add the date/time
$xml .= add_XML_value("projectid",$project['id']);
$xml .= add_XML_value("currentstarttime",$currentstarttime);
$xml .= add_XML_value("teststarttime",date(FMT_DATETIME,$beginning_timestamp));
$xml .= add_XML_value("testendtime",date(FMT_DATETIME,$end_timestamp));
$date_clause = '';
if (!$filterdata['hasdateclause'])
{
$date_clause = "AND b.starttime>='$beginning_UTCDate' AND b.starttime<'$end_UTCDate'";
}
$query = "SELECT
b.id, b.name, b.starttime, b.siteid,
build2test.testid AS testid, build2test.status, build2test.time, build2test.timestatus,
site.name AS sitename,
test.name AS testname, test.details
FROM build AS b
JOIN build2test ON (b.id = build2test.buildid)
JOIN site ON (b.siteid = site.id)
JOIN test ON (test.id = build2test.testid)
WHERE b.projectid = '" . $project['id'] . "' " .
$date_clause . " " .
$filter_sql .
"ORDER BY build2test.status, test.name".
$limit_sql;
$result = pdo_query($query);
while ($row = pdo_fetch_array($result))
{
$buildid = $row["id"];
$testid = $row["testid"];
$xml .= "<build>\n";
$xml .= add_XML_value("testname", $row["testname"]);
$xml .= add_XML_value("site", $row["sitename"]);
$xml .= add_XML_value("buildName", $row["name"]);
$xml .= add_XML_value("buildstarttime",
date(FMT_DATETIMETZ, strtotime($row["starttime"]." UTC")));
// use the default timezone, same as index.php
$xml .= add_XML_value("time", $row["time"]);
$xml .= add_XML_value("details", $row["details"]) . "\n";
$siteLink = "viewSite.php?siteid=".$row["siteid"];
$xml .= add_XML_value("siteLink", $siteLink);
$buildSummaryLink = "buildSummary.php?buildid=$buildid";
$xml .= add_XML_value("buildSummaryLink", $buildSummaryLink);
$testDetailsLink = "testDetails.php?test=$testid&build=$buildid";
$xml .= add_XML_value("testDetailsLink", $testDetailsLink);
switch($row["status"])
{
case "passed":
$xml .= add_XML_value("status", "Passed");
$xml .= add_XML_value("statusclass", "normal");
break;
case "failed":
$xml .= add_XML_value("status", "Failed");
$xml .= add_XML_value("statusclass", "error");
break;
case "notrun":
$xml .= add_XML_value("status", "Not Run");
$xml .= add_XML_value("statusclass", "warning");
break;
}
if($project['showtesttime'])
{
if($row["timestatus"] < $project['testtimemaxstatus'])
{
$xml .= add_XML_value("timestatus", "Passed");
$xml .= add_XML_value("timestatusclass", "normal");
}
else
{
$xml .= add_XML_value("timestatus", "Failed");
$xml .= add_XML_value("timestatusclass", "error");
}
}
$xml .= "</build>\n";
}
$xml .= "</builds>\n";
$end = microtime_float();
$xml .= "<generationtime>".round($end-$start,3)."</generationtime>";
$xml .= "</cdash>\n";
generate_XSLT($xml, "queryTests");
?>