Merge lp:~le-chi-thu/lava-android-test/add-sdcard-tests into lp:lava-android-test

Proposed by Le Chi Thu on 2012-04-12
Status: Needs review
Proposed branch: lp:~le-chi-thu/lava-android-test/add-sdcard-tests
Merge into: lp:lava-android-test
Diff against target: 345 lines (+281/-1)
8 files modified
MANIFEST.in (+2/-0)
doc/changes.rst (+6/-0)
doc/tests.rst (+8/-0)
lava_android_test/__init__.py (+1/-1)
lava_android_test/test_definitions/filetransfertest.py (+45/-0)
lava_android_test/test_definitions/filetransfertest/filetransfertest.py (+140/-0)
lava_android_test/test_definitions/sdcardtest.py (+36/-0)
lava_android_test/test_definitions/sdcardtest/dfcheck.py (+43/-0)
To merge this branch: bzr merge lp:~le-chi-thu/lava-android-test/add-sdcard-tests
Reviewer Review Type Date Requested Status
Yongqin Liu Approve on 2012-05-09
Le Chi Thu (community) Resubmit on 2012-05-02
Review via email: mp+101704@code.launchpad.net

Description of the change

Added SDcard and file transfer tests created by Per Andersson

To post a comment you must log in.
Yongqin Liu (liuyq0307) wrote :

