aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/test/test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/test/test.cpp')
-rw-r--r--linden/indra/test/test.cpp87
1 files changed, 69 insertions, 18 deletions
diff --git a/linden/indra/test/test.cpp b/linden/indra/test/test.cpp
index df4b037..91b1b22 100644
--- a/linden/indra/test/test.cpp
+++ b/linden/indra/test/test.cpp
@@ -43,8 +43,8 @@
43#include "llerrorcontrol.h" 43#include "llerrorcontrol.h"
44#include "lltut.h" 44#include "lltut.h"
45 45
46#include <apr-1/apr_pools.h> 46#include "apr_pools.h"
47#include <apr-1/apr_getopt.h> 47#include "apr_getopt.h"
48 48
49// the CTYPE_WORKAROUND is needed for linux dev stations that don't 49// the CTYPE_WORKAROUND is needed for linux dev stations that don't
50// have the broken libc6 packages needed by our out-of-date static 50// have the broken libc6 packages needed by our out-of-date static
@@ -62,13 +62,14 @@ namespace tut
62class LLTestCallback : public tut::callback 62class LLTestCallback : public tut::callback
63{ 63{
64public: 64public:
65 LLTestCallback(bool verbose_mode) : 65 LLTestCallback(bool verbose_mode, std::ostream *stream) :
66 mVerboseMode(verbose_mode), 66 mVerboseMode(verbose_mode),
67 mTotalTests(0), 67 mTotalTests(0),
68 mPassedTests(0), 68 mPassedTests(0),
69 mFailedTests(0), 69 mFailedTests(0),
70 mSkippedTests(0), 70 mSkippedTests(0),
71 mSkipedFailTests(0) 71 mSkippedFailTests(0),
72 mStream(stream)
72 { 73 {
73 } 74 }
74 75
@@ -109,7 +110,7 @@ public:
109 out << "skipped"; 110 out << "skipped";
110 break; 111 break;
111 case tut::test_result::skip_fail: 112 case tut::test_result::skip_fail:
112 ++mSkipedFailTests; 113 ++mSkippedFailTests;
113 out << "skipped known failure"; 114 out << "skipped known failure";
114 break; 115 break;
115 default: 116 default:
@@ -122,34 +123,57 @@ public:
122 { 123 {
123 out << ": '" << tr.message << "'"; 124 out << ": '" << tr.message << "'";
124 } 125 }
126 if (mStream)
127 {
128 *mStream << out.str() << std::endl;
129 }
130
125 std::cout << out.str() << std::endl; 131 std::cout << out.str() << std::endl;
126 } 132 }
127 } 133 }
128 134
129 void run_completed() 135 void run_completed()
130 { 136 {
131 std::cout << std::endl; 137 if (mStream)
132 std::cout << "Total Tests: " << mTotalTests << std::endl; 138 {
133 std::cout << "Passed Tests: " << mPassedTests << std::endl; 139 run_completed_(*mStream);
140 }
141 run_completed_(std::cout);
142
143 if (mFailedTests > 0)
144 {
145 exit(1);
146 }
147 }
148
149private:
150 void run_completed_(std::ostream &stream)
151 {
152 stream << std::endl;
153 stream << "Total Tests: " << mTotalTests << std::endl;
154 stream << "Passed Tests: " << mPassedTests << std::endl;
155
156 stream << std::endl;
157 stream << "Total Tests: " << mTotalTests << std::endl;
158 stream << "Passed Tests: " << mPassedTests << std::endl;
134 159
135 if (mSkippedTests > 0) 160 if (mSkippedTests > 0)
136 { 161 {
137 std::cout << "Skipped Tests: " << mSkippedTests << std::endl; 162 stream << "Skipped Tests: " << mSkippedTests << std::endl;
138 } 163 }
139 164
140 if (mSkipedFailTests > 0) 165 if (mSkippedFailTests > 0)
141 { 166 {
142 std::cout << "Skipped known failures: " << mSkipedFailTests 167 stream << "Skipped known failures: " << mSkippedFailTests
143 << std::endl; 168 << std::endl;
144 } 169 }
145 170
146 if(mFailedTests > 0) 171 if(mFailedTests > 0)
147 { 172 {
148 std::cout << "*********************************" << std::endl; 173 stream << "*********************************" << std::endl;
149 std::cout << "Failed Tests: " << mFailedTests << std::endl; 174 stream << "Failed Tests: " << mFailedTests << std::endl;
150 std::cout << "Please report or fix the problem." << std::endl; 175 stream << "Please report or fix the problem." << std::endl;
151 std::cout << "*********************************" << std::endl; 176 stream << "*********************************" << std::endl;
152 exit(1);
153 } 177 }
154 } 178 }
155 179
@@ -159,7 +183,8 @@ protected:
159 int mPassedTests; 183 int mPassedTests;
160 int mFailedTests; 184 int mFailedTests;
161 int mSkippedTests; 185 int mSkippedTests;
162 int mSkipedFailTests; 186 int mSkippedFailTests;
187 std::ostream *mStream;
163}; 188};
164 189
165static const apr_getopt_option_t TEST_CL_OPTIONS[] = 190static const apr_getopt_option_t TEST_CL_OPTIONS[] =
@@ -168,7 +193,9 @@ static const apr_getopt_option_t TEST_CL_OPTIONS[] =
168 {"list", 'l', 0, "List available test groups."}, 193 {"list", 'l', 0, "List available test groups."},
169 {"verbose", 'v', 0, "Verbose output."}, 194 {"verbose", 'v', 0, "Verbose output."},
170 {"group", 'g', 1, "Run test group specified by option argument."}, 195 {"group", 'g', 1, "Run test group specified by option argument."},
196 {"output", 'o', 1, "Write output to the named file."},
171 {"skip", 's', 1, "Skip test number specified by option argument. Only works when a specific group is being tested"}, 197 {"skip", 's', 1, "Skip test number specified by option argument. Only works when a specific group is being tested"},
198 {"touch", 't', 1, "Touch the given file if all tests succeed"},
172 {"wait", 'w', 0, "Wait for input before exit."}, 199 {"wait", 'w', 0, "Wait for input before exit."},
173 {"debug", 'd', 0, "Emit full debug logs."}, 200 {"debug", 'd', 0, "Emit full debug logs."},
174 {0, 0, 0, 0} 201 {0, 0, 0, 0}
@@ -256,6 +283,9 @@ int main(int argc, char **argv)
256 apr_status_t apr_err; 283 apr_status_t apr_err;
257 const char* opt_arg = NULL; 284 const char* opt_arg = NULL;
258 int opt_id = 0; 285 int opt_id = 0;
286 std::ofstream *output = NULL;
287 const char *touch = NULL;
288
259 while(true) 289 while(true)
260 { 290 {
261 apr_err = apr_getopt_long(os, TEST_CL_OPTIONS, &opt_id, &opt_arg); 291 apr_err = apr_getopt_long(os, TEST_CL_OPTIONS, &opt_id, &opt_arg);
@@ -285,6 +315,13 @@ int main(int argc, char **argv)
285 case 'v': 315 case 'v':
286 verbose_mode = true; 316 verbose_mode = true;
287 break; 317 break;
318 case 'o':
319 output = new std::ofstream;
320 output->open(opt_arg);
321 break;
322 case 't':
323 touch = opt_arg;
324 break;
288 case 'w': 325 case 'w':
289 wait_at_exit = true; 326 wait_at_exit = true;
290 break; 327 break;
@@ -301,7 +338,7 @@ int main(int argc, char **argv)
301 } 338 }
302 339
303 // run the tests 340 // run the tests
304 LLTestCallback callback(verbose_mode); 341 LLTestCallback callback(verbose_mode, output);
305 tut::runner.get().set_callback(&callback); 342 tut::runner.get().set_callback(&callback);
306 343
307 if(test_group.empty()) 344 if(test_group.empty())
@@ -319,6 +356,20 @@ int main(int argc, char **argv)
319 std::cin.get(); 356 std::cin.get();
320 } 357 }
321 358
359 if (output)
360 {
361 output->close();
362 delete output;
363 }
364
365 if (touch)
366 {
367 std::ofstream s;
368 s.open(touch);
369 s << "ok" << std::endl;
370 s.close();
371 }
372
322 apr_terminate(); 373 apr_terminate();
323 return 0; 374 return 0;
324} 375}