Skip to contentSkip to conversation

test: Extending USB gadget tests infrastructure

PATCH Superseded Lukasz Majewski 2 participants 17 messages Jul 29, 2014 – Aug 19, 2014

lore
Share & tools
lore
#0 lore raw

cover test: Extending USB gadget tests infrastructure

New test for UMS regressions catching has been added. Moreover some DFU enhancements have been included as well.

Lukasz Majewski (3):
test: dfu: Extend dfu_gadget_test_init.sh to accept sizes of test
files
test: dfu: cosmetic: Add missing license information to DFU test
scripts
test: ums: Add script for testing UMS gadget operation

 test/dfu/dfu_gadget_test.sh      |  10 +++
 test/dfu/dfu_gadget_test_init.sh |  16 ++++-
 test/ums/README                  |  17 +++++
 test/ums/ums_gadget_test.sh      | 130 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 172 insertions(+), 1 deletion(-)
 create mode 100644 test/ums/README
 create mode 100755 test/ums/ums_gadget_test.sh
Signature · 1 line
2.0.0.rc2
#1 lore raw

PATCH 1/3 test: dfu: Extend dfu_gadget_test_init.sh to accept sizes of test files

It is now possible to pass to the dfu_gadget_test_init.sh script the sizes of files to be generated.

This feature is required by UMS tests which reuse this code.

---
 test/dfu/dfu_gadget_test_init.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
test/dfu/dfu_gadget_test_init.sh +5 -1
index 2163a68..0d5c6c0 100755
@@ -9,7 +9,11 @@ COLOUR_DEFAULT="\33[0m"
 
 LOG_DIR="./log"
 
-TEST_FILES_SIZES="63 64 65 127 128 129 4095 4096 4097 959 960 961 1048575 1048576 8M"
+if [ $# -eq 0 ]; then
+    TEST_FILES_SIZES="63 64 65 127 128 129 4095 4096 4097 959 960 961 1048575 1048576 8M"
+else
+    TEST_FILES_SIZES=$@
+fi
 
 printf "Init script for generating data necessary for DFU test script"
 
Signature · 1 line
2.0.0.rc2
#2 lore raw

PATCH 2/3 test: dfu: cosmetic: Add missing license information to DFU test scripts

In reply to Lukasz Majewski

By mistake I've forgotten to add the SPDX license tags for the DFU testing scripts.
This commit fixes that and also provides some other relevant information.

---
 test/dfu/dfu_gadget_test.sh      | 10 ++++++++++
 test/dfu/dfu_gadget_test_init.sh | 10 ++++++++++
 2 files changed, 20 insertions(+)
test/dfu/dfu_gadget_test.sh +10 -0
index 4133155..2f5b7db 100755
@@ -1,5 +1,15 @@
 #! /bin/bash
 
+# Copyright (C) 2014 Samsung Electronics
+# Lukasz Majewski <[email protected]>
+#
+# Script fixes, enhancements and testing:
+# Stephen Warren <[email protected]>
+#
+# DFU operation test script
+#
+# SPDX-License-Identifier:	GPL-2.0+
+
 set -e # any command return if not equal to zero
 clear
 
test/dfu/dfu_gadget_test_init.sh +10 -0
index 0d5c6c0..640628e 100755
@@ -1,5 +1,15 @@
 #! /bin/bash
 
+# Copyright (C) 2014 Samsung Electronics
+# Lukasz Majewski <[email protected]>
+#
+# Script fixes, enhancements and testing:
+# Stephen Warren <[email protected]>
+#
+# Script for test files generation
+#
+# SPDX-License-Identifier:	GPL-2.0+
+
 set -e # any command return if not equal to zero
 clear
 
Signature · 1 line
2.0.0.rc2
#3 lore raw

PATCH 3/3 test: ums: Add script for testing UMS gadget operation

In reply to Lukasz Majewski

This commit adds new test for UMS USB gadget to u-boot mainline tree. It it similar in operation to the one already available in test/dfu directory.

---
 test/ums/README             |  17 ++++++
 test/ums/ums_gadget_test.sh | 130 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 147 insertions(+)
 create mode 100644 test/ums/README
 create mode 100755 test/ums/ums_gadget_test.sh
test/ums/README new file +17 -0
new file mode 100644
index 0000000..cb7b27d
@@ -0,0 +1,17 @@
+UMS test script.
+
+Example usage:
+1. On the target:
+   create UMS exportable partition with a proper file system created on
+   it (e.g. EXT4, FAT).
+   ums 0 mmc 0
+2. On the host:
+   sudo test/ums/ums_gadget_test.sh X Y dir [test_file]
+   e.g. sudo test/ums/ums_gadget_test.sh 1 vfat /mnt ./dat_14M.img
+
+... where X is the partition number on which UMS operates and the Y is
+the file system. The 'dir' parameter is the mount directory on the HOST.
+Information about available partitions one can read from target via the
+'mmc part' command.
+The optional [test_file] parameter is for specifying the exact test file
+to use.
\ No newline at end of file
test/ums/ums_gadget_test.sh new file +130 -0

131 lines not on this page · raw message

Signature · 1 line
2.0.0.rc2
#4 lore raw

PATCH 3/3 test: ums: Add script for testing UMS gadget operation

Quoted 3 lines · Lukasz Majewski

This commit adds new test for UMS USB gadget to u-boot mainline tree. It it similar in operation to the one already available in test/dfu directory.

Patches 1 and 2,

For this patch, I wonder whether:

a) Should it do some raw dd tests too, for partitions/devices without a filesystem? Perhaps we should have separate scripts (for each of DFU and UMS) for filesystem and raw testing. So, this could be addressed later.

