[test] set default paths of expect scripts (#10530)

This commit adds default paths for expect scripts to make it easier for
running expect scripts. With this change, we can run expect tests as
follows:

```bash
./script/cmake-build simulation
./script/cmake-build posix
./tests/scripts/expect/cli-ping.exp
OT_NODE_TYPE=rcp ./tests/scripts/expect/cli-ping.exp
```

This commit also updates an existing test to cover the change.
This commit is contained in:
Yakun Xu
2024-07-24 06:50:17 -07:00
committed by GitHub
parent d0fbfb8c76
commit af18582b4e
2 changed files with 33 additions and 14 deletions
+12 -9
View File
@@ -30,7 +30,7 @@
set -euxo pipefail
IFACE_NAME="dummy116"
EXPECT_TEST=tests/scripts/expect/cli-ping.exp
EXPECT_TEST=./tests/scripts/expect/cli-ping.exp
cleanup()
{
@@ -59,24 +59,27 @@ setup_dummy116()
test_ipv6()
{
setup_dummy116
OT_SIMULATION_LOCAL_HOST=$IFACE_NAME ./script/test build expect $EXPECT_TEST
OT_SIMULATION_LOCAL_HOST=$IP6ADDR ./script/test build expect $EXPECT_TEST
OT_SIMULATION_LOCAL_HOST=$IFACE_NAME $EXPECT_TEST
OT_SIMULATION_LOCAL_HOST=$IP6ADDR $EXPECT_TEST
OT_NODE_TYPE=rcp OT_SIMULATION_LOCAL_HOST=$IFACE_NAME ./script/test build expect $EXPECT_TEST
OT_NODE_TYPE=rcp OT_SIMULATION_LOCAL_HOST=$IP6ADDR ./script/test build expect $EXPECT_TEST
OT_NODE_TYPE=rcp OT_SIMULATION_LOCAL_HOST=$IFACE_NAME $EXPECT_TEST
OT_NODE_TYPE=rcp OT_SIMULATION_LOCAL_HOST=$IP6ADDR $EXPECT_TEST
}
test_ipv4()
{
OT_SIMULATION_LOCAL_HOST=lo ./script/test build expect $EXPECT_TEST
OT_SIMULATION_LOCAL_HOST=127.0.0.1 ./script/test build expect $EXPECT_TEST
OT_SIMULATION_LOCAL_HOST=lo $EXPECT_TEST
OT_SIMULATION_LOCAL_HOST=127.0.0.1 $EXPECT_TEST
OT_NODE_TYPE=rcp OT_SIMULATION_LOCAL_HOST=lo ./script/test build expect $EXPECT_TEST
OT_NODE_TYPE=rcp OT_SIMULATION_LOCAL_HOST=127.0.0.1 ./script/test build expect $EXPECT_TEST
OT_NODE_TYPE=rcp OT_SIMULATION_LOCAL_HOST=lo $EXPECT_TEST
OT_NODE_TYPE=rcp OT_SIMULATION_LOCAL_HOST=127.0.0.1 $EXPECT_TEST
}
main()
{
./script/cmake-build posix
./script/cmake-build simulation
test_ipv4
test_ipv6
}