summaryrefslogtreecommitdiff
path: root/app-launcher
diff options
context:
space:
mode:
authorMaggie White <maggiewhite@google.com>2017-07-05 17:01:40 -0700
committerMaggie White <maggiewhite@google.com>2017-07-06 15:38:11 -0700
commit0584bbd4803436bc0492b8086e01c920a1cb2178 (patch)
tree0c7e68653df67147335ad4efe7442c8b8986bc10 /app-launcher
parentec913d2a15dc1cc88dc56eeb844b521138f7423c (diff)
downloadextras-0584bbd4803436bc0492b8086e01c920a1cb2178.tar.gz
Additional setup and reduced file collision
There's some additional setup needed to make sure the devices are all in the same state, so I added instructions to the README. I also changed the system_stats functions to use variables to store string outputs instead of files to avoid collision when running multiple instances of the script from the same directory. Finally, I added cleanup at the end to remove the files created in the process, and some general code cleanup throughout the script. Bug: 62536649 Test: manual test on several devices Change-Id: I843a1cefcf6bd11f28e513d735b3bf313442efd2
Diffstat (limited to 'app-launcher')
-rw-r--r--app-launcher/README9
-rwxr-xr-xapp-launcher/app-launcher96
2 files changed, 60 insertions, 45 deletions
diff --git a/app-launcher/README b/app-launcher/README
index 238350e5..863a749a 100644
--- a/app-launcher/README
+++ b/app-launcher/README
@@ -5,6 +5,15 @@ Introduction: app-launcher is a script that launches apps many times,
measures various system metrics, computes basic stats for the metrics
and reports that stats.
+Setup:
+1) Make sure the device is seen via 'adb devices' and authorize adb via the
+popup dialog.
+2) Clear the setup wizard.
+3) Login to an android user test account.
+4) Clear the first time user dialogs on supported apps for your device (see
+below).
+5) Enable wifi and connect to a network (ex. GoogleGuest).
+
Launching app-launcher :
app-launcher -a|-b|-u [-c|-v|-s <serial number>] num-iterations
-a:Run on all cores
diff --git a/app-launcher/app-launcher b/app-launcher/app-launcher
index c9e4c8a4..703aafa0 100755
--- a/app-launcher/app-launcher
+++ b/app-launcher/app-launcher
@@ -306,48 +306,48 @@ get_volantis_devnames () {
system_stats_before() {
if [ $system_bdev_set == true ]; then
# Get BEFORE read stats for /system
- $adb shell 'cat /proc/diskstats' | grep -w $system_block_device > /tmp/$model-system
- BEFORE_RD_IOS_SYSTEM=`awk '{ print $4 }' /tmp/$model-system`
- BEFORE_RD_SECTORS_SYSTEM=`awk '{ print $6 }' /tmp/$model-system`
+ system=`$adb shell 'cat /proc/diskstats' | grep -w $system_block_device`
+ BEFORE_RD_IOS_SYSTEM=`echo $system | awk '{ print $4 }'`
+ BEFORE_RD_SECTORS_SYSTEM=`echo $system | awk '{ print $6 }'`
# iowait% computation
- $adb shell 'cat /proc/stat' | grep -w cpu > /tmp/procstat
- user_ticks_before=`awk '{ print ($2 + $3) }' /tmp/procstat`
- sys_ticks_before=`awk '{ print ($4 + $7 + $8) }' /tmp/procstat`
- cpubusy_ticks_before=`awk '{ print ($2 + $3 + $4 + $7 + $8) }' /tmp/procstat`
- iowait_ticks_before=`awk '{ print $6 }' /tmp/procstat`
- total_ticks_before=`awk '{ print ($2 + $3 + $4 + $5 + $7 + $8) }' /tmp/procstat`
+ procstat=`$adb shell 'cat /proc/stat' | grep -w cpu`
+ user_ticks_before=`echo $procstat | awk '{ print ($2 + $3) }'`
+ sys_ticks_before=`echo $procstat | awk '{ print ($4 + $7 + $8) }'`
+ cpubusy_ticks_before=`echo $procstat | awk '{ print ($2 + $3 + $4 + $7 + $8) }'`
+ iowait_ticks_before=`echo $procstat | awk '{ print $6 }'`
+ total_ticks_before=`echo $procstat | awk '{ print ($2 + $3 + $4 + $5 + $7 + $8) }'`
# Device util% computation
# Note hz=100, so multiplying uptime (in seconds) by 100, gives us
# the uptime in hz.
- $adb shell 'cat /proc/uptime' > /tmp/uptime
- uptime_before_hz=`awk '{ print ($1 * 100) }' /tmp/uptime`
+ uptime=`$adb shell 'cat /proc/uptime'`
+ uptime_before_hz=`echo $uptime | awk '{ print ($1 * 100) }'`
# Note that the device (busy) ticks is in ms. Since hz=100, dividing
# device (busy) ticks by 10, gives us this in the correct ticks units
- device_util_before_hz=`awk '{ print ($13 / 10) }' /tmp/$model-system`
+ device_util_before_hz=`echo $uptime | awk '{ print ($13 / 10) }'`
fi
}
system_stats_after() {
if [ $system_bdev_set == true ]; then
# Get AFTER read stats for /system
- $adb shell 'cat /proc/diskstats' | grep -w $system_block_device > /tmp/$model-system
- AFTER_RD_IOS_SYSTEM=`awk '{ print $4 }' /tmp/$model-system`
- AFTER_RD_SECTORS_SYSTEM=`awk '{ print $6 }' /tmp/$model-system`
+ system=`$adb shell 'cat /proc/diskstats' | grep -w $system_block_device`
+ AFTER_RD_IOS_SYSTEM=`echo $system | awk '{ print $4 }'`
+ AFTER_RD_SECTORS_SYSTEM=`echo $system | awk '{ print $6 }'`
# iowait% computation
- $adb shell 'cat /proc/stat' | grep -w cpu > /tmp/procstat
- user_ticks_after=`awk '{ print ($2 + $3) }' /tmp/procstat`
- sys_ticks_after=`awk '{ print ($4 + $7 + $8) }' /tmp/procstat`
- cpubusy_ticks_after=`awk '{ print ($2 + $3 + $4 + $7 + $8) }' /tmp/procstat`
- iowait_ticks_after=`awk '{ print $6 }' /tmp/procstat`
- total_ticks_after=`awk '{ print ($2 + $3 + $4 + $5 + $7 + $8) }' /tmp/procstat`
+ procstat=`$adb shell 'cat /proc/stat' | grep -w cpu`
+ user_ticks_after=`echo $procstat | awk '{ print ($2 + $3) }'`
+ sys_ticks_after=`echo $procstat | awk '{ print ($4 + $7 + $8) }'`
+ cpubusy_ticks_after=`echo $procstat | awk '{ print ($2 + $3 + $4 + $7 + $8) }'`
+ iowait_ticks_after=`echo $procstat | awk '{ print $6 }'`
+ total_ticks_after=`echo $procstat | awk '{ print ($2 + $3 + $4 + $5 + $7 + $8) }'`
# Device util% computation
# Note hz=100, so multiplying uptime (in seconds) by 100, gives us
# the uptime in hz.
- $adb shell 'cat /proc/uptime' > /tmp/uptime
- uptime_after_hz=`awk '{ print ($1 * 100) }' /tmp/uptime`
+ uptime=`$adb shell 'cat /proc/uptime'`
+ uptime_after_hz=`echo $uptime | awk '{ print ($1 * 100) }'`
# Note that the device (busy) ticks is in ms. Since hz=100, dividing
# device (busy) ticks by 10, gives us this in the correct ticks units
- device_util_after_hz=`awk '{ print ($13 / 10) }' /tmp/$model-system`
+ device_util_after_hz=`echo $system | awk '{ print ($13 / 10) }'`
fi
}
@@ -396,23 +396,23 @@ launch_app() {
}
launch_fugu_apps() {
- launch_app com.google.android.youtube.tv com.google.android.apps.youtube.tv.activity.TvGuideActivity > youtube-$model
- getstats youtube-$model YouTube
- launch_app com.google.android.play.games com.google.android.gms.games.pano.activity.PanoGamesOnboardHostActivity > games-$model
- getstats games-$model Games
- launch_app com.google.android.music com.android.music.activitymanagement.TopLevelActivity > music-$model
- getstats music-$model Music
+ launch_app com.google.android.youtube.tv com.google.android.apps.youtube.tv.activity.TvGuideActivity > $BASHPID-youtube-$model
+ getstats $BASHPID-youtube-$model YouTube
+ launch_app com.google.android.play.games com.google.android.gms.games.pano.activity.PanoGamesOnboardHostActivity > $BASHPID-games-$model
+ getstats $BASHPID-games-$model Games
+ launch_app com.google.android.music com.android.music.activitymanagement.TopLevelActivity > $BASHPID-music-$model
+ getstats $BASHPID-music-$model Music
}
launch_phone_apps() {
- launch_app com.android.chrome com.google.android.apps.chrome.Main > chrome-$model
- getstats chrome-$model Chrome
- launch_app com.google.android.GoogleCamera com.android.camera.CameraActivity > camera-$model
- getstats camera-$model Camera
- launch_app com.google.android.apps.maps com.google.android.maps.MapsActivity > maps-$model
- getstats maps-$model Maps
- launch_app com.google.android.youtube com.google.android.apps.youtube.app.WatchWhileActivity > youtube-$model
- getstats youtube-$model YouTube
+ launch_app com.android.chrome com.google.android.apps.chrome.Main > $BASHPID-chrome-$model
+ getstats $BASHPID-chrome-$model Chrome
+ launch_app com.google.android.GoogleCamera com.android.camera.CameraActivity > $BASHPID-camera-$model
+ getstats $BASHPID-camera-$model Camera
+ launch_app com.google.android.apps.maps com.google.android.maps.MapsActivity > $BASHPID-maps-$model
+ getstats $BASHPID-maps-$model Maps
+ launch_app com.google.android.youtube com.google.android.apps.youtube.app.WatchWhileActivity > $BASHPID-youtube-$model
+ getstats $BASHPID-youtube-$model YouTube
}
usage() {
@@ -432,21 +432,24 @@ usage() {
}
setup() {
- # Disable automatic rotation, NFC and wifi
- # This works on OC, but haven't tested on NYC or earlier
- $adb shell 'content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0'
- $adb shell 'svc nfc disable'
- $adb shell 'svc wifi disable'
-
+ echo "Setting up device"
# Set developer options, will automatically 'Stay Awake'
$adb shell 'am start -n com.android.settings/.DevelopmentSettings'
# Set screen timeout to 30 minutes
$adb shell 'settings put system screen_off_timeout 1800000'
+
+ # TODO: Consider rebooting device to start with a clean state
+
+ # Disable automatic rotation and NFC
+ # This works on OC, but haven't tested on NYC or earlier
+ $adb shell 'content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0'
+ $adb shell 'svc nfc disable'
+
# Clear all notifications
$adb shell 'service call notification 1'
# Go to home screen
$adb shell 'input keyevent KEYCODE_WAKEUP' && sleep 0.5
- $adb shell 'input keyevent KEYCODE_ENTER' && sleep 0.5
+ $adb shell 'input keyevent KEYCODE_MENU' && sleep 0.5
$adb shell 'input keyevent KEYCODE_HOME' && sleep 0.5
sleep 2
# TODO: kill all background apps
@@ -540,3 +543,6 @@ if [ $model == "fugu" ]; then
else # Phone Apps
launch_phone_apps
fi
+
+# cleanup
+rm $BASHPID*