| // 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. |
| library fuchsia.device.test; |
| |
| using zx; |
| |
| /// The path which can be used to open the control device. |
| /// This path is relative to /dev/. |
| const CONTROL_DEVICE string = "sys/test/test"; |
| |
| /// Returns the result summary of a test run |
| type TestReport = struct { |
| /// Total number of tests |
| test_count uint32; |
| /// Number of successful tests |
| success_count uint32; |
| /// Number of failed tests |
| failure_count uint32; |
| }; |
| |
| closed protocol Test { |
| /// Execute the tests for this device. Returns the status from the test. If |
| /// used as part of the Device protocol then Test output will be streamed to |
| /// the socket set by SetOutputSocket(). |
| strict RunTests() -> (struct { |
| status zx.Status; |
| report TestReport; |
| }); |
| }; |
| |
| /// Interface for controlling a device created via RootDevice.CreateDevice |
| closed protocol Device { |
| compose Test; |
| |
| /// Set a socket to stream test output to. |
| strict SetOutputSocket(resource struct { |
| sock zx.Handle:SOCKET; |
| }); |
| |
| /// Set a channel for the test to use in a test-specific manner. |
| strict SetChannel(resource struct { |
| chan zx.Handle:CHANNEL; |
| }); |
| |
| /// Unload this device. |
| strict Destroy(); |
| }; |
| |
| /// Maximum device name len. This value must match `ZX_DEVICE_NAME_MAX`. |
| const MAX_DEVICE_NAME_LEN uint32 = 31; |
| |
| /// Interface for creating devices within a devhost. |
| closed protocol RootDevice { |
| /// Create a device with the given `name` that is a child of this device. |
| strict CreateDevice(resource struct { |
| name string:MAX_DEVICE_NAME_LEN; |
| }) -> () error zx.Status; |
| }; |