blob: 95ef2e4d5f7f1b67c536662115f42e8397ead796 [file] [log] [blame]
Zhizhou Yange5986902017-08-10 17:37:53 -07001diff --git a/server/site_tests/android_Binder/android_Binder.py b/server/site_tests/android_Binder/android_Binder.py
2new file mode 100644
3index 000000000..b233b586a
4--- /dev/null
5+++ b/server/site_tests/android_Binder/android_Binder.py
6@@ -0,0 +1,57 @@
7+# Tests for android Binder
8+from __future__ import print_function
9+
10+import bench_config
11+import logging
12+import os
13+import re
14+
15+from autotest_lib.server import test
16+
17+class android_Binder(test.test):
18+ version = 1
19+
20+ def run_once(self, host=None):
21+ self.client = host
22+
23+ out_dir = os.path.join(bench_config.android_home,
24+ 'out/target/product/' + bench_config.product)
25+
26+ # Set binary directories
27+ lib_dir = os.path.join(out_dir, 'system/lib/libbinder.so')
28+ lib_dir_DUT = '/system/lib/libbinder.so'
29+ lib64_dir = os.path.join(out_dir, 'system/lib64/libbinder.so')
30+ lib64_dir_DUT = '/system/lib64/libbinder.so'
31+ bench_dir = os.path.join(out_dir,
32+ 'symbols/data/nativetest64',
33+ 'binderThroughputTest/binderThroughputTest')
34+ bench_dir_DUT = os.path.join('/data/local/tmp',
35+ 'binderThroughputTest')
36+
37+ # Push binary to the device
38+ print('Pushing binaries of Binder benchmark onto device!')
39+ host.send_file(bench_dir, bench_dir_DUT, delete_dest=True)
40+ host.send_file(lib_dir, lib_dir_DUT, delete_dest=True)
41+ host.send_file(lib64_dir, lib64_dir_DUT, delete_dest=True)
42+
43+ # Make sure the binary is executable
44+ self.client.run('chmod u+x ' + bench_dir_DUT)
45+
46+ print('Running tests on the device...')
47+ # First run creates bench_result
48+ self.client.run('taskset %s /data/local/tmp/'
49+ 'binderThroughputTest > /data/local/tmp/bench_result'
50+ % os.getenv('TEST_MODE'))
51+ # Next 4 runs add to bench_result
52+ for i in xrange(4):
53+ self.client.run('taskset %s /data/local/tmp/'
54+ 'binderThroughputTest >> '
55+ '/data/local/tmp/bench_result'
56+ % os.getenv('TEST_MODE'))
57+
58+ # Pull result from the device
59+ out_dir = bench_config.bench_suite_dir
60+ result_dir_DUT = '/data/local/tmp/bench_result'
61+
62+ host.get_file(result_dir_DUT, out_dir, delete_dest=True)
63+ print('Result has been pulled back to file bench_result!')
64diff --git a/server/site_tests/android_Binder/bench_config.py b/server/site_tests/android_Binder/bench_config.py
65new file mode 100644
66index 000000000..20f685eb9
67--- /dev/null
68+++ b/server/site_tests/android_Binder/bench_config.py
69@@ -0,0 +1,19 @@
70+#!/bin/bash/python
71+import os
72+
73+home = os.environ["HOME"]
74+
75+android_home = os.getenv("ANDROID_HOME",
76+ default=os.path.join(home,
77+ 'android_source/master-googleplex/'))
78+bench_suite_dir = os.getenv('BENCH_SUITE_DIR',
79+ default=os.path.join(android_home,
80+ 'benchtoolchain'))
81+
82+synthmark_dir = 'framework/native/libs/binder'
83+
84+real_synthmark_dir = os.path.join(android_home, synthmark_dir)
85+
86+out_dir = os.path.join(android_home, 'out')
87+
88+product = os.getenv("PRODUCT", default="generic")
89diff --git a/server/site_tests/android_Binder/control b/server/site_tests/android_Binder/control
90new file mode 100644
91index 000000000..d91854b11
92--- /dev/null
93+++ b/server/site_tests/android_Binder/control
94@@ -0,0 +1,19 @@
95+#Control
96+
97+NAME = "Binder"
98+AUTHOR = "Zhizhou Yang"
99+ATTRIBUTES = "suite:android_toolchain_benchmark"
100+TIME = "MEDIUM"
101+TEST_CATEGORY = "Functional"
102+TEST_CLASS = "application"
103+TEST_TYPE = "server"
104+
105+DOC = """
106+
107+"""
108+
109+def run_binder_test(machine):
110+ host = hosts.create_host(machine)
111+ job.run_test("android_Binder", host=host)
112+
113+parallel_simple(run_binder_test, machines)
114diff --git a/server/site_tests/android_Dex2oat/android_Dex2oat.py b/server/site_tests/android_Dex2oat/android_Dex2oat.py
115new file mode 100644
116index 000000000..dd6af0b53
117--- /dev/null
118+++ b/server/site_tests/android_Dex2oat/android_Dex2oat.py
119@@ -0,0 +1,70 @@
120+# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
121+# Use of this source code is governed by a BSD-style license that can be
122+# found in the LICENSE file.
123+
124+import bench_config
125+import time
126+import logging
127+import os
128+import re
129+
130+from autotest_lib.client.common_lib import error
131+from autotest_lib.server import test
132+
133+class android_Dex2oat(test.test):
134+ version = 1
135+
136+ def run_once(self, host=None):
137+ self.client = host
138+
139+ out_dir = os.path.join(bench_config.android_home,
140+ 'out/target/product/',
141+ bench_config.product)
142+
143+ # Set binary directories
144+ bench_dir = os.path.join(out_dir, 'system/lib/libart-compiler.so')
145+ bench_dir_DUT = '/system/lib/libart-compiler.so'
146+ bench64_dir = os.path.join(out_dir, 'system/lib64/libart-compiler.so')
147+ bench64_dir_DUT = '/system/lib64/libart-compiler.so'
148+
149+ # Push libart-compiler.so to the device
150+ print('Pushing binaries of newly generated library onto device!')
151+ host.send_file(bench_dir, bench_dir_DUT, delete_dest=True)
152+ host.send_file(bench64_dir, bench64_dir_DUT, delete_dest=True)
153+
154+ # Set testcase directories
155+ test_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
156+ 'dex2oat_input')
157+ test_dir_DUT = '/data/local/tmp/'
158+
159+ # Push testcases to the device
160+ print('Pushing tests onto device!')
161+ host.send_file(test_dir, test_dir_DUT, delete_dest=True)
162+
163+ # Open file to write the result
164+ with open(os.path.join(bench_config.bench_suite_dir,
165+ 'bench_result'), 'w') as f:
166+
167+ # There are two benchmarks, chrome and camera.
168+ for i in xrange(2):
169+ f.write('Test %d:\n' % i)
170+ total_time = 0
171+ # Run benchmark for several times for accurancy
172+ for j in xrange(3):
173+ f.write('Iteration %d: ' % j)
174+ result = self.client.run('time taskset %s dex2oat'
175+ ' --dex-file=data/local/tmp/dex2oat_input/test%d.apk'
176+ ' --oat-file=data/local/tmp/dex2oat_input/test%d.oat'
177+ % (os.getenv('TEST_MODE'), i+1, i+1))
178+ # Find and record real time of the run
179+ time_str = ''
180+ for t in result.stdout.split() + result.stderr.split():
181+ if 'm' in t and 's' in t:
182+ time_str = t.split('m')
183+ break
184+ time_sec = float(time_str[0]) * 60
185+ time_sec += float(time_str[1].split('s')[0])
186+ f.write('User Time: %.2f seconds\n' % time_sec)
187+ total_time += time_sec
188+
189+ f.write('Total elapsed time: %.2f seconds.\n\n' % total_time)
190diff --git a/server/site_tests/android_Dex2oat/bench_config.py b/server/site_tests/android_Dex2oat/bench_config.py
191new file mode 100644
192index 000000000..d2855f22c
193--- /dev/null
194+++ b/server/site_tests/android_Dex2oat/bench_config.py
195@@ -0,0 +1,15 @@
196+#!/bin/bash/python
197+import os
198+
199+home = os.environ["HOME"]
200+
201+android_home = os.getenv("ANDROID_HOME",
202+ default=os.path.join(home,
203+ 'android_source/master-googleplex/'))
204+bench_suite_dir = os.getenv('BENCH_SUITE_DIR',
205+ default=os.path.join(android_home,
206+ 'benchtoolchain'))
207+
208+out_dir = os.path.join(android_home, 'out')
209+
210+product = os.getenv("PRODUCT", default="generic")
211diff --git a/server/site_tests/android_Dex2oat/control b/server/site_tests/android_Dex2oat/control
212new file mode 100644
213index 000000000..763864f3a
214--- /dev/null
215+++ b/server/site_tests/android_Dex2oat/control
216@@ -0,0 +1,21 @@
217+# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
218+# Use of this source code is governed by a BSD-style license that can be
219+# found in the LICENSE file.
220+
221+NAME = "Dex2oat"
222+AUTHOR = "Zhizhou Yang"
223+ATTRIBUTES = "suite:android_toolchain_benchmark"
224+TIME = "SHORT"
225+TEST_CATEGORY = "Functional"
226+TEST_CLASS = "kernel"
227+TEST_TYPE = "server"
228+
229+DOC = """
230+
231+"""
232+
233+def run_dex2oat(machine):
234+ host = hosts.create_host(machine)
235+ job.run_test("android_Dex2oat", host=host)
236+
237+parallel_simple(run_dex2oat, machines)
238diff --git a/server/site_tests/android_Hwui/android_Hwui.py b/server/site_tests/android_Hwui/android_Hwui.py
239new file mode 100644
Zhizhou Yang726ded52017-08-23 22:47:50 -0700240index 000000000..9a1accb09
Zhizhou Yange5986902017-08-10 17:37:53 -0700241--- /dev/null
242+++ b/server/site_tests/android_Hwui/android_Hwui.py
243@@ -0,0 +1,67 @@
244+# Tests for android Hwui
245+from __future__ import print_function
246+
247+import bench_config
248+import logging
249+import os
250+import re
251+
252+from autotest_lib.server import test
253+
254+class android_Hwui(test.test):
255+ version = 1
256+
257+ def run_once(self, host=None):
258+ self.client = host
259+
260+ out_dir = os.path.join(bench_config.android_home,
261+ 'out/target/product/' + bench_config.product)
262+
263+ lib_dir = os.path.join(out_dir, 'system/lib/libhwui.so')
264+ lib_dir_DUT = '/system/lib/libhwui.so'
265+ lib64_dir = os.path.join(out_dir, 'system/lib64/libhwui.so')
266+ lib64_dir_DUT = '/system/lib64/libhwui.so'
267+ bench_dir = os.path.join(out_dir,
268+ 'symbols/data/nativetest64/',
269+ 'hwuimicro/hwuimicro')
270+ bench_dir_DUT = '/data/local/tmp/hwuimicro'
271+
272+ # Push binary to the device
273+ print('Pushing Hwui benchmark onto device!')
274+ host.send_file(bench_dir, bench_dir_DUT, delete_dest=True)
275+ host.send_file(lib_dir, lib_dir_DUT, delete_dest=True)
276+ host.send_file(lib64_dir, lib64_dir_DUT, delete_dest=True)
277+
278+ # Make sure the binary is executable
279+ self.client.run('chmod u+x ' + bench_dir_DUT)
280+
281+
282+ print('Running tests on the device...')
283+ self.client.run('taskset %s /data/local/tmp/hwuimicro'
284+ ' > /data/local/tmp/bench_result'
285+ % os.getenv('TEST_MODE'))
286+
287+ # Pull result from the device
288+ out_dir = bench_config.bench_suite_dir
289+ result_dir_DUT = '/data/local/tmp/bench_result'
290+
291+ host.get_file(result_dir_DUT, out_dir, delete_dest=True)
292+
293+ # Update total time of the test
294+ t = 0
295+ with open(os.path.join(out_dir, 'bench_result'), 'r') as fin:
296+
297+ for lines in fin:
298+ line = lines.split()
299+ print(line)
300+
301+ # Check if there is test result in this line
302+ if len(line) == 8:
303+ # Accumulate the Run time for the testcase
304+ t += int(line[2])
305+
306+ # Append total time to the file
307+ with open(os.path.join(out_dir, 'bench_result'), 'a') as fout:
308+ fout.write('\nTotal elapsed time: %d ns.\n' % t)
309+
310+ print('Result has been pulled back to file bench_result!')
311diff --git a/server/site_tests/android_Hwui/bench_config.py b/server/site_tests/android_Hwui/bench_config.py
312new file mode 100644
313index 000000000..a98d259f9
314--- /dev/null
315+++ b/server/site_tests/android_Hwui/bench_config.py
316@@ -0,0 +1,19 @@
317+#!/bin/bash/python
318+import os
319+
320+home = os.environ["HOME"]
321+
322+android_home = os.getenv("ANDROID_HOME",
323+ default=os.path.join(home,
324+ 'android_source/master-googleplex/'))
325+bench_suite_dir = os.getenv('BENCH_SUITE_DIR',
326+ default=os.path.join(android_home,
327+ 'benchtoolchain'))
328+
329+hwui_dir = 'frameworks/base/libs/hwui/'
330+
331+real_hwui_dir = os.path.join(android_home, hwui_dir)
332+
333+out_dir = os.path.join(android_home, 'out')
334+
335+product = os.getenv("PRODUCT", default="generic")
336diff --git a/server/site_tests/android_Hwui/control b/server/site_tests/android_Hwui/control
337new file mode 100644
338index 000000000..89c47da20
339--- /dev/null
340+++ b/server/site_tests/android_Hwui/control
341@@ -0,0 +1,19 @@
342+#Control
343+
344+NAME = "Hwui"
345+AUTHOR = "Zhizhou Yang"
346+ATTRIBUTES = "suite:android_toolchain_benchmark"
347+TIME = "MEDIUM"
348+TEST_CATEGORY = "Functional"
349+TEST_CLASS = "library"
350+TEST_TYPE = "server"
351+
352+DOC = """
353+
354+"""
355+
356+def run_hwui_test(machine):
357+ host = hosts.create_host(machine)
358+ job.run_test("android_Hwui", host=host)
359+
360+parallel_simple(run_hwui_test, machines)
361diff --git a/server/site_tests/android_Panorama/android_Panorama.py b/server/site_tests/android_Panorama/android_Panorama.py
362new file mode 100644
Zhizhou Yang726ded52017-08-23 22:47:50 -0700363index 000000000..89b2355e5
Zhizhou Yange5986902017-08-10 17:37:53 -0700364--- /dev/null
365+++ b/server/site_tests/android_Panorama/android_Panorama.py
366@@ -0,0 +1,53 @@
367+# Tests for android Panorama
368+from __future__ import print_function
369+
370+import bench_config
371+import logging
372+import os
373+import re
374+
375+from autotest_lib.server import test
376+
377+class android_Panorama(test.test):
378+ version = 1
379+
380+ def run_once(self, host=None):
381+ self.client = host
382+
383+ out_dir = os.path.join(bench_config.android_home,
384+ 'out/target/product/' + bench_config.product)
385+
386+ # Set binary directories
387+ bench_dir = os.path.join(out_dir,
388+ 'data/local/tmp/panorama_bench64')
389+ bench_dir_DUT = '/data/local/tmp/panorama_bench64'
390+
391+ # Set tests directories
392+ tests_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
393+ 'panorama_input')
394+ tests_dir_DUT = '/data/local/tmp/panorama_input/'
395+
396+ # Push binary to the device
397+ print('Pushing binaries of Panorama benchmark onto device!')
398+ host.send_file(bench_dir, bench_dir_DUT, delete_dest=True)
399+
400+ # Make sure the binary is executable
401+ self.client.run('chmod u+x ' + bench_dir_DUT)
402+
403+ # Push testcases to the device
404+ print('Pushing tests onto device!')
405+ host.send_file(tests_dir, tests_dir_DUT, delete_dest=True)
406+
407+ print('Running tests on the device...')
408+ self.client.run('taskset %s /data/local/tmp/panorama_bench64 '
409+ '/data/local/tmp/panorama_input/panorama_input/test '
410+ '/data/local/tmp/panorama.ppm'
411+ ' > /data/local/tmp/bench_result'
412+ % os.getenv('TEST_MODE'))
413+
414+ # Pull result from the device
415+ out_dir = bench_config.bench_suite_dir
416+ result_dir_DUT = '/data/local/tmp/bench_result'
417+
418+ host.get_file(result_dir_DUT, out_dir, delete_dest=True)
419+ print('Result has been pulled back to file bench_result!')
420diff --git a/server/site_tests/android_Panorama/bench_config.py b/server/site_tests/android_Panorama/bench_config.py
421new file mode 100644
422index 000000000..075beec76
423--- /dev/null
424+++ b/server/site_tests/android_Panorama/bench_config.py
425@@ -0,0 +1,19 @@
426+#!/bin/bash/python
427+import os
428+
429+home = os.environ["HOME"]
430+
431+android_home = os.getenv("ANDROID_HOME",
432+ default=os.path.join(home,
433+ 'android_source/master-googleplex/'))
434+bench_suite_dir = os.getenv('BENCH_SUITE_DIR',
435+ default=os.path.join(android_home,
436+ 'benchtoolchain'))
437+
438+panorama_dir = 'perftests/panorama/'
439+
440+real_panorama_dir = os.path.join(android_home, panorama_dir)
441+
442+out_dir = os.path.join(android_home, 'out')
443+
444+product = os.getenv("PRODUCT", default="generic")
445diff --git a/server/site_tests/android_Panorama/control b/server/site_tests/android_Panorama/control
446new file mode 100644
447index 000000000..3cd589eed
448--- /dev/null
449+++ b/server/site_tests/android_Panorama/control
450@@ -0,0 +1,19 @@
451+#Control
452+
453+NAME = "Panorama"
454+AUTHOR = "Zhizhou Yang"
455+ATTRIBUTES = "suite:android_toolchain_benchmark"
456+TIME = "MEDIUM"
457+TEST_CATEGORY = "Functional"
458+TEST_CLASS = "application"
459+TEST_TYPE = "server"
460+
461+DOC = """
462+
463+"""
464+
465+def run_panorama_test(machine):
466+ host = hosts.create_host(machine)
467+ job.run_test("android_Panorama", host=host)
468+
469+parallel_simple(run_panorama_test, machines)
Zhizhou Yang726ded52017-08-23 22:47:50 -0700470diff --git a/server/site_tests/android_Pull/android_Pull.py b/server/site_tests/android_Pull/android_Pull.py
471new file mode 100644
472index 000000000..cff373899
473--- /dev/null
474+++ b/server/site_tests/android_Pull/android_Pull.py
475@@ -0,0 +1,30 @@
476+# Pull profraw data from device
477+from __future__ import print_function
478+
479+import bench_config
480+
481+from autotest_lib.server import test
482+
483+class android_Pull(test.test):
484+ version = 1
485+
486+ def run_once(self, host=None):
487+ self.client = host
488+
489+ # Tar all the files in profraw directory
490+ tar_file= bench_config.location_DUT + '.tar'
491+ raw_cmd = ('tar -cvf {tar_file} {location_DUT}'.format(
492+ tar_file=tar_file,
493+ location_DUT=bench_config.location_DUT))
494+ self.client.run(raw_cmd)
495+
496+ # Pull tar of profraw data from the device
497+ out_dir = bench_config.location
498+
499+ host.get_file(tar_file, out_dir, delete_dest=True)
500+
501+ # Remove the data on the device
502+ self.client.run('rm %s' % tar_file)
503+ self.client.run('rm -rf %s' % bench_config.location_DUT)
504+
505+ print('Profraw data has been pulled from device to local.')
506diff --git a/server/site_tests/android_Pull/bench_config.py b/server/site_tests/android_Pull/bench_config.py
507new file mode 100644
508index 000000000..37967c2f9
509--- /dev/null
510+++ b/server/site_tests/android_Pull/bench_config.py
511@@ -0,0 +1,19 @@
512+#!/bin/bash/python
513+import os
514+
515+home = os.environ["HOME"]
516+
517+android_home = os.getenv("ANDROID_HOME",
518+ default=os.path.join(home,
519+ 'android_source/master-googleplex/'))
520+bench_suite_dir = os.getenv('BENCH_SUITE_DIR',
521+ default=os.path.join(android_home,
522+ 'benchtoolchain'))
523+
524+bench = os.getenv('BENCH', default='Hwui')
525+location_DUT = os.getenv('LOCATION_DUT',
526+ default=os.path.join('/data/local/tmp',
527+ bench + '_profraw'))
528+location = os.getenv('LOCATION', default=bench_suite_dir)
529+
530+product = os.getenv("PRODUCT", default="generic")
531diff --git a/server/site_tests/android_Pull/control b/server/site_tests/android_Pull/control
532new file mode 100644
533index 000000000..7b00df7cb
534--- /dev/null
535+++ b/server/site_tests/android_Pull/control
536@@ -0,0 +1,19 @@
537+#Control
538+
539+NAME = "Pull"
540+AUTHOR = "Zhizhou Yang"
541+ATTRIBUTES = "suite:android_toolchain_benchmark"
542+TIME = "MEDIUM"
543+TEST_CATEGORY = "Functional"
544+TEST_CLASS = "library"
545+TEST_TYPE = "server"
546+
547+DOC = """
548+
549+"""
550+
551+def run_pull_test(machine):
552+ host = hosts.create_host(machine)
553+ job.run_test("android_Pull", host=host)
554+
555+parallel_simple(run_pull_test, machines)
Zhizhou Yange5986902017-08-10 17:37:53 -0700556diff --git a/server/site_tests/android_SetDevice/android_SetDevice.py b/server/site_tests/android_SetDevice/android_SetDevice.py
557new file mode 100644
558index 000000000..7a7134d58
559--- /dev/null
560+++ b/server/site_tests/android_SetDevice/android_SetDevice.py
561@@ -0,0 +1,77 @@
562+# Set device modes such as cpu frequency
563+from __future__ import print_function
564+
565+import logging
566+import os
567+import re
568+import time
569+
570+from autotest_lib.server import test
571+
572+def _get_cat_value(result):
573+ return result.stdout.split('\n')[0]
574+
575+class android_SetDevice(test.test):
576+ version = 1
577+
578+ def run_once(self, host=None):
579+ self.client = host
580+
581+ # Disable GPU
582+ self.client.run('setprop debug.rs.default-GPU-driver 1')
583+
584+ # Freeze system
585+ # Stop perfd, mpdecision and thermal-engine to ensure setting runs
586+ # without unexpected errors.
587+ self.client.run('stop thermal-engine')
588+ self.client.run('stop mpdecision')
589+ self.client.run('stop perfd')
590+
591+ # Set airplane mode on the device
592+ self.client.run('settings put global airplane_mode_on 1')
593+
594+ print('Setting frequency on the device...')
595+ frequency = os.getenv('FREQUENCY')
596+
597+ # Get number of cores on device
598+ result = self.client.run('ls /sys/devices/system/cpu/ '
599+ '| grep cpu[0-9].*')
600+ cores = result.stdout.splitlines()
601+ for core in cores:
602+ if core.startswith('cpu'):
603+ # First set all cores online
604+ online = os.path.join('/sys/devices/system/cpu', core, 'online')
605+ online_status = _get_cat_value(self.client.run('cat %s' % online))
606+ if online_status == '0':
607+ self.client.run('echo %s > %s' % ('1', online))
608+
609+ freq_path = os.path.join('/sys/devices/system/cpu', core,
610+ 'cpufreq')
611+
612+ # Check if the frequency user entered is legal or not.
613+ available_freq = self.client.run('cat %s/'
614+ 'scaling_available_frequencies'
615+ % (freq_path))
616+ available_freq_list = _get_cat_value(available_freq).split()
617+
618+ if frequency not in available_freq_list:
619+ raise ValueError('Wrong freqeuncy input, '
620+ 'please select from: \n%s'
621+ % (' '.join(available_freq_list)))
622+
623+ # Set frequency
624+ self.client.run('echo %s > %s/scaling_min_freq'
625+ % (frequency, freq_path))
626+ self.client.run('echo %s > %s/scaling_max_freq'
627+ % (frequency, freq_path))
628+
629+ # Sleep for 2 seconds, let device update the frequency.
630+ time.sleep(2)
631+
632+ # Get current frequency
633+ freq = self.client.run('cat %s/cpuinfo_cur_freq' % freq_path)
634+ f = _get_cat_value(freq)
635+ if f != frequency:
636+ raise RuntimeError('Expected frequency for %s to be %s, '
637+ 'but is %s' % (core, frequency, f))
638+ print('CPU frequency has been set to %s' % (frequency))
639diff --git a/server/site_tests/android_SetDevice/control b/server/site_tests/android_SetDevice/control
640new file mode 100644
641index 000000000..85163706d
642--- /dev/null
643+++ b/server/site_tests/android_SetDevice/control
644@@ -0,0 +1,19 @@
645+# Control
646+
647+NAME = "SetDevice"
648+AUTHOR = "Zhizhou Yang"
649+ATTRIBUTES = "suite:android_toolchain_benchmark"
650+TIME = "MEDIUM"
651+TEST_CATEGORY = "Functional"
652+TEST_CLASS = "application"
653+TEST_TYPE = "server"
654+
655+DOC = """
656+Set the core frequency and which core online for devices.
657+"""
658+
659+def run_set_device_test(machine):
660+ host = hosts.create_host(machine)
661+ job.run_test("android_SetDevice", host=host)
662+
663+parallel_simple(run_set_device_test, machines)
664diff --git a/server/site_tests/android_Skia/android_Skia.py b/server/site_tests/android_Skia/android_Skia.py
665new file mode 100644
666index 000000000..fc8d09dab
667--- /dev/null
668+++ b/server/site_tests/android_Skia/android_Skia.py
669@@ -0,0 +1,65 @@
670+# Tests for android Skia
671+from __future__ import print_function
672+
673+import bench_config
674+import logging
675+import os
676+import re
677+
678+from autotest_lib.server import test
679+
680+class android_Skia(test.test):
681+ version = 1
682+
683+ def run_once(self, host=None):
684+ self.client = host
685+
686+ out_dir = os.path.join(bench_config.android_home,
687+ 'out/target/product/' + bench_config.product)
688+
689+ # Set binary directories
690+ lib_dir = os.path.join(out_dir, 'system/lib/libskia.so')
691+ lib_dir_DUT = '/system/lib/libskia.so'
692+ lib64_dir = os.path.join(out_dir, 'system/lib64/libskia.so')
693+ lib64_dir_DUT = '/system/lib64/libskia.so'
694+ bench_dir = os.path.join(out_dir,
695+ 'data/nativetest64/',
696+ 'skia_nanobench/skia_nanobench')
697+ bench_dir_DUT = '/data/local/tmp/skia_nanobench'
698+
699+ # Push binary to the device
700+ print('Pushing Skia benchmark onto device!')
701+ host.send_file(bench_dir, bench_dir_DUT, delete_dest=True)
702+ host.send_file(lib_dir, lib_dir_DUT, delete_dest=True)
703+ host.send_file(lib64_dir, lib64_dir_DUT, delete_dest=True)
704+
705+ # Make sure the binary is executable
706+ self.client.run('chmod u+x ' + bench_dir_DUT)
707+
708+ # Set resource directory
709+ resource_dir = os.path.join(bench_config.real_skia_dir, 'resources')
710+ resource_dir_DUT = '/data/local/tmp/skia_resources/'
711+
712+ # Push binary to the device
713+ print('Pushing Skia resources onto device!')
714+ host.send_file(resource_dir, resource_dir_DUT, delete_dest=True)
715+
716+ # Run tests
717+ print('Running tests on the device...')
718+ try:
719+ self.client.run('taskset %s ./data/local/tmp/skia_nanobench'
720+ ' --outResultsFile /data/local/tmp/bench_result'
721+ ' --samples 25'
722+ ' --config nonrendering'
723+ % os.getenv('TEST_MODE'))
724+ except:
725+ # Ignore Abort caused failure
726+ None
727+
728+ # Pull result from the device
729+ out_dir = bench_config.bench_suite_dir
730+ result_dir_DUT = '/data/local/tmp/bench_result'
731+
732+ host.get_file(result_dir_DUT, out_dir, delete_dest=True)
733+
734+ print('Result has been pulled back to file bench_result!')
735diff --git a/server/site_tests/android_Skia/bench_config.py b/server/site_tests/android_Skia/bench_config.py
736new file mode 100644
737index 000000000..5d38d452f
738--- /dev/null
739+++ b/server/site_tests/android_Skia/bench_config.py
740@@ -0,0 +1,19 @@
741+#!/bin/bash/python
742+import os
743+
744+home = os.environ["HOME"]
745+
746+android_home = os.getenv("ANDROID_HOME",
747+ default=os.path.join(home,
748+ 'android_source/master-googleplex/'))
749+bench_suite_dir = os.getenv('BENCH_SUITE_DIR',
750+ default=os.path.join(android_home,
751+ 'benchtoolchain'))
752+
753+skia_dir = 'external/skia'
754+
755+real_skia_dir = os.path.join(android_home, skia_dir)
756+
757+out_dir = os.path.join(android_home, 'out')
758+
759+product = os.getenv("PRODUCT", default="generic")
760diff --git a/server/site_tests/android_Skia/control b/server/site_tests/android_Skia/control
761new file mode 100644
762index 000000000..e38195a8c
763--- /dev/null
764+++ b/server/site_tests/android_Skia/control
765@@ -0,0 +1,19 @@
766+#Control
767+
768+NAME = "Skia"
769+AUTHOR = "Zhizhou Yang"
770+ATTRIBUTES = "suite:android_toolchain_benchmark"
771+TIME = "MEDIUM"
772+TEST_CATEGORY = "Functional"
773+TEST_CLASS = "library"
774+TEST_TYPE = "server"
775+
776+DOC = """
777+
778+"""
779+
780+def run_skia_test(machine):
781+ host = hosts.create_host(machine)
782+ job.run_test("android_Skia", host=host)
783+
784+parallel_simple(run_skia_test, machines)
785diff --git a/server/site_tests/android_Synthmark/android_Synthmark.py b/server/site_tests/android_Synthmark/android_Synthmark.py
786new file mode 100644
787index 000000000..b317bd0f3
788--- /dev/null
789+++ b/server/site_tests/android_Synthmark/android_Synthmark.py
790@@ -0,0 +1,48 @@
791+# Tests for android Synthmark
792+from __future__ import print_function
793+
794+import bench_config
795+import logging
796+import os
797+import re
798+
799+from autotest_lib.server import test
800+
801+class android_Synthmark(test.test):
802+ version = 1
803+
804+ def run_once(self, host=None):
805+ self.client = host
806+
807+ out_dir = os.path.join(bench_config.android_home,
808+ 'out/target/product/' + bench_config.product)
809+
810+ # Set binary directories
811+ bench_dir = os.path.join(out_dir,
812+ 'symbols/system/bin/synthmark')
813+ bench_dir_DUT = '/data/local/tmp/synthmark'
814+
815+ # Push binary to the device
816+ print('Pushing binaries of Synthmark benchmark onto device!')
817+ host.send_file(bench_dir, bench_dir_DUT, delete_dest=True)
818+
819+ # Make sure the binary is executable
820+ self.client.run('chmod u+x ' + bench_dir_DUT)
821+
822+ print('Running tests on the device...')
823+ # First run creates bench_result
824+ self.client.run('taskset %s /data/local/tmp/synthmark'
825+ ' > /data/local/tmp/bench_result'
826+ % os.getenv('TEST_MODE'))
827+ # Next 4 runs add to bench_result
828+ for i in xrange(4):
829+ self.client.run('taskset %s /data/local/tmp/synthmark'
830+ ' >> /data/local/tmp/bench_result'
831+ % os.getenv('TEST_MODE'))
832+
833+ # Pull result from the device
834+ out_dir = bench_config.bench_suite_dir
835+ result_dir_DUT = '/data/local/tmp/bench_result'
836+
837+ host.get_file(result_dir_DUT, out_dir, delete_dest=True)
838+ print('Result has been pulled back to file bench_result!')
839diff --git a/server/site_tests/android_Synthmark/bench_config.py b/server/site_tests/android_Synthmark/bench_config.py
840new file mode 100644
841index 000000000..7d7aacacd
842--- /dev/null
843+++ b/server/site_tests/android_Synthmark/bench_config.py
844@@ -0,0 +1,19 @@
845+#!/bin/bash/python
846+import os
847+
848+home = os.environ["HOME"]
849+
850+android_home = os.getenv("ANDROID_HOME",
851+ default=os.path.join(home,
852+ 'android_source/master-googleplex/'))
853+bench_suite_dir = os.getenv('BENCH_SUITE_DIR',
854+ default=os.path.join(android_home,
855+ 'benchtoolchain'))
856+
857+synthmark_dir = 'synthmark'
858+
859+real_synthmark_dir = os.path.join(android_home, synthmark_dir)
860+
861+out_dir = os.path.join(android_home, 'out')
862+
863+product = os.getenv("PRODUCT", default="generic")
864diff --git a/server/site_tests/android_Synthmark/control b/server/site_tests/android_Synthmark/control
865new file mode 100644
866index 000000000..144766351
867--- /dev/null
868+++ b/server/site_tests/android_Synthmark/control
869@@ -0,0 +1,19 @@
870+#Control
871+
872+NAME = "Synthmark"
873+AUTHOR = "Zhizhou Yang"
874+ATTRIBUTES = "suite:android_toolchain_benchmark"
875+TIME = "MEDIUM"
876+TEST_CATEGORY = "Functional"
877+TEST_CLASS = "application"
878+TEST_TYPE = "server"
879+
880+DOC = """
881+
882+"""
883+
884+def run_synthmark_test(machine):
885+ host = hosts.create_host(machine)
886+ job.run_test("android_Synthmark", host=host)
887+
888+parallel_simple(run_synthmark_test, machines)
Zhizhou Yang726ded52017-08-23 22:47:50 -0700889diff --git a/site_utils/pull_device.py b/site_utils/pull_device.py
890new file mode 100755
891index 000000000..959c4443d
892--- /dev/null
893+++ b/site_utils/pull_device.py
894@@ -0,0 +1,116 @@
895+#!/usr/bin/python
896+#
897+# Script to pull data from android device
898+from __future__ import print_function
899+
900+import argparse
901+import common
902+import logging
903+import os
904+import sys
905+
906+# Turn the logging level to INFO before importing other autotest
907+# code, to avoid having failed import logging messages confuse the
908+# test_droid user.
909+logging.basicConfig(level=logging.INFO)
910+
911+# Unfortunately, autotest depends on external packages for assorted
912+# functionality regardless of whether or not it is needed in a particular
913+# context.
914+# Since we can't depend on people to import these utilities in any principled
915+# way, we dynamically download code before any autotest imports.
916+try:
917+ import chromite.lib.terminal # pylint: disable=unused-import
918+ import django.http # pylint: disable=unused-import
919+except ImportError:
920+ # Ensure the chromite site-package is installed.
921+ import subprocess
922+ build_externals_path = os.path.join(
923+ os.path.dirname(os.path.dirname(os.path.realpath(__file__))),
924+ 'utils', 'build_externals.py')
925+ subprocess.check_call([build_externals_path, '--names_to_check',
926+ 'chromiterepo', 'django'])
927+ # Restart the script so python now finds the autotest site-packages.
928+ sys.exit(os.execv(__file__, sys.argv))
929+
930+from autotest_lib.client.common_lib import utils
931+from autotest_lib.server.hosts import adb_host
932+from autotest_lib.site_utils import test_runner_utils
933+from autotest_lib.site_utils import tester_feedback
934+
935+def _parse_arguments_internal(argv):
936+ """
937+ Parse command line arguments
938+
939+ @param argv: argument list to parse
940+
941+ @returns: tuple of parsed arguments and argv suitable for remote runs
942+
943+ @raises SystemExit if arguments are malformed, or required arguments
944+ are not present.
945+ """
946+
947+ parser = argparse.ArgumentParser(description='Run remote tests.')
948+
949+ parser.add_argument('-b', '--bench', metavar='BENCH', required=True,
950+ help='Select the benchmark want to be run for '
951+ 'test.')
952+ parser.add_argument('-s', '--serials', metavar='SERIALS',
953+ help='Comma separate list of device serials under '
954+ 'test.')
955+ parser.add_argument('-r', '--remote', metavar='REMOTE',
956+ default='localhost',
957+ help='hostname[:port] if the ADB device is connected '
958+ 'to a remote machine. Ensure this workstation '
959+ 'is configured for passwordless ssh access as '
960+ 'users "root" or "adb"')
961+
962+ parser.add_argument('-d', '--pathDUT',
963+ help='Specify the location to put the file on DUT.')
964+ parser.add_argument('-p', '--path',
965+ help='Specify the location to put the file locally.')
966+
967+ return parser.parse_args(argv)
968+
969+def main(argv):
970+ """
971+ Entry point for pull_device script.
972+
973+ @param argv: arguments list
974+ """
975+ arguments = _parse_arguments_internal(argv)
976+
977+ serials = arguments.serials
978+ if serials is None:
979+ result = utils.run(['adb', 'devices'])
980+ devices = adb_host.ADBHost.parse_device_serials(result.stdout)
981+ if len(devices) != 1:
982+ logging.error('Could not detect exactly one device; please select '
983+ 'one with -s: %s', devices)
984+ return 1
985+ serials = devices[0]
986+
987+ autotest_path = os.path.dirname(os.path.dirname(
988+ os.path.realpath(__file__)))
989+ site_utils_path = os.path.join(autotest_path, 'site_utils')
990+ realpath = os.path.realpath(__file__)
991+ site_utils_path = os.path.realpath(site_utils_path)
992+ host_attributes = {'serials': serials,
993+ 'os_type': 'android'}
994+ results_directory = test_runner_utils.create_results_directory(None)
995+
996+ os.environ['BENCH'] = arguments.bench
997+ os.environ['LOCATION_DUT'] = arguments.pathDUT
998+ os.environ['LOCATION'] = arguments.path
999+
1000+ tests = ['Pull']
1001+
1002+ if test_runner_utils.perform_run_from_autotest_root(
1003+ autotest_path, argv, tests, arguments.remote,
1004+ host_attributes=host_attributes,
1005+ results_directory=results_directory):
1006+ logging.error('Error while running on device.')
1007+ return 1
1008+
1009+if __name__ == '__main__':
1010+ sys.exit(main(sys.argv[1:]))
Zhizhou Yange5986902017-08-10 17:37:53 -07001011diff --git a/site_utils/set_device.py b/site_utils/set_device.py
1012new file mode 100755
1013index 000000000..abb8a8dcc
1014--- /dev/null
1015+++ b/site_utils/set_device.py
1016@@ -0,0 +1,110 @@
1017+#!/usr/bin/python
1018+from __future__ import print_function
1019+
1020+import argparse
1021+import common
1022+import logging
1023+import os
1024+import sys
1025+
1026+# Turn the logging level to INFO before importing other autotest code, to avoid
1027+# having failed import logging messages confuse the test_droid user.
1028+logging.basicConfig(level=logging.INFO)
1029+
1030+# Unfortunately, autotest depends on external packages for assorted
1031+# functionality regardless of whether or not it is needed in a particular
1032+# context. Since we can't depend on people to import these utilities in any
1033+# principled way, we dynamically download code before any autotest imports.
1034+try:
1035+ import chromite.lib.terminal # pylint: disable=unused-import
1036+ import django.http # pylint: disable=unused-import
1037+except ImportError:
1038+ # Ensure the chromite site-package is installed.
1039+ import subprocess
1040+ build_externals_path = os.path.join(
1041+ os.path.dirname(os.path.dirname(os.path.realpath(__file__))),
1042+ 'utils', 'build_externals.py')
1043+ subprocess.check_call([build_externals_path, '--names_to_check',
1044+ 'chromiterepo', 'django'])
1045+ # Restart the script so python now finds the autotest site-packages.
1046+ sys.exit(os.execv(__file__, sys.argv))
1047+
1048+from autotest_lib.client.common_lib import utils
1049+from autotest_lib.server.hosts import adb_host
1050+from autotest_lib.site_utils import test_runner_utils
1051+from autotest_lib.site_utils import tester_feedback
1052+
1053+def _parse_arguments_internal(argv):
1054+ """
1055+ Parse command line arguments
1056+
1057+ @param argv: argument list to parse
1058+
1059+ @returns: tuple of parsed arguments and argv suitable for remote runs
1060+
1061+ @raises SystemExit if arguments are malformed, or required arguments
1062+ are not present.
1063+ """
1064+
1065+ parser = argparse.ArgumentParser(description='Set device cpu cores and '
1066+ 'frequency.')
1067+
1068+ parser.add_argument('-s', '--serials', metavar='SERIALS',
1069+ help='Comma separate list of device serials under '
1070+ 'test.')
1071+ parser.add_argument('-r', '--remote', metavar='REMOTE',
1072+ default='localhost',
1073+ help='hostname[:port] if the ADB device is connected '
1074+ 'to a remote machine. Ensure this workstation '
1075+ 'is configured for passwordless ssh access as '
1076+ 'users "root" or "adb"')
1077+ parser.add_argument('-q', '--frequency', type=int, default=960000,
1078+ help='Specify the CPU frequency of the device, lower '
1079+ 'frequency will slow down the performance but '
1080+ 'reduce noise.')
1081+
1082+ return parser.parse_args(argv)
1083+
1084+def main(argv):
1085+ """
1086+ Entry point for set_device script.
1087+
1088+ @param argv: arguments list
1089+ """
1090+ arguments = _parse_arguments_internal(argv)
1091+
1092+ serials = arguments.serials
1093+ if serials is None:
1094+ result = utils.run(['adb', 'devices'])
1095+ devices = adb_host.ADBHost.parse_device_serials(result.stdout)
1096+ if len(devices) != 1:
1097+ logging.error('Could not detect exactly one device; please select '
1098+ 'one with -s: %s', devices)
1099+ return 1
1100+ serials = devices[0]
1101+
1102+ autotest_path = os.path.dirname(os.path.dirname(
1103+ os.path.realpath(__file__)))
1104+ site_utils_path = os.path.join(autotest_path, 'site_utils')
1105+ realpath = os.path.realpath(__file__)
1106+ site_utils_path = os.path.realpath(site_utils_path)
1107+ host_attributes = {'serials': serials,
1108+ 'os_type': 'android'}
1109+ results_directory = test_runner_utils.create_results_directory(None)
1110+
1111+ logging.info('Start setting CPU frequency on the device...')
1112+
1113+ os.environ['FREQUENCY'] = str(arguments.frequency)
1114+
1115+ set_device = ['SetDevice']
1116+ if test_runner_utils.perform_run_from_autotest_root(
1117+ autotest_path, argv, set_device, arguments.remote,
1118+ host_attributes=host_attributes,
1119+ results_directory=results_directory):
1120+ logging.error('Error while setting device!')
1121+ return 1
1122+
1123+ return 0
1124+
1125+if __name__ == '__main__':
1126+ sys.exit(main(sys.argv[1:]))
1127diff --git a/site_utils/test_bench.py b/site_utils/test_bench.py
1128new file mode 100755
1129index 000000000..4d0773ad9
1130--- /dev/null
1131+++ b/site_utils/test_bench.py
1132@@ -0,0 +1,133 @@
1133+#!/usr/bin/python
1134+from __future__ import print_function
1135+
1136+import argparse
1137+import common
1138+import logging
1139+import os
1140+import sys
1141+
1142+# Turn the logging level to INFO before importing other autotest
1143+# code, to avoid having failed import logging messages confuse the
1144+# test_droid user.
1145+logging.basicConfig(level=logging.INFO)
1146+
1147+# Unfortunately, autotest depends on external packages for assorted
1148+# functionality regardless of whether or not it is needed in a particular
1149+# context.
1150+# Since we can't depend on people to import these utilities in any principled
1151+# way, we dynamically download code before any autotest imports.
1152+try:
1153+ import chromite.lib.terminal # pylint: disable=unused-import
1154+ import django.http # pylint: disable=unused-import
1155+except ImportError:
1156+ # Ensure the chromite site-package is installed.
1157+ import subprocess
1158+ build_externals_path = os.path.join(
1159+ os.path.dirname(os.path.dirname(os.path.realpath(__file__))),
1160+ 'utils', 'build_externals.py')
1161+ subprocess.check_call([build_externals_path, '--names_to_check',
1162+ 'chromiterepo', 'django'])
1163+ # Restart the script so python now finds the autotest site-packages.
1164+ sys.exit(os.execv(__file__, sys.argv))
1165+
1166+from autotest_lib.client.common_lib import utils
1167+from autotest_lib.server.hosts import adb_host
1168+from autotest_lib.site_utils import test_runner_utils
1169+from autotest_lib.site_utils import tester_feedback
1170+
1171+def _parse_arguments_internal(argv):
1172+ """
1173+ Parse command line arguments
1174+
1175+ @param argv: argument list to parse
1176+
1177+ @returns: tuple of parsed arguments and argv suitable for remote runs
1178+
1179+ @raises SystemExit if arguments are malformed, or required arguments
1180+ are not present.
1181+ """
1182+
1183+ parser = argparse.ArgumentParser(description='Run remote tests.')
1184+
1185+ parser.add_argument('-b', '--bench', metavar='BENCH', required=True,
1186+ help='Select the benchmark want to be run for '
1187+ 'test.')
1188+ parser.add_argument('-s', '--serials', metavar='SERIALS',
1189+ help='Comma separate list of device serials under '
1190+ 'test.')
1191+ parser.add_argument('-r', '--remote', metavar='REMOTE',
1192+ default='localhost',
1193+ help='hostname[:port] if the ADB device is connected '
1194+ 'to a remote machine. Ensure this workstation '
1195+ 'is configured for passwordless ssh access as '
1196+ 'users "root" or "adb"')
1197+ parser.add_argument('-m', '--mode', default='little',
1198+ help='Two modes can be chosen, little mode runs on a '
1199+ 'single core of Cortex-A53, while big mode runs '
1200+ 'on single core of Cortex-A57.')
1201+
1202+ return parser.parse_args(argv)
1203+
1204+def main(argv):
1205+ """
1206+ Entry point for test_bench script.
1207+
1208+ @param argv: arguments list
1209+ """
1210+ arguments = _parse_arguments_internal(argv)
1211+
1212+ serials = arguments.serials
1213+ if serials is None:
1214+ result = utils.run(['adb', 'devices'])
1215+ devices = adb_host.ADBHost.parse_device_serials(result.stdout)
1216+ if len(devices) != 1:
1217+ logging.error('Could not detect exactly one device; please select '
1218+ 'one with -s: %s', devices)
1219+ return 1
1220+ serials = devices[0]
1221+
1222+ autotest_path = os.path.dirname(os.path.dirname(
1223+ os.path.realpath(__file__)))
1224+ site_utils_path = os.path.join(autotest_path, 'site_utils')
1225+ realpath = os.path.realpath(__file__)
1226+ site_utils_path = os.path.realpath(site_utils_path)
1227+ host_attributes = {'serials': serials,
1228+ 'os_type': 'android'}
1229+ results_directory = test_runner_utils.create_results_directory(None)
1230+
1231+ bench = arguments.bench
1232+
1233+ benchlist = ['Panorama', 'Skia', 'Dex2oat', 'Hwui', "Synthmark", "Binder"]
1234+
1235+ logging.info('Start testing benchmark on the device...')
1236+
1237+ if bench not in benchlist:
1238+ logging.error('Please select one benchmark from the list below: \n%s',
1239+ '\n'.join(benchlist))
1240+ return 1
1241+
1242+ # Use taskset command to run benchmarks with different CPU core settings.
1243+ #
1244+ # TEST_MODE variable is set to either 7 or 56 for coremask in taskset.
1245+ #
1246+ # While Nexus 6P has 8 cores and 5X has 6 cores. CPU number 0-3 in both
1247+ # devices belongs to Cortex 53, which are slow. CPU number 4-5 in 5X and 4-7
1248+ # in 6P belongs to Cortex 57, which are fast.
1249+ #
1250+ # So we set 7(0x00000111) for little mode, that runs the benchmark on three
1251+ # slow cores; 56(0x00111000) for big mode, that runs the benchmark on two
1252+ # fast and one slow cores.
1253+ os.environ['TEST_MODE'] = '7' if arguments.mode == 'little' else '56'
1254+
1255+ tests = [bench]
1256+
1257+ if test_runner_utils.perform_run_from_autotest_root(
1258+ autotest_path, argv, tests, arguments.remote,
1259+ host_attributes=host_attributes,
1260+ results_directory=results_directory):
1261+ logging.error('Error while testing on device.')
1262+ return 1
1263+
1264+if __name__ == '__main__':
1265+ sys.exit(main(sys.argv[1:]))