1*1a96fba6SXin Li // Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2*1a96fba6SXin Li // Use of this source code is governed by a BSD-style license that can be
3*1a96fba6SXin Li // found in the LICENSE file.
4*1a96fba6SXin Li
5*1a96fba6SXin Li #ifndef LIBBRILLO_BRILLO_TEST_HELPERS_H_
6*1a96fba6SXin Li #define LIBBRILLO_BRILLO_TEST_HELPERS_H_
7*1a96fba6SXin Li
8*1a96fba6SXin Li #include "gtest/gtest.h"
9*1a96fba6SXin Li
10*1a96fba6SXin Li #include <string>
11*1a96fba6SXin Li
12*1a96fba6SXin Li #include <base/command_line.h>
13*1a96fba6SXin Li #include <base/files/file_path.h>
14*1a96fba6SXin Li #include <base/files/file_util.h>
15*1a96fba6SXin Li #include <base/logging.h>
16*1a96fba6SXin Li
17*1a96fba6SXin Li #include "brillo/syslog_logging.h"
18*1a96fba6SXin Li
ExpectFileEquals(const char * golden,const char * file_path)19*1a96fba6SXin Li inline void ExpectFileEquals(const char* golden, const char* file_path) {
20*1a96fba6SXin Li std::string contents;
21*1a96fba6SXin Li EXPECT_TRUE(base::ReadFileToString(base::FilePath(file_path), &contents));
22*1a96fba6SXin Li EXPECT_EQ(golden, contents);
23*1a96fba6SXin Li }
24*1a96fba6SXin Li
SetUpTests(int * argc,char ** argv,bool log_to_stderr)25*1a96fba6SXin Li inline void SetUpTests(int* argc, char** argv, bool log_to_stderr) {
26*1a96fba6SXin Li base::CommandLine::Init(*argc, argv);
27*1a96fba6SXin Li ::brillo::InitLog(log_to_stderr ? brillo::kLogToStderr : 0);
28*1a96fba6SXin Li ::brillo::LogToString(true);
29*1a96fba6SXin Li ::testing::InitGoogleTest(argc, argv);
30*1a96fba6SXin Li }
31*1a96fba6SXin Li
32*1a96fba6SXin Li #endif // LIBBRILLO_BRILLO_TEST_HELPERS_H_
33