Testing Environment - Emulator

Download and Install Android SDK

  • Check Android SDK Page

    • If you're already using the Android SDK, you should update to the latest tools or platform using the Android SDK and AVD Manager, rather than downloading a new SDK starter package.

      Launching the Android SDK and AVD Manager

      • Navigate to the <sdk>/tools/ directory.

      • Execute the android tool command with no options.
        $ android
    • If you downloaded a .zip or .tgz package (instead of the SDK installer), unpack it to a safe location on your machine. By default, the SDK files are unpacked into a directory named android-sdk-<machine-platform>.

    • Optionally, you might want to add the location of the SDK's tools/ and platform-tools to your PATH environment variable, to provide easy access to the tools.

Create a Android Virtual Device

  • Create avd devices with sdcard image 10M, pick an avd name and the target id, for example: my_avd_2.3 and target id 9

$ android create avd -n my_avd_2.3 -t 9 -c 10M

After avd created, the file ~/.android/avd/my_avd_2.3.avd directory is created

Run Android Emulator

  • Run emulator to boot Android

$ emulator -avd my_avd_2.3
  • Check the screenshot of booted Android on emulator


  • To enlarge the partition size and emulate the memory size

$ emulator -avd my_avd_2.3 -partition-size 128 -memory 256
  • Check if the device can be connected by adb

$ adb devices
List of devices attached
emulator-5554   device

adb could be used to run remote shell command, for example, running monkey, the Android stress-test tool

$ adb shell monkey -s 1 --pct-syskeys 100 --throttle 500 100

adb could also be used to install Android package and copy files to and from the device.

Testing on Abrek

LAVA/Abrek is written in Python, which implies there must be a solid Python runtime for Android. Since Python runtime is hard to support, the proposed model would be:

  • LAVA server <--> LAVA client --> Abrek test suite || adb

extension (host) <--> adb (target) -> execute command

which means running abrek on the host side for integrating test items and benchmarks for Android.

  • Add the monkey.py test definition file in abrek

   1 import re
   2 import abrek.testdef
   4 VERSION="20110215"
   5 RUNSTEPS = ['adb shell monkey -s 1 --pct-syskeys 100 --throttle 500 100']
   7 class MonkeyParser(abrek.testdef.AbrekTestParser):
   8     def parse(self):
   9         filename = "testoutput.log"
  10         PAT = "^## Network stats: elapsed time?\W+(?P<measurement>\d+)ms"
  11         pat = re.compile(PAT)
  12         with open(filename) as fd:
  13             for line in fd:
  14                 match = pat.search(line)
  15                 if match:
  16                     d = match.groupdict()
  17                     d['units'] = "mseconds"
  18                     d['result'] = "pass"
  19                     d['test_case_id'] = "monkey"
  20                     self.results['test_results'].append(d)
  22 monkeyinst = abrek.testdef.AbrekTestInstaller(deps=["monkey"])
  23 monkeyrun = abrek.testdef.AbrekTestRunner(RUNSTEPS)
  24 monkeyparser = MonkeyParser()
  25 testobj = abrek.testdef.AbrekTest(testname="monkey", version=VERSION,
  26                                   installer=monkeyinst, runner=monkeyrun,
  27                                   parser=monkeyparser)
  • Run abrek on host side to trigger monkey test on target through adb.

$ abrek run monkey
  • Send to dashboard through abrek

$ abrek dashboard put $STREAM $RESULT


Platform/Android/EmulatorTestingEnvironment (last modified 2013-08-29 07:28:00)