Skip to content

Commit

Permalink
[Mbed] Add integration tests for example applications (#12039)
Browse files Browse the repository at this point in the history
* Move mbed unit test to test_driver/mbed/unit_test directory
Add integration test dir and files
Cahnge unit test path in launch.json, task.json and mbed_unit_tests.sh

* Add pytest and mbed-ls to pigweed env

* Fix realpath in unit_test Cmake file

* Improve serial data parsing
Update lock and lightings apps smoke tests

* Add network fixture
Add utlis file with common ble and wifi functions
Add wifi provisioning test

* Remove device_controller fixture is singleton al all
Update wifi provisioning tests

* Move unit test README file to right directory
Add Pigweed-app integration test and pigweed client

* Add shell app tests
Improve unit tests check

* Add RPC tests to lock and lighting apps

* Add wlan access point class - run Wi-Fi AP
Add access point as fixture
Use AP in shell wifi connect test

* Fix wlan AP

* Improve BoardAllocator - checking connected device
Improve unit-test checking

* Add mount new mbed device script

* Add close ble connection

* Add wait for wifi connection log and close ble to wifi provisioning tests

* Remove serial device warnings

* Improve lock-app test and refactor to get more common functions

* Improve lighting-app tests
Cleanup lock-app and shell tests

* Lock, ligthing and shell apps tests improvements
Change log sfor ZCL command send

* Changes restyle
Remove redundant changes
Remove acces point class - not ready to merge
Code cleanup

* Add integration tests README file
Improve relative paths in unit test README file

* Improve spelling

* Add new .wordlist exceptions

* Restore 40s timeout for session establishment in device controller

* Add resolve step in wifi_provisioning tests

* Improve lock and light control tests add wifi provisioning and resolve node steps

* Changes restyle
  • Loading branch information
ATmobica authored and monalisa-octocat-source committed Nov 16, 2022
1 parent 02a341a commit 2214197
Show file tree
Hide file tree
Showing 34 changed files with 1,994 additions and 26 deletions.
5 changes: 5 additions & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ armeabi
ARMmbed
armv
asdk
AssertionError
ASYNC
att
attId
Expand Down Expand Up @@ -387,6 +388,7 @@ FOTA
FreeRTOS
FreeRTOSConfig
fsl
fstab
fsync
fullclean
gcloud
Expand Down Expand Up @@ -768,6 +770,7 @@ PyFunction
pylint
PyObject
PyRun
pytest
QEMU
Qorvo
QPG
Expand All @@ -781,6 +784,7 @@ qvCHIP
RADVD
raspberryPi
RasPi
rAv
RCP
ReadConfigValue
readelf
Expand Down Expand Up @@ -866,6 +870,7 @@ SLAAC
SLTB
SLWSTK
SmartThings
smoketest
SMP
socat
socio
Expand Down
8 changes: 4 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
"name": "Debug Mbed unit tests",
"type": "cortex-debug",
"request": "launch",
"cwd": "${workspaceRoot}/src/test_driver/mbed",
"cwd": "${workspaceRoot}/src/test_driver/mbed/unit_tests",
"executable": "./build-${input:mbedTarget}/${input:mbedDebugProfile}/chip-mbed-unit-tests.elf",
"armToolchainPath": "${env:PW_ENVIRONMENT_ROOT}/cipd/pigweed/bin/", // Pigweed environment bootstraping required
"servertype": "openocd",
Expand Down Expand Up @@ -225,7 +225,7 @@
"name": "Debug Mbed unit tests [remote]",
"type": "cortex-debug",
"request": "launch",
"cwd": "${workspaceRoot}/src/test_driver/mbed",
"cwd": "${workspaceRoot}/src/test_driver/mbed/unit_tests",
"executable": "./build-${input:mbedTarget}/${input:mbedDebugProfile}/chip-mbed-unit-tests.elf",
"armToolchainPath": "${env:PW_ENVIRONMENT_ROOT}/cipd/pigweed/bin/", // Pigweed environment bootstraping required
"servertype": "external",
Expand All @@ -252,7 +252,7 @@
"name": "Flash Mbed unit tests",
"type": "cortex-debug",
"request": "launch",
"cwd": "${workspaceRoot}/src/test_driver/mbed",
"cwd": "${workspaceRoot}/src/test_driver/mbed//unit_tests",
"executable": "./build-${input:mbedTarget}/${input:mbedFlashProfile}/chip-mbed-unit-tests.elf",
"armToolchainPath": "${env:PW_ENVIRONMENT_ROOT}/cipd/pigweed/bin/", // Pigweed environment bootstraping required
"servertype": "openocd",
Expand All @@ -277,7 +277,7 @@
"name": "Flash Mbed unit tests [remote]",
"type": "cortex-debug",
"request": "launch",
"cwd": "${workspaceRoot}/src/test_driver/mbed",
"cwd": "${workspaceRoot}/src/test_driver/mbed/unit_tests",
"executable": "./build-${input:mbedTarget}/${input:mbedFlashProfile}/chip-mbed-unit-tests.elf",
"armToolchainPath": "${env:PW_ENVIRONMENT_ROOT}/cipd/pigweed/bin/", // Pigweed environment bootstraping required
"servertype": "external",
Expand Down
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
"base": "$gcc",
"fileLocation": [
"relative",
"${workspaceFolder}/src/test_driver/mbed/build"
"${workspaceFolder}/src/test_driver/mbed/unit_tests/build"
]
}
}
Expand Down
86 changes: 71 additions & 15 deletions scripts/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ anytree==2.8.0
appdirs==1.4.4
# via
# -r requirements.txt
# mbed-os-tools
# virtualenv
appnope==0.1.2
# via -r requirements.txt
attrs==21.2.0
# via pytest
backcall==0.2.0
# via ipython
bidict==0.21.2
# via python-socketio
beautifulsoup4==4.10.0
# via mbed-os-tools
bitstring==3.1.7
# via -r requirements.esp32.txt
brotli==1.0.9
Expand All @@ -29,13 +32,18 @@ chardet==4.0.0
click==7.1.2
# via
# -r requirements.esp32.txt
# -r requirements.txt
# flask
# mbed-tools
# pip-tools
colorama==0.4.4
# via west
# via
# mbed-os-tools
# west
coloredlogs==15.0.1
# via -r requirements.txt
construct==2.10.54
# via -r requirements.esp32.txt
cryptography==3.4.7
# via -r requirements.esp32.txt
cxxfilt==0.2.2
Expand All @@ -50,6 +58,10 @@ docopt==0.6.2
# via pykwalify
ecdsa==0.17.0
# via -r requirements.esp32.txt
fastcore==1.3.26
# via ghapi
fasteners==0.16.3
# via mbed-os-tools
filelock==3.0.12
# via virtualenv
flask-compress==1.10.0
Expand All @@ -64,11 +76,14 @@ flask==0.12.5
future==0.18.2
# via
# -r requirements.esp32.txt
# mbed-os-tools
# mobly
gdbgui==0.13.2.0 ; platform_machine != "aarch64"
gdbgui==0.13.2.0
# via -r requirements.esp32.txt
gevent==1.5.0
# via gdbgui
ghapi==0.1.19
# via -r requirements.txt
gitdb==4.0.7
# via gitpython
gitpython==3.1.14
Expand All @@ -79,8 +94,12 @@ humanfriendly==9.2
# via coloredlogs
idna==2.10
# via requests
iniconfig==1.1.1
# via pytest
intelhex==2.3.0
# via -r requirements.txt
# via
# -r requirements.txt
# mbed-os-tools
ipython-genutils==0.2.0
# via traitlets
ipython==7.24.1
Expand All @@ -93,8 +112,14 @@ jinja2==3.0.1
# via
# flask
# mbed-tools
junit-xml==1.9
# via mbed-os-tools
kconfiglib==13.7.1
# via -r requirements.esp32.txt
lockfile==0.12.2
# via -r requirements.txt
# via
# -r requirements.txt
# mbed-os-tools
mako==1.1.4
# via pdoc3
markdown==3.3.4
Expand All @@ -105,14 +130,22 @@ markupsafe==2.0.1
# mako
matplotlib-inline==0.1.2
# via ipython
mbed-tools==7.22.0
mbed-ls==1.8.11 ; platform_machine != "aarch64" and sys_platform == "linux"
# via -r requirements.mbed.txt
mbed-os-tools==1.8.11
# via mbed-ls
mbed-tools==7.22.0 ; platform_machine != "aarch64" and sys_platform == "linux"
# via -r requirements.mbed.txt
mobly==1.10.1
# via -r requirements.txt
numpy==1.20.3
# via pandas
packaging==20.9
# via west
# via
# fastcore
# ghapi
# pytest
# west
pandas==1.2.4 ; platform_machine != "aarch64" and platform_machine != "arm64"
# via -r requirements.txt
parso==0.8.2
Expand All @@ -129,12 +162,16 @@ pickleshare==0.7.5
# via ipython
pip-tools==6.1.0
# via -r requirements.txt
pluggy==1.0.0
# via pytest
portpicker==1.4.0
# via
# -r requirements.txt
# mobly
prettytable==0.7.2
# via -r requirements.mbed.txt
prettytable==2.2.1
# via
# mbed-ls
# mbed-os-tools
prompt-toolkit==3.0.20
# via ipython
protobuf==3.17.3
Expand All @@ -146,6 +183,8 @@ psutil==5.8.0
# mobly
ptyprocess==0.7.0
# via pexpect
py==1.10.0
# via pytest
pycparser==2.20
# via cffi
pyelftools==0.27
Expand All @@ -167,18 +206,23 @@ pyparsing==2.3.1
pyserial==3.5
# via
# -r requirements.esp32.txt
# mbed-os-tools
# mbed-tools
# mobly
pytest==6.2.5 ; platform_machine != "aarch64" and sys_platform == "linux"
# via -r requirements.mbed.txt
python-dateutil==2.8.1
# via
# pandas
# pykwalify
python-dotenv==0.17.1
# via mbed-tools
python-engineio==4.2.0
python-engineio==3.14.2
# via python-socketio
python-socketio<5
# via flask-socketio
python-socketio==4.6.1
# via
# -r requirements.esp32.txt
# flask-socketio
pytz==2021.1
# via pandas
pyudev==0.22.0
Expand All @@ -192,6 +236,7 @@ reedsolo==1.5.4
requests==2.25.1
# via
# -r requirements.txt
# mbed-os-tools
# mbed-tools
ruamel.yaml.clib==0.2.2
# via ruamel.yaml
Expand All @@ -201,18 +246,27 @@ six==1.16.0
# via
# anytree
# ecdsa
# fasteners
# junit-xml
# mbed-os-tools
# protobuf
# python-dateutil
# python-engineio
# python-socketio
# pyudev
# virtualenv
smmap==4.0.0
# via gitdb
soupsieve==2.2.1
# via beautifulsoup4
tabulate==0.8.9
# via mbed-tools
timeout-decorator==0.5.0
# via mobly
toml==0.10.2
# via pep517
# via
# pep517
# pytest
tqdm==4.61.1
# via mbed-tools
traitlets==5.0.5
Expand All @@ -228,7 +282,9 @@ virtualenv==20.4.7
watchdog==2.1.2
# via -r requirements.txt
wcwidth==0.2.5
# via prompt-toolkit
# via
# prettytable
# prompt-toolkit
werkzeug==0.16.1
# via flask
west==0.11.0
Expand Down
3 changes: 2 additions & 1 deletion scripts/requirements.mbed.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
mbed-tools>=7.0.0 ; platform_machine != 'aarch64' and sys_platform == 'linux'
prettytable==0.7.2 ; platform_machine != 'aarch64' and sys_platform == 'linux'
pytest==6.2.5 ; platform_machine != 'aarch64' and sys_platform == 'linux'
mbed-ls==1.8.11 ; platform_machine != 'aarch64' and sys_platform == 'linux'
2 changes: 1 addition & 1 deletion scripts/tests/mbed/mbed_unit_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