b) Should this script (optionally?) create the filesystem itself, so the test is completely self-contained. Otherwise, the user has to manually run e.g. parted and mk*fs themselves, by which time they've already tested UMS a fair bit without this script.

c) Do we really need the "Y" parameters (filesystem type) to the script? "mount" will automatically try all known filesystem types on my Linux host at least, and it would make it simpler to run the script if you simply dropped the "-t" option to "mount".

test/ums/README line 10

Quoted 10 lines
test/ums/README +8 -0
 
+Example usage:
+1. On the target:
+   create UMS exportable partition with a proper file system created on
+   it (e.g. EXT4, FAT).
+   ums 0 mmc 0
+2. On the host:
+   sudo test/ums/ums_gadget_test.sh X Y dir [test_file]
+   e.g. sudo test/ums/ums_gadget_test.sh 1 vfat /mnt ./dat_14M.img

can you s/X/PARTNUM/ s/Y/fstype/ here. That'd make the example command a bit more explanatory even without the paragraph below that explains what X and Y are, and also make it easier to correlate the description with the command.

test/ums/README line 15

Quoted 5 lines
test/ums/README +5 -0
+
+... where X is the partition number on which UMS operates and the Y is
+the file system. The 'dir' parameter is the mount directory on the HOST.
+Information about available partitions one can read from target via the
+'mmc part' command.

Perhaps this should say:
'mmc part' or 'part list' commands.

test/ums/README line 17

Quoted 3 lines
test/ums/README +2 -0
+The optional [test_file] parameter is for specifying the exact test file
+to use.
\ No newline at end of file

That's probably not right.

test/ums/ums_gadget_test.sh

Quoted 3 lines
test/ums/ums_gadget_test.sh +1 -0
 
+../dfu/dfu_gadget_test_init.sh 33M 97M

I'm just curious what's special about those two sizes.

test/ums/ums_gadget_test.sh line 53

