All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] test:dfu: Add test scripts for testing DFU regression
Date: Tue, 17 Jun 2014 12:09:41 +0200	[thread overview]
Message-ID: <20140617120941.006b9d9b@amdc2363> (raw)
In-Reply-To: <CAPnjgZ2k36KAuB56j4PQGVJN5L2RJjwMV_1iQT+9OYcOz+M55w@mail.gmail.com>

Hi Simon,

> Hi Lukasz,
> 
> On 3 June 2014 03:54, Lukasz Majewski <l.majewski@samsung.com> wrote:
> > 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 <l.majewski@samsung.com>
> > ---
> > 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
> 
> Looks good, but a few comments below.
> 
> > ---
> >  test/dfu/README                  |   27 ++++++++++++
> >  test/dfu/dfu_gadget_test.sh      |   88
> > ++++++++++++++++++++++++++++++++++++++
> > test/dfu/dfu_gadget_test_init.sh |   34 +++++++++++++++ 3 files
> > changed, 149 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..f8f5a43
> > --- /dev/null
> > +++ b/test/dfu/README
> > @@ -0,0 +1,27 @@
> > +DFU TEST CASE DESCRIPTION:
> > +
> > +The prerequisites for running this script are assured by
> > +dfu_gadget_test_init.sh script.
> > +In this file user is able to generate their own set of test files
> > by altering +the default set of TEST_FILES_SIZES variable
> > +
> > +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
> > +
> > +where 11 is the mumber of alt setting corresponding to entry [1].
> > +
> > +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..8abd8e7
> > --- /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
> > +
> > +COLOR_RED="\33[31m"
> > +COLOR_GREEN="\33[32m"
> > +COLOR_DEFAULT="\33[0m"
> 
> Which side of the pond are you? :-) I think it should be COLOUR in
> U-Boot.

Ok, I will change the spelling from COLOR to COLOUR.

> 
> > +
> > +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 "   $COLOR_RED FAILED $COLOR_DEFAULT \n"
> > +       cleanup
> > +       exit 1
> > +}
> > +
> > +calculate_md5sum () {
> > +    MD5SUM=`md5sum $1`
> > +    MD5SUM=`echo $MD5SUM | cut -d ' ' -f1`
> > +    echo "md5sum:"$MD5SUM
> > +}
> > +
> > +dfu_test_file () {
> > +    printf "$COLOR_GREEN
> > =========================================================================================
> > $COLOR_DEFAULT\n"
> > +    printf "File:$COLOR_GREEN %s $COLOR_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 "   $COLOR_GREEN -------> OK $COLOR_DEFAULT \n"
> > +    else
> > +       printf "   $COLOR_RED -------> FAILED $COLOR_DEFAULT \n"
> > +       cleanup
> > +       exit 1
> > +    fi
> > +
> > +}
> > +
> > +printf
> > "$COLOR_GREEN=========================================================================================
> > $COLOR_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 "   $COLOR_RED Please pass alt setting number!!
> > $COLOR_DEFAULT \n"
> > +       exit 0
> > +fi
> > +
> > +TARGET_ALT_SETTING=$1
> > +
> > +if [ -n "$2" ]
> > +then
> > +       dfu_test_file $2
> 
> Where is $2 mentioned? in your example usage?

$2 is for the case when one wants to test a particular file. I will add
this to the patch description.

> 
> > +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..ea2f715
> > --- /dev/null
> > +++ b/test/dfu/dfu_gadget_test_init.sh
> 
> Should this script be run by the main script in the default case? You
> could have a flag to force it to use existing files.

This script (dfu_gadget_test_init.sh) at [1] checks if file which it
intends to create already exists.

Is this the behaviour which you would like to see in this script?

> 
> > @@ -0,0 +1,34 @@
> > +#! /bin/bash
> > +set -e # any command return if not equal to zero
> > +clear
> > +
> > +COLOR_RED="\33[31m"
> > +COLOR_GREEN="\33[32m"
> > +COLOR_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
		^^^^^^^^^^ [1]

> > +       dd if=/dev/urandom of="./dat_$size.img" bs=$size count=1
> > > /dev/null 2>&1 || exit $?
> > +    fi
> > +done
> > +
> > +printf "$COLOR_GREEN OK $COLOR_DEFAULT \n"
> > +
> > +exit 0
> > --
> > 1.7.10.4
> >
> 
> Regards,
> Simon



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

  parent reply	other threads:[~2014-06-17 10:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-22 10:43 [U-Boot] [PATCH] test:dfu: Add test script for testing DFU regression Lukasz Majewski
2014-05-24  0:51 ` Simon Glass
2014-05-26  6:20   ` Lukasz Majewski
2014-05-29 15:58   ` Stephen Warren
2014-05-29 23:41     ` Simon Glass
2014-05-30  7:13       ` Lukasz Majewski
2014-06-03  9:54 ` [U-Boot] [PATCH v2] test:dfu: Add test scripts " Lukasz Majewski
2014-06-06 21:08   ` Simon Glass
2014-06-12  9:00     ` Lukasz Majewski
2014-06-12 13:34       ` Simon Glass
2014-06-17 10:09     ` Lukasz Majewski [this message]
2014-06-18  9:38 ` [U-Boot] [PATCH v3] " Lukasz Majewski
2014-06-20  7:48   ` Lukasz Majewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140617120941.006b9d9b@amdc2363 \
    --to=l.majewski@samsung.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.