summaryrefslogtreecommitdiff
diff options
authorDaniel Manrique <roadmr@ubuntu.com>2014-09-29 13:20:47 -0400
committerDaniel Manrique <roadmr@ubuntu.com>2014-09-29 13:20:47 -0400
commitd5b78282941b8eccbd444d98320cd05aaa962c82 (patch)
treef8a19ffa7cc0599e2cbeead6da993fe98bb634fd
parent849e07e9c3983f95e8a06098eb6f5ef062e902d1 (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.
-rwxr-xr-xbin/bluetooth_transfer_stress54
-rw-r--r--jobs/bluetooth.txt.in30
2 files changed, 84 insertions, 0 deletions
diff --git a/bin/bluetooth_transfer_stress b/bin/bluetooth_transfer_stress
new file mode 100755
index 0000000..2add0b1
--- /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
diff --git a/jobs/bluetooth.txt.in b/jobs/bluetooth.txt.in
index da371fb..ea9ee73 100644
--- a/jobs/bluetooth.txt.in
+++ b/jobs/bluetooth.txt.in
@@ -120,3 +120,33 @@ _description:
VERIFICATION:
Did the device work as expected?
+plugin: shell
+id: bluetooth/file_transfer_stress
+estimated_duration: 300.0
+requires:
+ package.name == 'bluez'
+ package.name == 'obexftp'
+ device.category == 'BLUETOOTH'
+command:
+ if [ -z "$BTDEVADDR" ]
+ then
+ echo "btdevaddr option not set to device address of Bluetooth target in plainbox.conf"
+ exit 1
+ fi
+ if rfkill list bluetooth | grep -q 'Hard blocked: yes'
+ then
+ echo "rfkill list shows BT is hard blocked"
+ fi
+ if rfkill list bluetooth | grep -q 'Soft blocked: yes'
+ then
+ echo "rfkill list shows BT is soft blocked, removing before testing"
+ rfkill unblock bluetooth
+ sleep 3
+ fi
+ bluetooth_transfer_stress $BTDEVADDR
+_description:
+ This is an automated Bluetooth file transfer test. It sends a large file
+ to the device specified by the BTDEVADDR environment variable, then
+ retrieves it again using Bluetooth and verifies the checksum to ensure the
+ transfer didn't corrupt the file.
+