1// Copyright 2018 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5library fuchsia.device.test;
6
7using zx;
8
9/// The path which can be used to open the control device
10const string CONTROL_DEVICE = "/dev/test/test";
11
12/// Returns the result summary of a test run
13struct TestReport {
14    /// Total number of tests
15    uint32 test_count;
16    /// Number of successful tests
17    uint32 success_count;
18    /// Number of failed tests
19    uint32 failure_count;
20};
21
22/// Interface for controlling a device created via RootDevice.CreateDevice
23[Layout = "Simple"]
24interface Device {
25    /// Set a socket to stream test output to.
26    SetOutputSocket(handle<socket> sock);
27
28    /// Set a channel for the test to use in a test-specific manner.
29    SetChannel(handle<channel> chan);
30
31    /// Execute the tests for this device.  Test output will be streamed to
32    /// the socket set by SetOutputSocket().  Returns the status from the test.
33    RunTests() -> (zx.status status, TestReport report);
34    /// Unload this device.
35    Destroy();
36};
37
38/// Maximum device name len.  This value must match ZX_DEVICE_NAME_MAX.
39const uint32 MAX_DEVICE_NAME_LEN = 31;
40
41/// Maximum device path len
42const uint32 MAX_DEVICE_PATH_LEN = 1024;
43
44/// Interface for creating devices within a devhost.
45[Layout = "Simple"]
46interface RootDevice {
47    /// Create a device with the given |name| that is a child of this device.
48    /// If |name| contains a trailing ".so", it will be removed.
49    ///
50    /// On success, |path| will be the filesystem path of the new device.
51    CreateDevice(string:MAX_DEVICE_NAME_LEN name)
52                -> (zx.status status, string:MAX_DEVICE_PATH_LEN? path);
53};
54