diff options
author | Stephane Desneux <stephane.desneux@iot.bzh> | 2016-06-14 11:51:43 +0200 |
---|---|---|
committer | Stephane Desneux <stephane.desneux@iot.bzh> | 2016-06-14 11:51:51 +0200 |
commit | e2472c7b1d061aef8bb05a4d7940fd8159c4a329 (patch) | |
tree | d02452b65c994c373f88199028f53020722d9815 /dung-3.4.25-m2/common/unbind-bind.sh | |
parent | 87cdfd4626c0cb47fc22f328867e49d6268df85c (diff) |
add dung-3.4.25-m2, required by some JTA Functional.* testsblowfish_2.0.12.0.1
collection of shell scripts Used in multiple tests:
* Functional.arch_timer/arch_timer.sh
* Functional.scifab/scifab.sh
* Functional.cmt/cmt.sh
* Functional.sdhi_0/sdhi_0.sh
Change-Id: I268c426071890554518e8b4927620fe6df587c34
Signed-off-by: Stephane Desneux <stephane.desneux@iot.bzh>
Diffstat (limited to 'dung-3.4.25-m2/common/unbind-bind.sh')
-rwxr-xr-x | dung-3.4.25-m2/common/unbind-bind.sh | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/dung-3.4.25-m2/common/unbind-bind.sh b/dung-3.4.25-m2/common/unbind-bind.sh new file mode 100755 index 0000000..25f9fb3 --- /dev/null +++ b/dung-3.4.25-m2/common/unbind-bind.sh @@ -0,0 +1,76 @@ +#!/bin/sh +# unbind-bind-write.sh +# +# Simple test of binding and unbinding a device +# +# Copyright (C) 2013 Horms Soltutions Ltd. +# +# Contact: Simon Horman <horms@verge.net.au> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. + +set -e +#set -x + +if [ $# -lt 2 ]; then + echo "usage: $(basename $0) DRIVER DEVICE_NAME [CHECK_PATH...]" >& 2 + exit 1 +fi + +DRIVER="$1"; shift +DEVICE_NAME="$1"; shift + +SYSFS_BASE_DIR="/sys/bus/platform/drivers/$DRIVER" +SYSFS_DEV_DIR="$SYSFS_BASE_DIR/$DEVICE_NAME" + +CHECK_PATH="$SYSFS_DEV_DIR $@" + +exists () +{ + for i in $CHECK_PATH; do + if [ ! -e "$i" ]; then + echo \'$i\': No such file or directory >&2 + exit 1 + fi + done +} + +echo "Test device files exists" + +exists + +echo "Unbind device" +echo "$DEVICE_NAME" > "$SYSFS_BASE_DIR/unbind" + +echo "Test that block device and sysfs directory no longer exist" +for i in $CHECK_PATH; do + if [ -e "$i" ]; then + echo Failed to unbind \'$DEVICE_NAME\': \'$i\' still exists >&2 + exit 1 + fi +done + +echo "Bind device" +echo "$DEVICE_NAME" > "$SYSFS_BASE_DIR/bind" + +echo "Wait for device files to be recreated" +for i in $(seq 1 32); do + OK="true" + for i in $CHECK_PATH; do + if [ ! -e "$i" ]; then + OK="false" + break + fi + done + if [ "$OK" = "false" ]; then + sleep 1 + else + break + fi +done + +echo "Test that device files once again exist" +exists + |