|  | // 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 | 
|  | const CONTROL_DEVICE string = "/dev/sys/test/test"; | 
|  |  | 
|  | /// Returns the result summary of a test run | 
|  | @for_deprecated_c_bindings | 
|  | type TestReport = struct { | 
|  | /// Total number of tests | 
|  | test_count uint32; | 
|  | /// Number of successful tests | 
|  | success_count uint32; | 
|  | /// Number of failed tests | 
|  | failure_count uint32; | 
|  | }; | 
|  |  | 
|  | @for_deprecated_c_bindings | 
|  | 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(). | 
|  | RunTests() -> (struct { | 
|  | status zx.status; | 
|  | report TestReport; | 
|  | }); | 
|  | }; | 
|  |  | 
|  | /// Interface for controlling a device created via RootDevice.CreateDevice | 
|  | @for_deprecated_c_bindings | 
|  | protocol Device { | 
|  | compose Test; | 
|  |  | 
|  | /// Set a socket to stream test output to. | 
|  | SetOutputSocket(resource struct { | 
|  | sock zx.handle:SOCKET; | 
|  | }); | 
|  |  | 
|  | /// Set a channel for the test to use in a test-specific manner. | 
|  | SetChannel(resource struct { | 
|  | chan zx.handle:CHANNEL; | 
|  | }); | 
|  |  | 
|  | /// Unload this device. | 
|  | Destroy(); | 
|  | }; | 
|  |  | 
|  | /// Maximum device name len.  This value must match `ZX_DEVICE_NAME_MAX`. | 
|  | const MAX_DEVICE_NAME_LEN uint32 = 31; | 
|  |  | 
|  | /// Maximum device path len | 
|  | const MAX_DEVICE_PATH_LEN uint32 = 1024; | 
|  |  | 
|  | /// Interface for creating devices within a devhost. | 
|  | @for_deprecated_c_bindings | 
|  | protocol RootDevice { | 
|  | /// Create a device with the given `name` that is a child of this device. | 
|  | /// If `name` contains a trailing ".so", it will be removed. | 
|  | /// | 
|  | /// If `device_request` is given, it is connected to the newly created device. | 
|  | /// | 
|  | /// On success, `path` will be the filesystem path of the new device. | 
|  | CreateDevice(resource struct { | 
|  | name string:MAX_DEVICE_NAME_LEN; | 
|  | device_request zx.handle:<CHANNEL, optional>; | 
|  | }) -> (struct { | 
|  | status zx.status; | 
|  | path string:<MAX_DEVICE_PATH_LEN, optional>; | 
|  | }); | 
|  | }; |