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

Subscribers

People subscribed via source and target branches