Skip to content

Commit 7250a61

Browse files
committed
Added shmbridge, Bluetooth, Ethernet, and WiFi functional test scripts, and license headers
This commit includes the following changes: - Adds an encrypted ext4 mount test with fscryptctl integration (Runner/suites/Kernel/FunctionalArea/baseport/shmbridge/run.sh) - Introduces standalone test scripts for validating Bluetooth, Ethernet, and WiFi functionality - Adds SPDX BSD-3-Clause-Clear license headers to all test scripts, ensuring proper attribution and compliance with open source licensing standards - Improves script reliability by checking for the availability of ip and ping utilities Signed-off-by: Anil Yadav <[email protected]>
1 parent 73a2a03 commit 7250a61

File tree

4 files changed

+244
-0
lines changed

4 files changed

+244
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/sh
2+
3+
# SPDX-License-Identifier: BSD-3-Clause-Clear
4+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
5+
6+
# Import test suite definitions
7+
. $(pwd)/init_env
8+
TESTNAME="Bluetooth"
9+
10+
#import test functions library
11+
. $TOOLS/functestlib.sh
12+
test_path=$(find_test_case_by_name "$TESTNAME")
13+
log_info "--------------------------------------------------------------------------"
14+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
15+
16+
log_info "Starting Bluetooth Test..."
17+
18+
# Check if bluetoothctl is available
19+
if ! command -v bluetoothctl >/dev/null 2>&1; then
20+
log_fail "bluetoothctl not found. Please install bluez."
21+
echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res
22+
exit 1
23+
fi
24+
25+
# Check if bluetoothd is running
26+
if ! pgrep bluetoothd >/dev/null; then
27+
log_fail "bluetoothd is not running. Please start the Bluetooth daemon."
28+
echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res
29+
exit 1
30+
fi
31+
32+
# Power off Bluetooth controller
33+
log_info "Powering off Bluetooth controller..."
34+
bluetoothctl power off
35+
36+
# Power on Bluetooth controller
37+
log_info "Powering on Bluetooth controller..."
38+
output=$(bluetoothctl power on)
39+
40+
# Check for success message
41+
if echo "$output" | grep -q "Changing power on succeeded"; then
42+
log_pass "Bluetooth controller powered on successfully."
43+
echo "$TESTNAME PASS" > $test_path/$TESTNAME.res
44+
else
45+
log_fail "Failed to power on Bluetooth controller."
46+
echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res
47+
fi
48+
49+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
50+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/sh
2+
3+
# SPDX-License-Identifier: BSD-3-Clause-Clear
4+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
5+
6+
# Import test suite definitions
7+
source $(pwd)/init_env
8+
TESTNAME="Ethernet"
9+
10+
#import test functions library
11+
source $TOOLS/functestlib.sh
12+
test_path=$(find_test_case_by_name "$TESTNAME")
13+
log_info "--------------------------------------------------------------------------"
14+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
15+
16+
log_info "Checking if dependency:net-tools is available"
17+
check_dependencies net-tools
18+
19+
log_info "Starting Ethernet test..."
20+
21+
IFACE="eth0"
22+
23+
# Check interface existence
24+
if ! ip link show "$IFACE" >/dev/null 2>&1; then
25+
log_fail "Ethernet interface $IFACE not found"
26+
echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res
27+
exit 1
28+
fi
29+
30+
# Check if interface is up, try to bring it up if not
31+
if ! ip link show "$IFACE" | grep -q "state UP"; then
32+
log_warn "Interface $IFACE is down, attempting to bring it up..."
33+
ip link set "$IFACE" up
34+
sleep 3
35+
if ! ip link show "$IFACE" | grep -q "state UP"; then
36+
log_fail "Failed to bring up $IFACE"
37+
echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res
38+
exit 1
39+
fi
40+
fi
41+
42+
# Ping test
43+
log_info "Running ping test to 8.8.8.8..."
44+
if ping -I "$IFACE" -c 4 -W 2 8.8.8.8 >/dev/null 2>&1; then
45+
log_pass "Ethernet connectivity verified"
46+
echo "$TESTNAME PASS" > $test_path/$TESTNAME.res
47+
else
48+
log_fail "Ethernet ping failed"
49+
echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res
50+
exit 1
51+
fi
52+
53+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
54+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: BSD-3-Clause-Clear
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
5+
# Import test suite definitions
6+
. "$(pwd)/init_env"
7+
TESTNAME="WIFI"
8+
9+
# Import test functions library
10+
. "$TOOLS/functestlib.sh"
11+
test_path=$(find_test_case_by_name "$TESTNAME")
12+
13+
log_info "--------------------------------------------------------------------------"
14+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
15+
log_info "Starting WiFi Test..."
16+
17+
WLAN="wlan0"
18+
SSID_CONF="$(dirname "$0")/wifi_test.conf" # should contain: SSID and PASSWORD
19+
20+
if [ ! -f "$SSID_CONF" ]; then
21+
log_fail "WiFi config $SSID_CONF not found"
22+
echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res"
23+
exit 1
24+
fi
25+
26+
. "$SSID_CONF"
27+
28+
log_info "Loaded SSID=$SSID, PASSWORD=$PASSWORD"
29+
30+
if ! command -v nmcli >/dev/null 2>&1; then
31+
log_fail "nmcli not found"
32+
echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res"
33+
exit 1
34+
fi
35+
36+
# Restart NetworkManager if needed
37+
if ! systemctl is-active NetworkManager >/dev/null 2>&1; then
38+
log_warn "NetworkManager not active. Trying to start it..."
39+
systemctl start NetworkManager
40+
sleep 3
41+
if ! systemctl is-active NetworkManager >/dev/null 2>&1; then
42+
log_fail "Failed to start NetworkManager"
43+
echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res"
44+
exit 1
45+
fi
46+
fi
47+
48+
# Connect to WiFi
49+
log_info "Attempting to connect to SSID: $SSID"
50+
nmcli_output=$(nmcli dev wifi connect "$SSID" password "$PASSWORD" ifname "$WLAN" 2>&1)
51+
log_info "nmcli output: $nmcli_output"
52+
sleep 5
53+
54+
if echo "$nmcli_output" | grep -qi "successfully activated"; then
55+
log_pass "Connected to $SSID"
56+
echo "$TESTNAME PASS" > "$test_path/$TESTNAME.res"
57+
else
58+
log_fail "Failed to connect to $SSID"
59+
echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res"
60+
exit 1
61+
fi
62+
63+
64+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
65+
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: BSD-3-Clause-Clear
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
5+
# Import test suite definitions
6+
source "$(pwd)/init_env"
7+
TESTNAME="shmbridge"
8+
9+
# Import test functions library
10+
source "$TOOLS/functestlib.sh"
11+
test_path=$(find_test_case_by_name "$TESTNAME")
12+
13+
log_info "--------------------------------------------------------------------------"
14+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
15+
16+
MOUNT_POINT="/mnt/overlay"
17+
PARTITION="/dev/disk/by-partlabel/xbl_ramdump_a"
18+
KEY_FILE="$MOUNT_POINT/stdkey"
19+
TEST_DIR="$MOUNT_POINT/test"
20+
TEST_FILE="$TEST_DIR/txt"
21+
22+
log_info "Creating mount point at $MOUNT_POINT"
23+
mkdir -p "$MOUNT_POINT"
24+
25+
log_info "Checking if partition exists"
26+
if [ ! -e "$PARTITION" ]; then
27+
log_fail "Partition $PARTITION not found"
28+
echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res"
29+
exit 1
30+
fi
31+
32+
log_info "Formatting partition with ext4 and encryption options"
33+
if ! mount | grep -q "$PARTITION"; then
34+
mkfs.ext4 -F -O encrypt,stable_inodes "$PARTITION"
35+
else
36+
log_warn "$PARTITION is already mounted; skipping format"
37+
fi
38+
39+
log_info "Mounting partition to $MOUNT_POINT with inlinecrypt"
40+
mount "$PARTITION" -o inlinecrypt "$MOUNT_POINT"
41+
42+
log_info "Generating 64-byte encryption key"
43+
head -c 64 /dev/urandom > "$KEY_FILE"
44+
45+
log_info "Checking if dependency binary is available"
46+
check_dependencies fscryptctl
47+
48+
log_info "Adding encryption key using fscryptctl"
49+
identifier=$(fscryptctl add_key "$MOUNT_POINT" < "$KEY_FILE")
50+
51+
mkdir -p "$TEST_DIR"
52+
53+
log_info "Setting encryption policy on $TEST_DIR"
54+
fscryptctl set_policy --iv-ino-lblk-64 "$identifier" "$TEST_DIR"
55+
56+
log_info "Verifying encryption policy"
57+
fscryptctl get_policy "$TEST_DIR"
58+
59+
log_info "Writing test file"
60+
echo "hello" > "$TEST_FILE"
61+
sync
62+
echo 3 > /proc/sys/vm/drop_caches
63+
64+
log_info "Reading test file"
65+
if cat "$TEST_FILE" | grep -q "hello"; then
66+
log_pass "$TESTNAME : Test Passed"
67+
echo "$TESTNAME PASS" > "$test_path/$TESTNAME.res"
68+
else
69+
log_fail "$TESTNAME : Test Failed"
70+
echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res"
71+
exit 1
72+
fi
73+
74+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
75+

0 commit comments

Comments
 (0)