xref: /aosp_15_r20/external/openthread/tools/harness-simulation/README.md (revision cfb92d1480a9e65faed56933e9c12405f45898b4)
1*cfb92d14SAndroid Build Coastguard Worker# Test Harness on Simulation Environment Setup
2*cfb92d14SAndroid Build Coastguard Worker
3*cfb92d14SAndroid Build Coastguard WorkerTHCI (Thread Host Controller Interface) is an implementation of the Python abstract class template `IThci`, which is used by the Thread Test Harness Software to control OpenThread-based reference devices according to each test scenario.
4*cfb92d14SAndroid Build Coastguard Worker
5*cfb92d14SAndroid Build Coastguard WorkerSI (Sniffer Interface) is an implementation of the sniffer abstract class template `ISniffer`, which is used by the Thread Test Harness Software to sniff all packets sent by devices.
6*cfb92d14SAndroid Build Coastguard Worker
7*cfb92d14SAndroid Build Coastguard WorkerBoth OpenThread simulation and sniffer simulation are required to run on a POSIX environment. However, Harness has to be run on Windows, which is a non-POSIX environment. So two systems are needed, and their setup procedures in detail are listed in the following sections. Either two machines or one machine running two (sub)systems (for example, VM, WSL) is feasible.
8*cfb92d14SAndroid Build Coastguard Worker
9*cfb92d14SAndroid Build Coastguard WorkerPlatform developers should modify the THCI implementation and/or the SI implementation directly to match their platform (for example, the path of the OpenThread repository).
10*cfb92d14SAndroid Build Coastguard Worker
11*cfb92d14SAndroid Build Coastguard Worker## POSIX Environment Setup
12*cfb92d14SAndroid Build Coastguard Worker
13*cfb92d14SAndroid Build Coastguard Worker1. Open the JSON format configuration file `tools/harness-simulation/posix/config.yml`:
14*cfb92d14SAndroid Build Coastguard Worker
15*cfb92d14SAndroid Build Coastguard Worker   - Edit the value of `ot_path` to the absolute path where the top directory of the OpenThread repository is located. For example, change the value of `ot_path` to `/home/<username>/repo/openthread`.
16*cfb92d14SAndroid Build Coastguard Worker   - For each entry in `ot_build.ot`, update the value of `number` to be the number of OT FTD simulations needed with the corresponding version.
17*cfb92d14SAndroid Build Coastguard Worker   - For each entry in `ot_build.otbr`, update the value of `number` to be the number of OTBR simulations needed with the corresponding version.
18*cfb92d14SAndroid Build Coastguard Worker   - The numbers above can be adjusted according to the requirement of test cases.
19*cfb92d14SAndroid Build Coastguard Worker   - Edit the value of `ssh.username` to the username to be used for connecting to the remote POSIX environment.
20*cfb92d14SAndroid Build Coastguard Worker   - Edit the value of `ssh.password` to the password corresponding to the username above.
21*cfb92d14SAndroid Build Coastguard Worker   - Edit the value of `discovery_ifname` to the network interface that the Harness will connect to.
22*cfb92d14SAndroid Build Coastguard Worker
23*cfb92d14SAndroid Build Coastguard Worker   Note that it may be time-consuming to build all versions of `ot-cli-ftd`s and OTBR Docker images especially on devices such as Raspberry Pis.
24*cfb92d14SAndroid Build Coastguard Worker
25*cfb92d14SAndroid Build Coastguard Worker2. Run the installation script.
26*cfb92d14SAndroid Build Coastguard Worker
27*cfb92d14SAndroid Build Coastguard Worker   ```bash
28*cfb92d14SAndroid Build Coastguard Worker   $ tools/harness-simulation/posix/install.sh
29*cfb92d14SAndroid Build Coastguard Worker   ```
30*cfb92d14SAndroid Build Coastguard Worker
31*cfb92d14SAndroid Build Coastguard Worker## Test Harness Environment Setup
32*cfb92d14SAndroid Build Coastguard Worker
33*cfb92d14SAndroid Build Coastguard Worker1. Copy the directory `tools/harness-simulation` from the POSIX machine to the Windows machine, and then switch to that directory.
34*cfb92d14SAndroid Build Coastguard Worker
35*cfb92d14SAndroid Build Coastguard Worker2. Double click the file `harness\install.bat` on Windows.
36*cfb92d14SAndroid Build Coastguard Worker
37*cfb92d14SAndroid Build Coastguard Worker## Run Test Harness on Simulation
38*cfb92d14SAndroid Build Coastguard Worker
39*cfb92d14SAndroid Build Coastguard Worker1. On the POSIX machine, change directory to the top of the OpenThread repository, and run the following commands.
40*cfb92d14SAndroid Build Coastguard Worker
41*cfb92d14SAndroid Build Coastguard Worker   ```bash
42*cfb92d14SAndroid Build Coastguard Worker   $ cd tools/harness-simulation/posix
43*cfb92d14SAndroid Build Coastguard Worker   $ ./launch_testbed.py -c config.yml
44*cfb92d14SAndroid Build Coastguard Worker   ```
45*cfb92d14SAndroid Build Coastguard Worker
46*cfb92d14SAndroid Build Coastguard Worker   This example starts several OT FTD simulations, OTBR simulations, and sniffer simulations and can be discovered on `eth0`. The number of each type of simulation is specified in the configuration file `config.yml`.
47*cfb92d14SAndroid Build Coastguard Worker
48*cfb92d14SAndroid Build Coastguard Worker2. Run the Test Harness. The information field of the device is encoded as `<tag>_<node_id>@<ip_addr>`. Choose the desired device as the DUT.
49*cfb92d14SAndroid Build Coastguard Worker
50*cfb92d14SAndroid Build Coastguard Worker3. Select one or more test cases to start the test.
51