-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_utils.cc
36 lines (27 loc) · 1006 Bytes
/
test_utils.cc
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
/* Copyright 2019 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "hardware_verifier/test_utils.h"
#include <cstdlib>
#include <string>
#include <base/logging.h>
#include <base/files/file_util.h>
#include <google/protobuf/text_format.h>
#include <gtest/gtest.h>
#include "hardware_verifier/hardware_verifier.pb.h"
namespace hardware_verifier {
base::FilePath GetTestDataPath() {
char* src_env = std::getenv("SRC");
CHECK_NE(src_env, nullptr)
<< "Expect to have the envvar |SRC| set when testing.";
return base::FilePath(src_env).Append("testdata");
}
HwVerificationReport LoadHwVerificationReport(const base::FilePath& file_path) {
std::string content;
EXPECT_TRUE(base::ReadFileToString(file_path, &content));
HwVerificationReport ret;
EXPECT_TRUE(google::protobuf::TextFormat::ParseFromString(content, &ret));
return ret;
}
} // namespace hardware_verifier