[Fuego] [PATCH 4/4] sdhi_0: re-write this sdhi_0 test

Qiu Tingting qiutt at cn.fujitsu.com
Mon Sep 17 08:23:33 UTC 2018


Use a similar mechanism[1] to re-write this sdhi_0 test, like Functional.arch_timer.
And there are some modify of generalizing this sdhi_0 test.

[1] https://github.com/Jinzai-solution/SALVATOR_SHELL.git

Signed-off-by: Qiu Tingting <qiutt at cn.fujitsu.com>
---
 engine/tests/Functional.sdhi_0/check_sdhi.sh | 131 +++++++++++++++++++++++++++
 engine/tests/Functional.sdhi_0/fuego_test.sh |  28 +++---
 2 files changed, 147 insertions(+), 12 deletions(-)
 create mode 100755 engine/tests/Functional.sdhi_0/check_sdhi.sh

diff --git a/engine/tests/Functional.sdhi_0/check_sdhi.sh b/engine/tests/Functional.sdhi_0/check_sdhi.sh
new file mode 100755
index 0000000..4248ef2
--- /dev/null
+++ b/engine/tests/Functional.sdhi_0/check_sdhi.sh
@@ -0,0 +1,131 @@
+#!/bin/sh
+# PDX-License-Identifier: MIT
+#
+# check_sdhi.sh - unbind and bind sd/mmc device, then use dd command to write random data in the device
+#
+# Usage: check_sdhi.sh <dev_name> <block_num> <driver_name>
+#
+# Output is in TAP13 format
+#
+# Author: Qiu Tingting<qiutt (at) cn.fujitsu.com>
+#
+
+usage() {
+    cat <<HERE
+Usage: check_sdhi.sh [-h] <dev_name> <block_num> <driver_name>
+
+Arguments:
+ -h  = show this usage help
+
+dev_name is the name of sd/mmc device in /dev/disk/by-path/
+(eg:sh_mobile_sdhi)
+block_num is the block of sd/mmc device used for test
+(eg:1)
+driver_name is the name of sd/mmc driver in /sys/bus/platform/drivers/
+(eg:sh_mobile_sdhi)
+HERE
+   exit 0
+}
+
+# parse arguments
+if [ "$#" -ne 3 ] ; then
+    usage
+fi
+
+DEV_NAME="$1"
+BLOCK_NUM="$2"
+DRIVER_NAME="$3"
+
+echo "TAP version 13"
+
+echo "Test for sd/mmc device unbind/bind and dd write"
+echo "DEV_NAME=\"$DEV_NAME\""
+echo "BLOCK_NUM=\"$BLOCK_NUM\""
+echo "DRIVER_NAME=\"$DRIVER_NAME\""
+
+# set sdhi driver path
+sysfs_base_dir="/sys/bus/platform/drivers/$DRIVER_NAME"
+sysfs_dev_dir=`find $sysfs_base_dir -name "*$DEV_NAME*"`
+
+if [ ! -e "$sysfs_dev_dir" ] ; then
+    echo "there is no $DEV_NAME in path $sysfs_base_dir"
+    exit 1
+fi
+
+tap_id=1
+desc="${tap_id} Test unbind device"
+#unbind sd/mmc device
+dev_name_for_test=`basename $sysfs_dev_dir`
+echo "device name for test $dev_name_for_test"
+echo "$dev_name_for_test" > "$sysfs_base_dir/unbind"
+if [ -e "$sysfs_dev_dir" ] ; then
+    echo "not ok ${desc}"
+else
+    echo "ok ${desc}"
+fi
+
+tap_id=$(( $tap_id + 1 ))
+desc="${tap_id} Test bind device"
+#bind sd/mmc device
+echo "$dev_name_for_test" > "$sysfs_base_dir/bind"
+#sleep 30s, wait for device files to be recreated
+sleep 30
+if [ ! -e "$sysfs_dev_dir" ] ; then
+    echo "not ok ${desc}"
+    exit 1
+else
+    echo "ok ${desc}"
+fi
+
+write_path="/dev/disk/by-path/"
+write_dev=`find $write_path -name "*$DEV_NAME*$BLOCK_NUM"`
+echo "write device is $write_dev"
+
+# dd_test uses dd command to write data to sd/mmc device
+# $1 the block size for dd command
+# $2 the write count for dd command
+dd_test ()
+{
+    bs_size="$1"
+    bs_count="$2"
+
+    tap_id=$(( $tap_id + 1 ))
+    desc="${tap_id} Test write $bs_size*$bs_count random data"
+    IN=$(mktemp)
+    OUT=$(mktemp)
+    echo "  Write random data to test file"
+    dd if=/dev/urandom of="$IN" bs="${bs_size}" count="${bs_count}"
+    
+    echo "  Write test data to device"
+    dd if="$IN" of="$write_dev" oflag=direct bs="${bs_size}" count="${bs_count}"
+    
+    echo "  Read test data from device"
+    dd if="$write_dev" of="$OUT" bs="${bs_size}" count="${bs_count}"
+    
+    IN_SUM=$(sha256sum "$IN" | cut -f 1 -d ' ')
+    OUT_SUM=$(sha256sum "$OUT" | cut -f 1 -d ' ')
+    
+    echo "  Compare data writen to data read"
+    if [ "$IN_SUM" != "$OUT_SUM" ]; then
+        echo "not ok ${desc}"
+        IN_SIZE=$(wc -c "$IN" | cut -f 1 -d ' ')
+        OUT_SIZE=$(wc -c "$OUT" | cut -f 1 -d ' ')
+        echo "  Data read does not match data written"
+        echo "    Size (bytes):"
+        echo "      in:  $IN_SIZE"
+        echo "      out: $OUT_SIZE"
+        echo "  SHA 256 Checksums:"
+        echo "      in:  $IN_SUM"
+        echo "      out: $OUT_SUM"
+    else
+        echo "ok ${desc}"
+    fi   
+}
+
+# Test write 10M data to sd/mmc
+dd_test "1M" "10"
+
+# Test write 1k data to sd/mmc
+dd_test "1k" "1"
+
+echo "1..$tap_id"
diff --git a/engine/tests/Functional.sdhi_0/fuego_test.sh b/engine/tests/Functional.sdhi_0/fuego_test.sh
index b3cee43..056adcf 100755
--- a/engine/tests/Functional.sdhi_0/fuego_test.sh
+++ b/engine/tests/Functional.sdhi_0/fuego_test.sh
@@ -1,21 +1,25 @@
-tarball=dung-3.4.25-m2.tar.gz
+#
+# user must define in the board file:
+#  SDHI_DEV_NAME = the name of SD/MMC device in /dev/disk/by-path/
+#  SDHI_BLOCK_NUM = which block of SD/MMC device used for test
+#  SDHI_DRIVER_NAME = the name of SD/MMC driver in /sys/bus/platform/drivers/
+#
+
+function test_pre_check {
+    assert_define SDHI_DEV_NAME "Please define in board file as the name of sd/mmc device from /dev/disk/by-path/"
+    assert_define SDHI_BLOCK_NUM "Please define in board file as the block number of sd/mmc device"
+    assert_define SDHI_DRIVER_NAME "Please define in board file as the name of sd/mmc driver from /sys/bus/platform/drivers/"
+
+}
 
 function test_deploy {
-    put ./* $OSV_HOME/osv.$TESTDIR/
+    put $TEST_HOME/check_sdhi.sh $BOARD_TESTDIR/fuego.$TESTDIR/
 }
 
 function test_run {
-    report "cd $OSV_HOME/osv.$TESTDIR/sdhi.0; ./unbind-bind-write.sh; ./write-10M.sh; ./write-1k.sh"
+    report "$BOARD_TESTDIR/fuego.$TESTDIR/check_sdhi.sh \"$SDHI_DEV_NAME\" \"$SDHI_BLOCK_NUM\" \"$SDHI_DRIVER_NAME\""
 }
 
 function test_processing {
-    assert_define FUNCTIONAL_SDHI_0_RES_LINES_COUNT
-
-    check_capability "RENESAS"
-
-    log_compare "$TESTDIR" ""FUNCTIONAL_SDHI_0_RES_LINES_COUNT "Test passed" "p"
-
+    log_compare "$TESTDIR" 0 "^not ok" "n"
 }
-
-
-
-- 
2.7.4





More information about the Fuego mailing list