blob: 274f13c40dd1412b4d7df98312f9a5c996bc8665 [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>
Stimim Chen464418f2020-04-20 10:37:08 +08009#include <string>
Yong Hongf4872de2019-01-30 19:04:18 +080010
Qijiang Fan713061e2021-03-08 15:45:12 +090011#include <base/check_op.h>
Yong Hongf4872de2019-01-30 19:04:18 +080012#include <base/logging.h>
Stimim Chendfc191a2020-04-14 17:38:16 +080013#include <base/files/file_util.h>
14#include <google/protobuf/text_format.h>
15#include <gtest/gtest.h>
16
17#include "hardware_verifier/hardware_verifier.pb.h"
Yong Hongf4872de2019-01-30 19:04:18 +080018
19namespace hardware_verifier {
20
21base::FilePath GetTestDataPath() {
22 char* src_env = std::getenv("SRC");
23 CHECK_NE(src_env, nullptr)
24 << "Expect to have the envvar |SRC| set when testing.";
25 return base::FilePath(src_env).Append("testdata");
26}
27
Stimim Chendfc191a2020-04-14 17:38:16 +080028HwVerificationReport LoadHwVerificationReport(const base::FilePath& file_path) {
29 std::string content;
30 EXPECT_TRUE(base::ReadFileToString(file_path, &content));
31
32 HwVerificationReport ret;
33 EXPECT_TRUE(google::protobuf::TextFormat::ParseFromString(content, &ret));
34 return ret;
35}
36
Yong Hongf4872de2019-01-30 19:04:18 +080037} // namespace hardware_verifier