Quoted 11 lines
test/ums/ums_gadget_test.sh +10 -0
+ums_test_file () {
 
+    mount -t $2 /dev/$MEM_DEV $MNT_DIR
+    if [ -f $MNT_DIR/dat_* ]; then
+	rm $MNT_DIR/dat_*
+    fi
+    sync
+
+    cp ./$1 $MNT_DIR
+    sync
+    umount $MNT_DIR

I'm not sure any of those "sync"s are necessary; "mount" should sync as part of its own operation.

test/ums/ums_gadget_test.sh line 60

Quoted 2 lines
test/ums/ums_gadget_test.sh +2 -0
+    MD5_TX=$MD5SUM
+    sleep 1

Why do we need to sleep?

test/ums/ums_gadget_test.sh line 98

Quoted 8 lines
test/ums/ums_gadget_test.sh +8 -0
+if [ $# -lt 3 ]; then
+	echo "Wrong number of arguments"
+	echo "Example:"
+	echo "sudo ./ums_gadget_test.sh 1 vfat /mnt [test_file]"
+	die
+fi
+
+MNT_DIR=$3

I think here, we should assign all positional arguments to named variables rather than using $1/... later on; something like:

PART_NUM=$1; shift
FSTYPE=$1; shift
MNT_DIR=$1; shift
TEST_FILES=$@

For MNT_DIR, can we simply create a temporary directory (e.g. /mnt/tmp-ums-test-$$) so the user doesn't have to pass in the name? The script requires root after all.

test/ums/ums_gadget_test.sh line 103

Quoted 2 lines
test/ums/ums_gadget_test.sh +2 -0
+MEM_DEV=`dmesg | tail -n 10 | grep -E " sd[a-z]:" - | cut -d ':' -f 1`
+MEM_DEV=$(echo $MEM_DEV | cut -d ']' -f2 | tr -d ' ')

May as well use `` or $() consistently for those two lines.

This seems slightly dangerous; what if my system has been plugged in for a long time and I've plugged in some other USB storage device since. Better to take the device name on the command-line, or perhaps to take the USB VID/PID on the command-line, then scan sysfs for a USB device with matching VID/PID, and find out what device node is hosted by it.

Quoted 1 line

\ No newline at end of file

Probably should fix that too.

Can you add a trap handler so that if the user CTRL-C's the script, the disk is unmounted, the mount directory is removed (if you make the script create one internally), and any temporary files are deleted. Right now, cleanup only runs if the script successfully runs to the end.

#5 lore raw

PATCH 3/3 test: ums: Add script for testing UMS gadget operation

Hi Stephen,

Quoted 6 lines · Lukasz Majewski
Quoted 3 lines

This commit adds new test for UMS USB gadget to u-boot mainline tree. It it similar in operation to the one already available in test/dfu directory.

Patches 1 and 2,

Quoted 8 lines

For this patch, I wonder whether:

a) Should it do some raw dd tests too, for partitions/devices without a filesystem? Perhaps we should have separate scripts (for each of DFU and UMS) for filesystem and raw testing. So, this could be addressed later.

I think that we should prepare separate scripts. One script per tested functionality.

Quoted 5 lines

b) Should this script (optionally?) create the filesystem itself, so the test is completely self-contained. Otherwise, the user has to manually run e.g. parted and mk*fs themselves, by which time they've already tested UMS a fair bit without this script.

The test should be extended to accept an additional flat - e.g. --create_fs.
As you pointed out, this could save some time.

Quoted 5 lines

c) Do we really need the "Y" parameters (filesystem type) to the script? "mount" will automatically try all known filesystem types on my Linux host at least, and it would make it simpler to run the script if you simply dropped the "-t" option to "mount".

I agree. The Y parameter will be removed and we will allow mount to do the job.

Quoted 13 lines

test/ums/README line 10

Quoted 12 lines
test/ums/README +3 -0
 
+Example usage:
+1. On the target:
+   create UMS exportable partition with a proper file system

created on

test/ums/README +5 -0
+   it (e.g. EXT4, FAT).
+   ums 0 mmc 0
+2. On the host:
+   sudo test/ums/ums_gadget_test.sh X Y dir [test_file]
+   e.g. sudo test/ums/ums_gadget_test.sh 1 vfat /mnt ./dat_14M.img
Quoted 4 lines

