Skip to content

Commit bb9c639

Browse files
authored
Merge branch 'main' into modularize-remoteproc
Signed-off-by: Sai-teja573 <[email protected]>
2 parents 7352b07 + 5baf561 commit bb9c639

File tree

10 files changed

+485
-104
lines changed

10 files changed

+485
-104
lines changed

Runner/plans/meta-qcom_PreMerge.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ metadata:
1414
run:
1515
steps:
1616
- cd Runner
17+
- $PWD/suites/Connectivity/Ethernet/run.sh || true
18+
- $PWD/utils/send-to-lava.sh $PWD/suites/Connectivity/Ethernet/Ethernet.res || true
1719
- $PWD/suites/Kernel/FunctionalArea/baseport/adsp_remoteproc/run.sh || true
1820
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/adsp_remoteproc/adsp_remoteproc.res || true
1921
- $PWD/suites/Kernel/FunctionalArea/baseport/cdsp_remoteproc/run.sh || true
@@ -36,6 +38,4 @@ run:
3638
- $PWD/utils/send-to-lava.sh $PWD/suites/Multimedia/Audio/AudioRecord/AudioRecord.res || true
3739
- $PWD/suites/Connectivity/Bluetooth/run.sh || true
3840
- $PWD/utils/send-to-lava.sh $PWD/suites/Connectivity/Bluetooth/Bluetooth.res || true
39-
- $PWD/suites/Connectivity/Ethernet/run.sh || true
40-
- $PWD/utils/send-to-lava.sh $PWD/suites/Connectivity/Ethernet/Ethernet.res || true
4141
- $PWD/utils/result_parse.sh
File renamed without changes.

Runner/suites/Connectivity/Bluetooth/run.sh renamed to Runner/suites/Connectivity/Bluetooth/BT_ON_FF/run.sh

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
44
# SPDX-License-Identifier: BSD-3-Clause-Clear
5-
6-
# Source init_env and functestlib.sh
5+
6+
# Robustly find and source init_env
77
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
88
INIT_ENV=""
99
SEARCH="$SCRIPT_DIR"
@@ -14,33 +14,36 @@ while [ "$SEARCH" != "/" ]; do
1414
fi
1515
SEARCH=$(dirname "$SEARCH")
1616
done
17-
17+
1818
if [ -z "$INIT_ENV" ]; then
1919
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
2020
exit 1
2121
fi
22-
23-
# shellcheck disable=SC1090
24-
. "$INIT_ENV"
25-
22+
23+
if [ -z "$__INIT_ENV_LOADED" ]; then
24+
# shellcheck disable=SC1090
25+
. "$INIT_ENV"
26+
fi
2627
# shellcheck disable=SC1090,SC1091
2728
. "$TOOLS/functestlib.sh"
28-
29-
TESTNAME="Bluetooth"
29+
30+
TESTNAME="BT_ON_FF"
3031
test_path=$(find_test_case_by_name "$TESTNAME") || {
3132
log_fail "$TESTNAME : Test directory not found."
3233
echo "$TESTNAME FAIL" > "./$TESTNAME.res"
3334
exit 1
3435
}
35-
36+
3637
cd "$test_path" || exit 1
3738
res_file="./$TESTNAME.res"
3839
rm -f "$res_file"
39-
40-
log_info "-----------------------------------------------------------------------------------------"
41-
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
40+
41+
log_info "------------------------------------------------------------"
42+
log_info "Starting $TESTNAME Testcase"
4243
log_info "Checking dependency: bluetoothctl"
43-
check_dependencies bluetoothctl
44+
45+
# verify that all necessary dependencies
46+
check_dependencies bluetoothctl pgrep
4447

