| // Copyright 2018 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| package testexec |
| |
| import ( |
| "fmt" |
| ) |
| |
| // TestDevicePlatforms is a wrapper type for a set of platforms used for validation of a |
| // TestSuiteSpec and its internal structures. |
| type TestDevicePlatforms []TestDevicePlatform |
| |
| // Get retrieves a platform by name. |
| func (t TestDevicePlatforms) Get(name string) (*TestDevicePlatform, bool) { |
| for _, platform := range t { |
| if name == platform.Name { |
| return &platform, true |
| } |
| } |
| return nil, false |
| } |
| |
| // Validate validates a given TestDevicePlatforms. |
| func (t TestDevicePlatforms) Validate() error { |
| names := map[string]struct{}{} |
| for _, platform := range t { |
| if _, ok := names[platform.Name]; ok { |
| return fmt.Errorf("found duplicate platform %q", platform.Name) |
| } |
| names[platform.Name] = struct{}{} |
| } |
| return nil |
| } |
| |
| // TestDevicePlatform represents a valid platform used for validation of a TestSuiteSpec and its |
| // internal structures. |
| type TestDevicePlatform struct { |
| // Name is the name of the test device platform. |
| Name string `json:"name"` |
| |
| // Arch is the CPU architecture of the test platform. |
| // The value "*" is used as a catch-all for architectures. |
| Arch string `json:"arch"` |
| } |