Merge lp:~jeremychang/lava-dispatcher/android-support into lp:lava-dispatcher

Proposed by Jeremy Chang
Status: Merged
Merged at revision: 58
Proposed branch: lp:~jeremychang/lava-dispatcher/android-support
Merge into: lp:lava-dispatcher
Diff against target: 166 lines (+52/-41)
4 files modified
lava/dispatcher/actions/android_0xbench.py (+0/-5)
lava/dispatcher/actions/android_basic.py (+2/-33)
lava/dispatcher/android_client.py (+46/-3)
lava/dispatcher/android_config.py (+4/-0)
To merge this branch: bzr merge lp:~jeremychang/lava-dispatcher/android-support
Reviewer Review Type Date Requested Status
Paul Larson Pending
Review via email: mp+62084@code.launchpad.net

Description of the change

Some more changes:
 1. Clean up unnecessary import.

 2. Add adb disconnect function.

 3. Stabilize the result of the basic test.

(I think I should not push changes to merged branch.)

To post a comment you must log in.
53. By Jeremy Chang

run_adb_shell_command implemented in android client.

adb should be just handled by the client.

54. By Jeremy Chang

Move check_adb_status to android client

check_adb_status function can be shared and should be put in android client.

55. By Jeremy Chang

Remove the commented out stuff in android_0xbench.py

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lava/dispatcher/actions/android_0xbench.py'
--- lava/dispatcher/actions/android_0xbench.py 2011-05-20 23:17:54 +0000
+++ lava/dispatcher/actions/android_0xbench.py 2011-05-26 19:08:41 +0000
@@ -1,12 +1,7 @@
1#!/usr/bin/python1#!/usr/bin/python
2from lava.dispatcher.actions import BaseAndroidAction2from lava.dispatcher.actions import BaseAndroidAction
3from lava.dispatcher.client import OperationFailed
4from lava.dispatcher.android_config import TESTER_STR
5import time3import time
6import pexpect4import pexpect
7import sys
8from datetime import datetime
9from lava.dispatcher.android_util import savebundlefile
105
11class cmd_test_android_0xbench(BaseAndroidAction):6class cmd_test_android_0xbench(BaseAndroidAction):
12 def run(self):7 def run(self):
138
=== modified file 'lava/dispatcher/actions/android_basic.py'
--- lava/dispatcher/actions/android_basic.py 2011-05-20 17:04:08 +0000
+++ lava/dispatcher/actions/android_basic.py 2011-05-26 19:08:41 +0000
@@ -52,7 +52,7 @@
5252
53 #TODO: Checking if sdcard is mounted by vold to replace sleep idle, or check the Home app status53 #TODO: Checking if sdcard is mounted by vold to replace sleep idle, or check the Home app status
54 # Give time for Android system to boot up, then test54 # Give time for Android system to boot up, then test
55 time.sleep(30)55 time.sleep(60)
56 TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'56 TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'
57 starttime = datetime.utcnow()57 starttime = datetime.utcnow()
58 timestring = datetime.strftime(starttime, TIMEFORMAT)58 timestring = datetime.strftime(starttime, TIMEFORMAT)
@@ -118,7 +118,7 @@
118118
119 #TODO: Wait for boot completed, if timeout, do logcat and save as booting fail log119 #TODO: Wait for boot completed, if timeout, do logcat and save as booting fail log
120120
121 adb_status = self.check_adb_status()121 adb_status = self.client.check_adb_status()
122 test_case_result = {}122 test_case_result = {}
123 test_case_result['test_case_id'] = "adb connection status"123 test_case_result['test_case_id'] = "adb connection status"
124 if adb_status:124 if adb_status:
@@ -129,34 +129,3 @@
129 results['test_results'].append(test_case_result)129 results['test_results'].append(test_case_result)
130 savebundlefile("basic", results, timestring)130 savebundlefile("basic", results, timestring)
131 self.client.proc.sendline("")131 self.client.proc.sendline("")
132
133 def check_adb_status(self):
134 # XXX: IP could be assigned in other way in the validation farm
135 try:
136 self.client.run_shell_command('netcfg %s dhcp' % \
137 self.network_interface, response = TESTER_STR, timeout = 60)
138 except:
139 print "netcfg %s dhcp exception" % self.network_interface
140 return False
141
142 # Check network ip and setup adb connection
143 ip_pattern = "(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"
144 cmd = "ifconfig %s" % self.network_interface
145 self.client.proc.sendline(cmd)
146 try:
147 id = self.client.proc.expect([ip_pattern, pexpect.EOF], timeout = 5)
148 except:
149 return False
150 if id == 0:
151 match_group = self.client.proc.match.groups()
152 if len(match_group) > 0:
153 device_ip = match_group[0]
154 adb_status, dev_name = self.client.check_android_adb_network_up(device_ip)
155 if adb_status == True:
156 print "dev_name = " + dev_name
157 cmd = "adb -s %s shell echo 1" % dev_name
158 self.adb_proc = pexpect.spawn(cmd, timeout=5, logfile=sys.stdout)
159 id = self.adb_proc.expect(["1", "error"], timeout=5)
160 if id == 0:
161 return True
162 return False
163132
=== modified file 'lava/dispatcher/android_client.py'
--- lava/dispatcher/android_client.py 2011-05-19 16:25:37 +0000
+++ lava/dispatcher/android_client.py 2011-05-26 19:08:41 +0000
@@ -8,8 +8,16 @@
8 super(LavaAndroidClient, self).__init__(hostname)8 super(LavaAndroidClient, self).__init__(hostname)
9 self.board = BOARDS[hostname]9 self.board = BOARDS[hostname]
1010
11 def run_adb_shell_command(self, cmd, response=None, timeout=-1):11 def run_adb_shell_command(self, dev_id, cmd, response, timeout=-1):
12 pass12 adb_cmd = "adb -s %s shell %s" % (dev_id, cmd)
13 try:
14 adb_proc = pexpect.spawn(adb_cmd, logfile=sys.stdout)
15 id = adb_proc.expect([response, pexpect.EOF], timeout=timeout)
16 if id == 0:
17 return True
18 except pexpect.TIMEOUT:
19 pass
20 return False
1321
14 def in_test_shell(self):22 def in_test_shell(self):
15 """ Check that we are in a shell on the test image23 """ Check that we are in a shell on the test image
@@ -59,7 +67,7 @@
59 print "logcat cancelled"67 print "logcat cancelled"
6068
61 # adb cound be connected through network69 # adb cound be connected through network
62 def check_android_adb_network_up(self, dev_ip):70 def android_adb_connect(self, dev_ip):
63 pattern1 = "connected to (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,5})"71 pattern1 = "connected to (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,5})"
64 pattern2 = "already connected to (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,5})"72 pattern2 = "already connected to (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,5})"
65 pattern3 = "unable to connect to"73 pattern3 = "unable to connect to"
@@ -73,3 +81,38 @@
73 else:81 else:
74 return False, None82 return False, None
7583
84 def android_adb_disconnect(self, dev_ip):
85 cmd = "adb disconnect %s" % dev_ip
86 adb_proc = pexpect.run(cmd, timeout=300, logfile=sys.stdout)
87
88 def check_adb_status(self):
89 # XXX: IP could be assigned in other way in the validation farm
90 network_interface = self.board.network_interface
91 try:
92 self.run_shell_command('netcfg %s dhcp' % \
93 network_interface, response = TESTER_STR, timeout = 60)
94 except:
95 print "netcfg %s dhcp exception" % network_interface
96 return False
97
98 # Check network ip and setup adb connection
99 ip_pattern = "(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"
100 cmd = "ifconfig %s" % network_interface
101 self.proc.sendline('')
102 self.proc.sendline(cmd)
103 try:
104 id = self.proc.expect([ip_pattern, pexpect.EOF], timeout = 60)
105 except:
106 print "ifconfig can not match ip pattern"
107 return False
108 if id == 0:
109 match_group = self.proc.match.groups()
110 if len(match_group) > 0:
111 device_ip = match_group[0]
112 adb_status, dev_name = self.android_adb_connect(device_ip)
113 if adb_status == True:
114 print "dev_name = " + dev_name
115 result = self.run_adb_shell_command(dev_name, "echo 1", "1")
116 self.android_adb_disconnect(device_ip)
117 return result
118 return False
76119
=== modified file 'lava/dispatcher/android_config.py'
--- lava/dispatcher/android_config.py 2011-05-20 23:07:47 +0000
+++ lava/dispatcher/android_config.py 2011-05-26 19:08:41 +0000
@@ -11,6 +11,7 @@
11 "init=/init androidboot.console=ttyO2'",11 "init=/init androidboot.console=ttyO2'",
12 "boot"]12 "boot"]
13 type = "beagle"13 type = "beagle"
14 network_interface = "eth0"
1415
1516
16class PandaBoard(Board):17class PandaBoard(Board):
@@ -25,6 +26,9 @@
25 "init=/init androidboot.console=ttyO2'",26 "init=/init androidboot.console=ttyO2'",
26 "boot"]27 "boot"]
27 type = "panda"28 type = "panda"
29 network_interface = "eth0"
30
31
28#Here, it still needs to maintain a map from boardid to board, for there is only32#Here, it still needs to maintain a map from boardid to board, for there is only
29#boardid in jobfile.json33#boardid in jobfile.json
30BOARDS = {34BOARDS = {

Subscribers

People subscribed via source and target branches