/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
syntax = "proto3";

import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";
import "tools/tradefederation/core/proto/metric_measurement.proto";

option java_package = "com.android.tradefed.result.proto";
option java_outer_classname = "TestRecordProto";

package android_test_record;

// A record containing the status, logs, and other information associated with a
// particular test execution.
message TestRecord {
  // The UUID of this TestRecord.
  string test_record_id = 1;

  // The UUID of this TestRecord's parent. Unset if this is a top-level record.
  string parent_test_record_id = 2;

  // References to any finer-grained TestRecords that were generated as part of
  // this test.
  repeated ChildReference children = 3;

  // The number of children this TestRecord was expected to have. Unset if not
  // known in advance.
  int64 num_expected_children = 4;

  // The result status (Pass, Fail, etc) of this test unit.
  TestStatus status = 5;

  // Extra debugging information.
  DebugInfo debug_info = 6;

  // The time at which this test started executing.
  google.protobuf.Timestamp start_time = 7;

  // The time at which this test finished executing.
  google.protobuf.Timestamp end_time = 8;

  // Any artifact files associated with this test.
  map<string, google.protobuf.Any> artifacts = 9;

  // Any metrics or measurements associated with this test.
  map<string, tradefed.metric.Metric> metrics = 10;

  // Metadata describing the test that was run.
  google.protobuf.Any description = 11;

  // The attempt number of a target if the target ran several times. First
  // attempt is 0 (Default value).
  int64 attempt_id = 12;
}

// A reference to a finer-grained TestRecord.
message ChildReference {
  oneof reference {
    // The UUID of the TestRecord.
    string test_record_id = 1;

    // An inlined TestRecord.
    TestRecord inline_test_record = 2;
  }
}

// The overall pass / fail status for a particular TestRecord.
enum TestStatus {
  UNKNOWN = 0;
  PASS = 1;
  FAIL = 2;
  IGNORED = 3;
  ASSUMPTION_FAILURE = 4;
}

// Associated debugging information to accompany a TestStatus.
message DebugInfo {
  // An error message.
  string error_message = 1;

  // A stacktrace.
  string trace = 2;
}