blob: 5f24a2476f93afafae1923ad43b275c689fafe2d [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
11#include <base/logging.h>
Stimim Chendfc191a2020-04-14 17:38:16 +080012#include <base/files/file_util.h>
13#include <google/protobuf/text_format.h>
14#include <gtest/gtest.h>
15
16#include "hardware_verifier/hardware_verifier.pb.h"
Yong Hongf4872de2019-01-30 19:04:18 +080017
18namespace hardware_verifier {
19
20base::FilePath GetTestDataPath() {
21 char* src_env = std::getenv("SRC");
22 CHECK_NE(src_env, nullptr)
23 << "Expect to have the envvar |SRC| set when testing.";
24 return base::FilePath(src_env).Append("testdata");
25}
26
Stimim Chendfc191a2020-04-14 17:38:16 +080027HwVerificationReport LoadHwVerificationReport(const base::FilePath& file_path) {
28 std::string content;
29 EXPECT_TRUE(base::ReadFileToString(file_path, &content));
30
31 HwVerificationReport ret;
32 EXPECT_TRUE(google::protobuf::TextFormat::ParseFromString(content, &ret));
33 return ret;
34}
35
Yong Hongf4872de2019-01-30 19:04:18 +080036} // namespace hardware_verifier