123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- #ifndef TESTING_PERF_LUCI_TEST_RESULT_H_
- #define TESTING_PERF_LUCI_TEST_RESULT_H_
- #include <string>
- #include <vector>
- #include "base/containers/flat_map.h"
- #include "base/files/file_path.h"
- #include "base/macros.h"
- #include "base/optional.h"
- #include "base/time/time.h"
- namespace perf_test {
- class LuciTestResult {
- public:
-
- enum class Status {
-
- kUnspecified,
-
- kPass,
-
- kFail,
-
- kCrash,
-
- kAbort,
-
-
- kSkip
- };
-
- struct Artifact {
- Artifact();
- Artifact(const Artifact& other);
- Artifact(const base::FilePath file_path, const std::string& content_type);
- Artifact(const std::string& contents, const std::string& content_type);
- ~Artifact();
-
-
- base::Optional<base::FilePath> file_path;
-
- base::Optional<std::string> contents;
- std::string content_type;
- };
-
- struct Tag {
- std::string key;
- std::string value;
- };
- LuciTestResult();
- LuciTestResult(const LuciTestResult& other);
- LuciTestResult(LuciTestResult&& other);
- ~LuciTestResult();
-
- static LuciTestResult CreateForGTest();
-
-
-
- void AddVariant(const std::string& key, const std::string& value);
-
- void AddOutputArtifactFile(const std::string& artifact_name,
- const base::FilePath& file_path,
- const std::string& content_type);
- void AddOutputArtifactContents(const std::string& artifact_name,
- const std::string& contents,
- const std::string& content_type);
-
- void AddTag(const std::string& key, const std::string& value);
-
- void WriteToFile(const base::FilePath& result_file) const;
-
- const std::string& test_path() const { return test_path_; }
- void set_test_path(const std::string& test_path) { test_path_ = test_path; }
- const base::flat_map<std::string, std::string>& extra_variant_pairs() const {
- return extra_variant_pairs_;
- }
- Status status() const { return status_; }
- void set_status(Status status) { status_ = status; }
- bool is_expected() const { return is_expected_; }
- void set_is_expected(bool is_expcted) { is_expected_ = is_expcted; }
- base::Time start_time() const { return start_time_; }
- void set_start_time(base::Time start_time) { start_time_ = start_time; }
- base::TimeDelta duration() const { return duration_; }
- void set_duration(base::TimeDelta duration) { duration_ = duration; }
- const base::flat_map<std::string, Artifact>& output_artifacts() const {
- return output_artifacts_;
- }
- const std::vector<Tag>& tags() const { return tags_; }
- private:
-
-
-
- std::string test_path_;
-
-
- base::flat_map<std::string, std::string> extra_variant_pairs_;
-
- Status status_ = Status::kUnspecified;
-
- bool is_expected_ = false;
-
- base::Time start_time_;
-
- base::TimeDelta duration_;
-
- base::flat_map<std::string, Artifact> output_artifacts_;
-
- std::vector<Tag> tags_;
- };
- }
- #endif // TESTING_PERF_LUCI_TEST_RESULT_H_
|