can you s/X/PARTNUM/ s/Y/fstype/ here. That'd make the example command a bit more explanatory even without the paragraph below that explains what X and Y are, and also make it easier to correlate the description with the command.

Ok, I will do that.

Quoted 9 lines
Quoted 6 lines

+
+... where X is the partition number on which UMS operates and the Y is +the file system. The 'dir' parameter is the mount directory on the HOST. +Information about available partitions one can read from target via the +'mmc part' command.

Perhaps this should say:
'mmc part' or 'part list' commands.

Ok.

Quoted 6 lines
Quoted 4 lines

+The optional [test_file] parameter is for specifying the exact test file +to use.
\ No newline at end of file

That's probably not right.

Ok.

Quoted 7 lines

test/ums/ums_gadget_test.sh

Quoted 5 lines
test/ums/ums_gadget_test.sh +1 -0
 
+../dfu/dfu_gadget_test_init.sh 33M 97M

I'm just curious what's special about those two sizes.

Nothing special. I just wanted to have sufficiently large files to test UMS capabilities (since I assume, that DFU will not transfer so large files very often).

With UMS it is not so important to test the corner cases values (as we did with DFU tests), but to check how well transfers of large files is performed.

Quoted 15 lines

test/ums/ums_gadget_test.sh line 53

Quoted 12 lines
test/ums/ums_gadget_test.sh +10 -0
+ums_test_file () {
 
+    mount -t $2 /dev/$MEM_DEV $MNT_DIR
+    if [ -f $MNT_DIR/dat_* ]; then
+	rm $MNT_DIR/dat_*
+    fi
+    sync
+
+    cp ./$1 $MNT_DIR
+    sync
+    umount $MNT_DIR

I'm not sure any of those "sync"s are necessary; "mount" should sync as part of its own operation.

Yes, I agree. mount/umount do the sync as well. I will fix this.

Quoted 5 lines

test/ums/ums_gadget_test.sh line 60

Quoted 3 lines
test/ums/ums_gadget_test.sh +2 -0
+    MD5_TX=$MD5SUM
+    sleep 1

Why do we need to sleep?

On my linux box there were some problems without this delay (probably caused by time needed for plugging in USB device).

Maybe on your setup it will work smoothly.

Quoted 13 lines

test/ums/ums_gadget_test.sh line 98

Quoted 9 lines
test/ums/ums_gadget_test.sh +8 -0
+if [ $# -lt 3 ]; then
+	echo "Wrong number of arguments"
+	echo "Example:"
+	echo "sudo ./ums_gadget_test.sh 1 vfat /mnt [test_file]"
+	die
+fi
+
+MNT_DIR=$3

I think here, we should assign all positional arguments to named variables rather than using $1/... later on; something like:

Quoted 5 lines

PART_NUM=$1; shift
FSTYPE=$1; shift
MNT_DIR=$1; shift
TEST_FILES=$@

Ok.

Quoted 3 lines

For MNT_DIR, can we simply create a temporary directory (e.g. /mnt/tmp-ums-test-$$) so the user doesn't have to pass in the name? The script requires root after all.

Ok.

Quoted 5 lines

test/ums/ums_gadget_test.sh

Quoted 3 lines
test/ums/ums_gadget_test.sh +1 -1
+MEM_DEV=`dmesg | tail -n 10 | grep -E " sd[a-z]:" - | cut -d ':'
-f 1` +MEM_DEV=$(echo $MEM_DEV | cut -d ']' -f2 | tr -d ' ')

May as well use `` or $() consistently for those two lines.

According to the reply written below, we will not need this code.

Quoted 7 lines

This seems slightly dangerous; what if my system has been plugged in for a long time and I've plugged in some other USB storage device since. Better to take the device name on the command-line, or perhaps to take the USB VID/PID on the command-line, then scan sysfs for a USB device with matching VID/PID, and find out what device node is hosted by it.

Your proposition is more reliable. I think that the idProduct/idVendor shall be passed to the script.

Quoted 4 lines
Quoted 2 lines

\ No newline at end of file

Probably should fix that too.

Ok.

Quoted 6 lines

Can you add a trap handler so that if the user CTRL-C's the script, the disk is unmounted, the mount directory is removed (if you make the script create one internally), and any temporary files are deleted. Right now, cleanup only runs if the script successfully runs to the end.

Good idea. I will add this to v2.

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#6 lore raw

v2 cover test: Extending USB gadget tests infrastructure

In reply to Lukasz Majewski

New test for UMS regressions catching has been added. Moreover some DFU enhancements have been included as well.

Lukasz Majewski (3):
test: dfu: Extend dfu_gadget_test_init.sh to accept sizes of test
files
test: dfu: cosmetic: Add missing license information to DFU test
scripts
test: ums: Add script for testing UMS gadget operation

 test/dfu/dfu_gadget_test.sh      |  10 +++
 test/dfu/dfu_gadget_test_init.sh |  16 +++-
 test/ums/README                  |  26 ++++++
 test/ums/ums_gadget_test.sh      | 169 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 220 insertions(+), 1 deletion(-)
 create mode 100644 test/ums/README
 create mode 100755 test/ums/ums_gadget_test.sh
Signature · 1 line
2.0.0.rc2
#7 lore raw

PATCH v2 1/3 test: dfu: Extend dfu_gadget_test_init.sh to accept sizes of test files

It is now possible to pass to the dfu_gadget_test_init.sh script the sizes of files to be generated.

This feature is required by UMS tests which reuse this code.

---
Changes for v2:
- None

---
 test/dfu/dfu_gadget_test_init.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
test/dfu/dfu_gadget_test_init.sh +5 -1
index 2163a68..0d5c6c0 100755
@@ -9,7 +9,11 @@ COLOUR_DEFAULT="\33[0m"
 
 LOG_DIR="./log"
 
-TEST_FILES_SIZES="63 64 65 127 128 129 4095 4096 4097 959 960 961 1048575 1048576 8M"
+if [ $# -eq 0 ]; then
+    TEST_FILES_SIZES="63 64 65 127 128 129 4095 4096 4097 959 960 961 1048575 1048576 8M"
+else
+    TEST_FILES_SIZES=$@
+fi
 
 printf "Init script for generating data necessary for DFU test script"
 
Signature · 1 line
2.0.0.rc2
#8 lore raw

PATCH v2 2/3 test: dfu: cosmetic: Add missing license information to DFU test scripts

In reply to Lukasz Majewski

By mistake I've forgotten to add the SPDX license tags for the DFU testing scripts.
This commit fixes that and also provides some other relevant information.

---
Changes for v2:
- None

---
 test/dfu/dfu_gadget_test.sh      | 10 ++++++++++
 test/dfu/dfu_gadget_test_init.sh | 10 ++++++++++
 2 files changed, 20 insertions(+)
test/dfu/dfu_gadget_test.sh +10 -0
index 4133155..2f5b7db 100755
@@ -1,5 +1,15 @@
 #! /bin/bash
 
+# Copyright (C) 2014 Samsung Electronics
+# Lukasz Majewski <[email protected]>
+#
+# Script fixes, enhancements and testing:
+# Stephen Warren <[email protected]>
+#
+# DFU operation test script
+#
+# SPDX-License-Identifier:	GPL-2.0+
+
 set -e # any command return if not equal to zero
 clear
 
test/dfu/dfu_gadget_test_init.sh +10 -0
index 0d5c6c0..640628e 100755
@@ -1,5 +1,15 @@
 #! /bin/bash
 
+# Copyright (C) 2014 Samsung Electronics
+# Lukasz Majewski <[email protected]>
+#
+# Script fixes, enhancements and testing:
+# Stephen Warren <[email protected]>
+#
+# Script for test files generation
+#
+# SPDX-License-Identifier:	GPL-2.0+
+
 set -e # any command return if not equal to zero
 clear
 
Signature · 1 line
2.0.0.rc2
#9 lore raw

PATCH v2 3/3 test: ums: Add script for testing UMS gadget operation

In reply to Lukasz Majewski

This commit adds new test for UMS USB gadget to u-boot mainline tree. It is similar in operation to the one already available in test/dfu directory.

---
Changes for v2:
- Add -f switch for optional FS creation on target UMS partition
- Remove need for passing FS type to script
- Remove syncs
- Use named variables instead of $1, $2, $3 ... etc
- Create temporary mount directory at /mnt/tmp-ums-test/
- Use target device's VID/PID to find exact mount device (/dev/sdX)
- Add support for Ctrl+C tap
- Rewrite README entry

---
 test/ums/README             |  26 +++++++
 test/ums/ums_gadget_test.sh | 169 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 195 insertions(+)
 create mode 100644 test/ums/README
 create mode 100755 test/ums/ums_gadget_test.sh
test/ums/README new file +26 -0
new file mode 100644
index 0000000..84906be
@@ -0,0 +1,26 @@
+UMS test script.
+
+ums_gadget_test.sh
+==================
+
+Example usage:
+1. On the target:
+   create UMS exportable partitions (with e.g. gpt write)
+   ums 0 mmc 0
+2. On the host:
+   sudo test/ums/ums_gadget_test.sh VID PID PART_NUM [-f FILE_SYSTEM] [test_file]
+   e.g. sudo test/ums/ums_gadget_test.sh 04e8 6601 6 -f vfat ./dat_14M.img
+
+... where:
+    VID - UMS device USB Vendor ID
+    PID - UMS device USB Product ID
+    PART_NUM - is the partition number on which UMS operates
+
+Information about available partitions on the target one can read with using
+the 'mmc part' or 'part list' commands.
+
+The [-f FILE_SYSTEM] optional switch allows for formatting target partition to
+FILE_SYSTEM.
+
+The last, optional [test_file] parameter is for specifying the exact test file
+to use.
test/ums/ums_gadget_test.sh new file +169 -0

169 lines not on this page · raw message

Signature · 1 line
2.0.0.rc2
#10 lore raw

PATCH v2 3/3 test: ums: Add script for testing UMS gadget operation

Quoted 3 lines · Lukasz Majewski

This commit adds new test for UMS USB gadget to u-boot mainline tree. It is similar in operation to the one already available in test/dfu directory.

This looks good, although I have a few small comments...

test/ums/README line 8

Quoted 5 lines
test/ums/README +3 -0
 
+Example usage:
+1. On the target:
+   create UMS exportable partitions (with e.g. gpt write)

I'd like to avoid that requirement. Perhaps the script can operate on raw devices without a partition table too. Can we enhance the script so that if the user specifies - as the partition ID, then $PART_NUM gets set to '' and hence the whole device is used?

If you do that, I'd like to add the following to the line I quoted above:

, or specify a partition ID of - to use the entire device.

You might want to insert an extra step in the documentation here:

Create a filesystem on the partition or device, or pass the -f option to the test script.

test/ums/ums_gadget_test.sh line 123

Quoted 8 lines
test/ums/ums_gadget_test.sh +6 -0
 
+idVendor=`find /sys -type f -name "idVendor" -exec grep -w $VID {} \;`
+idProduct=`find /sys -type f -name "idProduct" -exec grep -w $PID {} \;`
+if [ -z "$idVendor" ] || [ -z "$idProduct" ]; then
+    echo "Device $VID:$PID not connected!"
+    exit 0
+fi

That ensures that the given VID/PID exist somewhere, but not necessarily even on the same USB device.

test/ums/ums_gadget_test.sh line 126

Quoted 2 lines
test/ums/ums_gadget_test.sh +2 -0
+USB_DEV=`find /sys -type f -name "idProduct" -exec grep -l $PID {} \;`
+USB_DEV=`dirname $USB_DEV`

... and that simply finds a USB device with a matching PID, but ignores the VID.

This might work better:

#!/bin/bash

VID=0955
PID=701a

for f in find /sys -type f -name idProduct; do

     d=`dirname ${f}`
     if [ `cat ${d}/idVendor` != "${VID}" ]; then
         continue
     fi
     if [ `cat ${d}/idProduct` != "${PID}" ]; then
         continue
     fi
     USB_DEV=${d}
     break

done

if [ -z "${USB_DEV}" ]; then
echo "Connect target"
echo "e.g. ums 0 mmc 0"
exit 1
fi

echo ${USB_DEV}

Quoted 1 line

+MEM_DEV=find $USB_DEV -name "sd[a-z]" | awk -F/ '{print $(NF)}' -

"-type d" might be a good idea there.

That's probably OK, although it worries me slightly to rely on the naming convention of the device. If the code above doesn't work for some people, perhaps we could find a file named "dev", and extract the device major/minor from it. However, we'd need some complex logic to distinguish between the many files named "dev"; in ${USB_DEV}/ itself, the various partitions on the device, and the scsi_generic and "bsg" (whatever that is) devices. So, it's probably not worth changing that now.

#11 lore raw

v3 cover test: Extending USB gadget tests infrastructure

In reply to Lukasz Majewski

New test for UMS regressions catching has been added. Moreover some DFU enhancements have been included as well.

Lukasz Majewski (3):
test: dfu: Extend dfu_gadget_test_init.sh to accept sizes of test
files
test: dfu: cosmetic: Add missing license information to DFU test
scripts
test: ums: Add script for testing UMS gadget operation

 test/dfu/dfu_gadget_test.sh      |  10 +++
 test/dfu/dfu_gadget_test_init.sh |  16 +++-
 test/ums/README                  |  30 +++++++
 test/ums/ums_gadget_test.sh      | 175 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 230 insertions(+), 1 deletion(-)
 create mode 100644 test/ums/README
 create mode 100755 test/ums/ums_gadget_test.sh
Signature · 1 line
2.0.0.rc2
#12 lore raw

PATCH v3 1/3 test: dfu: Extend dfu_gadget_test_init.sh to accept sizes of test files

It is now possible to pass to the dfu_gadget_test_init.sh script the sizes of files to be generated.

This feature is required by UMS tests which reuse this code.

---
Changes for v2:
- None
Changes for v3:
- None

---
 test/dfu/dfu_gadget_test_init.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
test/dfu/dfu_gadget_test_init.sh +5 -1
index 2163a68..0d5c6c0 100755
@@ -9,7 +9,11 @@ COLOUR_DEFAULT="\33[0m"
 
 LOG_DIR="./log"
 
-TEST_FILES_SIZES="63 64 65 127 128 129 4095 4096 4097 959 960 961 1048575 1048576 8M"
+if [ $# -eq 0 ]; then
+    TEST_FILES_SIZES="63 64 65 127 128 129 4095 4096 4097 959 960 961 1048575 1048576 8M"
+else
+    TEST_FILES_SIZES=$@
+fi
 
 printf "Init script for generating data necessary for DFU test script"
 
Signature · 1 line
2.0.0.rc2
#13 lore raw

PATCH v3 2/3 test: dfu: cosmetic: Add missing license information to DFU test scripts

In reply to Lukasz Majewski

By mistake I've forgotten to add the SPDX license tags for the DFU testing scripts.
This commit fixes that and also provides some other relevant information.

---
Changes for v2:
- None
Changes for v3:
- None

---
 test/dfu/dfu_gadget_test.sh      | 10 ++++++++++
 test/dfu/dfu_gadget_test_init.sh | 10 ++++++++++
 2 files changed, 20 insertions(+)
test/dfu/dfu_gadget_test.sh +10 -0
index 4133155..2f5b7db 100755
@@ -1,5 +1,15 @@
 #! /bin/bash
 
+# Copyright (C) 2014 Samsung Electronics
+# Lukasz Majewski <[email protected]>
+#
+# Script fixes, enhancements and testing:
+# Stephen Warren <[email protected]>
+#
+# DFU operation test script
+#
+# SPDX-License-Identifier:	GPL-2.0+
+
 set -e # any command return if not equal to zero
 clear
 
test/dfu/dfu_gadget_test_init.sh +10 -0
index 0d5c6c0..640628e 100755
@@ -1,5 +1,15 @@
 #! /bin/bash
 
+# Copyright (C) 2014 Samsung Electronics
+# Lukasz Majewski <[email protected]>
+#
+# Script fixes, enhancements and testing:
+# Stephen Warren <[email protected]>
+#
+# Script for test files generation
+#
+# SPDX-License-Identifier:	GPL-2.0+
+
 set -e # any command return if not equal to zero
 clear
 
Signature · 1 line
2.0.0.rc2
#14 lore raw

PATCH v3 3/3 test: ums: Add script for testing UMS gadget operation

In reply to Lukasz Majewski

This commit adds new test for UMS USB gadget to u-boot mainline tree. It is similar in operation to the one already available in test/dfu directory.

---
Changes for v2:
- Add -f switch for optional FS creation on target UMS partition
- Remove need for passing FS type to script
- Remove syncs
- Use named variables instead of $1, $2, $3 ... etc
- Create temporary mount directory at /mnt/tmp-ums-test/
- Use target device's VID/PID to find exact mount device (/dev/sdX)
- Add support for Ctrl+C tap
- Rewrite README entry

Changes for v3:
- Allow PART_NUM to be "-", which gives access to the whole device
- Rewrite VID/PID sysfs matching code
- Update documentation for PART_NUM
- Add -type d switch for memory device matching

---
 test/ums/README             |  30 ++++++++
 test/ums/ums_gadget_test.sh | 175 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 205 insertions(+)
 create mode 100644 test/ums/README
 create mode 100755 test/ums/ums_gadget_test.sh
test/ums/README new file +30 -0
new file mode 100644
index 0000000..69aa6b7
@@ -0,0 +1,30 @@
+UMS test script.
+
+ums_gadget_test.sh
+==================
+
+Example usage:
+1. On the target:
+   create UMS exportable partitions (with e.g. gpt write), or specify a
+   partition number (PART_NUM) as "-" to use the entire device
+   ums 0 mmc 0
+2. On the host:
+   sudo test/ums/ums_gadget_test.sh VID PID PART_NUM [-f FILE_SYSTEM] [test_file]
+   e.g. sudo test/ums/ums_gadget_test.sh 04e8 6601 6 -f vfat ./dat_14M.img
+
+... where:
+    VID - UMS device USB Vendor ID
+    PID - UMS device USB Product ID
+    PART_NUM - is the partition number on which UMS operates or "-" to use the
+	       whole device
+
+Information about available partitions on the target one can read with using
+the 'mmc part' or 'part list' commands.
+
+The partition num (PART_NUM) can be specified as '-' for using the whole device.
+
+The [-f FILE_SYSTEM] optional switch allows for formatting target partition to
+FILE_SYSTEM.
+
+The last, optional [test_file] parameter is for specifying the exact test file
+to use.
test/ums/ums_gadget_test.sh new file +175 -0

175 lines not on this page · raw message

Signature · 1 line
2.0.0.rc2
#15 lore raw

PATCH v3 3/3 test: ums: Add script for testing UMS gadget operation

Quoted 3 lines · Lukasz Majewski

This commit adds new test for UMS USB gadget to u-boot mainline tree. It is similar in operation to the one already available in test/dfu directory.

#16 lore raw

PATCH v3 3/3 test: ums: Add script for testing UMS gadget operation

Hi Stephen,

Quoted 7 lines · Lukasz Majewski
Quoted 3 lines

This commit adds new test for UMS USB gadget to u-boot mainline tree. It is similar in operation to the one already available in test/dfu directory.

Applied to u-boot-dfu.

Thanks!

Signature · 5 lines
Best regards,

Lukasz Majewski

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