test_backup.sh revision 1f808c6f6ed893bb50c94cf5be676712e4d68b9b
1#!/bin/bash 2 3# Copyright (C) 2009 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17 18ADB_OPTS="$@" 19 20#FIXME: what was this for? 21#adb kill-server 22 23# run adb as root so we can poke at com.android.backuptest's data 24root_status=$(adb $ADB_OPTS root) 25if [ "x$root_status" != "xadbd is already running as root" ]; then 26 sleep 2 27 adb $ADB_OPTS 'wait-for-device' 28fi 29 30# show commands as we go 31set -x 32 33# set the transport 34adb $ADB_OPTS shell bmgr transport com.google.android.backup/.BackupTransportService 35 36# load up the three files 37adb $ADB_OPTS shell \ 38 "rm /data/data/com.android.backuptest/files/* ; \ 39 mkdir /data/data/com.android.backuptest ; \ 40 mkdir /data/data/com.android.backuptest/files ; \ 41 mkdir /data/data/com.android.backuptest/shared_prefs ; \ 42 echo -n \"<map><int name=\\\"pref\\\" value=\\\"1\\\" /></map>\" > /data/data com.android.backuptest/shared_prefs/raw.xml ; \ 43 echo -n first file > /data/data/com.android.backuptest/files/file.txt ; \ 44 echo -n asdf > /data/data/com.android.backuptest/files/another_file.txt ; \ 45 echo -n 3 > /data/data/com.android.backuptest/files/3.txt ; \ 46 echo -n "" > /data/data/com.android.backuptest/files/empty.txt ; \ 47" 48 49# say that the data has changed 50adb $ADB_OPTS shell bmgr backup com.android.backuptest 51 52# run the backup 53adb $ADB_OPTS shell bmgr run 54 55