Skip to content

Commit 330c16e

Browse files
committed
Adding Bluetooth validation test case
This test validates the Bluetooth controller by checking for the presence of bluetoothctl, ensuring bluetoothd is running, and toggling the controller power state using bluetoothctl. - Compliant with qcom-linux-testkit structure - Generates .res file for CI/CD - Uses functestlib logging and dependency checks Signed-off-by: Anil Yadav <[email protected]>
1 parent 5f93429 commit 330c16e

File tree

2 files changed

+130
-0
lines changed

2 files changed

+130
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Bluetooth Validation Test
2+
3+
## 📌 Overview
4+
5+
This test case validates the basic functionality of the Bluetooth controller on the device. It checks for:
6+
7+
- Presence of `bluetoothctl`
8+
- Running status of `bluetoothd`
9+
- Power state toggling of the Bluetooth controller
10+
11+
12+
13+
## How to Run
14+
15+
```sh
16+
source init_env
17+
cd suites/Connectivity/Bluetooth
18+
./run.sh
19+
```
20+
21+
## Prerequisites
22+
- bluez package must be installed (provides bluetoothctl)
23+
- bluetoothd daemon must be running
24+
- Root access may be required for complete validation
25+
26+
## Result Format
27+
28+
Test result will be saved in Bluetooth.res as:
29+
✅ Pass Criteria
30+
- bluetoothctl is available
31+
- bluetoothd is running
32+
- Power on command returns success
33+
- Bluetooth controller powered on successfully. – if all validations pass
34+
<!-- -->
35+
❌ Fail Criteria
36+
- bluetoothctl not found
37+
- bluetoothd not running
38+
- Power on command fails
39+
- Failed to power on Bluetooth controller. – if any check fails
40+
41+
42+
## 📄 Output
43+
A .res file is generated in the same directory:
44+
45+
`PASS Bluetooth` OR `FAIL Bluetooth`
46+
47+
## License
48+
49+
SPDX-License-Identifier: BSD-3-Clause-Clear
50+
(C) Qualcomm Technologies, Inc. and/or its subsidiaries.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/sh
2+
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
# SPDX-License-Identifier: BSD-3-Clause-Clear
5+
6+
# Source init_env and functestlib.sh
7+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8+
INIT_ENV=""
9+
SEARCH="$SCRIPT_DIR"
10+
while [ "$SEARCH" != "/" ]; do
11+
if [ -f "$SEARCH/init_env" ]; then
12+
INIT_ENV="$SEARCH/init_env"
13+
break
14+
fi
15+
SEARCH=$(dirname "$SEARCH")
16+
done
17+
18+
if [ -z "$INIT_ENV" ]; then
19+
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
20+
exit 1
21+
fi
22+
23+
# shellcheck disable=SC1090
24+
. "$INIT_ENV"
25+
26+
# shellcheck disable=SC1090,SC1091
27+
. "$TOOLS/functestlib.sh"
28+
29+
TESTNAME="Bluetooth"
30+
test_path=$(find_test_case_by_name "$TESTNAME") || {
31+
log_fail "$TESTNAME : Test directory not found."
32+
echo "FAIL $TESTNAME" > "./$TESTNAME.res"
33+
exit 1
34+
}
35+
36+
cd "$test_path" || exit 1
37+
res_file="./$TESTNAME.res"
38+
rm -f "$res_file"
39+
40+
log_info "--------------------------------------------------------------------------"
41+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
42+
43+
log_info "Checking if dependency: bluez is available"
44+
check_dependencies bluez
45+
46+
log_info "Starting Bluetooth Test..."
47+
48+
# Check if bluetoothctl is available
49+
if ! command -v bluetoothctl >/dev/null 2>&1; then
50+
log_fail "bluetoothctl not found. Please install bluez."
51+
echo "FAIL $TESTNAME" > "$res_file"
52+
exit 1
53+
fi
54+
55+
# Check if bluetoothd is running
56+
if ! pgrep bluetoothd >/dev/null; then
57+
log_fail "bluetoothd is not running. Please start the Bluetooth daemon."
58+
echo "FAIL $TESTNAME" > "$res_file"
59+
exit 1
60+
fi
61+
62+
# Power off Bluetooth controller
63+
log_info "Powering off Bluetooth controller..."
64+
bluetoothctl power off
65+
66+
# Power on Bluetooth controller
67+
log_info "Powering on Bluetooth controller..."
68+
output=$(bluetoothctl power on)
69+
70+
# Check for success message
71+
if echo "$output" | grep -q "Changing power on succeeded"; then
72+
log_pass "Bluetooth controller powered on successfully."
73+
echo "PASS $TESTNAME" > "$res_file"
74+
else
75+
log_fail "Failed to power on Bluetooth controller."
76+
echo "FAIL $TESTNAME" > "$res_file"
77+
fi
78+
79+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
80+

0 commit comments

Comments
 (0)