blob: 70e5ff7f3bbc9fa24ffc8ea0c347e360b98b693f [file] [log] [blame]
// Copyright 2020 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.
#ifndef CRASH_REPORTER_ANOMALY_DETECTOR_TEST_UTILS_H_
#define CRASH_REPORTER_ANOMALY_DETECTOR_TEST_UTILS_H_
#include <initializer_list>
#include <optional>
#include <string>
#include <vector>
#include <base/files/file_path.h>
namespace anomaly {
struct CrashReport;
class Parser;
struct ParserRun {
std::optional<std::string> find_this = std::nullopt;
std::optional<std::string> replace_with = std::nullopt;
std::optional<std::string> expected_text = std::nullopt;
std::optional<std::vector<std::string>> expected_flags = std::nullopt;
size_t expected_size = 1;
};
std::vector<CrashReport> ParseLogMessages(
Parser* parser, const std::vector<std::string>& log_msgs);
void ReplaceMsgContent(std::vector<std::string>* log_msgs,
const std::string& find_this,
const std::string& replace_with);
std::vector<std::string> GetTestLogMessages(base::FilePath input_file);
void ParserTest(const std::string& input_file_name,
std::initializer_list<ParserRun> parser_runs,
anomaly::Parser* parser);
template <class T>
void ParserTest(const std::string& input_file_name,
std::initializer_list<ParserRun> parser_runs) {
T parser;
ParserTest(input_file_name, parser_runs, &parser);
}
} // namespace anomaly
#endif // CRASH_REPORTER_ANOMALY_DETECTOR_TEST_UTILS_H_