Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 58 additions & 23 deletions automated/linux/wlan-smoke/wlan-smoke-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
# Author: Nicolas Dechesne <nicolas.dechesne@linaro.org>
#

# shellcheck disable=SC1091,SC2034
# shellcheck disable=SC1091,SC2034,SC2039
. ../../lib/sh-test-lib
OUTPUT="$(pwd)/output"
RESULT_FILE="${OUTPUT}/result.txt"
export RESULT_FILE
DEVICE="wlan0"
DEVICE=""
BOOT="enabled"
WAIT_TIME=0

Expand All @@ -44,50 +44,64 @@ while getopts "d:b:w:" o; do
esac
done

# list wireless interfaces, one per line
list_wlan_devices() {
for dev in /sys/class/net/*/wireless; do
[ -d "${dev}" ] || continue
basename "$(dirname "${dev}")"
done
}

# sanity test ip command
test_iplink() {
info_msg "Running ip link test..."
ip link show "${DEVICE}"
exit_on_fail "ip-link"
local device="$1"
info_msg "Running ip link test on ${device}..."
ip link show "${device}"
check_return "ip-link"
}

# test WLAN device at boot is $BOOT
test_wlan_boot() {
info_msg "Running wlan boot test..."
local device="$1"
info_msg "Running wlan boot test on ${device}..."
if [ "${BOOT}" = "enabled" ]; then
ip link show "${DEVICE}" | grep "${DEVICE}" | grep "UP"
ip link show "${device}" | grep "${device}" | grep "UP"
else
ip link show "${DEVICE}" | grep "${DEVICE}" | grep -v "UP"
ip link show "${device}" | grep "${device}" | grep -v "UP"
fi
check_return "wlan-boot"
}

# test WLAN device is up
test_wlan_up() {
info_msg "Running wlan-up test..."
ip link set "${DEVICE}" up
local device="$1"
info_msg "Running wlan-up test on ${device}..."
ip link set "${device}" up
sleep 1
ip link show "${DEVICE}" | grep "${DEVICE}" | grep "UP"
ip link show "${device}" | grep "${device}" | grep "UP"
check_return "wlan-up"
}

# test WLAN device is down
test_wlan_down() {
info_msg "Running wlan-down test..."
ip link set "${DEVICE}" down
local device="$1"
info_msg "Running wlan-down test on ${device}..."
ip link set "${device}" down
sleep 1
ip link show "${DEVICE}" | grep "${DEVICE}" | grep -v "UP"
ip link show "${device}" | grep "${device}" | grep -v "UP"
check_return "wlan-down"
}

# helper function to wait for wifi device to come up
# helper function to wait for wifi device(s) to come up. When DEVICE is
# unset, wait for any wireless interface to be enumerated.
wait_for_device() {
info_msg "Waiting ${WAIT_TIME} seconds for requested device to exist..."
for i in $(seq 1 "${WAIT_TIME}")
do
ip link show "${DEVICE}" > /dev/null 2>&1
if [ $? -eq 0 ]; then
break
if [ -n "${DEVICE}" ]; then
ip link show "${DEVICE}" > /dev/null 2>&1 && break
else
[ -n "$(list_wlan_devices)" ] && break
fi
sleep 1
done
Expand All @@ -100,11 +114,32 @@ create_out_dir "${OUTPUT}"
info_msg "About to run wlan smoke test..."
info_msg "Output directory: ${OUTPUT}"

# ensure that device is available at boot
# ensure that device(s) are available at boot
wait_for_device
test_iplink
test_wlan_boot
test_wlan_down
test_wlan_up

# use the explicitly requested device, or auto-detect all wireless
# interfaces present on the DUT
devices="${DEVICE:-$(list_wlan_devices)}"

if [ -z "${devices}" ]; then
report_skip "wlan-device-exists"
exit 0
fi
report_pass "wlan-device-exists"

# keep plain test case names so results stay comparable across runs; when
# several interfaces are tested, wrap each one in its own test set to keep
# the names unique
multiple="false"
[ "$(echo "${devices}" | wc -l)" -gt 1 ] && multiple="true"

for device in ${devices}; do
[ "${multiple}" = "true" ] && report_set_start "${device}"
test_iplink "${device}"
test_wlan_boot "${device}"
test_wlan_down "${device}"
test_wlan_up "${device}"
[ "${multiple}" = "true" ] && report_set_stop
done

exit 0
3 changes: 2 additions & 1 deletion automated/linux/wlan-smoke/wlan-smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ metadata:
- dragonboard410c

params:
DEVICE: wlan0
# leave empty to auto-detect and test all wireless interfaces present
DEVICE: ""
# expected state on first boot: <enabled> or <disabled>
BOOT: enabled
WAIT_TIME: 0
Expand Down
Loading