mirror of
https://github.com/linux-msm/bootrr.git
synced 2026-02-25 13:12:03 -08:00
bootrr: Move common functions to bootrr
Move the common functions to a helper and use this from assert_device_present. Make assert_device_present accept a fourth parameter for a timeout, which will cause the assert to wait for the given amount of time for the device to appear. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
source /usr/bin/bootrr
|
||||
|
||||
TEST_CASE_ID="$1"
|
||||
DRIVER="$2"
|
||||
DEVICE="$3"
|
||||
TIMEOUT="${4:-1}"
|
||||
|
||||
if [ -z "${TEST_CASE_ID}" -o -z "${DRIVER}" -o -z "${DEVICE}" ]; then
|
||||
echo "Usage: $0 <test-case-id> <driver> <device>"
|
||||
echo "Usage: $0 <test-case-id> <driver> <device> [<timeout>]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -L /sys/bus/*/drivers/${DRIVER}/${DEVICE} ]; then
|
||||
TEST_RESULT="pass"
|
||||
else
|
||||
TEST_RESULT="fail"
|
||||
fi
|
||||
timeout ${TIMEOUT} [ -L /sys/bus/*/drivers/${DRIVER}/${DEVICE} ] || test_report_exit fail
|
||||
|
||||
lava-test-case "${TEST_CASE_ID}" --result ${TEST_RESULT}
|
||||
test_report_exit pass
|
||||
|
||||
21
helpers/bootrr
Normal file
21
helpers/bootrr
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
timeout() {
|
||||
attempts="$1"; shift
|
||||
cmd="$@"
|
||||
|
||||
for i in `seq ${attempts}`
|
||||
do
|
||||
$cmd && return 0
|
||||
sleep 1
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
test_report_exit() {
|
||||
TEST_RESULT=$1
|
||||
lava-test-case ${TEST_CASE_ID} --result ${TEST_RESULT}
|
||||
exit 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user