From patchwork Wed Jun 18 09:38:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Majewski?= X-Patchwork-Id: 361378 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id D99F3140084 for ; Wed, 18 Jun 2014 19:39:33 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0EC78A7409; Wed, 18 Jun 2014 11:39:32 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BwUtQovOJk2c; Wed, 18 Jun 2014 11:39:31 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id ECAAAA740F; Wed, 18 Jun 2014 11:39:27 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B9CA5A740F for ; Wed, 18 Jun 2014 11:39:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xE1THWq5krHi for ; Wed, 18 Jun 2014 11:39:20 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by theia.denx.de (Postfix) with ESMTPS id 9BFAFA7409 for ; Wed, 18 Jun 2014 11:39:15 +0200 (CEST) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N7C007DJYTAMH70@mailout4.samsung.com> for u-boot@lists.denx.de; Wed, 18 Jun 2014 18:39:11 +0900 (KST) X-AuditID: cbfee61b-b7fbb6d000001be3-d9-53a15e3ee3e3 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id BA.90.07139.E3E51A35; Wed, 18 Jun 2014 18:39:10 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N7C00ENWYT1U030@mmp1.samsung.com>; Wed, 18 Jun 2014 18:39:10 +0900 (KST) From: Lukasz Majewski To: u-boot@lists.denx.de, Tom Rini , Stephen Warren Date: Wed, 18 Jun 2014 11:38:56 +0200 Message-id: <1403084336-27503-1-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-reply-to: <1400755421-9996-1-git-send-email-l.majewski@samsung.com> References: <1400755421-9996-1-git-send-email-l.majewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJLMWRmVeSWpSXmKPExsVy+t9jAV27uIXBBueuGlrsuHOf2eLNI26L Nw83M1q8aWtktNhx+QaLxa7bk1ksvm3ZxmhxY3oLq8Wrg20sFpMXz2e2eLu3k92B22Pez4lM HrMbLrJ4zJt1gsXj7J0djB7rpr1l9uhtfsfm0bdlFaPH8RvbmTw2zg0N4IzisklJzcksSy3S t0vgyji4Jr3gsnbFppObWRsYu5S7GDk5JARMJFZOWs8GYYtJXLgHYnNxCAksYpS4fX0qM4TT xSSxb94KJpAqNgE9ic93n4LZIgLREq8vnWQCKWIW2MMkcerhCbBRwgKeEv9+rwFKcHCwCKhK 7N6nCmLyCrhJnDlfCLFMUaL72QSwak6gcO+ZxWC2kICrxPXnX1gnMPIuYGRYxSiaWpBcUJyU nmukV5yYW1yal66XnJ+7iREcoM+kdzCuarA4xCjAwajEw8uRuyBYiDWxrLgy9xCjBAezkgjv FM+FwUK8KYmVValF+fFFpTmpxYcYpTlYlMR5D7ZaBwoJpCeWpGanphakFsFkmTg4pRoYp5/S LW/YeWntJrbPR1Inqcw5bTFz1j+N+pXz5tfZ/VhyRj+zI21av7Ma42JVd/lPjKde/3ms9/tc m8vLmqSfulfXLlxy4IXfhAvGhz7Jh1lLmC7jSkgsWOt8IcUsebVV2Iv4k146OvIzRc+u5J2Q eDmDd2OA7KQfnqrnfzZHdulEfL71VNCzR4mlOCPRUIu5qDgRAAyTMRJMAgAA Cc: Marek Vasut , Stephen Warren , Pantelis Antoniou , Przemyslaw Marczak Subject: [U-Boot] [PATCH v3] test:dfu: Add test scripts for testing DFU regression X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This commit adds test scripts for testing if any commit has introduced regression to the DFU subsystem. It uses md5 to test if sent and received file is correct. The test detailed description is available at README file. Signed-off-by: Lukasz Majewski --- Changes for v3: - Rename COLOR with COLOUR - Add README description for the optional second parameter passed to dfu_gadget_test.sh Changes for v2: - Rename DESCRIPTION.TXT to README - Introduction of COLOUR_* variables to hold code necessary to change console color - File to create initial setup - dfu_gadget_test_init.sh has been added - Test files are now automatically generated with the above script --- test/dfu/README | 30 ++++++++++++++ test/dfu/dfu_gadget_test.sh | 88 ++++++++++++++++++++++++++++++++++++++++ test/dfu/dfu_gadget_test_init.sh | 34 ++++++++++++++++ 3 files changed, 152 insertions(+) create mode 100644 test/dfu/README create mode 100755 test/dfu/dfu_gadget_test.sh create mode 100755 test/dfu/dfu_gadget_test_init.sh diff --git a/test/dfu/README b/test/dfu/README new file mode 100644 index 0000000..f8c1a74 --- /dev/null +++ b/test/dfu/README @@ -0,0 +1,30 @@ +DFU TEST CASE DESCRIPTION: + +The prerequisites for running this script are assured by dfu_gadget_test_init.sh. +In this file user is able to generate their own set of test files by altering +the default set of TEST_FILES_SIZES variable. +The dfu_gadget_test_init.sh would generate test images only if they are not +already generated. + +Moreover, on a target device the "dfu_alt_info" env variable should be extended +to have "dfu_test.bin fat 0 6;" \ entry ([1]). For reference please consult the +config file for TRATS/TRATS2 devices (./include/configs/trats{2}.h) + +One can use fat, ext4 or any other supported file system, which can be +created in a convenient way with exporting partitions via UMS (ums 0 mmc 0) +and using standard tools on host (like mkfs.ext4). + +Example usage: +1. On the target: + env default -a + dfu 0 mmc 0 +2. On the host: + ./dfu_gadget_test.sh 11 [test_file] + +where 11 is the mumber of alt setting corresponding to entry [1] and [test_file] +is an optional parameter, with which one can explicitly indicate the test file +to be used. + +The number of the alt setting entry can be obtained with dfu-util -l command. +In its output one should look for the 'name="dfu_test1.bin"' and corresponding +alt=11. diff --git a/test/dfu/dfu_gadget_test.sh b/test/dfu/dfu_gadget_test.sh new file mode 100755 index 0000000..4a848c8 --- /dev/null +++ b/test/dfu/dfu_gadget_test.sh @@ -0,0 +1,88 @@ +#! /bin/bash +set -e # any command return if not equal to zero +clear + +COLOUR_RED="\33[31m" +COLOUR_GREEN="\33[32m" +COLOUR_DEFAULT="\33[0m" + +DIR=./ +SUFFIX=img +RCV_DIR=rcv/ +LOG_FILE=./log/log-`date +%d-%m-%Y_%H-%M-%S` + +./dfu_gadget_test_init.sh + +cleanup () { + rm -rf $RCV_DIR +} + +die () { + printf " $COLOUR_RED FAILED $COLOUR_DEFAULT \n" + cleanup + exit 1 +} + +calculate_md5sum () { + MD5SUM=`md5sum $1` + MD5SUM=`echo $MD5SUM | cut -d ' ' -f1` + echo "md5sum:"$MD5SUM +} + +dfu_test_file () { + printf "$COLOUR_GREEN ========================================================================================= $COLOUR_DEFAULT\n" + printf "File:$COLOUR_GREEN %s $COLOUR_DEFAULT\n" $1 + + dfu-util -D $1 -a $TARGET_ALT_SETTING >> $LOG_FILE 2>&1 || die $? + + echo -n "TX: " + calculate_md5sum $1 + + MD5_TX=$MD5SUM + + N_FILE=$DIR$RCV_DIR${1:2}"_rcv" + + dfu-util -U $N_FILE -a $TARGET_ALT_SETTING >> $LOG_FILE 2>&1 || die $? + + echo -n "RX: " + calculate_md5sum $N_FILE + MD5_RX=$MD5SUM + + if [ "$MD5_TX" == "$MD5_RX" ]; then + printf " $COLOUR_GREEN -------> OK $COLOUR_DEFAULT \n" + else + printf " $COLOUR_RED -------> FAILED $COLOUR_DEFAULT \n" + cleanup + exit 1 + fi + +} + +printf "$COLOUR_GREEN========================================================================================= $COLOUR_DEFAULT\n" +echo "DFU EP0 transmission test program" +echo "Trouble shoot -> disable DBG (even the KERN_DEBUG) in the UDC driver" +echo "@ -> TRATS2 # dfu 0 mmc 0" +mkdir -p $RCV_DIR +touch $LOG_FILE + +if [ $# -eq 0 ] +then + printf " $COLOUR_RED Please pass alt setting number!! $COLOUR_DEFAULT \n" + exit 0 +fi + +TARGET_ALT_SETTING=$1 + +if [ -n "$2" ] +then + dfu_test_file $2 +else + for file in $DIR*.$SUFFIX + do + dfu_test_file $file + done +fi + +cleanup + +exit 0 diff --git a/test/dfu/dfu_gadget_test_init.sh b/test/dfu/dfu_gadget_test_init.sh new file mode 100755 index 0000000..b319ed0 --- /dev/null +++ b/test/dfu/dfu_gadget_test_init.sh @@ -0,0 +1,34 @@ +#! /bin/bash +set -e # any command return if not equal to zero +clear + +COLOUR_RED="\33[31m" +COLOUR_GREEN="\33[32m" +COLOUR_DEFAULT="\33[0m" + +LOG_DIR="./log" +BKP_DIR="./bkp" + +TEST_FILES_SIZES="127 128 129 8M 4095 4096 4097 63 64 65 960" + +printf "Init script for generating data necessary for DFU test script" + +if [ ! -d $LOG_DIR ]; then + `mkdir $LOG_DIR` +fi + +if [ ! -d $BKP_DIR ]; then + `mkdir $BKP_DIR` +fi + +for size in $TEST_FILES_SIZES +do + FILE="./dat_$size.img" + if [ ! -f $FILE ]; then + dd if=/dev/urandom of="./dat_$size.img" bs=$size count=1 > /dev/null 2>&1 || exit $? + fi +done + +printf "$COLOUR_GREEN OK $COLOUR_DEFAULT \n" + +exit 0