1 |
786 |
skrzyp |
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####
|
2 |
|
|
// -------------------------------------------
|
3 |
|
|
// This file is part of the eCos host tools.
|
4 |
|
|
// Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
|
5 |
|
|
//
|
6 |
|
|
// This program is free software; you can redistribute it and/or modify
|
7 |
|
|
// it under the terms of the GNU General Public License as published by
|
8 |
|
|
// the Free Software Foundation; either version 2 or (at your option) any
|
9 |
|
|
// later version.
|
10 |
|
|
//
|
11 |
|
|
// This program is distributed in the hope that it will be useful, but
|
12 |
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
|
|
// General Public License for more details.
|
15 |
|
|
//
|
16 |
|
|
// You should have received a copy of the GNU General Public License
|
17 |
|
|
// along with this program; if not, write to the
|
18 |
|
|
// Free Software Foundation, Inc., 51 Franklin Street,
|
19 |
|
|
// Fifth Floor, Boston, MA 02110-1301, USA.
|
20 |
|
|
// -------------------------------------------
|
21 |
|
|
// ####ECOSHOSTGPLCOPYRIGHTEND####
|
22 |
|
|
// runtestsdlg.cpp :
|
23 |
|
|
//
|
24 |
|
|
//===========================================================================
|
25 |
|
|
//#####DESCRIPTIONBEGIN####
|
26 |
|
|
//
|
27 |
|
|
// Author(s): julians
|
28 |
|
|
// Contact(s): julians
|
29 |
|
|
// Date: 2000/09/29
|
30 |
|
|
// Version: $Id: runtestsdlg.cpp,v 1.14 2001/06/29 13:48:22 julians Exp $
|
31 |
|
|
// Purpose:
|
32 |
|
|
// Description: Implementation file for ecRunTestsDialog
|
33 |
|
|
// Requires:
|
34 |
|
|
// Provides:
|
35 |
|
|
// See also:
|
36 |
|
|
// Known bugs:
|
37 |
|
|
// Usage:
|
38 |
|
|
//
|
39 |
|
|
//####DESCRIPTIONEND####
|
40 |
|
|
//
|
41 |
|
|
//===========================================================================
|
42 |
|
|
|
43 |
|
|
#ifdef __GNUG__
|
44 |
|
|
#pragma implementation "runtestsdlg.cpp"
|
45 |
|
|
#endif
|
46 |
|
|
|
47 |
|
|
#include "ecpch.h"
|
48 |
|
|
|
49 |
|
|
#ifdef __BORLANDC__
|
50 |
|
|
#pragma hdrstop
|
51 |
|
|
#endif
|
52 |
|
|
|
53 |
|
|
#include "wx/notebook.h"
|
54 |
|
|
#include "wx/cshelp.h"
|
55 |
|
|
#include "wx/checklst.h"
|
56 |
|
|
#include "wx/listctrl.h"
|
57 |
|
|
#include "wx/tokenzr.h"
|
58 |
|
|
|
59 |
|
|
#include "TestResource.h"
|
60 |
|
|
#include "runtestsdlg.h"
|
61 |
|
|
#include "configtool.h"
|
62 |
|
|
#include "settingsdlg.h"
|
63 |
|
|
#include "eCosThreadUtils.h"
|
64 |
|
|
#include "eCosTrace.h"
|
65 |
|
|
|
66 |
|
|
void ecRunTestsTimer::Notify()
|
67 |
|
|
{
|
68 |
|
|
static bool s_inNotify = FALSE;
|
69 |
|
|
|
70 |
|
|
if (s_inNotify)
|
71 |
|
|
return;
|
72 |
|
|
|
73 |
|
|
s_inNotify = TRUE;
|
74 |
|
|
|
75 |
|
|
// On Windows, simply having the timer going will ping the message queue
|
76 |
|
|
// and cause idle processing to happen.
|
77 |
|
|
// On Unix, this doesn't happen so we have to do the processing explicitly.
|
78 |
|
|
#ifdef __WXMSW__
|
79 |
|
|
// Nothing to do
|
80 |
|
|
#else
|
81 |
|
|
if ( ecRunTestsDialog::m_runTestsDialog )
|
82 |
|
|
{
|
83 |
|
|
wxIdleEvent event;
|
84 |
|
|
ecRunTestsDialog::m_runTestsDialog->OnIdle(event);
|
85 |
|
|
}
|
86 |
|
|
#endif
|
87 |
|
|
|
88 |
|
|
s_inNotify = FALSE;
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
/*
|
92 |
|
|
* Run Tests dialog
|
93 |
|
|
*/
|
94 |
|
|
|
95 |
|
|
IMPLEMENT_CLASS(ecRunTestsDialog, wxDialog)
|
96 |
|
|
|
97 |
|
|
BEGIN_EVENT_TABLE(ecRunTestsDialog, wxDialog)
|
98 |
|
|
EVT_BUTTON(wxID_OK, ecRunTestsDialog::OnOK)
|
99 |
|
|
EVT_BUTTON(ecID_RUN_TESTS_RUN, ecRunTestsDialog::OnRun)
|
100 |
|
|
EVT_BUTTON(ecID_RUN_TESTS_PROPERTIES, ecRunTestsDialog::OnProperties)
|
101 |
|
|
//EVT_BUTTON(wxID_HELP, ecRunTestsDialog::OnHelp)
|
102 |
|
|
EVT_NOTEBOOK_PAGE_CHANGED(-1, ecRunTestsDialog::OnPageChange)
|
103 |
|
|
EVT_SIZE(ecRunTestsDialog::OnSize)
|
104 |
|
|
EVT_IDLE(ecRunTestsDialog::OnIdle)
|
105 |
|
|
EVT_CLOSE(ecRunTestsDialog::OnCloseWindow)
|
106 |
|
|
END_EVENT_TABLE()
|
107 |
|
|
|
108 |
|
|
#define PROPERTY_DIALOG_WIDTH 600
|
109 |
|
|
#define PROPERTY_DIALOG_HEIGHT 550
|
110 |
|
|
|
111 |
|
|
ecRunTestsDialog* ecRunTestsDialog::m_runTestsDialog = NULL;
|
112 |
|
|
|
113 |
|
|
// For 400x400 settings dialog, size your panels to about 375x325 in dialog editor
|
114 |
|
|
// (209 x 162 dialog units)
|
115 |
|
|
|
116 |
|
|
ecRunTestsDialog::ecRunTestsDialog(wxWindow* parent):
|
117 |
|
|
wxDialog(),
|
118 |
|
|
m_runStatus(ecStopped),
|
119 |
|
|
m_nNextToSubmit(-1),
|
120 |
|
|
m_pResource(NULL),
|
121 |
|
|
m_testsAreComplete(FALSE)
|
122 |
|
|
{
|
123 |
|
|
m_runTestsDialog = this;
|
124 |
|
|
|
125 |
|
|
SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
|
126 |
|
|
|
127 |
|
|
wxDialog::Create(parent, ecID_RUN_TESTS_DIALOG, _("Run Tests"), wxPoint(0, 0), wxSize(PROPERTY_DIALOG_WIDTH, PROPERTY_DIALOG_HEIGHT),
|
128 |
|
|
wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);
|
129 |
|
|
|
130 |
|
|
// Under MSW, we don't seem to be able to react to a click on the dialog background (no
|
131 |
|
|
// event is generated).
|
132 |
|
|
SetHelpText(_("Run tests from this dialog."));
|
133 |
|
|
|
134 |
|
|
wxScreenDC dc;
|
135 |
|
|
wxSize ppi = dc.GetPPI();
|
136 |
|
|
|
137 |
|
|
//double scaleFactor = ((double) charH) / 13.0;
|
138 |
|
|
double scaleFactor = ((double) ppi.y) / 96.0;
|
139 |
|
|
// Fudge the scale factor to make the dialog slightly smaller,
|
140 |
|
|
// otherwise it's a bit big. (We're assuming that most displays
|
141 |
|
|
// are 96 or 120 ppi).
|
142 |
|
|
if (ppi.y == 120)
|
143 |
|
|
scaleFactor = 1.14;
|
144 |
|
|
int dialogWidth = (int)(PROPERTY_DIALOG_WIDTH * scaleFactor);
|
145 |
|
|
int dialogHeight = (int)(PROPERTY_DIALOG_HEIGHT * scaleFactor);
|
146 |
|
|
SetSize(dialogWidth, dialogHeight);
|
147 |
|
|
|
148 |
|
|
m_notebook = new wxNotebook(this, ecID_RUN_TESTS_NOTEBOOK,
|
149 |
|
|
wxPoint(2, 2), wxSize(PROPERTY_DIALOG_WIDTH - 100, PROPERTY_DIALOG_HEIGHT - 200));
|
150 |
|
|
|
151 |
|
|
m_executables = new ecRunTestsExecutablesDialog(m_notebook);
|
152 |
|
|
m_notebook->AddPage(m_executables, wxT("Executables"));
|
153 |
|
|
m_executables->TransferDataToWindow();
|
154 |
|
|
|
155 |
|
|
m_output = new ecRunTestsOutputDialog(m_notebook);
|
156 |
|
|
m_notebook->AddPage(m_output, wxT("Output"));
|
157 |
|
|
m_output->TransferDataToWindow();
|
158 |
|
|
|
159 |
|
|
m_summary = new ecRunTestsSummaryDialog(m_notebook);
|
160 |
|
|
m_notebook->AddPage(m_summary, wxT("Summary"));
|
161 |
|
|
m_summary->TransferDataToWindow();
|
162 |
|
|
|
163 |
|
|
wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
|
164 |
|
|
|
165 |
|
|
item0->Add( m_notebook, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 );
|
166 |
|
|
|
167 |
|
|
wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
|
168 |
|
|
|
169 |
|
|
wxButton *runButton = new wxButton( this, ecID_RUN_TESTS_RUN, "&Run", wxDefaultPosition, wxDefaultSize, 0 );
|
170 |
|
|
item1->Add( runButton, 0, wxALIGN_CENTRE|wxALL, 5 );
|
171 |
|
|
|
172 |
|
|
wxButton *okButton = new wxButton( this, wxID_OK, "&Close", wxDefaultPosition, wxDefaultSize, 0 );
|
173 |
|
|
item1->Add( okButton, 0, wxALIGN_CENTRE|wxALL, 5 );
|
174 |
|
|
|
175 |
|
|
wxButton *propertiesButton = new wxButton( this, ecID_RUN_TESTS_PROPERTIES, "&Properties...", wxDefaultPosition, wxDefaultSize, 0 );
|
176 |
|
|
item1->Add( propertiesButton, 0, wxALIGN_CENTRE|wxALL, 5 );
|
177 |
|
|
|
178 |
|
|
/*
|
179 |
|
|
wxButton *helpButton = new wxButton( this, wxID_HELP, "&Help", wxDefaultPosition, wxDefaultSize, 0 );
|
180 |
|
|
item1->Add( helpButton, 0, wxALIGN_CENTRE|wxALL, 5 );
|
181 |
|
|
*/
|
182 |
|
|
|
183 |
|
|
#ifdef __WXGTK__
|
184 |
|
|
// Context-sensitive help button (question mark)
|
185 |
|
|
wxButton *contextButton = new wxContextHelpButton( this );
|
186 |
|
|
item1->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );
|
187 |
|
|
#endif
|
188 |
|
|
|
189 |
|
|
// Necessary to add a spacer or the button highlight interferes with the notebook under wxGTK
|
190 |
|
|
item0->Add( 4, 4, 0, wxALIGN_CENTRE|wxALL, 0 );
|
191 |
|
|
|
192 |
|
|
item0->Add( item1, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
|
193 |
|
|
|
194 |
|
|
this->SetAutoLayout( TRUE );
|
195 |
|
|
this->SetSizer( item0 );
|
196 |
|
|
|
197 |
|
|
okButton->SetDefault();
|
198 |
|
|
okButton->SetFocus();
|
199 |
|
|
|
200 |
|
|
Layout();
|
201 |
|
|
|
202 |
|
|
m_executables->Layout();
|
203 |
|
|
m_output->Layout();
|
204 |
|
|
m_summary->Layout();
|
205 |
|
|
|
206 |
|
|
okButton->SetHelpText(_("Closes the dialog."));
|
207 |
|
|
runButton->SetHelpText(_("Runs one or more tests selected in the Executables window."));
|
208 |
|
|
propertiesButton->SetHelpText(_("Shows timeout and connection properties."));
|
209 |
|
|
//helpButton->SetHelpText(_("Invokes help for the selected dialog."));
|
210 |
|
|
|
211 |
|
|
Centre(wxBOTH);
|
212 |
|
|
|
213 |
|
|
// TODO: Is this necessary?
|
214 |
|
|
#if 0
|
215 |
|
|
m_prop.Add(_T("Active timeout"), wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeout);
|
216 |
|
|
m_prop.Add(_T("Download timeout"), wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeout);
|
217 |
|
|
m_prop.Add(_T("Active timeout type"), wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeoutType);
|
218 |
|
|
m_prop.Add(_T("Download timeout type"), wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeoutType);
|
219 |
|
|
m_prop.Add(_T("Remote"), wxGetApp().GetSettings().GetRunTestsSettings().m_bRemote);
|
220 |
|
|
m_prop.Add(_T("Serial"), wxGetApp().GetSettings().GetRunTestsSettings().m_bSerial);
|
221 |
|
|
m_prop.Add(_T("Port"), wxGetApp().GetSettings().GetRunTestsSettings().m_strPort);
|
222 |
|
|
m_prop.Add(_T("Baud"), wxGetApp().GetSettings().GetRunTestsSettings().m_nBaud);
|
223 |
|
|
m_prop.Add(_T("Local TCPIP Host"), wxGetApp().GetSettings().GetRunTestsSettings().m_strLocalTCPIPHost);
|
224 |
|
|
m_prop.Add(_T("Local TCPIP Port"), wxGetApp().GetSettings().GetRunTestsSettings().m_nLocalTCPIPPort);
|
225 |
|
|
m_prop.Add(_T("Reset Type"), wxGetApp().GetSettings().GetRunTestsSettings().m_nReset);
|
226 |
|
|
m_prop.Add(_T("Reset String"), wxGetApp().GetSettings().GetRunTestsSettings().m_strReset);
|
227 |
|
|
m_prop.Add(_T("Resource Host"), wxGetApp().GetSettings().GetRunTestsSettings().m_strResourceHost);
|
228 |
|
|
m_prop.Add(_T("Resource Port"), wxGetApp().GetSettings().GetRunTestsSettings().m_nResourcePort);
|
229 |
|
|
m_prop.Add(_T("Remote Host"), wxGetApp().GetSettings().GetRunTestsSettings().m_strRemoteHost);
|
230 |
|
|
m_prop.Add(_T("Remote Port"), wxGetApp().GetSettings().GetRunTestsSettings().m_nRemotePort);
|
231 |
|
|
// TODO
|
232 |
|
|
//m_prop.Add(_T("Recurse"), executionpage.m_bRecurse);
|
233 |
|
|
m_prop.Add(_T("Farmed"), wxGetApp().GetSettings().GetRunTestsSettings().m_bFarmed);
|
234 |
|
|
// TODO
|
235 |
|
|
// m_prop.Add(_T("Extension"),executionpage.m_strExtension);
|
236 |
|
|
#endif
|
237 |
|
|
|
238 |
|
|
#ifdef _DEBUG
|
239 |
|
|
CeCosTrace::EnableTracing(CeCosTrace::TRACE_LEVEL_TRACE);
|
240 |
|
|
#endif
|
241 |
|
|
CeCosTrace::SetInteractive(TRUE);
|
242 |
|
|
CeCosTrace::SetOutput(TestOutputCallback, this);
|
243 |
|
|
CeCosTrace::SetError (TestOutputCallback, this);
|
244 |
|
|
|
245 |
|
|
m_timer.Start(200);
|
246 |
|
|
}
|
247 |
|
|
|
248 |
|
|
ecRunTestsDialog::~ecRunTestsDialog()
|
249 |
|
|
{
|
250 |
|
|
m_timer.Stop();
|
251 |
|
|
CeCosTrace::SetInteractive(FALSE);
|
252 |
|
|
m_runTestsDialog = NULL;
|
253 |
|
|
if (m_pResource)
|
254 |
|
|
{
|
255 |
|
|
delete m_pResource;
|
256 |
|
|
}
|
257 |
|
|
}
|
258 |
|
|
|
259 |
|
|
void ecRunTestsDialog::OnOK(wxCommandEvent& event)
|
260 |
|
|
{
|
261 |
|
|
if (ecRunning == m_runStatus)
|
262 |
|
|
{
|
263 |
|
|
wxMessageBox(_("Tests are running. Please press Stop before quitting this dialog."),
|
264 |
|
|
wxGetApp().GetSettings().GetAppName(), wxICON_INFORMATION|wxOK, this);
|
265 |
|
|
return;
|
266 |
|
|
}
|
267 |
|
|
|
268 |
|
|
event.Skip();
|
269 |
|
|
}
|
270 |
|
|
|
271 |
|
|
void ecRunTestsDialog::OnCloseWindow(wxCloseEvent& event)
|
272 |
|
|
{
|
273 |
|
|
if (ecRunning == m_runStatus)
|
274 |
|
|
{
|
275 |
|
|
wxMessageBox(_("Tests are running. Please press Stop before quitting this dialog."),
|
276 |
|
|
wxGetApp().GetSettings().GetAppName(), wxICON_INFORMATION|wxOK, this);
|
277 |
|
|
event.Veto();
|
278 |
|
|
return;
|
279 |
|
|
}
|
280 |
|
|
|
281 |
|
|
this->EndModal(wxID_CANCEL);
|
282 |
|
|
this->Destroy();
|
283 |
|
|
}
|
284 |
|
|
|
285 |
|
|
void ecRunTestsDialog::OnProperties(wxCommandEvent& event)
|
286 |
|
|
{
|
287 |
|
|
ecSettingsDialog dialog(this);
|
288 |
|
|
dialog.SetSelection(3);
|
289 |
|
|
dialog.ShowModal();
|
290 |
|
|
}
|
291 |
|
|
|
292 |
|
|
void ecRunTestsDialog::OnRun(wxCommandEvent& event)
|
293 |
|
|
{
|
294 |
|
|
if (ecRunning == m_runStatus)
|
295 |
|
|
{
|
296 |
|
|
m_output->AddLogMsg(_("Run cancelled"));
|
297 |
|
|
m_runStatus = ecStopping;
|
298 |
|
|
m_CS.Enter();
|
299 |
|
|
m_nNextToSubmit=0x7fffffff;
|
300 |
|
|
m_CS.Leave();
|
301 |
|
|
CeCosTest::CancelAllInstances();
|
302 |
|
|
}
|
303 |
|
|
else
|
304 |
|
|
{
|
305 |
|
|
if ( 0 == m_executables->SelectedTestCount())
|
306 |
|
|
{
|
307 |
|
|
wxMessageBox(_("No tests have been selected for execution."),
|
308 |
|
|
wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK, this);
|
309 |
|
|
return ;
|
310 |
|
|
}
|
311 |
|
|
else
|
312 |
|
|
{
|
313 |
|
|
m_ep = CeCosTest::ExecutionParameters(
|
314 |
|
|
CeCosTest::ExecutionParameters::RUN,
|
315 |
|
|
wxGetApp().GetSettings().GetRunTestsSettings().m_strTarget,
|
316 |
|
|
TIMEOUT_NONE==wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeoutType?0x7fffffff:TIMEOUT_AUTOMATIC==wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeoutType?900000:1000*wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeout,
|
317 |
|
|
TIMEOUT_NONE==wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeoutType?0x7fffffff:TIMEOUT_AUTOMATIC==wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeoutType?0:1000*wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeout);
|
318 |
|
|
|
319 |
|
|
if ( wxGetApp().GetSettings().GetRunTestsSettings().m_bRemote )
|
320 |
|
|
{
|
321 |
|
|
CTestResource::SetResourceServer(CeCosSocket::HostPort(wxGetApp().GetSettings().GetRunTestsSettings().m_strResourceHost, wxGetApp().GetSettings().GetRunTestsSettings().m_nResourcePort));
|
322 |
|
|
if (!CTestResource::Load())
|
323 |
|
|
{
|
324 |
|
|
wxMessageBox(_("Could not connect to resource server."),
|
325 |
|
|
wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK, this);
|
326 |
|
|
return;
|
327 |
|
|
}
|
328 |
|
|
}
|
329 |
|
|
else
|
330 |
|
|
{
|
331 |
|
|
wxString strPort;
|
332 |
|
|
if (wxGetApp().GetSettings().GetRunTestsSettings().m_bSerial)
|
333 |
|
|
strPort = wxGetApp().GetSettings().GetRunTestsSettings().m_strPort;
|
334 |
|
|
else
|
335 |
|
|
strPort = (const wxChar*) CeCosSocket::HostPort(wxGetApp().GetSettings().GetRunTestsSettings().m_strLocalTCPIPHost,wxGetApp().GetSettings().GetRunTestsSettings().m_nLocalTCPIPPort);
|
336 |
|
|
if(0==strPort.Length()){
|
337 |
|
|
m_pResource=new CTestResource(_T(""),m_ep.PlatformName());
|
338 |
|
|
} else
|
339 |
|
|
{
|
340 |
|
|
// Translate from e.g. COM2 to /dev/ttyS1 on Unix.
|
341 |
|
|
// Let's assume the Windows notation is the 'standard'.
|
342 |
|
|
strPort = TranslatePort(strPort);
|
343 |
|
|
int nBaud = wxGetApp().GetSettings().GetRunTestsSettings().m_bSerial ? wxGetApp().GetSettings().GetRunTestsSettings().m_nBaud:0;
|
344 |
|
|
if (RESET_X10 != wxGetApp().GetSettings().GetRunTestsSettings().m_nReset) {
|
345 |
|
|
m_pResource=new CTestResource(_T(""),m_ep.PlatformName(), strPort, nBaud);
|
346 |
|
|
} else {
|
347 |
|
|
m_pResource=new CTestResource(_T(""),m_ep.PlatformName(), strPort, nBaud, wxGetApp().GetSettings().GetRunTestsSettings().m_strReset);
|
348 |
|
|
}
|
349 |
|
|
}
|
350 |
|
|
}
|
351 |
|
|
m_runStatus = ecRunning;
|
352 |
|
|
m_testsAreComplete = FALSE;
|
353 |
|
|
|
354 |
|
|
wxButton* runButton = (wxButton*) FindWindow(ecID_RUN_TESTS_RUN);
|
355 |
|
|
runButton->SetLabel(_("&Stop"));
|
356 |
|
|
|
357 |
|
|
m_nNextToSubmit=0;
|
358 |
|
|
m_output->AddLogMsg(_("Run started"));
|
359 |
|
|
|
360 |
|
|
SubmitTests();
|
361 |
|
|
}
|
362 |
|
|
}
|
363 |
|
|
}
|
364 |
|
|
|
365 |
|
|
wxString ecRunTestsDialog::TranslatePort(const wxString& port) const
|
366 |
|
|
{
|
367 |
|
|
#ifdef __WXGTK__
|
368 |
|
|
wxString name(port.Left(3));
|
369 |
|
|
if (name.CmpNoCase(wxT("COM")) == 0)
|
370 |
|
|
{
|
371 |
|
|
wxString strNum(port.Mid(3));
|
372 |
|
|
if (strNum.IsEmpty())
|
373 |
|
|
return port;
|
374 |
|
|
int num = atoi(strNum);
|
375 |
|
|
wxString newPort;
|
376 |
|
|
newPort.Printf(wxT("/dev/ttyS%d"), num-1);
|
377 |
|
|
return newPort;
|
378 |
|
|
}
|
379 |
|
|
else
|
380 |
|
|
#endif
|
381 |
|
|
return port;
|
382 |
|
|
}
|
383 |
|
|
|
384 |
|
|
void ecRunTestsDialog::SubmitTests()
|
385 |
|
|
{
|
386 |
|
|
int iTest;
|
387 |
|
|
int nResources=wxGetApp().GetSettings().GetRunTestsSettings().m_bRemote ? wxMax(1,CTestResource::GetMatchCount (m_ep)):1;
|
388 |
|
|
if(nResources>CeCosTest::InstanceCount){
|
389 |
|
|
if (m_nNextToSubmit >= m_executables->SelectedTestCount()){
|
390 |
|
|
m_runStatus = ecStopped;
|
391 |
|
|
|
392 |
|
|
wxButton* runButton = (wxButton*) FindWindow(ecID_RUN_TESTS_RUN);
|
393 |
|
|
runButton->SetLabel(_("&Run"));
|
394 |
|
|
m_output->AddLogMsg(_("Run complete"));
|
395 |
|
|
|
396 |
|
|
delete m_pResource;
|
397 |
|
|
m_pResource=0;
|
398 |
|
|
return;
|
399 |
|
|
}
|
400 |
|
|
ecRunTestsInfo *pInfo=new ecRunTestsInfo;
|
401 |
|
|
pInfo->pTest=new CeCosTest(m_ep, m_executables->SelectedTest(m_nNextToSubmit++));
|
402 |
|
|
pInfo->pSheet=this;
|
403 |
|
|
if(wxGetApp().GetSettings().GetRunTestsSettings().m_bRemote){
|
404 |
|
|
CeCosThreadUtils::RunThread(RunRemoteFunc,pInfo, (CeCosThreadUtils::CallbackProc*) RunCallback,_T("RunRemoteFunc"));
|
405 |
|
|
} else {
|
406 |
|
|
bool bRun=false;
|
407 |
|
|
switch((ResetType)wxGetApp().GetSettings().GetRunTestsSettings().m_nReset){
|
408 |
|
|
case RESET_NONE:
|
409 |
|
|
bRun=true;
|
410 |
|
|
break;
|
411 |
|
|
case RESET_X10:
|
412 |
|
|
{
|
413 |
|
|
// Resetting can take a while, so spawn a thread
|
414 |
|
|
bRun=false;
|
415 |
|
|
ecResetThread* thread = new ecResetThread(pInfo);
|
416 |
|
|
if (thread->Create() != wxTHREAD_NO_ERROR)
|
417 |
|
|
{
|
418 |
|
|
// Thread will be deleted automatically when it has finished running
|
419 |
|
|
thread->Run();
|
420 |
|
|
}
|
421 |
|
|
else
|
422 |
|
|
delete thread;
|
423 |
|
|
|
424 |
|
|
break;
|
425 |
|
|
}
|
426 |
|
|
case RESET_MANUAL:
|
427 |
|
|
{
|
428 |
|
|
bRun=(wxOK == wxMessageBox(_("Press OK when target is reset - cancel to abort run"),_("Reset board"), wxOK|wxCANCEL));
|
429 |
|
|
if(!bRun)
|
430 |
|
|
{
|
431 |
|
|
m_nNextToSubmit = m_executables->SelectedTestCount();
|
432 |
|
|
RunCallback(pInfo);
|
433 |
|
|
}
|
434 |
|
|
break;
|
435 |
|
|
}
|
436 |
|
|
}
|
437 |
|
|
if(bRun){
|
438 |
|
|
if (1 < m_nNextToSubmit)
|
439 |
|
|
m_output->AddLogMsg(_("Run continuing"));
|
440 |
|
|
CeCosThreadUtils::RunThread(RunLocalFunc, pInfo, (CeCosThreadUtils::CallbackProc*) RunCallback,_T("RunLocalFunc"));
|
441 |
|
|
}
|
442 |
|
|
}
|
443 |
|
|
}
|
444 |
|
|
}
|
445 |
|
|
|
446 |
|
|
// thread execution starts here
|
447 |
|
|
void *ecResetThread::Entry()
|
448 |
|
|
{
|
449 |
|
|
wxString str;
|
450 |
|
|
String str1;
|
451 |
|
|
bool bOk=false;
|
452 |
|
|
CResetAttributes::ResetResult n=m_info->pSheet->m_pResource->Reset(str1);
|
453 |
|
|
str = str1.GetCString();
|
454 |
|
|
if(CResetAttributes::RESET_OK!=n){
|
455 |
|
|
str += wxT(">>> Could not reset target\n");
|
456 |
|
|
}
|
457 |
|
|
str += wxT('\n');
|
458 |
|
|
|
459 |
|
|
m_info->pSheet->OutputToBuffer(str);
|
460 |
|
|
|
461 |
|
|
if(bOk){
|
462 |
|
|
// we're already in a thread, so we can call the function directly
|
463 |
|
|
m_info->pTest->RunLocal();
|
464 |
|
|
}
|
465 |
|
|
ecRunTestsDialog::RunCallback(m_info);
|
466 |
|
|
|
467 |
|
|
return NULL;
|
468 |
|
|
}
|
469 |
|
|
|
470 |
|
|
// called when the thread exits - whether it terminates normally or is
|
471 |
|
|
// stopped with Delete() (but not when it is Kill()ed!)
|
472 |
|
|
void ecResetThread::OnExit()
|
473 |
|
|
{
|
474 |
|
|
}
|
475 |
|
|
|
476 |
|
|
void CALLBACK ecRunTestsDialog::RunLocalFunc(void *pParam)
|
477 |
|
|
{
|
478 |
|
|
((ecRunTestsInfo *)pParam)->pTest->RunLocal();
|
479 |
|
|
}
|
480 |
|
|
|
481 |
|
|
void CALLBACK ecRunTestsDialog::RunRemoteFunc(void *pParam)
|
482 |
|
|
{
|
483 |
|
|
((ecRunTestsInfo *)pParam)->pTest->RunRemote(NULL);
|
484 |
|
|
}
|
485 |
|
|
|
486 |
|
|
void ecRunTestsDialog::RunCallback(void *pParam)
|
487 |
|
|
{
|
488 |
|
|
ecRunTestsInfo *pInfo=(ecRunTestsInfo *)pParam;
|
489 |
|
|
ecRunTestsDialog *pSheet=pInfo->pSheet;
|
490 |
|
|
if (m_runTestsDialog) // Will be NULL if dialog has been closed & deleted
|
491 |
|
|
{
|
492 |
|
|
CeCosTest *pTest=pInfo->pTest;
|
493 |
|
|
|
494 |
|
|
pInfo->pSheet->m_CS.Enter();
|
495 |
|
|
|
496 |
|
|
pSheet->m_summary->AddResult(pTest);
|
497 |
|
|
delete pTest;
|
498 |
|
|
|
499 |
|
|
// OnIdle will check this variable and reset the status and button label
|
500 |
|
|
pSheet->m_testsAreComplete = TRUE;
|
501 |
|
|
|
502 |
|
|
pInfo->pSheet->m_CS.Leave();
|
503 |
|
|
}
|
504 |
|
|
delete pInfo;
|
505 |
|
|
}
|
506 |
|
|
|
507 |
|
|
void ecRunTestsDialog::OnIdle(wxIdleEvent& event)
|
508 |
|
|
{
|
509 |
|
|
FlushBuffer();
|
510 |
|
|
|
511 |
|
|
if (m_testsAreComplete)
|
512 |
|
|
{
|
513 |
|
|
m_testsAreComplete = FALSE;
|
514 |
|
|
SubmitTests();
|
515 |
|
|
}
|
516 |
|
|
|
517 |
|
|
event.Skip();
|
518 |
|
|
}
|
519 |
|
|
|
520 |
|
|
void CALLBACK ecRunTestsDialog::TestOutputCallback(void *pParam,LPCTSTR psz)
|
521 |
|
|
{
|
522 |
|
|
ecRunTestsDialog* pWnd = (ecRunTestsDialog*)pParam;
|
523 |
|
|
if (ecRunTestsDialog::m_runTestsDialog)
|
524 |
|
|
{
|
525 |
|
|
// FIXME: test output should not contain CR characters on non-Windows
|
526 |
|
|
// platforms so need to find the root of this problem
|
527 |
|
|
#ifndef __WXMSW__
|
528 |
|
|
wxString output(psz);
|
529 |
|
|
output.Replace(wxT("\r"), wxEmptyString); // remove CR characters
|
530 |
|
|
pWnd->OutputToBuffer(output);
|
531 |
|
|
#else
|
532 |
|
|
// FIXME ends
|
533 |
|
|
pWnd->OutputToBuffer(psz);
|
534 |
|
|
#endif
|
535 |
|
|
}
|
536 |
|
|
}
|
537 |
|
|
|
538 |
|
|
// Write to the output buffer for OnIdle to pick up
|
539 |
|
|
void ecRunTestsDialog::OutputToBuffer(const wxString& str)
|
540 |
|
|
{
|
541 |
|
|
wxCriticalSection ct;
|
542 |
|
|
ct.Enter();
|
543 |
|
|
|
544 |
|
|
if (m_outputBufferPresent)
|
545 |
|
|
m_outputBuffer += str;
|
546 |
|
|
else
|
547 |
|
|
m_outputBuffer = str;
|
548 |
|
|
m_outputBufferPresent = TRUE;
|
549 |
|
|
|
550 |
|
|
ct.Leave();
|
551 |
|
|
}
|
552 |
|
|
|
553 |
|
|
// Write any remaining text
|
554 |
|
|
void ecRunTestsDialog::FlushBuffer()
|
555 |
|
|
{
|
556 |
|
|
if (m_outputBufferPresent)
|
557 |
|
|
{
|
558 |
|
|
m_output->AddText(m_outputBuffer);
|
559 |
|
|
m_outputBuffer = wxEmptyString;
|
560 |
|
|
m_outputBufferPresent = FALSE;
|
561 |
|
|
}
|
562 |
|
|
}
|
563 |
|
|
|
564 |
|
|
#if 0
|
565 |
|
|
void ecRunTestsDialog::OnHelp(wxCommandEvent& event)
|
566 |
|
|
{
|
567 |
|
|
int sel = m_notebook->GetSelection();
|
568 |
|
|
|
569 |
|
|
wxASSERT_MSG( (sel != -1), wxT("A notebook tab should always be selected."));
|
570 |
|
|
|
571 |
|
|
wxWindow* page = (wxWindow*) m_notebook->GetPage(sel);
|
572 |
|
|
|
573 |
|
|
wxString helpTopic;
|
574 |
|
|
if (page == m_displayOptions)
|
575 |
|
|
{
|
576 |
|
|
helpTopic = wxT("Display options dialog");
|
577 |
|
|
}
|
578 |
|
|
|
579 |
|
|
if (!helpTopic.IsEmpty())
|
580 |
|
|
{
|
581 |
|
|
wxGetApp().GetHelpController().KeywordSearch(helpTopic);
|
582 |
|
|
}
|
583 |
|
|
}
|
584 |
|
|
#endif
|
585 |
|
|
|
586 |
|
|
// This sets the text for the selected page, but doesn't help
|
587 |
|
|
// when trying to click on a tab: we would expect the appropriate help
|
588 |
|
|
// for that tab. We would need to look at the tabs to do this, from within OnContextHelp -
|
589 |
|
|
// probably not worth it.
|
590 |
|
|
void ecRunTestsDialog::OnPageChange(wxNotebookEvent& event)
|
591 |
|
|
{
|
592 |
|
|
event.Skip();
|
593 |
|
|
#if 0
|
594 |
|
|
int sel = m_notebook->GetSelection();
|
595 |
|
|
if (sel < 0)
|
596 |
|
|
return;
|
597 |
|
|
|
598 |
|
|
wxWindow* page = m_notebook->GetPage(sel);
|
599 |
|
|
if (page)
|
600 |
|
|
{
|
601 |
|
|
wxString helpText;
|
602 |
|
|
|
603 |
|
|
if (page == m_displayOptions)
|
604 |
|
|
helpText = _("The display options dialog allows you to change display-related options.");
|
605 |
|
|
else if (page == m_viewerOptions)
|
606 |
|
|
helpText = _("The viewer options dialog allows you to configure viewers.");
|
607 |
|
|
else if (page == m_pathOptions)
|
608 |
|
|
helpText = _("The path options dialog allows you to change tool paths.");
|
609 |
|
|
else if (page == m_conflictResolutionOptions)
|
610 |
|
|
helpText = _("The conflict resolution options dialog allows you to change options related to conflict resolution.");
|
611 |
|
|
m_notebook->SetHelpText(helpText);
|
612 |
|
|
}
|
613 |
|
|
#endif
|
614 |
|
|
}
|
615 |
|
|
|
616 |
|
|
bool ecRunTestsDialog::TransferDataToWindow()
|
617 |
|
|
{
|
618 |
|
|
// In this case there is no data to be transferred
|
619 |
|
|
m_executables->TransferDataToWindow();
|
620 |
|
|
m_output->TransferDataToWindow();
|
621 |
|
|
m_summary->TransferDataToWindow();
|
622 |
|
|
return TRUE;
|
623 |
|
|
}
|
624 |
|
|
|
625 |
|
|
bool ecRunTestsDialog::TransferDataFromWindow()
|
626 |
|
|
{
|
627 |
|
|
// In this case there is no data to be transferred
|
628 |
|
|
m_executables->TransferDataFromWindow();
|
629 |
|
|
m_output->TransferDataFromWindow();
|
630 |
|
|
m_summary->TransferDataFromWindow();
|
631 |
|
|
return TRUE;
|
632 |
|
|
}
|
633 |
|
|
|
634 |
|
|
void ecRunTestsDialog::OnSize(wxSizeEvent& event)
|
635 |
|
|
{
|
636 |
|
|
event.Skip();
|
637 |
|
|
|
638 |
|
|
wxRefreshControls(this);
|
639 |
|
|
}
|
640 |
|
|
|
641 |
|
|
// Add the test to the dialog
|
642 |
|
|
void ecRunTestsDialog::Populate(const wxString& test, bool select)
|
643 |
|
|
{
|
644 |
|
|
wxCheckListBox* checkListBox = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);
|
645 |
|
|
|
646 |
|
|
wxASSERT( checkListBox );
|
647 |
|
|
|
648 |
|
|
checkListBox->Append(test);
|
649 |
|
|
if (select)
|
650 |
|
|
checkListBox->Check(checkListBox->GetCount() - 1, TRUE);
|
651 |
|
|
}
|
652 |
|
|
|
653 |
|
|
|
654 |
|
|
/* Executables dialog
|
655 |
|
|
*/
|
656 |
|
|
|
657 |
|
|
IMPLEMENT_CLASS(ecRunTestsExecutablesDialog, wxPanel)
|
658 |
|
|
|
659 |
|
|
BEGIN_EVENT_TABLE(ecRunTestsExecutablesDialog, wxPanel)
|
660 |
|
|
EVT_BUTTON(ecID_RUN_TESTS_CHECK_ALL, ecRunTestsExecutablesDialog::OnCheckAll)
|
661 |
|
|
EVT_BUTTON(ecID_RUN_TESTS_UNCHECK_ALL, ecRunTestsExecutablesDialog::OnUncheckAll)
|
662 |
|
|
EVT_BUTTON(ecID_RUN_TESTS_ADD, ecRunTestsExecutablesDialog::OnAdd)
|
663 |
|
|
EVT_BUTTON(ecID_RUN_TESTS_ADD_FOLDER, ecRunTestsExecutablesDialog::OnAddFromFolder)
|
664 |
|
|
EVT_BUTTON(ecID_RUN_TESTS_REMOVE, ecRunTestsExecutablesDialog::OnRemove)
|
665 |
|
|
|
666 |
|
|
EVT_UPDATE_UI(ecID_RUN_TESTS_CHECK_ALL, ecRunTestsExecutablesDialog::OnUpdateCheckAll)
|
667 |
|
|
EVT_UPDATE_UI(ecID_RUN_TESTS_UNCHECK_ALL, ecRunTestsExecutablesDialog::OnUpdateUncheckAll)
|
668 |
|
|
|
669 |
|
|
END_EVENT_TABLE()
|
670 |
|
|
|
671 |
|
|
ecRunTestsExecutablesDialog::ecRunTestsExecutablesDialog(wxWindow* parent):
|
672 |
|
|
wxPanel(parent, ecID_RUN_TESTS_EXECUTABLES)
|
673 |
|
|
{
|
674 |
|
|
CreateControls(this);
|
675 |
|
|
|
676 |
|
|
SetHelpText(_("The executables dialog allows you to select tests to be run."));
|
677 |
|
|
}
|
678 |
|
|
|
679 |
|
|
void ecRunTestsExecutablesDialog::CreateControls( wxPanel *parent)
|
680 |
|
|
{
|
681 |
|
|
// Create the foreign control
|
682 |
|
|
wxCheckListBox* listBox = new wxCheckListBox(parent, ecID_RUN_TESTS_TEST_LIST, wxDefaultPosition, wxSize(100, 100),
|
683 |
|
|
0, NULL, wxSUNKEN_BORDER|wxLB_EXTENDED);
|
684 |
|
|
|
685 |
|
|
wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
|
686 |
|
|
|
687 |
|
|
wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
|
688 |
|
|
|
689 |
|
|
wxButton *item2 = new wxButton( parent, ecID_RUN_TESTS_CHECK_ALL, "C&heck All", wxDefaultPosition, wxDefaultSize, 0 );
|
690 |
|
|
item1->Add( item2, 0, wxALIGN_CENTRE|wxALL, 5 );
|
691 |
|
|
|
692 |
|
|
item1->Add( 2, 2, 1, wxALIGN_CENTRE|wxALL, 0 );
|
693 |
|
|
|
694 |
|
|
wxButton *item3 = new wxButton( parent, ecID_RUN_TESTS_UNCHECK_ALL, "&Uncheck All", wxDefaultPosition, wxDefaultSize, 0 );
|
695 |
|
|
item1->Add( item3, 0, wxALIGN_CENTRE|wxALL, 5 );
|
696 |
|
|
|
697 |
|
|
item1->Add( 2, 2, 1, wxALIGN_CENTRE|wxALL, 0 );
|
698 |
|
|
|
699 |
|
|
wxButton *item4 = new wxButton( parent, ecID_RUN_TESTS_ADD, "&Add...", wxDefaultPosition, wxDefaultSize, 0 );
|
700 |
|
|
item1->Add( item4, 0, wxALIGN_CENTRE|wxALL, 5 );
|
701 |
|
|
|
702 |
|
|
item1->Add( 2, 2, 1, wxALIGN_CENTRE|wxALL, 0 );
|
703 |
|
|
|
704 |
|
|
wxButton *item5 = new wxButton( parent, ecID_RUN_TESTS_ADD_FOLDER, "Add from &Folder...", wxDefaultPosition, wxDefaultSize, 0 );
|
705 |
|
|
item1->Add( item5, 0, wxALIGN_CENTRE|wxALL, 5 );
|
706 |
|
|
|
707 |
|
|
item1->Add( 2, 2, 1, wxALIGN_CENTRE|wxALL, 0 );
|
708 |
|
|
|
709 |
|
|
wxButton *item6 = new wxButton( parent, ecID_RUN_TESTS_REMOVE, "&Remove", wxDefaultPosition, wxDefaultSize, 0 );
|
710 |
|
|
item1->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
|
711 |
|
|
|
712 |
|
|
item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
713 |
|
|
|
714 |
|
|
wxWindow *item7 = parent->FindWindow( ecID_RUN_TESTS_TEST_LIST );
|
715 |
|
|
wxASSERT( item7 );
|
716 |
|
|
item0->Add( item7, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
717 |
|
|
|
718 |
|
|
// Add context-sensitive help
|
719 |
|
|
FindWindow(ecID_RUN_TESTS_TEST_LIST)->SetHelpText(_("Displays the set of tests that can be executed. Each test can be selected for execution by checking the adjacent box."));
|
720 |
|
|
FindWindow(ecID_RUN_TESTS_CHECK_ALL)->SetHelpText(_("Selects all tests for execution."));
|
721 |
|
|
FindWindow(ecID_RUN_TESTS_UNCHECK_ALL)->SetHelpText(_("Clears the selection of tests."));
|
722 |
|
|
FindWindow(ecID_RUN_TESTS_ADD)->SetHelpText(_("Adds a test to the set that can be executed."));
|
723 |
|
|
FindWindow(ecID_RUN_TESTS_ADD_FOLDER)->SetHelpText(_("Adds one or more tests to the set that can be executed, from a folder."));
|
724 |
|
|
FindWindow(ecID_RUN_TESTS_REMOVE)->SetHelpText(_("Removes a test from the set that can executed."));
|
725 |
|
|
|
726 |
|
|
parent->SetAutoLayout( TRUE );
|
727 |
|
|
parent->SetSizer( item0 );
|
728 |
|
|
}
|
729 |
|
|
|
730 |
|
|
void ecRunTestsExecutablesDialog::OnCheckAll(wxCommandEvent& event)
|
731 |
|
|
{
|
732 |
|
|
wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);
|
733 |
|
|
if (!checkList)
|
734 |
|
|
return;
|
735 |
|
|
|
736 |
|
|
int i;
|
737 |
|
|
int n = checkList->GetCount();
|
738 |
|
|
for (i = 0; i < n; i++)
|
739 |
|
|
checkList->Check(i, TRUE);
|
740 |
|
|
}
|
741 |
|
|
|
742 |
|
|
void ecRunTestsExecutablesDialog::OnUncheckAll(wxCommandEvent& event)
|
743 |
|
|
{
|
744 |
|
|
wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);
|
745 |
|
|
if (!checkList)
|
746 |
|
|
return;
|
747 |
|
|
|
748 |
|
|
int i;
|
749 |
|
|
int n = checkList->GetCount();
|
750 |
|
|
for (i = 0; i < n; i++)
|
751 |
|
|
checkList->Check(i, FALSE);
|
752 |
|
|
}
|
753 |
|
|
|
754 |
|
|
void ecRunTestsExecutablesDialog::OnAdd(wxCommandEvent& event)
|
755 |
|
|
{
|
756 |
|
|
wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);
|
757 |
|
|
if (!checkList)
|
758 |
|
|
return;
|
759 |
|
|
|
760 |
|
|
//#ifdef __WXMSW__
|
761 |
|
|
// wxString wildcard(wxT("Executables (*.exe)|*.exe"));
|
762 |
|
|
//#else
|
763 |
|
|
wxString wildcard(wxT("Executables (*)|*"));
|
764 |
|
|
//#endif
|
765 |
|
|
|
766 |
|
|
wxFileDialog dialog(this, _("Choose one or more executables to add"), wxGetCwd(), wxEmptyString,
|
767 |
|
|
wildcard, wxMULTIPLE|wxOPEN);
|
768 |
|
|
|
769 |
|
|
if (dialog.ShowModal() == wxID_OK)
|
770 |
|
|
{
|
771 |
|
|
wxArrayString paths;
|
772 |
|
|
dialog.GetPaths(paths);
|
773 |
|
|
|
774 |
|
|
bool err = FALSE;
|
775 |
|
|
|
776 |
|
|
unsigned int i;
|
777 |
|
|
int n = paths.Count();
|
778 |
|
|
for (i = 0; i < n; i++)
|
779 |
|
|
{
|
780 |
|
|
// TODO: check that it's the right kind of file
|
781 |
|
|
if (-1 == checkList->FindString(paths[i]))
|
782 |
|
|
{
|
783 |
|
|
checkList->Append(paths[i]);
|
784 |
|
|
checkList->Check(checkList->GetCount()-1, TRUE);
|
785 |
|
|
}
|
786 |
|
|
else
|
787 |
|
|
err = TRUE;
|
788 |
|
|
}
|
789 |
|
|
if (err)
|
790 |
|
|
wxMessageBox(_("One or more of the files was already present"),
|
791 |
|
|
wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK, this);
|
792 |
|
|
}
|
793 |
|
|
}
|
794 |
|
|
|
795 |
|
|
void ecRunTestsExecutablesDialog::OnAddFromFolder(wxCommandEvent& event)
|
796 |
|
|
{
|
797 |
|
|
wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);
|
798 |
|
|
if (!checkList)
|
799 |
|
|
return;
|
800 |
|
|
|
801 |
|
|
// In the MFC tool, a modified version of the folder dialog was used but
|
802 |
|
|
// we can't do that in general in wxWindows; so instead we ask the questions
|
803 |
|
|
// before we show the folder dialog.
|
804 |
|
|
// We won't bother allowing the user to change the extension: on Windows it's .exe,
|
805 |
|
|
// on Unix it's anything.
|
806 |
|
|
//#ifdef __WXMSW__
|
807 |
|
|
// wxString filespec(wxT("*.exe"));
|
808 |
|
|
//#else
|
809 |
|
|
wxString filespec(wxT("*"));
|
810 |
|
|
//#endif
|
811 |
|
|
|
812 |
|
|
wxString msg;
|
813 |
|
|
msg.Printf(_("Would you like to add from subfolders, or just the folder you specify?\nChoose Yes to add from subfolders."));
|
814 |
|
|
int ans = wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_QUESTION|wxYES_NO|wxCANCEL, this);
|
815 |
|
|
if (ans == wxCANCEL)
|
816 |
|
|
return;
|
817 |
|
|
|
818 |
|
|
bool recurse = (ans == wxYES);
|
819 |
|
|
|
820 |
|
|
wxDirDialog dialog(this, _("Choose a folder to add tests from"), wxGetCwd());
|
821 |
|
|
if (dialog.ShowModal() == wxID_OK)
|
822 |
|
|
{
|
823 |
|
|
wxString folder(dialog.GetPath());
|
824 |
|
|
|
825 |
|
|
if (!wxDirExists(folder))
|
826 |
|
|
{
|
827 |
|
|
wxMessageBox(_("Sorry, this folder does not exist."), wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK, this);
|
828 |
|
|
return;
|
829 |
|
|
}
|
830 |
|
|
|
831 |
|
|
wxBusyCursor busy;
|
832 |
|
|
AddFromFolder(folder, recurse, filespec);
|
833 |
|
|
}
|
834 |
|
|
}
|
835 |
|
|
|
836 |
|
|
void ecRunTestsExecutablesDialog::AddFromFolder(const wxString& folder, bool recurse, const wxString& wildcard)
|
837 |
|
|
{
|
838 |
|
|
wxString filename;
|
839 |
|
|
wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);
|
840 |
|
|
|
841 |
|
|
{
|
842 |
|
|
wxDir dir;
|
843 |
|
|
if (!dir.Open(folder))
|
844 |
|
|
return;
|
845 |
|
|
|
846 |
|
|
|
847 |
|
|
bool success = dir.GetFirst(& filename, wildcard, wxDIR_FILES);
|
848 |
|
|
while (success)
|
849 |
|
|
{
|
850 |
|
|
wxString path = folder + wxString(wxFILE_SEP_PATH) + filename;
|
851 |
|
|
|
852 |
|
|
if (-1 == checkList->FindString(path))
|
853 |
|
|
{
|
854 |
|
|
checkList->Append(path);
|
855 |
|
|
checkList->Check(checkList->GetCount()-1, TRUE);
|
856 |
|
|
}
|
857 |
|
|
|
858 |
|
|
success = dir.GetNext(& filename);
|
859 |
|
|
}
|
860 |
|
|
}
|
861 |
|
|
|
862 |
|
|
// Recurse down the subfolders
|
863 |
|
|
if (recurse)
|
864 |
|
|
{
|
865 |
|
|
wxArrayString subfolders;
|
866 |
|
|
|
867 |
|
|
{
|
868 |
|
|
wxDir dir2;
|
869 |
|
|
if (!dir2.Open(folder))
|
870 |
|
|
return;
|
871 |
|
|
|
872 |
|
|
bool success = dir2.GetFirst(& filename, wxT("*"), wxDIR_DIRS);
|
873 |
|
|
while (success)
|
874 |
|
|
{
|
875 |
|
|
wxString path = folder + wxString(wxFILE_SEP_PATH) + filename;
|
876 |
|
|
subfolders.Add(path);
|
877 |
|
|
|
878 |
|
|
success = dir2.GetNext(& filename);
|
879 |
|
|
}
|
880 |
|
|
}
|
881 |
|
|
|
882 |
|
|
unsigned int i;
|
883 |
|
|
for (i = 0; i < subfolders.Count(); i ++)
|
884 |
|
|
{
|
885 |
|
|
AddFromFolder(subfolders[i], recurse, wildcard);
|
886 |
|
|
}
|
887 |
|
|
}
|
888 |
|
|
}
|
889 |
|
|
|
890 |
|
|
void ecRunTestsExecutablesDialog::OnRemove(wxCommandEvent& event)
|
891 |
|
|
{
|
892 |
|
|
wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);
|
893 |
|
|
if (!checkList)
|
894 |
|
|
return;
|
895 |
|
|
|
896 |
|
|
bool cont = FALSE;
|
897 |
|
|
do
|
898 |
|
|
{
|
899 |
|
|
// Delete the selections one at a time since
|
900 |
|
|
// the indexes change when you delete one
|
901 |
|
|
|
902 |
|
|
wxArrayInt ar;
|
903 |
|
|
if (checkList->GetSelections(ar) > 0)
|
904 |
|
|
{
|
905 |
|
|
checkList->Delete(ar[0]);
|
906 |
|
|
cont = TRUE;
|
907 |
|
|
}
|
908 |
|
|
else
|
909 |
|
|
cont = FALSE;
|
910 |
|
|
|
911 |
|
|
} while (cont);
|
912 |
|
|
|
913 |
|
|
}
|
914 |
|
|
|
915 |
|
|
void ecRunTestsExecutablesDialog::OnUpdateCheckAll(wxUpdateUIEvent& event)
|
916 |
|
|
{
|
917 |
|
|
wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);
|
918 |
|
|
if (!checkList)
|
919 |
|
|
return;
|
920 |
|
|
|
921 |
|
|
// If there were no unchecked items, we can disable the check all button
|
922 |
|
|
event.Enable( checkList->GetCount() != SelectedTestCount() );
|
923 |
|
|
}
|
924 |
|
|
|
925 |
|
|
void ecRunTestsExecutablesDialog::OnUpdateUncheckAll(wxUpdateUIEvent& event)
|
926 |
|
|
{
|
927 |
|
|
event.Enable( SelectedTestCount() > 0 );
|
928 |
|
|
}
|
929 |
|
|
|
930 |
|
|
int ecRunTestsExecutablesDialog::SelectedTestCount()
|
931 |
|
|
{
|
932 |
|
|
wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);
|
933 |
|
|
if (!checkList)
|
934 |
|
|
return 0;
|
935 |
|
|
|
936 |
|
|
int selCount = 0;
|
937 |
|
|
int i;
|
938 |
|
|
int n = checkList->GetCount();
|
939 |
|
|
for (i = 0; i < n; i++)
|
940 |
|
|
{
|
941 |
|
|
if (checkList->IsChecked(i))
|
942 |
|
|
{
|
943 |
|
|
selCount ++;
|
944 |
|
|
}
|
945 |
|
|
}
|
946 |
|
|
return selCount;
|
947 |
|
|
}
|
948 |
|
|
|
949 |
|
|
wxString ecRunTestsExecutablesDialog::SelectedTest(int nIndex)
|
950 |
|
|
{
|
951 |
|
|
wxString str;
|
952 |
|
|
wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);
|
953 |
|
|
if (!checkList)
|
954 |
|
|
return str;
|
955 |
|
|
|
956 |
|
|
int i;
|
957 |
|
|
for (i=0; i < checkList->GetCount(); i++)
|
958 |
|
|
{
|
959 |
|
|
if (checkList->IsChecked(i))
|
960 |
|
|
{
|
961 |
|
|
if(0==nIndex--)
|
962 |
|
|
{
|
963 |
|
|
str = checkList->GetString(i);
|
964 |
|
|
break;
|
965 |
|
|
}
|
966 |
|
|
}
|
967 |
|
|
}
|
968 |
|
|
return str;
|
969 |
|
|
}
|
970 |
|
|
|
971 |
|
|
/* Output dialog
|
972 |
|
|
*/
|
973 |
|
|
|
974 |
|
|
IMPLEMENT_CLASS(ecRunTestsOutputDialog, wxPanel)
|
975 |
|
|
|
976 |
|
|
ecRunTestsOutputDialog::ecRunTestsOutputDialog(wxWindow* parent):
|
977 |
|
|
wxPanel(parent, ecID_RUN_TESTS_OUTPUT)
|
978 |
|
|
{
|
979 |
|
|
CreateControls(this);
|
980 |
|
|
|
981 |
|
|
SetHelpText(_("The output dialog displays the run output."));
|
982 |
|
|
}
|
983 |
|
|
|
984 |
|
|
void ecRunTestsOutputDialog::CreateControls( wxPanel *parent)
|
985 |
|
|
{
|
986 |
|
|
wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
|
987 |
|
|
|
988 |
|
|
wxTextCtrl *item1 = new wxTextCtrl( parent, ecID_RUN_TESTS_OUTPUT_TEXT, "", wxDefaultPosition, wxSize(80,40), wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH|wxCLIP_CHILDREN );
|
989 |
|
|
item0->Add( item1, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
990 |
|
|
|
991 |
|
|
// Add context-sensitive help
|
992 |
|
|
FindWindow(ecID_RUN_TESTS_OUTPUT_TEXT)->SetHelpText(_("Displays the output of test execution."));
|
993 |
|
|
|
994 |
|
|
parent->SetAutoLayout( TRUE );
|
995 |
|
|
parent->SetSizer( item0 );
|
996 |
|
|
}
|
997 |
|
|
|
998 |
|
|
void ecRunTestsOutputDialog::AddText(const wxString& msg)
|
999 |
|
|
{
|
1000 |
|
|
wxTextCtrl* textCtrl = (wxTextCtrl*) FindWindow(ecID_RUN_TESTS_OUTPUT_TEXT);
|
1001 |
|
|
wxASSERT (textCtrl != NULL);
|
1002 |
|
|
|
1003 |
|
|
textCtrl->SetInsertionPointEnd();
|
1004 |
|
|
textCtrl->AppendText(msg);
|
1005 |
|
|
}
|
1006 |
|
|
|
1007 |
|
|
void ecRunTestsOutputDialog::AddLogMsg(const wxString& msg)
|
1008 |
|
|
{
|
1009 |
|
|
wxString msg2(msg);
|
1010 |
|
|
|
1011 |
|
|
if ((msg == wxEmptyString) || (msg.Last() != wxT('\n')))
|
1012 |
|
|
msg2 += wxT("\n");
|
1013 |
|
|
|
1014 |
|
|
AddText(msg2);
|
1015 |
|
|
}
|
1016 |
|
|
|
1017 |
|
|
/* Summary dialog
|
1018 |
|
|
*/
|
1019 |
|
|
|
1020 |
|
|
IMPLEMENT_CLASS(ecRunTestsSummaryDialog, wxPanel)
|
1021 |
|
|
|
1022 |
|
|
BEGIN_EVENT_TABLE(ecRunTestsSummaryDialog, wxPanel)
|
1023 |
|
|
EVT_LIST_COL_CLICK(ecID_RUN_TESTS_SUMMARY_LIST, ecRunTestsSummaryDialog::OnColClick)
|
1024 |
|
|
END_EVENT_TABLE()
|
1025 |
|
|
|
1026 |
|
|
wxListCtrl* ecRunTestsSummaryDialog::m_listCtrl = NULL;
|
1027 |
|
|
|
1028 |
|
|
ecRunTestsSummaryDialog::ecRunTestsSummaryDialog(wxWindow* parent):
|
1029 |
|
|
wxPanel(parent, ecID_RUN_TESTS_SUMMARY)
|
1030 |
|
|
{
|
1031 |
|
|
CreateControls(this);
|
1032 |
|
|
|
1033 |
|
|
SetHelpText(_("The summary dialog shows a summary of the results of each run."));
|
1034 |
|
|
}
|
1035 |
|
|
|
1036 |
|
|
void ecRunTestsSummaryDialog::CreateControls( wxPanel *parent)
|
1037 |
|
|
{
|
1038 |
|
|
m_listCtrl = new wxListCtrl(parent, ecID_RUN_TESTS_SUMMARY_LIST, wxDefaultPosition, wxSize(100, 100), wxSUNKEN_BORDER|wxLC_REPORT);
|
1039 |
|
|
m_listCtrl->InsertColumn(0, "Time", wxLIST_FORMAT_LEFT, 60);
|
1040 |
|
|
m_listCtrl->InsertColumn(1, "Host", wxLIST_FORMAT_LEFT, 60);
|
1041 |
|
|
m_listCtrl->InsertColumn(2, "Platform", wxLIST_FORMAT_LEFT, 60);
|
1042 |
|
|
m_listCtrl->InsertColumn(3, "Executable", wxLIST_FORMAT_LEFT, 60);
|
1043 |
|
|
m_listCtrl->InsertColumn(4, "Status", wxLIST_FORMAT_LEFT, 60);
|
1044 |
|
|
m_listCtrl->InsertColumn(5, "Size", wxLIST_FORMAT_LEFT, 60);
|
1045 |
|
|
m_listCtrl->InsertColumn(6, "Download", wxLIST_FORMAT_LEFT, 60);
|
1046 |
|
|
m_listCtrl->InsertColumn(7, "Elapsed", wxLIST_FORMAT_LEFT, 60);
|
1047 |
|
|
m_listCtrl->InsertColumn(8, "Execution", wxLIST_FORMAT_LEFT, 60);
|
1048 |
|
|
|
1049 |
|
|
wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
|
1050 |
|
|
|
1051 |
|
|
wxWindow *item1 = parent->FindWindow( ecID_RUN_TESTS_SUMMARY_LIST );
|
1052 |
|
|
wxASSERT( item1 );
|
1053 |
|
|
item0->Add( item1, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
1054 |
|
|
|
1055 |
|
|
parent->SetAutoLayout( TRUE );
|
1056 |
|
|
parent->SetSizer( item0 );
|
1057 |
|
|
|
1058 |
|
|
// Add context-sensitive help
|
1059 |
|
|
FindWindow(ecID_RUN_TESTS_SUMMARY_LIST)->SetHelpText(_("Displays a summary of test execution."));
|
1060 |
|
|
}
|
1061 |
|
|
|
1062 |
|
|
void ecRunTestsSummaryDialog::AddResult (CeCosTest *pTest)
|
1063 |
|
|
{
|
1064 |
|
|
const wxString strResult(pTest->ResultString(FALSE));
|
1065 |
|
|
int nLength=strResult.Length();
|
1066 |
|
|
wxString arstr[8];
|
1067 |
|
|
wxString strTime,strDate;
|
1068 |
|
|
int i;
|
1069 |
|
|
|
1070 |
|
|
// 1999-05-28 10:29:28 nan:0 TX39-jmr3904-sim tx39-jmr3904sim-libc10-signal2.exe Fail 0k/1108k D=0.0/0.0 Total=9.3 E=0.6/300.0
|
1071 |
|
|
wxStringTokenizer tok(strResult, wxT(" "));
|
1072 |
|
|
strDate = tok.GetNextToken();
|
1073 |
|
|
strTime = tok.GetNextToken();
|
1074 |
|
|
|
1075 |
|
|
strDate += wxT(" ");
|
1076 |
|
|
strDate += strTime;
|
1077 |
|
|
|
1078 |
|
|
for (i = 0; i < 8; i++)
|
1079 |
|
|
arstr[i] = tok.GetNextToken();
|
1080 |
|
|
|
1081 |
|
|
// Remove characters before '=' in time fields
|
1082 |
|
|
for ( i = 5 ; i < 8 ; i ++ )
|
1083 |
|
|
{
|
1084 |
|
|
wxString str = arstr[i].AfterFirst(wxT('-')) ;
|
1085 |
|
|
arstr[i] = str.IsEmpty() ? arstr[i] : str;
|
1086 |
|
|
}
|
1087 |
|
|
|
1088 |
|
|
int nItem = m_listCtrl->GetItemCount() ;
|
1089 |
|
|
int nIndex = m_listCtrl->InsertItem (nItem, strDate);
|
1090 |
|
|
m_listCtrl->SetItemData(nItem,nItem);// to support sorting
|
1091 |
|
|
for (i = 0; i < 8; i++)
|
1092 |
|
|
{
|
1093 |
|
|
m_listCtrl->SetItem(nIndex, i+1, arstr[i]);
|
1094 |
|
|
}
|
1095 |
|
|
|
1096 |
|
|
#if 0
|
1097 |
|
|
// OLD CODE
|
1098 |
|
|
int i;
|
1099 |
|
|
// TRACE(_T("%s\n"),strResult);
|
1100 |
|
|
// 1999-05-28 10:29:28 nan:0 TX39-jmr3904-sim tx39-jmr3904sim-libc10-signal2.exe Fail 0k/1108k D=0.0/0.0 Total=9.3 E=0.6/300.0
|
1101 |
|
|
_stscanf(strResult,_T("%s %s %s %s %s %s %s %s %s %s"),
|
1102 |
|
|
strDate.GetBuffer(1+nLength),
|
1103 |
|
|
strTime.GetBuffer(1+nLength),
|
1104 |
|
|
arstr[0].GetBuffer(1+nLength),
|
1105 |
|
|
arstr[1].GetBuffer(1+nLength),
|
1106 |
|
|
arstr[2].GetBuffer(1+nLength),
|
1107 |
|
|
arstr[3].GetBuffer(1+nLength),
|
1108 |
|
|
arstr[4].GetBuffer(1+nLength),
|
1109 |
|
|
arstr[5].GetBuffer(1+nLength),
|
1110 |
|
|
arstr[6].GetBuffer(1+nLength),
|
1111 |
|
|
arstr[7].GetBuffer(1+nLength));
|
1112 |
|
|
|
1113 |
|
|
// Remove before '=' in time fields
|
1114 |
|
|
for(i=5;i<8;i++){
|
1115 |
|
|
TCHAR *pch=_tcschr(arstr[i],_TCHAR('='));
|
1116 |
|
|
if(pch){
|
1117 |
|
|
arstr[i]=pch+1;
|
1118 |
|
|
}
|
1119 |
|
|
}
|
1120 |
|
|
|
1121 |
|
|
strDate.ReleaseBuffer();
|
1122 |
|
|
strTime.ReleaseBuffer();
|
1123 |
|
|
strDate+=_TCHAR(' ');
|
1124 |
|
|
strDate+=strTime;
|
1125 |
|
|
int nItem=m_List.GetItemCount();
|
1126 |
|
|
m_List.InsertItem(nItem,strDate);
|
1127 |
|
|
m_List.SetItemData(nItem,nItem);// to support sorting
|
1128 |
|
|
for(i=0;i<8;i++){
|
1129 |
|
|
m_List.SetItemText(nItem,1+i,arstr[i]);
|
1130 |
|
|
arstr[i].ReleaseBuffer();
|
1131 |
|
|
}
|
1132 |
|
|
#endif
|
1133 |
|
|
}
|
1134 |
|
|
|
1135 |
|
|
// Sort function.
|
1136 |
|
|
// The function is passed the client data of the two items,
|
1137 |
|
|
// plus another general client data value which in this case
|
1138 |
|
|
// we use for the column index.
|
1139 |
|
|
int CALLBACK ecRunTestsSummaryDialog::SummarySortFunc(long data1, long data2, long col)
|
1140 |
|
|
{
|
1141 |
|
|
wxString str1 = wxListCtrlGetItemTextColumn(* m_listCtrl, data1, col);
|
1142 |
|
|
wxString str2 = wxListCtrlGetItemTextColumn(* m_listCtrl, data2, col);
|
1143 |
|
|
|
1144 |
|
|
int ret = str1.CmpNoCase(str2);
|
1145 |
|
|
return ret;
|
1146 |
|
|
}
|
1147 |
|
|
|
1148 |
|
|
void ecRunTestsSummaryDialog::OnColClick(wxListEvent& event)
|
1149 |
|
|
{
|
1150 |
|
|
m_listCtrl->SortItems((wxListCtrlCompare) SummarySortFunc,(long) event.m_col);
|
1151 |
|
|
|
1152 |
|
|
// The item data contains the index in the list control, so this needs
|
1153 |
|
|
// to be reset after sorting.
|
1154 |
|
|
int i;
|
1155 |
|
|
for (i = m_listCtrl->GetItemCount()-1;i>=0;--i)
|
1156 |
|
|
{
|
1157 |
|
|
m_listCtrl->SetItemData(i,i);
|
1158 |
|
|
}
|
1159 |
|
|
}
|