author | Craig Dowell <craigdo@ee.washington.edu> |
Mon, 19 Apr 2010 10:10:49 -0700 | |
changeset 6248 | 3ccf4cea2480 |
parent 6245 | a88bde26913e |
child 6251 | ff3501de65dc |
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" |
6194
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
20 |
#include "ns3/assert.h" |
6248
3ccf4cea2480
break down and check return values
Craig Dowell <craigdo@ee.washington.edu>
parents:
6245
diff
changeset
|
21 |
#include "ns3/abort.h" |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
22 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
23 |
#include <iostream> |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
24 |
#include <fstream> |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
25 |
#include <string> |
6194
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
26 |
#include <stdlib.h> |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
27 |
#include <stdio.h> |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
28 |
#include <time.h> |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
29 |
#include <sys/types.h> |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
30 |
#include <sys/stat.h> |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
31 |
#include <dirent.h> |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
32 |
#include <string.h> |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
33 |
|
6204
db1a9442b29f
enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
6194
diff
changeset
|
34 |
extern bool gBreakOnFailure; |
db1a9442b29f
enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
6194
diff
changeset
|
35 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
36 |
using namespace ns3; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
37 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
38 |
// |
6194
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
39 |
// Create a temporary directory for use by test programs. This is not a |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
40 |
// foolproof thing, but a reasonably good way to get a throwaway directory |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
41 |
// while running tests in a debugger. |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
42 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
43 |
std::string |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
44 |
TempDir (void) |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
45 |
{ |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
46 |
char *path = NULL; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
47 |
|
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
48 |
path = getenv ("TMP"); |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
49 |
if (path == NULL) |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
50 |
{ |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
51 |
path = getenv ("TEMP"); |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
52 |
if (path == NULL) |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
53 |
{ |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
54 |
path = const_cast<char *> ("/tmp"); |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
55 |
} |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
56 |
} |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
57 |
|
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
58 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
59 |
// Just in case the user wants to go back and find the output, we give |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
60 |
// a hint as to which dir we created by including a time hint. |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
61 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
62 |
time_t now = time (NULL); |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
63 |
struct tm *tm_now = localtime (&now); |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
64 |
|
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
65 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
66 |
// But we also randomize the name in case there are multiple users doing |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
67 |
// this at the same time |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
68 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
69 |
srandom (time (0)); |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
70 |
long int n = random (); |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
71 |
|
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
72 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
73 |
// The final path to the directory is going to look something like |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
74 |
// |
6228
4a2c9eaedb7f
tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents:
6204
diff
changeset
|
75 |
// /tmp/ns3-14.30.29.32767 |
6194
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
76 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
77 |
// The first segment comes from one of the temporary directory env |
6228
4a2c9eaedb7f
tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents:
6204
diff
changeset
|
78 |
// variables or /tmp if not found. The directory name starts with an |
4a2c9eaedb7f
tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents:
6204
diff
changeset
|
79 |
// identifier telling folks who is making all of the temp directories |
4a2c9eaedb7f
tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents:
6204
diff
changeset
|
80 |
// and then the local time (in this case 14.30.29 -- which is 2:30 and |
4a2c9eaedb7f
tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents:
6204
diff
changeset
|
81 |
// 29 seconds PM). |
6194
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
82 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
83 |
char dirname[1024]; |
6228
4a2c9eaedb7f
tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents:
6204
diff
changeset
|
84 |
snprintf (dirname, sizeof(dirname), "%s/ns-3.%d.%d.%d.%ld", path, tm_now->tm_hour, tm_now->tm_min, tm_now->tm_sec, n); |
6194
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
85 |
|
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
86 |
if (mkdir (dirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0) |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
87 |
{ |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
88 |
return dirname; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
89 |
} |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
90 |
else |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
91 |
{ |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
92 |
return ""; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
93 |
} |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
94 |
} |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
95 |
|
6228
4a2c9eaedb7f
tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents:
6204
diff
changeset
|
96 |
// |
4a2c9eaedb7f
tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents:
6204
diff
changeset
|
97 |
// Test suites may need to figure out where their source directory is in order |
4a2c9eaedb7f
tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents:
6204
diff
changeset
|
98 |
// to find test vectors. To do that they will need to know where the base |
4a2c9eaedb7f
tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents:
6204
diff
changeset
|
99 |
// directory of the distribution is (the directory in which "src" is found). |
4a2c9eaedb7f
tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents:
6204
diff
changeset
|
100 |
// It is painful for a user debugging test suites to always provide that dir |
4a2c9eaedb7f
tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents:
6204
diff
changeset
|
101 |
// so we try and find it in the current directory tree. |
4a2c9eaedb7f
tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents:
6204
diff
changeset
|
102 |
// |
6194
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
103 |
std::string |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
104 |
BaseDir (void) |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
105 |
{ |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
106 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
107 |
// Get an absolute path to the current working directory. Following code |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
108 |
// depends on the leading '/' |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
109 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
110 |
char pathbuf[PATH_MAX]; |
6248
3ccf4cea2480
break down and check return values
Craig Dowell <craigdo@ee.washington.edu>
parents:
6245
diff
changeset
|
111 |
if (getcwd (pathbuf, sizeof(pathbuf)) == NULL) |
3ccf4cea2480
break down and check return values
Craig Dowell <craigdo@ee.washington.edu>
parents:
6245
diff
changeset
|
112 |
{ |
3ccf4cea2480
break down and check return values
Craig Dowell <craigdo@ee.washington.edu>
parents:
6245
diff
changeset
|
113 |
NS_ABORT_MSG ("Basedir(): unable to getcwd()"); |
3ccf4cea2480
break down and check return values
Craig Dowell <craigdo@ee.washington.edu>
parents:
6245
diff
changeset
|
114 |
} |
6194
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
115 |
|
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
116 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
117 |
// Walk up the directory tree looking for a directory that has files that |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
118 |
// indicate it is the base of an ns-3 distribution. We use VERSION and |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
119 |
// LICENSE which have been there from the beginning of time. |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
120 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
121 |
for (;;) |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
122 |
{ |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
123 |
bool haveVersion = false; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
124 |
bool haveLicense = false; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
125 |
|
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
126 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
127 |
// Open the directory file for the current directory and loop through |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
128 |
// the directory entries. |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
129 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
130 |
DIR *dp = opendir (pathbuf); |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
131 |
if (dp != NULL) |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
132 |
{ |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
133 |
while (struct dirent *de = readdir (dp)) |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
134 |
{ |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
135 |
if (strcmp (de->d_name, "VERSION") == 0) |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
136 |
{ |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
137 |
haveVersion = true; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
138 |
} |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
139 |
|
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
140 |
if (strcmp (de->d_name, "LICENSE") == 0) |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
141 |
{ |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
142 |
haveLicense = true; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
143 |
} |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
144 |
} |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
145 |
} |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
146 |
|
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
147 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
148 |
// If there's a file named VERSION and a file named LICENSE in this |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
149 |
// directory, we assume it's our base directory. |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
150 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
151 |
if (haveVersion && haveLicense) |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
152 |
{ |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
153 |
return pathbuf; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
154 |
} |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
155 |
|
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
156 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
157 |
// Strip off the last segment of the current directory. |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
158 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
159 |
char *last = strrchr (pathbuf, '/'); |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
160 |
NS_ASSERT_MSG (last, "No \"/\" found in absolute path ???"); |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
161 |
*last = '\0'; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
162 |
|
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
163 |
if (strlen(pathbuf) == 0) |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
164 |
{ |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
165 |
return ""; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
166 |
} |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
167 |
} |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
168 |
|
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
169 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
170 |
// Quiet the compiler. |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
171 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
172 |
return ""; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
173 |
} |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
174 |
|
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
175 |
// |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
176 |
// 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
|
177 |
// "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
|
178 |
// error occurred. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
179 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
180 |
int |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
181 |
main (int argc, char *argv[]) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
182 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
183 |
bool doVerbose = false; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
184 |
bool doList = false; |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5297
diff
changeset
|
185 |
bool doMultiple = false; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
186 |
bool doHelp = false; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
187 |
bool doSuite = false; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
188 |
bool doKinds = false; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
189 |
|
6204
db1a9442b29f
enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
6194
diff
changeset
|
190 |
gBreakOnFailure = false; |
db1a9442b29f
enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
6194
diff
changeset
|
191 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
192 |
bool haveBasedir = false; |
5481
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5369
diff
changeset
|
193 |
bool haveTempdir = false; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
194 |
bool haveOutfile = false; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
195 |
bool haveType = false; |
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 |
std::string suiteName; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
198 |
std::string basedir; |
5481
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5369
diff
changeset
|
199 |
std::string tempdir; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
200 |
std::string outfileName; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
201 |
std::string typeName; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
202 |
|
6204
db1a9442b29f
enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
6194
diff
changeset
|
203 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
204 |
for (int i = 1; i < argc; ++i) |
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 |
std::string arg(argv[i]); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
207 |
|
6204
db1a9442b29f
enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
6194
diff
changeset
|
208 |
if (arg.find ("--assert") != std::string::npos) |
db1a9442b29f
enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
6194
diff
changeset
|
209 |
{ |
db1a9442b29f
enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
6194
diff
changeset
|
210 |
gBreakOnFailure = true; |
db1a9442b29f
enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
6194
diff
changeset
|
211 |
} |
db1a9442b29f
enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
6194
diff
changeset
|
212 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
213 |
if (arg.find ("--basedir=") != std::string::npos) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
214 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
215 |
basedir = arg.substr (arg.find_first_of ("=") + 1, 9999); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
216 |
haveBasedir = true; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
217 |
} |
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 |
if (arg.find ("--constrain=") != std::string::npos) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
220 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
221 |
typeName = arg.substr (arg.find_first_of ("=") + 1, 9999); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
222 |
haveType = true; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
223 |
} |
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 |
if (arg.compare ("--help") == 0) |
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 |
doHelp = true; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
228 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
229 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
230 |
if (arg.compare ("--kinds") == 0) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
231 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
232 |
doKinds = true; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
233 |
} |
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 |
if (arg.compare ("--list") == 0) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
236 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
237 |
doList = true; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
238 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
239 |
|
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5297
diff
changeset
|
240 |
if (arg.compare ("--multiple") == 0) |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5297
diff
changeset
|
241 |
{ |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5297
diff
changeset
|
242 |
doMultiple = true; |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5297
diff
changeset
|
243 |
} |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5297
diff
changeset
|
244 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
245 |
if (arg.find ("--out=") != std::string::npos) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
246 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
247 |
outfileName = arg.substr (arg.find_first_of ("=") + 1, 9999); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
248 |
haveOutfile = true; |
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 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
251 |
if (arg.find ("--suite=") != std::string::npos) |
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 |
suiteName = arg.substr (arg.find_first_of ("=") + 1, 9999); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
254 |
doSuite = true; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
255 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
256 |
|
5481
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5369
diff
changeset
|
257 |
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
|
258 |
{ |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5369
diff
changeset
|
259 |
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
|
260 |
haveTempdir = true; |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5369
diff
changeset
|
261 |
} |
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5369
diff
changeset
|
262 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
263 |
if (arg.compare ("--verbose") == 0) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
264 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
265 |
doVerbose = true; |
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 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
269 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
270 |
// 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
|
271 |
// and leave. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
272 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
273 |
if (doHelp) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
274 |
{ |
6204
db1a9442b29f
enable debugger breaks in test-runner and document changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
6194
diff
changeset
|
275 |
std::cout << " --assert: Tell tests to segfault (like assert) if an error is detected" << std::endl; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
276 |
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
|
277 |
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
|
278 |
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
|
279 |
std::cout << " --help: Print this message" << std::endl; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
280 |
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
|
281 |
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
|
282 |
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
|
283 |
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
|
284 |
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
|
285 |
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
|
286 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
287 |
return false; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
288 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
289 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
290 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
291 |
// 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
|
292 |
// print the list of types and leave. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
293 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
294 |
if (doKinds) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
295 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
296 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
297 |
// 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
|
298 |
// 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
|
299 |
// enum defined in test.h converted to lower case. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
300 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
301 |
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
|
302 |
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
|
303 |
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
|
304 |
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
|
305 |
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
|
306 |
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
|
307 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
308 |
return false; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
309 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
310 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
311 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
312 |
// 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
|
313 |
// 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
|
314 |
// 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
|
315 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
316 |
if (doList) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
317 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
318 |
for (uint32_t i = 0; i < TestRunner::GetNTestSuites (); ++i) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
319 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
320 |
TestSuite *suite = TestRunner::GetTestSuite (i); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
321 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
322 |
// |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
5324
diff
changeset
|
323 |
// 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
|
324 |
// "core" means any TestSuite. |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
325 |
// |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
5324
diff
changeset
|
326 |
if (haveType && typeName != "core") |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
327 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
328 |
TestSuite::TestType type = suite->GetTestType (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
329 |
if (typeName == "bvt" && type != TestSuite::BVT) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
330 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
331 |
continue; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
332 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
333 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
334 |
if (typeName == "unit" && type != TestSuite::UNIT) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
335 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
336 |
continue; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
337 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
338 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
339 |
if (typeName == "system" && type != TestSuite::SYSTEM) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
340 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
341 |
continue; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
342 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
343 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
344 |
if (typeName == "example" && type != TestSuite::EXAMPLE) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
345 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
346 |
continue; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
347 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
348 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
349 |
if (typeName == "performance" && type != TestSuite::PERFORMANCE) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
350 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
351 |
continue; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
352 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
353 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
354 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
355 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
356 |
// 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
|
357 |
// 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
|
358 |
// typically launch individual tests in parallel, calling back here |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
359 |
// with a specific "suite=" to run. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
360 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
361 |
std::cout << suite->GetName () << std::endl; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
362 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
363 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
364 |
return false; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
365 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
366 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
367 |
// |
6194
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
368 |
// We have a lot of options possible to provide flexibility. It can become |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
369 |
// painful, however, to provide all of the options when debugging, and it |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
370 |
// turns out that not all tests require all options. It is really helpful |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
371 |
// to try and put together some reasonable defaults if we're not provided |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
372 |
// them. |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
373 |
// |
6194
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
374 |
if (!haveTempdir) |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
375 |
{ |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
376 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
377 |
// No temporary directory was provided. We don't know if the selected |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
378 |
// test or tests will need one, but we can cook something up. The |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
379 |
// tmpnam function has its own set of problems, so we'll just do our |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
380 |
// own thing. |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
381 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
382 |
tempdir = TempDir (); |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
383 |
if (tempdir.size ()) |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
384 |
{ |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
385 |
std::cout << "Temporary directory not provided. Using \"" << tempdir << "\"" << std::endl; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
386 |
haveTempdir = true; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
387 |
} |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
388 |
else |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
389 |
{ |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
390 |
std::cout << "Temporary directory not provided and unable to create one." << std::endl; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
391 |
return true; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
392 |
} |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
393 |
} |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
394 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
395 |
if (haveBasedir == false) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
396 |
{ |
6194
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
397 |
// |
6228
4a2c9eaedb7f
tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents:
6204
diff
changeset
|
398 |
// No basedir was provided. If we don't have it, we can try and find it |
4a2c9eaedb7f
tom wanted to prefix the test-runner tmp file with ns-3
Craig Dowell <craigdo@ee.washington.edu>
parents:
6204
diff
changeset
|
399 |
// in the current directory tree. |
6194
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
400 |
// |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
401 |
basedir = BaseDir (); |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
402 |
if (basedir.size ()) |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
403 |
{ |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
404 |
std::cout << "Base directory not provided. Using \"" << basedir << "\"" << std::endl; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
405 |
haveBasedir = true; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
406 |
} |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
407 |
else |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
408 |
{ |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
409 |
std::cout << "Base directory not provided and unable to find one." << std::endl; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
410 |
return true; |
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
411 |
} |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
412 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
413 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
414 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
415 |
// 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
|
416 |
// 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
|
417 |
// 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
|
418 |
// 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
|
419 |
// 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
|
420 |
// 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
|
421 |
// given by the test. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
422 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
423 |
std::ofstream *pofs = 0; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
424 |
std::ofstream ofs; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
425 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
426 |
if (!outfileName.empty ()) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
427 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
428 |
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
|
429 |
pofs = &ofs; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
430 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
431 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
432 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
433 |
// 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
|
434 |
// 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
|
435 |
// 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
|
436 |
// but we'll do it if asked. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
437 |
// |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
438 |
bool result = false; |
5297
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
439 |
bool suiteRan = false; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
440 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
441 |
for (uint32_t i = 0; i < TestRunner::GetNTestSuites (); ++i) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
442 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
443 |
TestSuite *testSuite = TestRunner::GetTestSuite (i); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
444 |
if (doSuite == false || (doSuite == true && suiteName == testSuite->GetName ())) |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
445 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
446 |
testSuite->SetBaseDir (basedir); |
5481
de01c67af975
pass explicit temp directory to test suites
Craig Dowell <craigdo@ee.washington.edu>
parents:
5369
diff
changeset
|
447 |
testSuite->SetTempDir (tempdir); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
448 |
testSuite->SetStream (pofs); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
449 |
testSuite->SetVerbose (doVerbose); |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5297
diff
changeset
|
450 |
testSuite->SetContinueOnFailure (doMultiple); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
451 |
result |= testSuite->Run (); |
5297
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
452 |
suiteRan = true; |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
453 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
454 |
} |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
455 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
456 |
ofs.close(); |
5297
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
457 |
|
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
458 |
// |
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
459 |
// 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
|
460 |
// |
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
461 |
if (suiteRan == false) |
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
462 |
{ |
6194
5f8e99c4c456
make life easier for folks running test-runner directly
Craig Dowell <craigdo@ee.washington.edu>
parents:
5780
diff
changeset
|
463 |
std::cout << "Unable to find a test to run (constraints too severe or test not found)" << std::endl; |
5297
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
464 |
return true; |
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
465 |
} |
a7f197a2410b
If test suite not found, return failure
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
466 |
|
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
467 |
return result; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
468 |
} |