Thanks for this addition, but the bad news is that the lava deployed android image does not have the sdcard partition:(

But I'd like to integrated this first, so when we add the sdcard partition for lava deployed android image,
this test can be used immediately. Also we can use the test for data partition now.

And Here I have some comments about this.

203 +internalPath = "/sdcard/"
204 +externalPath = "/data/app/"

In android /sdcard is normally call external, so it's better to change the two variable names.
And about the "/data/app/" path, if not have special meanings I'd like to use "/data/local" instead.

311 + print "sdcard_df_check=fail"

From the above, it seems that just used to check the mount of sdcard.
But actually we check the sdcard and data two.

And about the filetransfertest test, only one transfer is enough for the test?
Normally, only one time will not have any problem IMO.

149. By Le Chi Thu <email address hidden> <email address hidden> on 2012-05-02

Updated after review.

Le Chi Thu (le-chi-thu) wrote :

Updated after the review comments.

review: Resubmit
Yongqin Liu (liuyq0307) wrote :

seems ok.
Thanks.

review: Approve

Unmerged revisions

149. By Le Chi Thu <email address hidden> <email address hidden> on 2012-05-02

Updated after review.

148. By Le Chi Thu <email address hidden> <email address hidden> on 2012-04-12

Added sdcard tests

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'MANIFEST.in'
2--- MANIFEST.in 2012-03-28 06:41:07 +0000
3+++ MANIFEST.in 2012-05-02 11:43:17 +0000
4@@ -7,3 +7,5 @@
5 include lava_android_test/test_definitions/cts/*
6 include lava_android_test/test_definitions/glmark2/*
7 include lava_android_test/test_definitions/gatortest/*
8+include lava_android_test/test_definitions/filetransfertest/*
9+include lava_android_test/test_definitions/sdcardtest/*
10
11=== modified file 'doc/changes.rst'
12--- doc/changes.rst 2012-04-26 03:20:30 +0000
13+++ doc/changes.rst 2012-05-02 11:43:17 +0000
14@@ -1,6 +1,12 @@
15 Version History
16 ***************
17
18+.. _version_0_4_dev:
19+
20+Version 0.4 dev
21+===============
22+* new sdcard tests
23+
24 .. _version_0_3:
25
26 Version 0.3
27
28=== modified file 'doc/tests.rst'
29--- doc/tests.rst 2012-02-17 02:12:14 +0000
30+++ doc/tests.rst 2012-05-02 11:43:17 +0000
31@@ -15,6 +15,8 @@
32 * `v8`_
33 * `mmtest`_
34 * `gatortest`_
35+ * `filetransfertest`_
36+ * `sdcardtest`_
37
38 busybox
39 +++++++
40@@ -51,3 +53,9 @@
41 gatortest
42 +++++++++
43 .. automodule:: lava_android_test.test_definitions.gatortest
44+filetransfertest
45+++++++++++++++++
46+.. automodule:: lava_android_test.test_definitions.filetransfertest
47+sdcardtest
48+++++++++++
49+.. automodule:: lava_android_test.test_definitions.sdcardtest
50
51=== modified file 'lava_android_test/__init__.py'
52--- lava_android_test/__init__.py 2012-04-26 03:20:30 +0000
53+++ lava_android_test/__init__.py 2012-05-02 11:43:17 +0000
54@@ -13,4 +13,4 @@
55 # You should have received a copy of the GNU General Public License
56 # along with this program. If not, see <http://www.gnu.org/licenses/>.
57
58-__version__ = (0, 3, 0, "final", 0)
59+__version__ = (0, 4, 0, "dev", 0)
60
61=== added directory 'lava_android_test/test_definitions/filetransfertest'
62=== added file 'lava_android_test/test_definitions/filetransfertest.py'
63--- lava_android_test/test_definitions/filetransfertest.py 1970-01-01 00:00:00 +0000
64+++ lava_android_test/test_definitions/filetransfertest.py 2012-05-02 11:43:17 +0000
65@@ -0,0 +1,45 @@
66+# Copyright (c) 2012 Linaro
67+#
68+# Author: Per Andersson
69+#
70+# This file is part of LAVA Android Test.
71+#
72+#
73+# This program is free software: you can redistribute it and/or modify
74+# it under the terms of the GNU General Public License as published by
75+# the Free Software Foundation, either version 3 of the License, or
76+# (at your option) any later version.
77+#
78+# This program is distributed in the hope that it will be useful,
79+# but WITHOUT ANY WARRANTY; without even the implied warranty of
80+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
81+# GNU General Public License for more details.
82+#
83+# You should have received a copy of the GNU General Public License
84+# along with this program. If not, see <http://www.gnu.org/licenses/>.
85+import os
86+import lava_android_test.testdef
87+
88+curdir = os.path.realpath(os.path.dirname(__file__))
89+test_name = 'filetransfertest'
90+
91+RUN_STEPS_HOST_PRE = ['python %s/filetransfertest/filetransfertest.py $(SERIAL)' % curdir]
92+
93+#<testid>: <message>... pass
94+
95+PATTERN = (
96+ "^(?P<test_case_id>[\w/\.]+):"
97+ "\s+"
98+ "(?P<message>.+)"
99+ "\.\.\.\s+"
100+ "(?P<result>\w+)")
101+
102+
103+parser = lava_android_test.testdef.AndroidTestParser(PATTERN)
104+run = lava_android_test.testdef.AndroidTestRunner(steps_host_pre=RUN_STEPS_HOST_PRE)
105+inst = lava_android_test.testdef.AndroidTestInstaller()
106+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
107+ installer=inst,
108+ runner=run,
109+ parser=parser)
110+
111
112=== added file 'lava_android_test/test_definitions/filetransfertest/filetransfertest.py'
113--- lava_android_test/test_definitions/filetransfertest/filetransfertest.py 1970-01-01 00:00:00 +0000
114+++ lava_android_test/test_definitions/filetransfertest/filetransfertest.py 2012-05-02 11:43:17 +0000
115@@ -0,0 +1,140 @@
116+# Copyright (c) 2012 Linaro
117+
118+# Author: Per Andersson
119+#
120+# This file is part of LAVA Android Test.
121+#
122+#
123+# This program is free software: you can redistribute it and/or modify
124+# it under the terms of the GNU General Public License as published by
125+# the Free Software Foundation, either version 3 of the License, or
126+# (at your option) any later version.
127+#
128+# This program is distributed in the hope that it will be useful,
129+# but WITHOUT ANY WARRANTY; without even the implied warranty of
130+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
131+# GNU General Public License for more details.
132+#
133+# You should have received a copy of the GNU General Public License
134+# along with this program. If not, see <http://www.gnu.org/licenses/>.
135+import hashlib
136+import re
137+import sys
138+import os
139+import array
140+from commands import getstatusoutput
141+
142+def checkSDCard(adb):
143+ df_cmd = '%s shell df' % (adb)
144+ df_pattern = "/(sdcard|data)"
145+ rc, output = getstatusoutput(df_cmd)
146+ if rc != 0:
147+ print 'Failed to run command %s : %s' % (df_cmd, output)
148+ return False
149+ if re.search(df_pattern, output) != None:
150+ return True
151+ else:
152+ return False
153+
154+def createBinaryFile(curdir, fileName, size):
155+ m = hashlib.md5()
156+ try:
157+ csvfile = open(curdir + fileName, 'wb')
158+ abs_path = os.path.abspath(csvfile.name)
159+ data = array.array('B')
160+ for c in range(0, 1024):
161+ data.append(int(c % 256))
162+ try:
163+ for _ in range(size):
164+ m.update(data)
165+ csvfile.write(data)
166+ finally:
167+ csvfile.flush()
168+ csvfile.close()
169+ except IOError:
170+ print "createBinaryFile failed:" + str(sys.exc_info())
171+ print "filetransfer_test=fail"
172+ sys.exit(1)
173+ return m.digest()
174+
175+def readBinaryFile(curdir, fileName):
176+ m = hashlib.md5()
177+ try:
178+ csvfile = open(curdir + fileName, 'rb')
179+ try:
180+ data = csvfile.read(1024)
181+ m.update(data)
182+ while len(data) > 0:
183+ data = csvfile.read(1024)
184+ m.update(data)
185+ finally:
186+ csvfile.close()
187+ except IOError:
188+ print "readBinaryFile failed:" + str(sys.exc_info())
189+ print "filetransfer_test=fail"
190+ return None
191+ return m.digest()
192+
193+def transferFiles(adb, devicePath, filename, size, curdir):
194+ md5_1 = createBinaryFile(curdir, fileName, size)
195+
196+ push_cmd = '%s push ' % (adb) + curdir + fileName + " " + devicePath + fileName
197+ rc, perf1 = getstatusoutput(push_cmd)
198+ if rc != 0:
199+ print 'Failed to run command %s : %s' % (push_cmd, perf1)
200+ return False
201+ os.system("rm " + curdir + fileName)
202+ pull_cmd = '%s pull ' % (adb) + devicePath + fileName + " " + curdir + fileName
203+ rc, perf2 = getstatusoutput(pull_cmd)
204+ if rc != 0:
205+ print 'Failed to run command %s : %s' % (pull_cmd, perf2)
206+ return False
207+ md5_2 = readBinaryFile(curdir, fileName)
208+ print "Push speed : " + str(perf1)
209+ print "Pull speed : " + str(perf2)
210+ if (md5_1 != md5_2):
211+ print("TC_AD_MLF_026_FileTransfer_MD5 error: Checksum do not match: "
212+ + md5_1 + " : " + md5_2)
213+ return False
214+ return True
215+
216+def cleanup(adb, path):
217+ os.system("rm " + curdir + '/' + fileName)
218+ rm_cmd = '%s shell rm %s' % (adb, path)
219+ rc, output = getstatusoutput(rm_cmd)
220+ if rc != 0:
221+ print 'Failed to run command %s : %s' % (rm_cmd, output)
222+ sys.exit(1)
223+
224+if len(sys.argv) == 1:
225+ adb_cmd = "adb"
226+else:
227+ adb_cmd = "adb -s %s" % (sys.argv[1])
228+
229+fileName = "data.bin"
230+sdcard_path = "/sdcard/"
231+data_app_path = "/data/app/"
232+size = 8096
233+curdir = os.path.realpath(os.path.dirname(__file__))
234+curdir += '/'
235+
236+if not checkSDCard(adb_cmd):
237+ print "filetransfer_test: checking sdcard... fail"
238+ sys.exit(1)
239+
240+if not transferFiles(adb_cmd, sdcard_path, fileName, size, curdir):
241+ print "filetransfer_test: internal path... fail"
242+ cleanup(adb_cmd, sdcard_path + fileName)
243+ sys.exit(1)
244+cleanup(adb_cmd, sdcard_path + fileName)
245+
246+if not transferFiles(adb_cmd, data_app_path, fileName, size, curdir):
247+ print "filetransfer_test: external path... fail"
248+ cleanup(adb_cmd, data_app_path + fileName)
249+ sys.exit(1)
250+cleanup(adb_cmd, data_app_path + fileName)
251+
252+print "filetransfer_test: All tests passed... pass"
253+
254+
255+
256
257=== added directory 'lava_android_test/test_definitions/sdcardtest'
258=== added file 'lava_android_test/test_definitions/sdcardtest.py'
259--- lava_android_test/test_definitions/sdcardtest.py 1970-01-01 00:00:00 +0000
260+++ lava_android_test/test_definitions/sdcardtest.py 2012-05-02 11:43:17 +0000
261@@ -0,0 +1,36 @@
262+# Copyright (c) 2012 Linaro
263+#
264+# Author: Per Andersson
265+#
266+# This file is part of LAVA Android Test.
267+#
268+#
269+# This program is free software: you can redistribute it and/or modify
270+# it under the terms of the GNU General Public License as published by
271+# the Free Software Foundation, either version 3 of the License, or
272+# (at your option) any later version.
273+#
274+# This program is distributed in the hope that it will be useful,
275+# but WITHOUT ANY WARRANTY; without even the implied warranty of
276+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
277+# GNU General Public License for more details.
278+#
279+# You should have received a copy of the GNU General Public License
280+# along with this program. If not, see <http://www.gnu.org/licenses/>.
281+import os
282+import lava_android_test.testdef
283+
284+curdir = os.path.realpath(os.path.dirname(__file__))
285+test_name = 'sdcardtest'
286+
287+RUN_STEPS_HOST_PRE = ['python %s/sdcardtest/dfcheck.py $(SERIAL)' % curdir]
288+PATTERN = "^\s*(?P<test_case_id>\w+)=(?P<result>\w+)\s*$"
289+
290+parser = lava_android_test.testdef.AndroidTestParser(PATTERN)
291+run = lava_android_test.testdef.AndroidTestRunner(steps_host_pre=RUN_STEPS_HOST_PRE)
292+inst = lava_android_test.testdef.AndroidTestInstaller()
293+testobj = lava_android_test.testdef.AndroidTest(testname=test_name,
294+ installer=inst,
295+ runner=run,
296+ parser=parser)
297+
298
299=== added file 'lava_android_test/test_definitions/sdcardtest/dfcheck.py'
300--- lava_android_test/test_definitions/sdcardtest/dfcheck.py 1970-01-01 00:00:00 +0000
301+++ lava_android_test/test_definitions/sdcardtest/dfcheck.py 2012-05-02 11:43:17 +0000
302@@ -0,0 +1,43 @@
303+# Copyright (c) 2012 Linaro
304+#
305+# Author: Per Andersson
306+#
307+# This file is part of LAVA Android Test.
308+#
309+#
310+# This program is free software: you can redistribute it and/or modify
311+# it under the terms of the GNU General Public License as published by
312+# the Free Software Foundation, either version 3 of the License, or
313+# (at your option) any later version.
314+#
315+# This program is distributed in the hope that it will be useful,
316+# but WITHOUT ANY WARRANTY; without even the implied warranty of
317+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
318+# GNU General Public License for more details.
319+#
320+# You should have received a copy of the GNU General Public License
321+# along with this program. If not, see <http://www.gnu.org/licenses/>.
322+import re
323+import sys
324+from commands import getstatusoutput
325+
326+if len(sys.argv) == 1:
327+ adb_cmd = "adb"
328+else:
329+ adb_cmd = "adb -s %s" % (sys.argv[1])
330+
331+df_cmd = '%s shell df' % (adb_cmd)
332+df_pattern = "/(sdcard|data)"
333+
334+rc, output = getstatusoutput(df_cmd)
335+
336+if rc != 0:
337+ print 'Failed to run command %s : %s' % (cmd, output)
338+ print "sdcard_or_data_df_check=fail"
339+ sys.exit(1)
340+
341+if re.search(df_pattern, output) != None:
342+ print "sdcard_or_data_df_check=pass"
343+else:
344+ print "sdcard_or_data_df_check=fail"
345+

Subscribers

People subscribed via source and target branches