4548
log_info "Checking if bluetoothd is running..."
4649
MAX_RETRIES=3
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
2+
# Bluetooth BT_SCAN_PAIR Test
3+
4+
This test automates Bluetooth scanning and pairing for embedded Linux devices using BlueZ and bluetoothctl. It is designed for use in the [qcom-linux-testkit](https://github.com/qualcomm-linux/qcom-linux-testkit) test suite.
5+
6+
## Features
7+
8+
- Scans for Bluetooth devices
9+
- Optionally pairs with a device by name or MAC address
10+
- Retries pairing on failure, including handling for busy/temporarily unavailable devices
11+
- Cleans up previous pairings for repeatable CI runs
12+
- Accepts device name/MAC as argument, environment variable, or in `bt_device_list.txt`
13+
- Generates summary and detailed logs (`scan.log`, `pair.log`, `found_devices.log`)
14+
15+
## Usage
16+
17+
```sh
18+
./run.sh [DEVICE_NAME_OR_MAC] [WHITELIST]
19+
```
20+
- `DEVICE_NAME_OR_MAC` – (optional) Device name or MAC address to pair.
21+
- Can also be set as `BT_NAME_ENV` or in `bt_device_list.txt`
22+
- `WHITELIST` – (optional) Comma-separated MACs/names allowed for pairing.
23+
- Can also be set as `BT_WHITELIST_ENV`
24+
25+
If no device name is given, only scanning is performed and the test passes if devices are found.
26+
27+
## Examples
28+
29+
```sh
30+
./run.sh [BT_NAME] [WHITELIST]
31+
```
32+
33+
- `BT_NAME` - Optional. Bluetooth name or MAC to search for.
34+
- `WHITELIST` - Optional. Comma-separated names/MACs allowed for pairing.
35+
36+
- Scan for any device (no pairing):
37+
38+
```
39+
./run.sh
40+
```
41+
42+
- Scan and pair with a device named "MySpeaker":
43+
44+
```
45+
./run.sh MySpeaker
46+
```
47+
48+
- Scan and pair only if device MAC is in whitelist:
49+
50+
```
51+
./run.sh MySpeaker 00:11:22:33:44:55,AnotherSpeaker
52+
```
53+
54+
- Use environment variables:
55+
56+
```
57+
export BT_NAME_ENV="MySpeaker"
58+
export BT_WHITELIST_ENV="00:11:22:33:44:55"
59+
./run.sh
60+
```
61+
62+
- Device list file (first line is used):
63+
64+
```
65+
echo "MySpeaker" > bt_device_list.txt
66+
./run.sh
67+
```
68+
69+
## Whitelist Usage
70+
71+
To ensure only known devices are considered during scan:
72+
73+
```sh
74+
./run.sh JBL_Speaker "JBL_Speaker,12:34:56:78:9A:BC"
75+
```
76+
77+
## Arguments & Variables
78+
79+
- Argument 1: Device name or MAC address (takes precedence)
80+
- `BT_NAME_ENV`: Device name or MAC from the environment
81+
- `bt_device_list.txt`: Fallback if argument or env is not set
82+
83+
## Example Summary Output
84+
85+
```
86+
[INFO] 2025-06-23 10:00:00 - Starting BT_SCAN_PAIR Testcase
87+
[INFO] 2025-06-23 10:00:02 - Unblocking and powering on Bluetooth
88+
[INFO] 2025-06-23 10:00:05 - Devices found during scan:
89+
Device 12:34:56:78:9A:BC SomeBTHeadset
90+
[INFO] 2025-06-23 10:00:06 - Expected device 'SomeBTHeadset' found in scan
91+
[PASS] 2025-06-23 10:00:08 - Pairing successful with 12:34:56:78:9A:BC
92+
```
93+
94+
## Result
95+
96+
- PASS: Device paired (or scan-only with no target)
97+
- FAIL: Device not found, not in whitelist, or pairing failed
98+
- All paired devices are removed after the test
99+
100+
## Files Generated
101+
102+
- `BT_SCAN_PAIR.res`: Test PASS/FAIL/SKIP result
103+
- `scan.log`: Output of Bluetooth device scan
104+
- `found_devices.log`: List of discovered device names/MACs
105+
- `pair.log`: Detailed pairing output and errors
106+
107+
## Troubleshooting
108+
109+
- Ensure `bluetoothctl`, `rfkill`, `expect`, and `hciconfig` are available.
110+
- For headless automation, the remote device must be in pairing/discoverable mode.
111+
- The script retries pairing if "busy" or "temporarily unavailable" errors are seen.
112+
- Check `pair.log` and `scan.log` for detailed debug info if a failure occurs.
113+
114+
## Helper Functions (in functestlib.sh)
115+
116+
- `bt_scan_devices` – Scans and logs found BT devices
117+
- `bt_pair_with_mac` – Attempts pairing via expect with retries
118+
- `bt_in_whitelist` – Checks if MAC/name is in whitelist
119+
- `bt_cleanup_paired_device` – Removes paired device by MAC
120+
121+
## Customization
122+
123+
- **Whitelist**: You can restrict scan to a whitelist of MAC addresses or names using environment variables or script customization.
124+
- **Retries/Timeouts**: Retry and timeout values can be set in the script for more robust pairing.
125+
126+
## Integration with LAVA
127+
128+
In your LAVA job:
129+
130+
```yaml
131+
deploy:
132+
to: tftp
133+
images:
134+
bt_device_list.txt:
135+
image: path/to/bt_device_list.txt
136+
compression: none
137+
```
138+
139+
Injects a per-DUT Bluetooth configuration.
140+
141+
## Dependencies
142+
143+
- `bluetoothctl`, `expect`, `rfkill`, `hciconfig`
144+
- BlueZ stack running on embedded Linux
145+
146+
## License
147+
148+
SPDX-License-Identifier: BSD-3-Clause-Clear
149+
Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.

Runner/suites/Connectivity/Bluetooth/BT_SCAN_PAIR/bt_device_list.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)