]> git.sur5r.net Git - u-boot/blob - test/dfu/dfu_gadget_test_init.sh
test: dfu: Extend dfu_gadget_test_init.sh to accept sizes of test files
[u-boot] / test / dfu / dfu_gadget_test_init.sh
1 #! /bin/bash
2
3 set -e # any command return if not equal to zero
4 clear
5
6 COLOUR_RED="\33[31m"
7 COLOUR_GREEN="\33[32m"
8 COLOUR_DEFAULT="\33[0m"
9
10 LOG_DIR="./log"
11
12 if [ $# -eq 0 ]; then
13     TEST_FILES_SIZES="63 64 65 127 128 129 4095 4096 4097 959 960 961 1048575 1048576 8M"
14 else
15     TEST_FILES_SIZES=$@
16 fi
17
18 printf "Init script for generating data necessary for DFU test script"
19
20 if [ ! -d $LOG_DIR ]; then
21     `mkdir $LOG_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 dd if=/dev/urandom of="./dfudummy.bin" bs=1024 count=1 > /dev/null 2>&1 || exit $?
32
33 printf "$COLOUR_GREEN OK $COLOUR_DEFAULT \n"
34
35 exit 0