// Copyright 2019 The Pigweed Authors
//
// 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
//
//     https://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";

package pw.target_runner;

option go_package = "pigweed/proto/pw_target_runner/target_runner_pb";

service TargetRunner {
  // Queues a single executable, blocking until it has run.
  rpc RunBinary(RunBinaryRequest) returns (RunBinaryResponse) {}

  // Returns information about the server.
  rpc Status(Empty) returns (ServerStatus) {}
}

message Empty {}

enum RunStatus {
  PENDING = 0;
  SUCCESS = 1;
  FAILURE = 2;
  SKIPPED = 3;
}

message RunBinaryRequest {
  oneof binary {
    // Local file path to the binary.
    string file_path = 1;
    // The executable test file to run.
    bytes test_binary = 2;
  }
}

message RunBinaryResponse {
  RunStatus result = 1;
  uint64 queue_time_ns = 2;
  uint64 run_time_ns = 3;
  bytes output = 4;
}

message ServerStatus {
  uint64 uptime_ns = 1;
  uint32 tasks_queued = 2;
  uint32 tasks_passed = 3;
  uint32 tasks_failed = 4;
}
