diff options
Diffstat (limited to 'dung-3.4.25-m2/common')
-rwxr-xr-x | dung-3.4.25-m2/common/dmesg-quiet.sh | 29 | ||||
-rwxr-xr-x | dung-3.4.25-m2/common/dmesg.sh | 24 | ||||
-rwxr-xr-x | dung-3.4.25-m2/common/interrupt-count.sh | 20 | ||||
-rwxr-xr-x | dung-3.4.25-m2/common/mount-device.sh | 31 | ||||
-rwxr-xr-x | dung-3.4.25-m2/common/proc-interrupts.sh | 31 | ||||
-rwxr-xr-x | dung-3.4.25-m2/common/umount-device.sh | 25 | ||||
-rwxr-xr-x | dung-3.4.25-m2/common/unbind-bind-write.sh | 27 | ||||
-rwxr-xr-x | dung-3.4.25-m2/common/unbind-bind.sh | 76 | ||||
-rwxr-xr-x | dung-3.4.25-m2/common/write-common.sh | 77 | ||||
-rwxr-xr-x | dung-3.4.25-m2/common/write-dd.sh | 73 |
10 files changed, 413 insertions, 0 deletions
diff --git a/dung-3.4.25-m2/common/dmesg-quiet.sh b/dung-3.4.25-m2/common/dmesg-quiet.sh new file mode 100755 index 0000000..d0b6219 --- /dev/null +++ b/dung-3.4.25-m2/common/dmesg-quiet.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# dmesg-quiet.sh +# +# Simple dmesg based feature test (quiet variant) +# +# 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 [ $# -ne 1 ]; then + echo "usage: $(basename $0) PATTERN" >& 2 + exit 1 +fi + +PATTERN="$1" + +#echo "dmesg feature test for '$PATTERN'" + +if ! dmesg | grep "$PATTERN" > /dev/null; then + echo "error: not matched" >&2 + exit 1 +fi diff --git a/dung-3.4.25-m2/common/dmesg.sh b/dung-3.4.25-m2/common/dmesg.sh new file mode 100755 index 0000000..4047043 --- /dev/null +++ b/dung-3.4.25-m2/common/dmesg.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# dmesg.sh +# +# Simple dmesg based feature test +# +# 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 + +$(dirname $0)/dmesg-quiet.sh "$@" +STATUS="$?" + +if [ "$STATUS" -eq "0" ]; then + echo "Test passed" +fi + +exit "$STATUS" diff --git a/dung-3.4.25-m2/common/interrupt-count.sh b/dung-3.4.25-m2/common/interrupt-count.sh new file mode 100755 index 0000000..ab5c16a --- /dev/null +++ b/dung-3.4.25-m2/common/interrupt-count.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# count interrupt of device + +set -e +#set -x + +if [ $# -ne 1 ]; then + echo "usage: $(basename $0) PATTERN" >& 2 + exit 1 +fi + +IRQ="" + +$(dirname $0)/../common/proc-interrupts.sh "$1" > irq_temp + +# Filter interrupt number +read IRQ < irq_temp +IRQ=${IRQ%% [A-Za-z]*} +IRQ=${IRQ#* } +echo $IRQ diff --git a/dung-3.4.25-m2/common/mount-device.sh b/dung-3.4.25-m2/common/mount-device.sh new file mode 100755 index 0000000..a5e4b78 --- /dev/null +++ b/dung-3.4.25-m2/common/mount-device.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# mount devices + +echo "Mount devices" + +set -e +#set -x + +if [ $# -ne 1 ]; then + echo "usage: $(basename $0) PATTERN" >& 2 + exit 1 +fi + +DEV_DIR="$1" + +# Mount device +if [ $DEV_DIR == "/mnt/sd0" ]; then + mount /dev/mmcblk1p1 /mnt/sd0/ +elif [ $DEV_DIR == "/mnt/sd1" ]; then + mount /dev/mmcblk2p1 /mnt/sd1/ +else + mount -t tmpfs -o size=450M tmpfs /tmp/temp/ +fi + +# Mount check +if [ $? -eq 0 ];then + echo "Device have mounted" +else + echo "Device mount is error" >&2 + exit 1 +fi diff --git a/dung-3.4.25-m2/common/proc-interrupts.sh b/dung-3.4.25-m2/common/proc-interrupts.sh new file mode 100755 index 0000000..3e709a0 --- /dev/null +++ b/dung-3.4.25-m2/common/proc-interrupts.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# dmesg.sh +# +# Simple /proc/interrupts presence test +# +# 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 [ $# -ne 1 ]; then + echo "usage: $(basename $0) PATTERN" >& 2 + exit 1 +fi + +PATTERN="$1" + +#echo "/proc/interrupts feature test for '$PATTERN'" + +if ! grep "$PATTERN" /proc/interrupts; then + echo "error: not matched" >&2 + exit 1 +fi + +#echo "Test passed" diff --git a/dung-3.4.25-m2/common/umount-device.sh b/dung-3.4.25-m2/common/umount-device.sh new file mode 100755 index 0000000..59a829a --- /dev/null +++ b/dung-3.4.25-m2/common/umount-device.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# umount devices + +echo "Umount devices" + +set -e +#set -x + +if [ $# -ne 1 ]; then + echo "usage: $(basename $0) PATTERN" >& 2 + exit 1 +fi + +DEV_DIR="$1" + +# Umount device +umount ${DEV_DIR}/ + +# Umount check +if [ $? -eq 0 ];then + echo "Device have umounted" +else + echo "Device umount is error" >&2 + exit 1 +fi diff --git a/dung-3.4.25-m2/common/unbind-bind-write.sh b/dung-3.4.25-m2/common/unbind-bind-write.sh new file mode 100755 index 0000000..a858aa3 --- /dev/null +++ b/dung-3.4.25-m2/common/unbind-bind-write.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# unbind-bind-write.sh +# +# Simple test of unbinding and re-binding a device followed +# by writing to an associated block 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 [ $# -ne 3 ]; then + echo "usage: $(basename $0) DRIVER DEVICE_NAME BLOCK_DEVICE" >& 2 + exit 1 +fi + +$(dirname $0)/../common/unbind-bind.sh "$@" + +echo "Perform write test" +exec $(dirname $0)/../common/write-dd.sh "$3" 1M 10 + 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 + diff --git a/dung-3.4.25-m2/common/write-common.sh b/dung-3.4.25-m2/common/write-common.sh new file mode 100755 index 0000000..09b5720 --- /dev/null +++ b/dung-3.4.25-m2/common/write-common.sh @@ -0,0 +1,77 @@ +#!/bin/sh +# write-dev.sh +# +# Simple dd-based write test +# +# 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 [ $# -ne 4 ]; then + echo "usage: $(basename $0) PATH BLOCK_SIZE BLOCK_COUNT" >& 2 + exit 1 +fi + +SRC_DEV="$1" +DST_DEV="$2" +BLOCK_SIZE="$3" +BLOCK_COUNT="$4" + +echo "test data (bs=$BLOCK_SIZE count=$BLOCK_COUNT)" + +echo "Test that device exists" +if [ ! -e "$SRC_DEV" ]; then + echo \'$SRC_DEV\': No such file or directory >&2 + exit 1 +fi + +if [ ! -e "$DST_DEV" ]; then + echo \'$SRC_DE\': No such file or directory >&2 + exit 1 + +fi + +IN="" +OUT="" +cleanup () +{ + [ -n "$IN" -a -f "$IN" ] && rm "$IN" + [ -n "$OUT" -a -f "$OUT" ] && rm "$OUT" +} +trap cleanup exit +IN=$(mktemp -p $SRC_DEV/) +OUT=$(mktemp -p $DST_DEV/) + +echo "Write random data to test file" +dd if=/dev/urandom of="$IN" bs="$BLOCK_SIZE" count="$BLOCK_COUNT" > /dev/null 2>&1 + +echo "Write test data to device" +dd if="$IN" of="$OUT" bs="$BLOCK_SIZE" count="$BLOCK_COUNT" > /dev/null 2>&1 + + +IN_SUM=$(sha256sum "$IN" | cut -f 1 -d ' ') +OUT_SUM=$(sha256sum "$OUT" | cut -f 1 -d ' ') + +IN_SIZE=$(wc -c "$IN" | cut -f 1 -d ' ') +OUT_SIZE=$(wc -c "$OUT" | cut -f 1 -d ' ') + +echo "Compare data writen to data read" +if [ "$IN_SUM" != "$OUT_SUM" ]; then + echo "Data read does not match data written" >&2 + echo "Size (bytes):" >&2 + echo " in: $IN_SIZE" >&2 + echo " out: $OUT_SIZE" >&2 + echo "SHA 256 Checksums:" >&2 + echo " in: $IN_SUM" >&2 + echo " out: $OUT_SUM" >&2 + exit 1 +fi + +echo "Test passed" diff --git a/dung-3.4.25-m2/common/write-dd.sh b/dung-3.4.25-m2/common/write-dd.sh new file mode 100755 index 0000000..0299819 --- /dev/null +++ b/dung-3.4.25-m2/common/write-dd.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# write-dev.sh +# +# Simple dd-based write test +# +# 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 [ $# -ne 3 ]; then + echo "usage: $(basename $0) PATH BLOCK_SIZE BLOCK_COUNT" >& 2 + exit 1 +fi + +DEV="$1" +BLOCK_SIZE="$2" +BLOCK_COUNT="$3" + +echo "write test for $DEV (bs=$BLOCK_SIZE count=$BLOCK_COUNT)" + +echo "Test that device exists" +if [ ! -e "$DEV" ]; then + echo \'$DEV\': No such file or directory >&2 + exit 1 +fi + +IN="" +OUT="" +cleanup () +{ + [ -n "$IN" -a -f "$IN" ] && rm "$IN" + [ -n "$OUT" -a -f "$OUT" ] && rm "$OUT" +} +trap cleanup exit +IN=$(mktemp) +OUT=$(mktemp) + +echo "Write random data to test file" +dd if=/dev/urandom of="$IN" bs="$BLOCK_SIZE" count="$BLOCK_COUNT" + +echo "Write test data to device" + +dd if="$IN" of="$DEV" oflag=direct bs="$BLOCK_SIZE" count="$BLOCK_COUNT" + +echo "Read test data from device" +dd if="$DEV" of="$OUT" bs="$BLOCK_SIZE" count="$BLOCK_COUNT" + +IN_SUM=$(sha256sum "$IN" | cut -f 1 -d ' ') +OUT_SUM=$(sha256sum "$OUT" | cut -f 1 -d ' ') + +IN_SIZE=$(wc -c "$IN" | cut -f 1 -d ' ') +OUT_SIZE=$(wc -c "$OUT" | cut -f 1 -d ' ') + +echo "Compare data writen to data read" +if [ "$IN_SUM" != "$OUT_SUM" ]; then + echo "Data read does not match data written" >&2 + echo "Size (bytes):" >&2 + echo " in: $IN_SIZE" >&2 + echo " out: $OUT_SIZE" >&2 + echo "SHA 256 Checksums:" >&2 + echo " in: $IN_SUM" >&2 + echo " out: $OUT_SUM" >&2 + exit 1 +fi + +echo "Test passed" |