summaryrefslogtreecommitdiffstats
path: root/tests/backup
diff options
context:
space:
mode:
authorJoe Onorato <joeo@android.com>2009-06-25 23:53:29 -0400
committerJoe Onorato <joeo@android.com>2009-06-25 23:53:29 -0400
commit4a64bded06a0299785c295a975e2818308eb53e2 (patch)
treea24057a8f82108aae7f8e6fcb5067c2ed7fe9690 /tests/backup
parent5e8a4b842c20dd47b82e9915f1bd730ee1b0d46d (diff)
downloadframeworks_base-4a64bded06a0299785c295a975e2818308eb53e2.zip
frameworks_base-4a64bded06a0299785c295a975e2818308eb53e2.tar.gz
frameworks_base-4a64bded06a0299785c295a975e2818308eb53e2.tar.bz2
Add some helpful tests scripts for backup and make bmgr restore wait until the backup is done.
Diffstat (limited to 'tests/backup')
-rw-r--r--tests/backup/src/com/android/backuptest/BackupTestAgent.java2
-rwxr-xr-xtests/backup/test_backup.sh21
-rwxr-xr-xtests/backup/test_restore.sh45
3 files changed, 67 insertions, 1 deletions
diff --git a/tests/backup/src/com/android/backuptest/BackupTestAgent.java b/tests/backup/src/com/android/backuptest/BackupTestAgent.java
index 0fdfb18..931dcb0 100644
--- a/tests/backup/src/com/android/backuptest/BackupTestAgent.java
+++ b/tests/backup/src/com/android/backuptest/BackupTestAgent.java
@@ -23,7 +23,7 @@ public class BackupTestAgent extends BackupHelperAgent
{
public void onCreate() {
addHelper("data_files", new FileBackupHelper(this, BackupTestActivity.FILE_NAME));
- addHelper("more_data_files", new FileBackupHelper(this, "another_file.txt"));
+ addHelper("more_data_files", new FileBackupHelper(this, "another_file.txt", "3.txt"));
}
}
diff --git a/tests/backup/test_backup.sh b/tests/backup/test_backup.sh
new file mode 100755
index 0000000..f6c73d8
--- /dev/null
+++ b/tests/backup/test_backup.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+#adb kill-server
+
+# set the transport
+adb shell bmgr transport 1
+
+# load up the three files
+adb shell "rm /data/data/com.android.backuptest/files/* ; \
+ mkdir /data/data/com.android.backuptest ; \
+ mkdir /data/data/com.android.backuptest/files ; \
+ echo -n first file > /data/data/com.android.backuptest/files/file.txt ; \
+ echo -n asdf > /data/data/com.android.backuptest/files/another_file.txt ; \
+ echo -n 3 > /data/data/com.android.backuptest/files/3.txt ; \
+"
+
+# say that the data has changed
+adb shell bmgr backup com.android.backuptest
+
+# run the backup
+adb shell bmgr run
diff --git a/tests/backup/test_restore.sh b/tests/backup/test_restore.sh
new file mode 100755
index 0000000..69da28c
--- /dev/null
+++ b/tests/backup/test_restore.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+function check_file
+{
+ data=$(adb shell cat /data/data/com.android.backuptest/files/$1)
+ if [ "$data" = "$2" ] ; then
+ echo "$1 has correct value [$2]"
+ else
+ echo $1 is INCORRECT
+ echo " value: [$data]"
+ echo " expected: [$2]"
+ fi
+}
+
+# delete the old data
+echo --- Previous files
+adb shell "ls -l /data/data/com.android.backuptest/files"
+adb shell "rm /data/data/com.android.backuptest/files/*"
+echo --- Erased files
+adb shell "ls -l /data/data/com.android.backuptest/files"
+echo ---
+
+echo
+echo
+echo
+
+# run the restore
+adb shell bmgr restore 0
+
+echo
+echo
+echo
+
+# check the results
+check_file file.txt "first file"
+check_file another_file.txt "asdf"
+check_file 3.txt "3"
+
+echo
+echo
+echo
+echo --- Restored files
+adb shell "ls -l /data/data/com.android.backuptest/files"
+echo ---
+echo