1# Copyright 2019 Oticon A/S
2# SPDX-License-Identifier: Apache-2.0
3
4from components.basic_commands import echo;
5from components.test_spec import TestSpec;
6
7def _echo_test(transport, trace):
8    trace.trace(3, "Starting echo test");
9
10    try:
11        for i in range(0,transport.n_devices):
12            echo(transport, i, str.encode("A random test string"), 100);
13    except Exception as e:
14        trace.trace(1,"Echo test failed: %s"%str(e));
15        return 1;
16
17    trace.trace(3,"Echo test passed with %i device(s)"% transport.n_devices);
18    return 0;
19
20_spec = {};
21_spec["Echo_test"] = \
22    TestSpec(name = "Echo_test",
23             number_devices = 1,
24             description = "Test that we can echo to any connected device",
25             test_private = _echo_test);
26
27"""
28    Return the test spec which contains info about all the tests
29    this test module provides
30"""
31def get_tests_specs():
32    return _spec;
33
34"""
35    Run a test given its test_spec
36"""
37def run_a_test(args, transport, trace, test_spec):
38    return test_spec.test_private(transport, trace);
39