author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Thu, 26 Nov 2009 14:53:53 +0100 | |
changeset 5780 | 1ae8031ed08f |
parent 5481 | de01c67af975 |
child 6194 | 5f8e99c4c456 |
permissions | -rw-r--r-- |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
2 |
/* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
3 |
* Copyright (c) 2009 University of Washington |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
4 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
8 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
13 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
17 |
*/ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
18 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
19 |
#include "ns3/test.h" |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
20 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
21 |
#include <iostream> |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
22 |
#include <fstream> |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
23 |
#include <string> |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
24 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
25 |
using namespace ns3; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
26 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
27 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
28 |
// Run one of the test suites. Returns an integer with the boolean sense of |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
29 |
// "an error has occurred." That is, 0 == false -> no error; 1 == true -> an |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
30 |
// error occurred. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
31 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
32 |
int |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
33 |
main (int argc, char *argv[]) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
34 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
35 |
bool doVerbose = false; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
36 |
bool doList = false; |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5297
diff
changeset
|
37 |
bool doMultiple = false; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
38 |
bool doHelp = false; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
39 |
bool doSuite = false; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
40 |
bool doKinds = false; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
41 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
42 |
bool haveBasedir = false; |
5481
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5369
diff
changeset
|
43 |
bool haveTempdir = false; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
44 |
bool haveOutfile = false; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
45 |
bool haveType = false; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
46 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
47 |
std::string suiteName; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
48 |
std::string basedir; |
5481
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5369
diff
changeset
|
49 |
std::string tempdir; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
50 |
std::string outfileName; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
51 |
std::string typeName; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
52 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
53 |
for (int i = 1; i < argc; ++i) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
54 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
55 |
std::string arg(argv[i]); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
56 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
57 |
if (arg.find ("--basedir=") != std::string::npos) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
58 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
59 |
basedir = arg.substr (arg.find_first_of ("=") + 1, 9999); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
60 |
haveBasedir = true; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
61 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
62 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
63 |
if (arg.find ("--constrain=") != std::string::npos) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
64 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
65 |
typeName = arg.substr (arg.find_first_of ("=") + 1, 9999); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
66 |
haveType = true; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
67 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
68 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
69 |
if (arg.compare ("--help") == 0) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
70 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
71 |
doHelp = true; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
72 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
73 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
74 |
if (arg.compare ("--kinds") == 0) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
75 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
76 |
doKinds = true; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
77 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
78 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
79 |
if (arg.compare ("--list") == 0) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
80 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
81 |
doList = true; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
82 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
83 |
|
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5297
diff
changeset
|
84 |
if (arg.compare ("--multiple") == 0) |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5297
diff
changeset
|
85 |
{ |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5297
diff
changeset
|
86 |
doMultiple = true; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5297
diff
changeset
|
87 |
} |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5297
diff
changeset
|
88 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
89 |
if (arg.find ("--out=") != std::string::npos) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
90 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
91 |
outfileName = arg.substr (arg.find_first_of ("=") + 1, 9999); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
92 |
haveOutfile = true; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
93 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
94 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
95 |
if (arg.find ("--suite=") != std::string::npos) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
96 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
97 |
suiteName = arg.substr (arg.find_first_of ("=") + 1, 9999); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
98 |
doSuite = true; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
99 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
100 |
|
5481
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5369
diff
changeset
|
101 |
if (arg.find ("--tempdir=") != std::string::npos) |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5369
diff
changeset
|
102 |
{ |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5369
diff
changeset
|
103 |
tempdir = arg.substr (arg.find_first_of ("=") + 1, 9999); |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5369
diff
changeset
|
104 |
haveTempdir = true; |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5369
diff
changeset
|
105 |
} |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5369
diff
changeset
|
106 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
107 |
if (arg.compare ("--verbose") == 0) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
108 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
109 |
doVerbose = true; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
110 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
111 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
112 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
113 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
114 |
// A help request trumps everything else. If we have one, just print the help |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
115 |
// and leave. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
116 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
117 |
if (doHelp) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
118 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
119 |
std::cout << " --basedir=dir: Set the base directory (where to find src) to \"dir\"" << std::endl; |
5780
1ae8031ed08f
document the new --tempdir option
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5481
diff
changeset
|
120 |
std::cout << " --tempdir=dir: Set the temporary directory (where to find data files) to \"dir\"" << std::endl; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
121 |
std::cout << " --constrain=test-type: Constrain checks to test suites of type \"test-type\"" << std::endl; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
122 |
std::cout << " --help: Print this message" << std::endl; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
123 |
std::cout << " --kinds: List all of the available kinds of tests" << std::endl; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
124 |
std::cout << " --list: List all of the test suites (optionally constrained by test-type)" << std::endl; |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5297
diff
changeset
|
125 |
std::cout << " --multiple: Allow test suites and cases to produce multiple failures" << std::endl; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
126 |
std::cout << " --out=file-name: Set the test status output file to \"file-name\"" << std::endl; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
127 |
std::cout << " --suite=suite-name: Run the test suite named \"suite-name\"" << std::endl; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
128 |
std::cout << " --verbose: Turn on messages in the run test suites" << std::endl; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
129 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
130 |
return false; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
131 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
132 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
133 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
134 |
// A kinds request trumps everything remaining. If we are asked, just |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
135 |
// print the list of types and leave. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
136 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
137 |
if (doKinds) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
138 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
139 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
140 |
// Coming up with a string to represent a test type is completely up to |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
141 |
// us here. We just define the types as being a string composed of the |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
142 |
// enum defined in test.h converted to lower case. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
143 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
144 |
std::cout << " bvt: Build Verification Tests (to see if build completed successfully)" << std::endl; |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
5324
diff
changeset
|
145 |
std::cout << " core: Run all TestSuite-based tests (exclude examples)" << std::endl; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
146 |
std::cout << " example: Examples (to see if example programs run successfully)" << std::endl; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
147 |
std::cout << " performance: Performance Tests (check to see if the system is as fast as expected)" << std::endl; |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
5324
diff
changeset
|
148 |
std::cout << " system: System Tests (spans modules to check integration of modules)" << std::endl; |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
5324
diff
changeset
|
149 |
std::cout << " unit: Unit Tests (within modules to check basic functionality)" << std::endl; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
150 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
151 |
return false; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
152 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
153 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
154 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
155 |
// A list request is the first functional request. It trumps running the |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
156 |
// actual tests. If we get a list request, we don't run anything, we just |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
157 |
// do the requested list which may or may not be qualified by a typename. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
158 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
159 |
if (doList) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
160 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
161 |
for (uint32_t i = 0; i < TestRunner::GetNTestSuites (); ++i) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
162 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
163 |
TestSuite *suite = TestRunner::GetTestSuite (i); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
164 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
165 |
// |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
5324
diff
changeset
|
166 |
// Filter the tests listed by type if requested. The special typeName |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
5324
diff
changeset
|
167 |
// "core" means any TestSuite. |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
168 |
// |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
5324
diff
changeset
|
169 |
if (haveType && typeName != "core") |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
170 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
171 |
TestSuite::TestType type = suite->GetTestType (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
172 |
if (typeName == "bvt" && type != TestSuite::BVT) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
173 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
174 |
continue; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
175 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
176 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
177 |
if (typeName == "unit" && type != TestSuite::UNIT) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
178 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
179 |
continue; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
180 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
181 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
182 |
if (typeName == "system" && type != TestSuite::SYSTEM) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
183 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
184 |
continue; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
185 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
186 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
187 |
if (typeName == "example" && type != TestSuite::EXAMPLE) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
188 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
189 |
continue; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
190 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
191 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
192 |
if (typeName == "performance" && type != TestSuite::PERFORMANCE) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
193 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
194 |
continue; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
195 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
196 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
197 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
198 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
199 |
// This creates a list of test suite names that can be used by the |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
200 |
// high level test manager to get a list of all tests. It will then |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
201 |
// typically launch individual tests in parallel, calling back here |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
202 |
// with a specific "suite=" to run. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
203 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
204 |
std::cout << suite->GetName () << std::endl; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
205 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
206 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
207 |
return false; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
208 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
209 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
210 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
211 |
// If we haven't been asked to run a test suite, we are just going to happily |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
212 |
// try and run everything. Test suites are possibly going to need to figure |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
213 |
// out where there source directory is, and to do that they will need to know |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
214 |
// where the base directory of the distribution is (the directory in which |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
215 |
// "src" is found). We could try and run without it, but when it is needed, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
216 |
// the test will fail with an assertion. So to be safe, we require a basedir |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
217 |
// to proceed. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
218 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
219 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
220 |
if (haveBasedir == false) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
221 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
222 |
std::cout << "Must specify a base directory to run tests (use --basedir option)" << std::endl; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
223 |
return true; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
224 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
225 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
226 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
227 |
// If given an output file, we just append the output of each test suite |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
228 |
// we're asked to run to the end of that file. We need to append since the |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
229 |
// higher level test runner may be just running a number of tests back to |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
230 |
// back. We leave it up to that code to decide how to deal with possible |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
231 |
// parallel operation -- we just append to a file here. If no output file |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
232 |
// is specified, we don't do any output and just return the sense of error |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
233 |
// given by the test. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
234 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
235 |
std::ofstream *pofs = 0; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
236 |
std::ofstream ofs; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
237 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
238 |
if (!outfileName.empty ()) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
239 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
240 |
ofs.open (outfileName.c_str (), std::fstream::out | std::fstream::app); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
241 |
pofs = &ofs; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
242 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
243 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
244 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
245 |
// If we have a specified test suite to run, then we only run that suite. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
246 |
// The default case is to "run everything. We don't expect this to be done |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
247 |
// much since typically higher level code will be running suites in parallel |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
248 |
// but we'll do it if asked. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
249 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
250 |
bool result = false; |
5297
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
251 |
bool suiteRan = false; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
252 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
253 |
for (uint32_t i = 0; i < TestRunner::GetNTestSuites (); ++i) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
254 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
255 |
TestSuite *testSuite = TestRunner::GetTestSuite (i); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
256 |
if (doSuite == false || (doSuite == true && suiteName == testSuite->GetName ())) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
257 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
258 |
testSuite->SetBaseDir (basedir); |
5481
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5369
diff
changeset
|
259 |
testSuite->SetTempDir (tempdir); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
260 |
testSuite->SetStream (pofs); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
261 |
testSuite->SetVerbose (doVerbose); |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5297
diff
changeset
|
262 |
testSuite->SetContinueOnFailure (doMultiple); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
263 |
result |= testSuite->Run (); |
5297
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
264 |
suiteRan = true; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
265 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
266 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
267 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
268 |
ofs.close(); |
5297
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
269 |
|
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
270 |
// |
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
271 |
// If we couldn't figure out how to run at least one test, then return an error |
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
272 |
// |
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
273 |
if (suiteRan == false) |
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
274 |
{ |
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
275 |
return true; |
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
276 |
} |
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
277 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
278 |
return result; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
279 |
} |