blob: 78ce9e82abeb90f0025f104861d7300be588d5da [file] [log] [blame]
Yong Hongf4872de2019-01-30 19:04:18 +08001/* Copyright 2019 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5
6#include "hardware_verifier/test_utils.h"
7
8#include <cstdlib>
9
10#include <base/logging.h>
Stimim Chendfc191a2020-04-14 17:38:16 +080011#include <base/files/file_util.h>
12#include <google/protobuf/text_format.h>
13#include <gtest/gtest.h>
14
15#include "hardware_verifier/hardware_verifier.pb.h"
Yong Hongf4872de2019-01-30 19:04:18 +080016
17namespace hardware_verifier {
18
19base::FilePath GetTestDataPath() {
20 char* src_env = std::getenv("SRC");
21 CHECK_NE(src_env, nullptr)
22 << "Expect to have the envvar |SRC| set when testing.";
23 return base::FilePath(src_env).Append("testdata");
24}
25
Stimim Chendfc191a2020-04-14 17:38:16 +080026HwVerificationReport LoadHwVerificationReport(const base::FilePath& file_path) {
27 std::string content;
28 EXPECT_TRUE(base::ReadFileToString(file_path, &content));
29
30 HwVerificationReport ret;
31 EXPECT_TRUE(google::protobuf::TextFormat::ParseFromString(content, &ret));
32 return ret;
33}
34
Yong Hongf4872de2019-01-30 19:04:18 +080035} // namespace hardware_verifier