cd "$(dirname "$0")"/../../..
CHIP_ROOT=$PWD
cd "$CHIP_ROOT"/src/test_driver/mbed/
cd "$CHIP_ROOT"/src/test_driver/mbed/unit_tests/

SUPPORTED_TOOLCHAIN=(GCC_ARM ARM)
SUPPORTED_TARGET_BOARD=(CY8CPROTO_062_4343W)
Expand Down
36 changes: 36 additions & 0 deletions scripts/tests/mbed/mount_new_mbed_device.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
DIR=/dev/disk/by-id
DEVICE_CONFIG_FILE=/etc/fstab

echo "Add new device start..."
echo "Connect your device via USB"

res=$(inotifywait "$DIR")
if [[ ${res} != *"CREATE"* ]]; then
echo "Create new device in /dev/disk/by-id directory error"
exit 1
fi

new_device_id=$(echo "$res" | awk '{printf $NF}')

if sudo cat "$DEVICE_CONFIG_FILE" | grep -q "$new_device_id"; then
echo "$new_device_id device is already set"
exit 0
fi

device_index=1

while :; do
dir_name="MBED_$device_index"
if [ ! -d /media/"$dir_name" ]; then
break
fi

((device_index++))
done

sudo mkdir -p /media/MBED_"$device_index"
line="/dev/disk/by-id/$new_device_id /media/MBED_$device_index vfat rw,user,sync,nofail,umask=007,gid=20 0 0"
echo "$line" | sudo tee -a "$DEVICE_CONFIG_FILE"

echo "Finished"
Loading

0 comments on commit 2214197

Please sign in to comment.