author | Sebastien Vincent <vincent@clarinet.u-strasbg.fr> |
Wed, 24 Mar 2010 08:49:24 +0100 | |
changeset 6157 | e3f238a05acb |
parent 5483 | ad83d869c08c |
child 6204 | db1a9442b29f |
permissions | -rw-r--r-- |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
133
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
3 |
* Copyright (c) 2009 University of Washington |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
*/ |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
|
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
#include "test.h" |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
20 |
#include "assert.h" |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
21 |
#include "abort.h" |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
22 |
#include <math.h> |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
23 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
24 |
namespace ns3 { |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
25 |
|
5239
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
26 |
|
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
27 |
// |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
28 |
// XML files have restrictions on certain characters that may be present in |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
29 |
// data. We need to replace these characters with their alternate |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
30 |
// representation on the way into the XML file. |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
31 |
// |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
32 |
std::string |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
33 |
ReplaceXmlSpecialCharacters (std::string xml) |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
34 |
{ |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
35 |
std::string specials = "<>&\"'"; |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
36 |
std::string replacements[] = {"<", ">", "&", "'", """}; |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
37 |
std::string result; |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
38 |
std::size_t index, length = xml.length (); |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
39 |
|
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
40 |
for (size_t i = 0; i < length; ++i) |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
41 |
{ |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
42 |
char character = xml[i]; |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
43 |
|
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
44 |
if ((index = specials.find (character)) == std::string::npos) |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
45 |
{ |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
46 |
result.push_back (character); |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
47 |
} |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
48 |
else |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
49 |
{ |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
50 |
result += replacements[index]; |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
51 |
} |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
52 |
} |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
53 |
return result; |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
54 |
} |
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
55 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
56 |
bool |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
57 |
TestDoubleIsEqual (const double x1, const double x2, const double epsilon) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
58 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
59 |
int exponent; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
60 |
double delta, difference; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
61 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
62 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
63 |
// Find exponent of largest absolute value |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
64 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
65 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
66 |
double max = (fabs (x1) > fabs (x2)) ? x1 : x2; |
6157
e3f238a05acb
Fix build with g++-4.5.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5483
diff
changeset
|
67 |
(void)frexp (max, &exponent); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
68 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
69 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
70 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
71 |
// Form a neighborhood of size 2 * delta |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
72 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
73 |
delta = ldexp (epsilon, exponent); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
74 |
difference = x1 - x2; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
75 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
76 |
if (difference > delta || difference < -delta) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
77 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
78 |
return false; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
79 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
80 |
return true; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
81 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
82 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
83 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
84 |
TestCase::TestCase (std::string name) |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
85 |
: m_name (name), |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
86 |
m_verbose (false), |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
87 |
m_continueOnFailure (false), |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
88 |
m_detailsReported (false), |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
89 |
m_basedir ("invalid"), |
5481
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
90 |
m_tempdir ("invalid"), |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
91 |
m_ofs (0), |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
92 |
m_error (false) |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
93 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
94 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
95 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
96 |
TestCase::~TestCase () |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
97 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
98 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
99 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
100 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
101 |
TestCase::ReportStart (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
102 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
103 |
DoReportStart (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
104 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
105 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
106 |
void |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
107 |
TestCase::ReportCaseSuccess (void) |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
108 |
{ |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
109 |
UpdateErrorStatus (false); |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
110 |
DoReportCaseSuccess (); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
111 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
112 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
113 |
void |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
114 |
TestCase::ReportCaseFailure (void) |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
115 |
{ |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
116 |
UpdateErrorStatus (true); |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
117 |
DoReportCaseFailure (); |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
118 |
} |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
119 |
|
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
120 |
void |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
121 |
TestCase::ReportTestFailure ( |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
122 |
std::string cond, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
123 |
std::string actual, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
124 |
std::string limit, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
125 |
std::string message, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
126 |
std::string file, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
127 |
int32_t line) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
128 |
{ |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
129 |
UpdateErrorStatus (true); |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
130 |
DoReportTestFailure (cond, actual, limit, message, file, line); |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
131 |
m_detailsReported = true; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
132 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
133 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
134 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
135 |
TestCase::ReportEnd (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
136 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
137 |
DoReportStart (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
138 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
139 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
140 |
bool |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
141 |
TestCase::Run (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
142 |
{ |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
143 |
// |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
144 |
// We set up a flag to make sure the user plays by the rules and actually |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
145 |
// does something to report the details of an error. |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
146 |
// |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
147 |
m_detailsReported = false; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
148 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
149 |
DoReportStart (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
150 |
DoSetup (); |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
151 |
|
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
152 |
bool result = DoRun (); |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
153 |
UpdateErrorStatus (result); |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
154 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
155 |
DoTeardown (); |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
156 |
|
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
157 |
if (GetErrorStatus () == false) |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
158 |
{ |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
159 |
DoReportCaseSuccess (); |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
160 |
} |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
161 |
else |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
162 |
{ |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
163 |
// |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
164 |
// It is a programming error to return an error from a test case without |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
165 |
// calling ReportTestFailure. Typically this is done automagically when |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
166 |
// using the ASSERT or EXPECT macros. If you don't use these, you must |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
167 |
// ReportTestFailure on any errors yourself, which will set |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
168 |
// m_detailsReported and make us happy. |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
169 |
// |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
170 |
NS_ASSERT_MSG (m_detailsReported, "The details of a failing test was not reported"); |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
171 |
|
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
172 |
DoReportCaseFailure (); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
173 |
} |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
174 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
175 |
DoReportEnd (); |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
176 |
|
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
177 |
return GetErrorStatus (); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
178 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
179 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
180 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
181 |
TestCase::SetVerbose (bool verbose) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
182 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
183 |
m_verbose = verbose; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
184 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
185 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
186 |
void |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
187 |
TestCase::SetContinueOnFailure (bool continueOnFailure) |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
188 |
{ |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
189 |
m_continueOnFailure = continueOnFailure; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
190 |
} |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
191 |
|
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
192 |
void |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
193 |
TestCase::SetName (std::string name) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
194 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
195 |
m_name = name; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
196 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
197 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
198 |
std::string |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
199 |
TestCase::GetName (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
200 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
201 |
return m_name; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
202 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
203 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
204 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
205 |
TestCase::SetBaseDir (std::string basedir) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
206 |
{ |
5483
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
207 |
// |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
208 |
// C and C++ allow one to use forward slashes even on systems where the |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
209 |
// separator is actually a backslash. |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
210 |
// |
5481
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
211 |
if (basedir[basedir.length () - 1] != '/') |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
212 |
{ |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
213 |
m_basedir = basedir + "/"; |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
214 |
} |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
215 |
else |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
216 |
{ |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
217 |
m_basedir = basedir; |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
218 |
} |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
219 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
220 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
221 |
std::string |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
222 |
TestCase::GetBaseDir (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
223 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
224 |
return m_basedir; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
225 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
226 |
|
5481
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
227 |
void |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
228 |
TestCase::SetTempDir (std::string tempdir) |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
229 |
{ |
5483
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
230 |
// |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
231 |
// C and C++ allow one to use forward slashes even on systems where the |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
232 |
// separator is actually a backslash. |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
233 |
// |
5481
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
234 |
if (tempdir[tempdir.length () - 1] != '/') |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
235 |
{ |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
236 |
m_tempdir = tempdir + "/"; |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
237 |
} |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
238 |
else |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
239 |
{ |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
240 |
m_tempdir = tempdir; |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
241 |
} |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
242 |
} |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
243 |
|
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
244 |
std::string |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
245 |
TestCase::GetTempDir (void) |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
246 |
{ |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
247 |
return m_tempdir; |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
248 |
} |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
249 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
250 |
std::string |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
251 |
TestCase::GetSourceDir (std::string file) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
252 |
{ |
5483
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
253 |
// |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
254 |
// The <file> parameter is actually going to be __FILE__ which may have |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
255 |
// backslashes in it on win32 systems. For example, |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
256 |
// |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
257 |
// ..\src\common\pcap-file-test-suite.cc (win32) |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
258 |
// |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
259 |
// or |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
260 |
// |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
261 |
// ../src/common/pcap-file-test-suite.cc (grown-up systems) |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
262 |
// |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
263 |
#ifdef WIN32 |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
264 |
std::string::size_type relPathBegin = file.find_first_of ("\\"); |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
265 |
std::string::size_type relPathEnd = file.find_last_of ("\\"); |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
266 |
#else |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
267 |
std::string::size_type relPathBegin = file.find_first_of ("/"); |
5483
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
268 |
std::string::size_type relPathEnd = file.find_last_of ("/"); |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
269 |
#endif |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
270 |
|
5481
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
271 |
NS_ABORT_MSG_IF (relPathBegin == std::string::npos, "TestCase::GetSourceDir(): Internal Error"); |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
272 |
NS_ABORT_MSG_IF (relPathEnd == std::string::npos, "TestCase::GetSourceDir(): Internal Error"); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
273 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
274 |
return GetBaseDir () + file.substr (relPathBegin, relPathEnd + 1 - relPathBegin); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
275 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
276 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
277 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
278 |
TestCase::SetStream (std::ofstream *ofs) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
279 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
280 |
m_ofs = ofs; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
281 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
282 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
283 |
std::ofstream * |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
284 |
TestCase::GetStream (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
285 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
286 |
return m_ofs; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
287 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
288 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
289 |
void |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
290 |
TestCase::UpdateErrorStatus (bool error) |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
291 |
{ |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
292 |
m_error |= error; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
293 |
} |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
294 |
|
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
295 |
void |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
296 |
TestCase::SetErrorStatus (bool error) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
297 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
298 |
m_error = error; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
299 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
300 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
301 |
bool |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
302 |
TestCase::GetErrorStatus (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
303 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
304 |
return m_error; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
305 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
306 |
|
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
307 |
bool |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
308 |
TestCase::ContinueOnFailure (void) |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
309 |
{ |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
310 |
return m_continueOnFailure; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
311 |
} |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
312 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
313 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
314 |
TestCase::DoReportStart (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
315 |
{ |
5458
15fcd24f8b1e
make win32 compile again
Craig Dowell <craigdo@ee.washington.edu>
parents:
5457
diff
changeset
|
316 |
m_msClock.Start (); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
317 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
318 |
if (m_ofs == 0) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
319 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
320 |
return; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
321 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
322 |
*m_ofs << " <TestCase>" << std::endl; |
5239
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
323 |
*m_ofs << " <CaseName>" << ReplaceXmlSpecialCharacters (GetName ()) << "</CaseName>" << std::endl; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
324 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
325 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
326 |
void |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
327 |
TestCase::DoReportCaseSuccess (void) |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
328 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
329 |
if (m_ofs == 0) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
330 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
331 |
return; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
332 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
333 |
*m_ofs << " <CaseResult>PASS</CaseResult>" << std::endl; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
334 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
335 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
336 |
void |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
337 |
TestCase::DoReportCaseFailure (void) |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
338 |
{ |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
339 |
if (m_ofs == 0) |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
340 |
{ |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
341 |
return; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
342 |
} |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
343 |
*m_ofs << " <CaseResult>FAIL</CaseResult>" << std::endl; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
344 |
} |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
345 |
|
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
346 |
void |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
347 |
TestCase::DoReportTestFailure ( |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
348 |
std::string cond, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
349 |
std::string actual, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
350 |
std::string limit, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
351 |
std::string message, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
352 |
std::string file, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
353 |
int32_t line) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
354 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
355 |
if (m_ofs == 0) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
356 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
357 |
return; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
358 |
} |
5239
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
359 |
|
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
360 |
*m_ofs << " <FailureDetails>" << std::endl; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
361 |
*m_ofs << " <Condition>" << ReplaceXmlSpecialCharacters (cond) << "</Condition>" << std::endl; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
362 |
*m_ofs << " <Actual>" << ReplaceXmlSpecialCharacters (actual) << "</Actual>" << std::endl; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
363 |
*m_ofs << " <Limit>" << ReplaceXmlSpecialCharacters (limit) << "</Limit>" << std::endl; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
364 |
*m_ofs << " <Message>" << ReplaceXmlSpecialCharacters (message) << "</Message>" << std::endl; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
365 |
*m_ofs << " <File>" << ReplaceXmlSpecialCharacters (file) << "</File>" << std::endl; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
366 |
*m_ofs << " <Line>" << line << "</Line>" << std::endl; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
367 |
*m_ofs << " </FailureDetails>" << std::endl; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
368 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
369 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
370 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
371 |
TestCase::DoReportEnd (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
372 |
{ |
5458
15fcd24f8b1e
make win32 compile again
Craig Dowell <craigdo@ee.washington.edu>
parents:
5457
diff
changeset
|
373 |
m_msClock.End (); |
15fcd24f8b1e
make win32 compile again
Craig Dowell <craigdo@ee.washington.edu>
parents:
5457
diff
changeset
|
374 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
375 |
if (m_ofs == 0) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
376 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
377 |
return; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
378 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
379 |
|
5458
15fcd24f8b1e
make win32 compile again
Craig Dowell <craigdo@ee.washington.edu>
parents:
5457
diff
changeset
|
380 |
(*m_ofs).precision (3); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
381 |
*m_ofs << std::fixed; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
382 |
|
5458
15fcd24f8b1e
make win32 compile again
Craig Dowell <craigdo@ee.washington.edu>
parents:
5457
diff
changeset
|
383 |
const double MS_PER_SEC = 1000.; |
15fcd24f8b1e
make win32 compile again
Craig Dowell <craigdo@ee.washington.edu>
parents:
5457
diff
changeset
|
384 |
|
15fcd24f8b1e
make win32 compile again
Craig Dowell <craigdo@ee.washington.edu>
parents:
5457
diff
changeset
|
385 |
*m_ofs << " <CaseTime>" << "real " << m_msClock.GetElapsedReal () / MS_PER_SEC |
15fcd24f8b1e
make win32 compile again
Craig Dowell <craigdo@ee.washington.edu>
parents:
5457
diff
changeset
|
386 |
<< " user " << m_msClock.GetElapsedUser () / MS_PER_SEC |
15fcd24f8b1e
make win32 compile again
Craig Dowell <craigdo@ee.washington.edu>
parents:
5457
diff
changeset
|
387 |
<< " system " << m_msClock.GetElapsedSystem () / MS_PER_SEC |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
388 |
<< "</CaseTime>" << std::endl; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
389 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
390 |
*m_ofs << " </TestCase>" << std::endl; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
391 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
392 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
393 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
394 |
TestCase::DoSetup (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
395 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
396 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
397 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
398 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
399 |
TestCase::DoTeardown (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
400 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
401 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
402 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
403 |
TestSuite::TestSuite (std::string name, TestType type) |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
404 |
: m_name (name), |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
405 |
m_verbose (false), |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
406 |
m_basedir ("invalid"), |
5481
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
407 |
m_tempdir ("invalid"), |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
408 |
m_ofs (0), |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
409 |
m_error (false), |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
410 |
m_type (type) |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
411 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
412 |
TestRunner::AddTestSuite (this); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
413 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
414 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
415 |
TestSuite::~TestSuite () |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
416 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
417 |
for (TestCaseVector_t::iterator i = m_tests.begin (); i != m_tests.end (); ++i) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
418 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
419 |
delete *i; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
420 |
*i = 0; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
421 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
422 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
423 |
m_tests.erase (m_tests.begin (), m_tests.end ()); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
424 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
425 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
426 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
427 |
TestSuite::ReportStart (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
428 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
429 |
DoReportStart (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
430 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
431 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
432 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
433 |
TestSuite::ReportSuccess (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
434 |
{ |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
435 |
UpdateErrorStatus (false); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
436 |
DoReportSuccess (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
437 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
438 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
439 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
440 |
TestSuite::ReportFailure (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
441 |
{ |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
442 |
UpdateErrorStatus (true); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
443 |
DoReportFailure (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
444 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
445 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
446 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
447 |
TestSuite::ReportEnd (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
448 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
449 |
DoReportEnd (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
450 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
451 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
452 |
bool |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
453 |
TestSuite::Run (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
454 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
455 |
DoReportStart (); |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
456 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
457 |
DoSetup (); |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
458 |
|
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
459 |
bool result = DoRun (); |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
460 |
UpdateErrorStatus (result); |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
461 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
462 |
DoTeardown (); |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
463 |
|
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
464 |
if (GetErrorStatus () == false) |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
465 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
466 |
DoReportSuccess (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
467 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
468 |
else |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
469 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
470 |
DoReportFailure (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
471 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
472 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
473 |
DoReportEnd (); |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
474 |
|
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
475 |
return GetErrorStatus (); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
476 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
477 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
478 |
uint32_t |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
479 |
TestSuite::AddTestCase (TestCase *testCase) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
480 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
481 |
uint32_t index = m_tests.size (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
482 |
m_tests.push_back (testCase); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
483 |
return index; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
484 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
485 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
486 |
uint32_t |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
487 |
TestSuite::GetNTestCases (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
488 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
489 |
return m_tests.size (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
490 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
491 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
492 |
TestCase * |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
493 |
TestSuite::GetTestCase (uint32_t n) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
494 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
495 |
return m_tests[n]; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
496 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
497 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
498 |
TestSuite::TestType |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
499 |
TestSuite::GetTestType (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
500 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
501 |
return m_type; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
502 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
503 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
504 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
505 |
TestSuite::SetVerbose (bool verbose) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
506 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
507 |
m_verbose = verbose; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
508 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
509 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
510 |
void |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
511 |
TestSuite::SetContinueOnFailure (bool continueOnFailure) |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
512 |
{ |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
513 |
m_continueOnFailure = continueOnFailure; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
514 |
} |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
515 |
|
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
516 |
void |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
517 |
TestSuite::SetName (std::string name) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
518 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
519 |
m_name = name; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
520 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
521 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
522 |
std::string |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
523 |
TestSuite::GetName (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
524 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
525 |
return m_name; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
526 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
527 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
528 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
529 |
TestSuite::SetBaseDir (std::string basedir) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
530 |
{ |
5483
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
531 |
// |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
532 |
// C and C++ allow one to use forward slashes even on systems where the |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
533 |
// separator is actually a backslash. |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
534 |
// |
5481
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
535 |
if (basedir[basedir.length () - 1] != '/') |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
536 |
{ |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
537 |
m_basedir = basedir + "/"; |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
538 |
} |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
539 |
else |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
540 |
{ |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
541 |
m_basedir = basedir; |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
542 |
} |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
543 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
544 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
545 |
std::string |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
546 |
TestSuite::GetBaseDir (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
547 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
548 |
return m_basedir; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
549 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
550 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
551 |
void |
5481
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
552 |
TestSuite::SetTempDir (std::string tempdir) |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
553 |
{ |
5483
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
554 |
// |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
555 |
// C and C++ allow one to use forward slashes even on systems where the |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
556 |
// separator is actually a backslash. |
ad83d869c08c
Make tests pass on MinGW, add fifth tutorial example
Craig Dowell <craigdo@ee.washington.edu>
parents:
5481
diff
changeset
|
557 |
// |
5481
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
558 |
if (tempdir[tempdir.length () - 1] != '/') |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
559 |
{ |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
560 |
m_tempdir = tempdir + "/"; |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
561 |
} |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
562 |
else |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
563 |
{ |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
564 |
m_tempdir = tempdir; |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
565 |
} |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
566 |
} |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
567 |
|
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
568 |
std::string |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
569 |
TestSuite::GetTempDir (void) |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
570 |
{ |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
571 |
return m_tempdir; |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
572 |
} |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
573 |
|
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
574 |
void |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
575 |
TestSuite::SetStream (std::ofstream *ofs) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
576 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
577 |
m_ofs = ofs; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
578 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
579 |
|
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
580 |
void |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
581 |
TestSuite::UpdateErrorStatus (bool error) |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
582 |
{ |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
583 |
m_error |= error; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
584 |
} |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
585 |
|
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
586 |
void |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
587 |
TestSuite::SetErrorStatus (bool error) |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
588 |
{ |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
589 |
m_error = error; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
590 |
} |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
591 |
|
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
592 |
bool |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
593 |
TestSuite::GetErrorStatus (void) |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
594 |
{ |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
595 |
return m_error; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
596 |
} |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
597 |
|
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
598 |
bool |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
599 |
TestSuite::ContinueOnFailure (void) |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
600 |
{ |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
601 |
return m_continueOnFailure; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
602 |
} |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
603 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
604 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
605 |
TestSuite::DoReportStart (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
606 |
{ |
5458
15fcd24f8b1e
make win32 compile again
Craig Dowell <craigdo@ee.washington.edu>
parents:
5457
diff
changeset
|
607 |
m_msClock.Start (); |
5457
8cb18165e22f
Apply Gustavo's patch for MinGW compatibiliy
Craig Dowell <craigdo@ee.washington.edu>
parents:
5441
diff
changeset
|
608 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
609 |
if (m_ofs == 0) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
610 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
611 |
return; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
612 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
613 |
*m_ofs << "<TestSuite>" << std::endl; |
5239
2e753de86174
Remove and replace attribute unit tests (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
614 |
*m_ofs << " <SuiteName>" << ReplaceXmlSpecialCharacters (GetName ()) << "</SuiteName>" << std::endl; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
615 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
616 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
617 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
618 |
TestSuite::DoReportFailure (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
619 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
620 |
if (m_ofs == 0) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
621 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
622 |
return; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
623 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
624 |
*m_ofs << " <SuiteResult>FAIL</SuiteResult>" << std::endl; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
625 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
626 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
627 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
628 |
TestSuite::DoReportSuccess (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
629 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
630 |
if (m_ofs == 0) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
631 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
632 |
return; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
633 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
634 |
*m_ofs << " <SuiteResult>PASS</SuiteResult>" << std::endl; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
635 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
636 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
637 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
638 |
TestSuite::DoReportEnd (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
639 |
{ |
5458
15fcd24f8b1e
make win32 compile again
Craig Dowell <craigdo@ee.washington.edu>
parents:
5457
diff
changeset
|
640 |
m_msClock.End (); |
5457
8cb18165e22f
Apply Gustavo's patch for MinGW compatibiliy
Craig Dowell <craigdo@ee.washington.edu>
parents:
5441
diff
changeset
|
641 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
642 |
if (m_ofs == 0) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
643 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
644 |
return; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
645 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
646 |
|
5458
15fcd24f8b1e
make win32 compile again
Craig Dowell <craigdo@ee.washington.edu>
parents:
5457
diff
changeset
|
647 |
(*m_ofs).precision (3); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
648 |
*m_ofs << std::fixed; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
649 |
|
5458
15fcd24f8b1e
make win32 compile again
Craig Dowell <craigdo@ee.washington.edu>
parents:
5457
diff
changeset
|
650 |
const double MS_PER_SEC = 1000.; |
15fcd24f8b1e
make win32 compile again
Craig Dowell <craigdo@ee.washington.edu>
parents:
5457
diff
changeset
|
651 |
|
15fcd24f8b1e
make win32 compile again
Craig Dowell <craigdo@ee.washington.edu>
parents:
5457
diff
changeset
|
652 |
*m_ofs << " <SuiteTime>" << "real " << m_msClock.GetElapsedReal () / MS_PER_SEC |
15fcd24f8b1e
make win32 compile again
Craig Dowell <craigdo@ee.washington.edu>
parents:
5457
diff
changeset
|
653 |
<< " user " << m_msClock.GetElapsedUser () / MS_PER_SEC |
15fcd24f8b1e
make win32 compile again
Craig Dowell <craigdo@ee.washington.edu>
parents:
5457
diff
changeset
|
654 |
<< " system " << m_msClock.GetElapsedSystem () / MS_PER_SEC |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
655 |
<< "</SuiteTime>" << std::endl; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
656 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
657 |
*m_ofs << "</TestSuite>" << std::endl; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
658 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
659 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
660 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
661 |
TestSuite::DoSetup (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
662 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
663 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
664 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
665 |
bool |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
666 |
TestSuite::DoRun (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
667 |
{ |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
668 |
SetErrorStatus (false); |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
669 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
670 |
for (TestCaseVector_t::iterator i = m_tests.begin (); i != m_tests.end (); ++i) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
671 |
{ |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
672 |
// |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
673 |
// Set the current options for the test case |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
674 |
// |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
675 |
(*i)->SetVerbose (m_verbose); |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
676 |
(*i)->SetContinueOnFailure (m_continueOnFailure); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
677 |
(*i)->SetBaseDir (m_basedir); |
5481
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5458
diff
changeset
|
678 |
(*i)->SetTempDir (m_tempdir); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
679 |
(*i)->SetStream (m_ofs); |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
680 |
|
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
681 |
// |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
682 |
// Run the test case |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
683 |
// |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
684 |
bool result = (*i)->Run (); |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
685 |
UpdateErrorStatus (result); |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
686 |
|
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
687 |
// |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
688 |
// Exit if we have detected an error and we are not allowing multiple filures |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
689 |
// |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
690 |
if (GetErrorStatus () && m_continueOnFailure == false) |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
691 |
{ |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
692 |
return GetErrorStatus (); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
693 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
694 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
695 |
|
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5300
diff
changeset
|
696 |
return GetErrorStatus (); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
697 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
698 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
699 |
void |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
700 |
TestSuite::DoTeardown (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
701 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
702 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
703 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
704 |
class TestRunnerImpl |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
705 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
706 |
public: |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
707 |
uint32_t AddTestSuite (TestSuite *testSuite); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
708 |
uint32_t GetNTestSuites (void); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
709 |
TestSuite *GetTestSuite (uint32_t n); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
710 |
bool RunTestSuite (uint32_t n); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
711 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
712 |
static TestRunnerImpl *Instance (void); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
713 |
private: |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
714 |
TestRunnerImpl (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
715 |
~TestRunnerImpl (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
716 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
717 |
typedef std::vector<TestSuite *> TestSuiteVector_t; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
718 |
TestSuiteVector_t m_suites; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
719 |
}; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
720 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
721 |
TestRunnerImpl::TestRunnerImpl () |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
722 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
723 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
724 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
725 |
TestRunnerImpl::~TestRunnerImpl () |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
726 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
727 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
728 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
729 |
TestRunnerImpl * |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
730 |
TestRunnerImpl::Instance (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
731 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
732 |
static TestRunnerImpl runner; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
733 |
return &runner; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
734 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
735 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
736 |
uint32_t |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
737 |
TestRunnerImpl::AddTestSuite (TestSuite *testSuite) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
738 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
739 |
uint32_t index = m_suites.size (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
740 |
m_suites.push_back (testSuite); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
741 |
return index; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
742 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
743 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
744 |
uint32_t |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
745 |
TestRunnerImpl::GetNTestSuites (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
746 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
747 |
return m_suites.size (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
748 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
749 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
750 |
TestSuite * |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
751 |
TestRunnerImpl::GetTestSuite (uint32_t n) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
752 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
753 |
return m_suites[n]; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
754 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
755 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
756 |
uint32_t |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
757 |
TestRunner::AddTestSuite (TestSuite *testSuite) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
758 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
759 |
return TestRunnerImpl::Instance ()->AddTestSuite (testSuite); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
760 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
761 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
762 |
uint32_t |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
763 |
TestRunner::GetNTestSuites (void) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
764 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
765 |
return TestRunnerImpl::Instance ()->GetNTestSuites (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
766 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
767 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
768 |
TestSuite * |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
769 |
TestRunner::GetTestSuite (uint32_t n) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
770 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
771 |
return TestRunnerImpl::Instance ()->GetTestSuite (n); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
772 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4531
diff
changeset
|
773 |
|
5342
3c6109eec550
bug 675: kill old test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5324
diff
changeset
|
774 |
} // namespace ns3 |