forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_runner.h
37 lines (30 loc) · 1.26 KB
/
test_runner.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "common/common/logger.h"
#include "common/common/thread.h"
#include "common/event/libevent.h"
#include "test/test_common/environment.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace Envoy {
class TestRunner {
public:
static int RunTests(int argc, char** argv) {
::testing::InitGoogleMock(&argc, argv);
Event::Libevent::Global::initialize();
// Set gtest properties
// (https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md#logging-additional-information),
// they are available in the test XML.
// TODO(htuch): Log these as well?
::testing::Test::RecordProperty("TemporaryDirectory", TestEnvironment::temporaryDirectory());
::testing::Test::RecordProperty("RunfilesDirectory", TestEnvironment::runfilesDirectory());
if (::setenv("TEST_UDSDIR", TestEnvironment::unixDomainSocketDirectory().c_str(), 1) != 0) {
::perror("Failed to set temporary UDS directory.");
::exit(1);
}
TestEnvironment::initializeOptions(argc, argv);
Thread::MutexBasicLockable lock;
Logger::Registry::initialize(TestEnvironment::getOptions().logLevel(),
TestEnvironment::getOptions().logFormat(), lock);
return RUN_ALL_TESTS();
}
};
} // namespace Envoy