Commit a4c86bbb5ae89606d5318be4e2a6ae23110bb220

Authored by Lukasz Majewski
Committed by Tom Rini
1 parent 6f12ebf6ea

test:dfu: Add test scripts for testing DFU regression

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>

Showing 3 changed files with 152 additions and 0 deletions Side-by-side Diff

  1 +DFU TEST CASE DESCRIPTION:
  2 +
  3 +The prerequisites for running this script are assured by dfu_gadget_test_init.sh.
  4 +In this file user is able to generate their own set of test files by altering
  5 +the default set of TEST_FILES_SIZES variable.
  6 +The dfu_gadget_test_init.sh would generate test images only if they are not
  7 +already generated.
  8 +
  9 +Moreover, on a target device the "dfu_alt_info" env variable should be extended
  10 +to have "dfu_test.bin fat 0 6;" \ entry ([1]). For reference please consult the
  11 +config file for TRATS/TRATS2 devices (./include/configs/trats{2}.h)
  12 +
  13 +One can use fat, ext4 or any other supported file system, which can be
  14 +created in a convenient way with exporting partitions via UMS (ums 0 mmc 0)
  15 +and using standard tools on host (like mkfs.ext4).
  16 +
  17 +Example usage:
  18 +1. On the target:
  19 + env default -a
  20 + dfu 0 mmc 0
  21 +2. On the host:
  22 + ./dfu_gadget_test.sh 11 [test_file]
  23 +
  24 +where 11 is the mumber of alt setting corresponding to entry [1] and [test_file]
  25 +is an optional parameter, with which one can explicitly indicate the test file
  26 +to be used.
  27 +
  28 +The number of the alt setting entry can be obtained with dfu-util -l command.
  29 +In its output one should look for the 'name="dfu_test1.bin"' and corresponding
  30 +alt=11.
test/dfu/dfu_gadget_test.sh
  1 +#! /bin/bash
  2 +set -e # any command return if not equal to zero
  3 +clear
  4 +
  5 +COLOUR_RED="\33[31m"
  6 +COLOUR_GREEN="\33[32m"
  7 +COLOUR_DEFAULT="\33[0m"
  8 +
  9 +DIR=./
  10 +SUFFIX=img
  11 +RCV_DIR=rcv/
  12 +LOG_FILE=./log/log-`date +%d-%m-%Y_%H-%M-%S`
  13 +
  14 +./dfu_gadget_test_init.sh
  15 +
  16 +cleanup () {
  17 + rm -rf $RCV_DIR
  18 +}
  19 +
  20 +die () {
  21 + printf " $COLOUR_RED FAILED $COLOUR_DEFAULT \n"
  22 + cleanup
  23 + exit 1
  24 +}
  25 +
  26 +calculate_md5sum () {
  27 + MD5SUM=`md5sum $1`
  28 + MD5SUM=`echo $MD5SUM | cut -d ' ' -f1`
  29 + echo "md5sum:"$MD5SUM
  30 +}
  31 +
  32 +dfu_test_file () {
  33 + printf "$COLOUR_GREEN ========================================================================================= $COLOUR_DEFAULT\n"
  34 + printf "File:$COLOUR_GREEN %s $COLOUR_DEFAULT\n" $1
  35 +
  36 + dfu-util -D $1 -a $TARGET_ALT_SETTING >> $LOG_FILE 2>&1 || die $?
  37 +
  38 + echo -n "TX: "
  39 + calculate_md5sum $1
  40 +
  41 + MD5_TX=$MD5SUM
  42 +
  43 + N_FILE=$DIR$RCV_DIR${1:2}"_rcv"
  44 +
  45 + dfu-util -U $N_FILE -a $TARGET_ALT_SETTING >> $LOG_FILE 2>&1 || die $?
  46 +
  47 + echo -n "RX: "
  48 + calculate_md5sum $N_FILE
  49 + MD5_RX=$MD5SUM
  50 +
  51 + if [ "$MD5_TX" == "$MD5_RX" ]; then
  52 + printf " $COLOUR_GREEN -------> OK $COLOUR_DEFAULT \n"
  53 + else
  54 + printf " $COLOUR_RED -------> FAILED $COLOUR_DEFAULT \n"
  55 + cleanup
  56 + exit 1
  57 + fi
  58 +
  59 +}
  60 +
  61 +printf "$COLOUR_GREEN========================================================================================= $COLOUR_DEFAULT\n"
  62 +echo "DFU EP0 transmission test program"
  63 +echo "Trouble shoot -> disable DBG (even the KERN_DEBUG) in the UDC driver"
  64 +echo "@ -> TRATS2 # dfu 0 mmc 0"
  65 +mkdir -p $RCV_DIR
  66 +touch $LOG_FILE
  67 +
  68 +if [ $# -eq 0 ]
  69 +then
  70 + printf " $COLOUR_RED Please pass alt setting number!! $COLOUR_DEFAULT \n"
  71 + exit 0
  72 +fi
  73 +
  74 +TARGET_ALT_SETTING=$1
  75 +
  76 +if [ -n "$2" ]
  77 +then
  78 + dfu_test_file $2
  79 +else
  80 + for file in $DIR*.$SUFFIX
  81 + do
  82 + dfu_test_file $file
  83 + done
  84 +fi
  85 +
  86 +cleanup
  87 +
  88 +exit 0
test/dfu/dfu_gadget_test_init.sh
  1 +#! /bin/bash
  2 +set -e # any command return if not equal to zero
  3 +clear
  4 +
  5 +COLOUR_RED="\33[31m"
  6 +COLOUR_GREEN="\33[32m"
  7 +COLOUR_DEFAULT="\33[0m"
  8 +
  9 +LOG_DIR="./log"
  10 +BKP_DIR="./bkp"
  11 +
  12 +TEST_FILES_SIZES="127 128 129 8M 4095 4096 4097 63 64 65 960"
  13 +
  14 +printf "Init script for generating data necessary for DFU test script"
  15 +
  16 +if [ ! -d $LOG_DIR ]; then
  17 + `mkdir $LOG_DIR`
  18 +fi
  19 +
  20 +if [ ! -d $BKP_DIR ]; then
  21 + `mkdir $BKP_DIR`
  22 +fi
  23 +
  24 +for size in $TEST_FILES_SIZES
  25 +do
  26 + FILE="./dat_$size.img"
  27 + if [ ! -f $FILE ]; then
  28 + dd if=/dev/urandom of="./dat_$size.img" bs=$size count=1 > /dev/null 2>&1 || exit $?
  29 + fi
  30 +done
  31 +
  32 +printf "$COLOUR_GREEN OK $COLOUR_DEFAULT \n"
  33 +
  34 +exit 0