diff options
author | James Maki <jmaki@multitech.com> | 2010-04-23 15:10:19 -0500 |
---|---|---|
committer | James Maki <jmaki@multitech.com> | 2010-04-23 15:10:19 -0500 |
commit | 34609050e110fdeaf9cd63888c5902031ca21b1f (patch) | |
tree | 1ac2e994ad8803c68d402a846111e7d19219ea63 /io-tool/sysfs-tests | |
download | mts-io-34609050e110fdeaf9cd63888c5902031ca21b1f.tar.gz mts-io-34609050e110fdeaf9cd63888c5902031ca21b1f.tar.bz2 mts-io-34609050e110fdeaf9cd63888c5902031ca21b1f.zip |
initial commit
Diffstat (limited to 'io-tool/sysfs-tests')
-rwxr-xr-x | io-tool/sysfs-tests | 181 |
1 files changed, 181 insertions, 0 deletions
diff --git a/io-tool/sysfs-tests b/io-tool/sysfs-tests new file mode 100755 index 0000000..cb65c57 --- /dev/null +++ b/io-tool/sysfs-tests @@ -0,0 +1,181 @@ +#!/usr/bin/env bash + +PATH=${PATH}:. + +source /usr/lib/mts-io-sysfs/mts-io-sysfs-inc.sh + +yesno() { + if [ $# -ne 1 ]; then + echo "yesno question" + exit 99 + fi + + local question=${1} + + while : + do + echo -n "${question}? [y/n] " + read line + local line=$(echo ${line} | tr A-Z a-z) + case "${line}" in + y) + return 0 + ;; + n) + return 1 + ;; + *) + ;; + esac + done +} + +store_assert() { + if [ $# -ne 2 ]; then + log_error "store_assert name value" + exit 99 + fi + + local name=${1} + local value=${2} + + local old_value="$(cat ${SYSFS_PLATFORM_DIR}/${name})" + store ${name} "${value}" + local new_value="$(cat ${SYSFS_PLATFORM_DIR}/${name})" + + if [ "${new_value}" != "${value}" ]; then + log_error "${name}: '${new_value}' != '${value}'" + exit 1 + fi +} + +show_assert() { + if [ $# -ne 2 ]; then + log_error "show_assert name value" + exit 99 + fi + + local name=${1} + local expected_value=${2} + + log_info "checking if ${name} is '${expected_value}'" + + local actual_value="$(show ${name})" + + if [ "${expected_value}" != "${actual_value}" ]; then + log_error "${name}: '${expected_value}' != '${actual_value}'" + exit 1 + fi +} + +show_assert_in_set() { + if [ $# -lt 2 ]; then + log_error "show_assert_in_set name value0 [value1 ...]" + exit 99 + fi + + local name=${1} + shift + + log_info "checking if ${name} is in set [$*]" + + local actual_value="$(show ${name})" + + for value in "$@"; do + if [ "${value}" = "${actual_value}" ]; then + log_info "${name} is '${value}'" + return + fi + done + + exit 1 +} + +VERBOSE=true + +echo none > /sys/devices/platform/leds-gpio/leds/status/trigger + +modprobe -r mts-io +modprobe mts-io + +sleep 2 + +show_assert radio-reset 1 +log_info "resetting radio..." +store radio-reset 0 +sleep 2 +show_assert radio-reset 1 +log_info "radio reset" + +show_assert eth0-enabled 1 +store_assert eth0-enabled 0 +sleep 2 +if ! yesno "Are the ethernet LEDs off"; then + exit 1 +fi +store_assert eth0-enabled 1 +sleep 2 +if ! yesno "Are the ethernet LEDs on"; then + exit 1 +fi + +show_assert extserial-dcd 0 +store_assert extserial-dcd 1 +store_assert extserial-dcd 0 + +show_assert extserial-ri 0 +store_assert extserial-ri 1 +store_assert extserial-ri 0 + +show_assert led-sig1 0 +store_assert led-sig1 1 +store_assert led-sig1 0 + +show_assert led-sdk-c 0 +store_assert led-sdk-c 1 +store_assert led-sdk-c 0 + +show_assert led-sig2 0 +store_assert led-sig2 1 +store_assert led-sig2 0 + +show_assert led-sdk-d 0 +store_assert led-sdk-d 1 +store_assert led-sdk-d 0 + +show_assert led-sig3 0 +store_assert led-sig3 1 +store_assert led-sig3 0 + +show_assert led-sdk-e 0 +store_assert led-sdk-e 1 +store_assert led-sdk-e 0 + +show_assert led-cd 0 +store_assert led-cd 1 +store_assert led-cd 0 + +show_assert led-sdk-b 0 +store_assert led-sdk-b 1 +store_assert led-sdk-b 0 + +show_assert led-status 0 +store_assert led-status 1 +store_assert led-status 0 + +show_assert led-sdk-a 0 +store_assert led-sdk-a 1 +store_assert led-sdk-a 0 + +show_assert reset 0 +store reset 1 +show_assert reset 0 + +show_assert_in_set board-temperature {30..40} +store board-temperature 1000 +show_assert_in_set board-temperature {30..40} + +show_assert reset-monitor "-1 10 12" + +exit 0 + |