Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "TestBase.h"
8 #include <sstream>
10 using namespace std;
12 int
13 TestBase::RunTests(int *aFailures)
14 {
15 int testsRun = 0;
16 *aFailures = 0;
18 for(unsigned int i = 0; i < mTests.size(); i++) {
19 stringstream stream;
20 stream << "Test (" << mTests[i].name << "): ";
21 LogMessage(stream.str());
22 stream.str("");
24 mTestFailed = false;
26 // Don't try this at home! We know these are actually pointers to members
27 // of child clases, so we reinterpret cast those child class pointers to
28 // TestBase and then call the functions. Because the compiler believes
29 // these function calls are members of TestBase.
30 ((*reinterpret_cast<TestBase*>((mTests[i].implPointer))).*(mTests[i].funcCall))();
32 if (!mTestFailed) {
33 LogMessage("PASSED\n");
34 } else {
35 LogMessage("FAILED\n");
36 (*aFailures)++;
37 }
38 testsRun++;
39 }
41 return testsRun;
42 }
44 void
45 TestBase::LogMessage(string aMessage)
46 {
47 printf("%s", aMessage.c_str());
48 }