summaryrefslogtreecommitdiff
path: root/bin
diff options
authorDaniel Manrique <roadmr@ubuntu.com>2014-09-29 20:04:24 +0000
committerDaniel Manrique <>2014-09-29 20:04:24 +0000
commite7073037ca122924309167a821c7a2d5cb985bde (patch)
treee1ab836b33e89e662f9bc97616f0af148209a92b /bin
parentad72040b672a4b12e40b94a682cf92c24b0f9bcf (diff)
parentd5b78282941b8eccbd444d98320cd05aaa962c82 (diff)
" providers:checkbox: Added bluetooth file transfer stress test
Test creates a random 10-MB file, transfers to an obexftp target using bluetooth, then retrieves the same file again, and checksums both files to ensure data didn't get corrupted in either transfer path. [r=zkrynicki][bug=1347119][author=roadmr]"
Diffstat (limited to 'bin')
-rwxr-xr-xbin/bluetooth_transfer_stress54
1 files changed, 54 insertions, 0 deletions
diff --git a/bin/bluetooth_transfer_stress b/bin/bluetooth_transfer_stress
new file mode 100755
index 00000000..2add0b1e
--- /dev/null
+++ b/bin/bluetooth_transfer_stress
@@ -0,0 +1,54 @@
+#!/bin/bash
+#
+# Copyright (C) 2014 Canonical
+#
+# Authors:
+# Daniel Manrique <daniel.manrique@canonical.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+BTDEVADDR="$1"
+
+if [ -z "$BTDEVADDR" ]; then
+ echo "Please give Bluetooth device address as first parameter"
+ exit 1
+fi
+
+ORIGIN=$(mktemp --tmpdir bluetooth-stress.XXXXXX)
+DESTINATION=$(mktemp --tmpdir bluetooth-stress.XXXXXX)
+REMOTE=$RANDOM
+SIZEKB=10240
+echo "Creating ${SIZEKB}KB file to test transfer"
+dd if=/dev/urandom of=$ORIGIN count=$SIZEKB bs=1024
+ORIGIN_SUM=$(sha256sum $ORIGIN | cut -f 1 -d ' ')
+set -o pipefail
+echo "Sending file using Bluetooth"
+time obexftp -v -b $BTDEVADDR -o $REMOTE --put $ORIGIN 2>&1 | ansi_parser
+sleep 5
+echo "Receiving file using Bluetooth"
+time obexftp -v -b $BTDEVADDR -o $DESTINATION --get $REMOTE 2>&1 | ansi_parser
+# Now checksum destination and compare
+DESTINATION_SUM=$(sha256sum $DESTINATION | cut -f 1 -d ' ')
+# Clean up before reporting
+rm $ORIGIN $DESTINATION
+if [ "$ORIGIN_SUM" = "$DESTINATION_SUM" ]; then
+ echo "Checksums match, file transfer succeeded"
+ exit 0
+else
+ echo "Checksums don't match, file was corrupted during transfers."
+ echo "Original checksum: $ORIGIN_SUM"
+ echo "Checksum of received file: $DESTINATION_SUM"
+ exit 1
+fi