blob: 0b7f8224b2c7dbc8f416a8a42eadf8f13265ff4a [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 Yang645c6642017-12-13 18:01:43 -0800240index 000000000..21e77fd54
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,
Zhizhou Yang7b6346f2017-09-12 11:32:14 -0700268+ 'symbols/data/benchmarktest64/',
Zhizhou Yange5986902017-08-10 17:37:53 -0700269+ '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
Zhizhou Yang645c6642017-12-13 18:01:43 -0800666index 000000000..80b39a027
Zhizhou Yange5986902017-08-10 17:37:53 -0700667--- /dev/null
668+++ b/server/site_tests/android_Skia/android_Skia.py
Zhizhou Yang645c6642017-12-13 18:01:43 -0800669@@ -0,0 +1,59 @@
Zhizhou Yange5986902017-08-10 17:37:53 -0700670+# 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
Zhizhou Yange5986902017-08-10 17:37:53 -0700690+ bench_dir = os.path.join(out_dir,
691+ 'data/nativetest64/',
692+ 'skia_nanobench/skia_nanobench')
693+ bench_dir_DUT = '/data/local/tmp/skia_nanobench'
694+
695+ # Push binary to the device
696+ print('Pushing Skia benchmark onto device!')
697+ host.send_file(bench_dir, bench_dir_DUT, delete_dest=True)
Zhizhou Yange5986902017-08-10 17:37:53 -0700698+
699+ # Make sure the binary is executable
700+ self.client.run('chmod u+x ' + bench_dir_DUT)
701+
702+ # Set resource directory
703+ resource_dir = os.path.join(bench_config.real_skia_dir, 'resources')
704+ resource_dir_DUT = '/data/local/tmp/skia_resources/'
705+
706+ # Push binary to the device
707+ print('Pushing Skia resources onto device!')
708+ host.send_file(resource_dir, resource_dir_DUT, delete_dest=True)
709+
710+ # Run tests
711+ print('Running tests on the device...')
712+ try:
713+ self.client.run('taskset %s ./data/local/tmp/skia_nanobench'
714+ ' --outResultsFile /data/local/tmp/bench_result'
715+ ' --samples 25'
716+ ' --config nonrendering'
717+ % os.getenv('TEST_MODE'))
718+ except:
719+ # Ignore Abort caused failure
720+ None
721+
722+ # Pull result from the device
723+ out_dir = bench_config.bench_suite_dir
724+ result_dir_DUT = '/data/local/tmp/bench_result'
725+
726+ host.get_file(result_dir_DUT, out_dir, delete_dest=True)
727+
728+ print('Result has been pulled back to file bench_result!')
729diff --git a/server/site_tests/android_Skia/bench_config.py b/server/site_tests/android_Skia/bench_config.py
730new file mode 100644
731index 000000000..5d38d452f
732--- /dev/null
733+++ b/server/site_tests/android_Skia/bench_config.py
734@@ -0,0 +1,19 @@
735+#!/bin/bash/python
736+import os
737+
738+home = os.environ["HOME"]
739+
740+android_home = os.getenv("ANDROID_HOME",
741+ default=os.path.join(home,
742+ 'android_source/master-googleplex/'))
743+bench_suite_dir = os.getenv('BENCH_SUITE_DIR',
744+ default=os.path.join(android_home,
745+ 'benchtoolchain'))
746+
747+skia_dir = 'external/skia'
748+
749+real_skia_dir = os.path.join(android_home, skia_dir)
750+
751+out_dir = os.path.join(android_home, 'out')
752+
753+product = os.getenv("PRODUCT", default="generic")
754diff --git a/server/site_tests/android_Skia/control b/server/site_tests/android_Skia/control
755new file mode 100644
756index 000000000..e38195a8c
757--- /dev/null
758+++ b/server/site_tests/android_Skia/control
759@@ -0,0 +1,19 @@
760+#Control
761+
762+NAME = "Skia"
763+AUTHOR = "Zhizhou Yang"
764+ATTRIBUTES = "suite:android_toolchain_benchmark"
765+TIME = "MEDIUM"
766+TEST_CATEGORY = "Functional"
767+TEST_CLASS = "library"
768+TEST_TYPE = "server"
769+
770+DOC = """
771+
772+"""
773+
774+def run_skia_test(machine):
775+ host = hosts.create_host(machine)
776+ job.run_test("android_Skia", host=host)
777+
778+parallel_simple(run_skia_test, machines)
779diff --git a/server/site_tests/android_Synthmark/android_Synthmark.py b/server/site_tests/android_Synthmark/android_Synthmark.py
780new file mode 100644
781index 000000000..b317bd0f3
782--- /dev/null
783+++ b/server/site_tests/android_Synthmark/android_Synthmark.py
784@@ -0,0 +1,48 @@
785+# Tests for android Synthmark
786+from __future__ import print_function
787+
788+import bench_config
789+import logging
790+import os
791+import re
792+
793+from autotest_lib.server import test
794+
795+class android_Synthmark(test.test):
796+ version = 1
797+
798+ def run_once(self, host=None):
799+ self.client = host
800+
801+ out_dir = os.path.join(bench_config.android_home,
802+ 'out/target/product/' + bench_config.product)
803+
804+ # Set binary directories
805+ bench_dir = os.path.join(out_dir,
806+ 'symbols/system/bin/synthmark')
807+ bench_dir_DUT = '/data/local/tmp/synthmark'
808+
809+ # Push binary to the device
810+ print('Pushing binaries of Synthmark benchmark onto device!')
811+ host.send_file(bench_dir, bench_dir_DUT, delete_dest=True)
812+
813+ # Make sure the binary is executable
814+ self.client.run('chmod u+x ' + bench_dir_DUT)
815+
816+ print('Running tests on the device...')
817+ # First run creates bench_result
818+ self.client.run('taskset %s /data/local/tmp/synthmark'
819+ ' > /data/local/tmp/bench_result'
820+ % os.getenv('TEST_MODE'))
821+ # Next 4 runs add to bench_result
822+ for i in xrange(4):
823+ self.client.run('taskset %s /data/local/tmp/synthmark'
824+ ' >> /data/local/tmp/bench_result'
825+ % os.getenv('TEST_MODE'))
826+
827+ # Pull result from the device
828+ out_dir = bench_config.bench_suite_dir
829+ result_dir_DUT = '/data/local/tmp/bench_result'
830+
831+ host.get_file(result_dir_DUT, out_dir, delete_dest=True)
832+ print('Result has been pulled back to file bench_result!')
833diff --git a/server/site_tests/android_Synthmark/bench_config.py b/server/site_tests/android_Synthmark/bench_config.py
834new file mode 100644
835index 000000000..7d7aacacd
836--- /dev/null
837+++ b/server/site_tests/android_Synthmark/bench_config.py
838@@ -0,0 +1,19 @@
839+#!/bin/bash/python
840+import os
841+
842+home = os.environ["HOME"]
843+
844+android_home = os.getenv("ANDROID_HOME",
845+ default=os.path.join(home,
846+ 'android_source/master-googleplex/'))
847+bench_suite_dir = os.getenv('BENCH_SUITE_DIR',
848+ default=os.path.join(android_home,
849+ 'benchtoolchain'))
850+
851+synthmark_dir = 'synthmark'
852+
853+real_synthmark_dir = os.path.join(android_home, synthmark_dir)
854+
855+out_dir = os.path.join(android_home, 'out')
856+
857+product = os.getenv("PRODUCT", default="generic")
858diff --git a/server/site_tests/android_Synthmark/control b/server/site_tests/android_Synthmark/control
859new file mode 100644
860index 000000000..144766351
861--- /dev/null
862+++ b/server/site_tests/android_Synthmark/control
863@@ -0,0 +1,19 @@
864+#Control
865+
866+NAME = "Synthmark"
867+AUTHOR = "Zhizhou Yang"
868+ATTRIBUTES = "suite:android_toolchain_benchmark"
869+TIME = "MEDIUM"
870+TEST_CATEGORY = "Functional"
871+TEST_CLASS = "application"
872+TEST_TYPE = "server"
873+
874+DOC = """
875+
876+"""
877+
878+def run_synthmark_test(machine):
879+ host = hosts.create_host(machine)
880+ job.run_test("android_Synthmark", host=host)
881+
882+parallel_simple(run_synthmark_test, machines)
Zhizhou Yang726ded52017-08-23 22:47:50 -0700883diff --git a/site_utils/pull_device.py b/site_utils/pull_device.py
884new file mode 100755
885index 000000000..959c4443d
886--- /dev/null
887+++ b/site_utils/pull_device.py
888@@ -0,0 +1,116 @@
889+#!/usr/bin/python
890+#
891+# Script to pull data from android device
892+from __future__ import print_function
893+
894+import argparse
895+import common
896+import logging
897+import os
898+import sys
899+
900+# Turn the logging level to INFO before importing other autotest
901+# code, to avoid having failed import logging messages confuse the
902+# test_droid user.
903+logging.basicConfig(level=logging.INFO)
904+
905+# Unfortunately, autotest depends on external packages for assorted
906+# functionality regardless of whether or not it is needed in a particular
907+# context.
908+# Since we can't depend on people to import these utilities in any principled
909+# way, we dynamically download code before any autotest imports.
910+try:
911+ import chromite.lib.terminal # pylint: disable=unused-import
912+ import django.http # pylint: disable=unused-import
913+except ImportError:
914+ # Ensure the chromite site-package is installed.
915+ import subprocess
916+ build_externals_path = os.path.join(
917+ os.path.dirname(os.path.dirname(os.path.realpath(__file__))),
918+ 'utils', 'build_externals.py')
919+ subprocess.check_call([build_externals_path, '--names_to_check',
920+ 'chromiterepo', 'django'])
921+ # Restart the script so python now finds the autotest site-packages.
922+ sys.exit(os.execv(__file__, sys.argv))
923+
924+from autotest_lib.client.common_lib import utils
925+from autotest_lib.server.hosts import adb_host
926+from autotest_lib.site_utils import test_runner_utils
927+from autotest_lib.site_utils import tester_feedback
928+
929+def _parse_arguments_internal(argv):
930+ """
931+ Parse command line arguments
932+
933+ @param argv: argument list to parse
934+
935+ @returns: tuple of parsed arguments and argv suitable for remote runs
936+
937+ @raises SystemExit if arguments are malformed, or required arguments
938+ are not present.
939+ """
940+
941+ parser = argparse.ArgumentParser(description='Run remote tests.')
942+
943+ parser.add_argument('-b', '--bench', metavar='BENCH', required=True,
944+ help='Select the benchmark want to be run for '
945+ 'test.')
946+ parser.add_argument('-s', '--serials', metavar='SERIALS',
947+ help='Comma separate list of device serials under '
948+ 'test.')
949+ parser.add_argument('-r', '--remote', metavar='REMOTE',
950+ default='localhost',
951+ help='hostname[:port] if the ADB device is connected '
952+ 'to a remote machine. Ensure this workstation '
953+ 'is configured for passwordless ssh access as '
954+ 'users "root" or "adb"')
955+
956+ parser.add_argument('-d', '--pathDUT',
957+ help='Specify the location to put the file on DUT.')
958+ parser.add_argument('-p', '--path',
959+ help='Specify the location to put the file locally.')
960+
961+ return parser.parse_args(argv)
962+
963+def main(argv):
964+ """
965+ Entry point for pull_device script.
966+
967+ @param argv: arguments list
968+ """
969+ arguments = _parse_arguments_internal(argv)
970+
971+ serials = arguments.serials
972+ if serials is None:
973+ result = utils.run(['adb', 'devices'])
974+ devices = adb_host.ADBHost.parse_device_serials(result.stdout)
975+ if len(devices) != 1:
976+ logging.error('Could not detect exactly one device; please select '
977+ 'one with -s: %s', devices)
978+ return 1
979+ serials = devices[0]
980+
981+ autotest_path = os.path.dirname(os.path.dirname(
982+ os.path.realpath(__file__)))
983+ site_utils_path = os.path.join(autotest_path, 'site_utils')
984+ realpath = os.path.realpath(__file__)
985+ site_utils_path = os.path.realpath(site_utils_path)
986+ host_attributes = {'serials': serials,
987+ 'os_type': 'android'}
988+ results_directory = test_runner_utils.create_results_directory(None)
989+
990+ os.environ['BENCH'] = arguments.bench
991+ os.environ['LOCATION_DUT'] = arguments.pathDUT
992+ os.environ['LOCATION'] = arguments.path
993+
994+ tests = ['Pull']
995+
996+ if test_runner_utils.perform_run_from_autotest_root(
997+ autotest_path, argv, tests, arguments.remote,
998+ host_attributes=host_attributes,
999+ results_directory=results_directory):
1000+ logging.error('Error while running on device.')
1001+ return 1
1002+
1003+if __name__ == '__main__':
1004+ sys.exit(main(sys.argv[1:]))
Zhizhou Yange5986902017-08-10 17:37:53 -07001005diff --git a/site_utils/set_device.py b/site_utils/set_device.py
1006new file mode 100755
1007index 000000000..abb8a8dcc
1008--- /dev/null
1009+++ b/site_utils/set_device.py
1010@@ -0,0 +1,110 @@
1011+#!/usr/bin/python
1012+from __future__ import print_function
1013+
1014+import argparse
1015+import common
1016+import logging
1017+import os
1018+import sys
1019+
1020+# Turn the logging level to INFO before importing other autotest code, to avoid
1021+# having failed import logging messages confuse the test_droid user.
1022+logging.basicConfig(level=logging.INFO)
1023+
1024+# Unfortunately, autotest depends on external packages for assorted
1025+# functionality regardless of whether or not it is needed in a particular
1026+# context. Since we can't depend on people to import these utilities in any
1027+# principled way, we dynamically download code before any autotest imports.
1028+try:
1029+ import chromite.lib.terminal # pylint: disable=unused-import
1030+ import django.http # pylint: disable=unused-import
1031+except ImportError:
1032+ # Ensure the chromite site-package is installed.
1033+ import subprocess
1034+ build_externals_path = os.path.join(
1035+ os.path.dirname(os.path.dirname(os.path.realpath(__file__))),
1036+ 'utils', 'build_externals.py')
1037+ subprocess.check_call([build_externals_path, '--names_to_check',
1038+ 'chromiterepo', 'django'])
1039+ # Restart the script so python now finds the autotest site-packages.
1040+ sys.exit(os.execv(__file__, sys.argv))
1041+
1042+from autotest_lib.client.common_lib import utils
1043+from autotest_lib.server.hosts import adb_host
1044+from autotest_lib.site_utils import test_runner_utils
1045+from autotest_lib.site_utils import tester_feedback
1046+
1047+def _parse_arguments_internal(argv):
1048+ """
1049+ Parse command line arguments
1050+
1051+ @param argv: argument list to parse
1052+
1053+ @returns: tuple of parsed arguments and argv suitable for remote runs
1054+
1055+ @raises SystemExit if arguments are malformed, or required arguments
1056+ are not present.
1057+ """
1058+
1059+ parser = argparse.ArgumentParser(description='Set device cpu cores and '
1060+ 'frequency.')
1061+
1062+ parser.add_argument('-s', '--serials', metavar='SERIALS',
1063+ help='Comma separate list of device serials under '
1064+ 'test.')
1065+ parser.add_argument('-r', '--remote', metavar='REMOTE',
1066+ default='localhost',
1067+ help='hostname[:port] if the ADB device is connected '
1068+ 'to a remote machine. Ensure this workstation '
1069+ 'is configured for passwordless ssh access as '
1070+ 'users "root" or "adb"')
1071+ parser.add_argument('-q', '--frequency', type=int, default=960000,
1072+ help='Specify the CPU frequency of the device, lower '
1073+ 'frequency will slow down the performance but '
1074+ 'reduce noise.')
1075+
1076+ return parser.parse_args(argv)
1077+
1078+def main(argv):
1079+ """
1080+ Entry point for set_device script.
1081+
1082+ @param argv: arguments list
1083+ """
1084+ arguments = _parse_arguments_internal(argv)
1085+
1086+ serials = arguments.serials
1087+ if serials is None:
1088+ result = utils.run(['adb', 'devices'])
1089+ devices = adb_host.ADBHost.parse_device_serials(result.stdout)
1090+ if len(devices) != 1:
1091+ logging.error('Could not detect exactly one device; please select '
1092+ 'one with -s: %s', devices)
1093+ return 1
1094+ serials = devices[0]
1095+
1096+ autotest_path = os.path.dirname(os.path.dirname(
1097+ os.path.realpath(__file__)))
1098+ site_utils_path = os.path.join(autotest_path, 'site_utils')
1099+ realpath = os.path.realpath(__file__)
1100+ site_utils_path = os.path.realpath(site_utils_path)
1101+ host_attributes = {'serials': serials,
1102+ 'os_type': 'android'}
1103+ results_directory = test_runner_utils.create_results_directory(None)
1104+
1105+ logging.info('Start setting CPU frequency on the device...')
1106+
1107+ os.environ['FREQUENCY'] = str(arguments.frequency)
1108+
1109+ set_device = ['SetDevice']
1110+ if test_runner_utils.perform_run_from_autotest_root(
1111+ autotest_path, argv, set_device, arguments.remote,
1112+ host_attributes=host_attributes,
1113+ results_directory=results_directory):
1114+ logging.error('Error while setting device!')
1115+ return 1
1116+
1117+ return 0
1118+
1119+if __name__ == '__main__':
1120+ sys.exit(main(sys.argv[1:]))
1121diff --git a/site_utils/test_bench.py b/site_utils/test_bench.py
1122new file mode 100755
1123index 000000000..4d0773ad9
1124--- /dev/null
1125+++ b/site_utils/test_bench.py
1126@@ -0,0 +1,133 @@
1127+#!/usr/bin/python
1128+from __future__ import print_function
1129+
1130+import argparse
1131+import common
1132+import logging
1133+import os
1134+import sys
1135+
1136+# Turn the logging level to INFO before importing other autotest
1137+# code, to avoid having failed import logging messages confuse the
1138+# test_droid user.
1139+logging.basicConfig(level=logging.INFO)
1140+
1141+# Unfortunately, autotest depends on external packages for assorted
1142+# functionality regardless of whether or not it is needed in a particular
1143+# context.
1144+# Since we can't depend on people to import these utilities in any principled
1145+# way, we dynamically download code before any autotest imports.
1146+try:
1147+ import chromite.lib.terminal # pylint: disable=unused-import
1148+ import django.http # pylint: disable=unused-import
1149+except ImportError:
1150+ # Ensure the chromite site-package is installed.
1151+ import subprocess
1152+ build_externals_path = os.path.join(
1153+ os.path.dirname(os.path.dirname(os.path.realpath(__file__))),
1154+ 'utils', 'build_externals.py')
1155+ subprocess.check_call([build_externals_path, '--names_to_check',
1156+ 'chromiterepo', 'django'])
1157+ # Restart the script so python now finds the autotest site-packages.
1158+ sys.exit(os.execv(__file__, sys.argv))
1159+
1160+from autotest_lib.client.common_lib import utils
1161+from autotest_lib.server.hosts import adb_host
1162+from autotest_lib.site_utils import test_runner_utils
1163+from autotest_lib.site_utils import tester_feedback
1164+
1165+def _parse_arguments_internal(argv):
1166+ """
1167+ Parse command line arguments
1168+
1169+ @param argv: argument list to parse
1170+
1171+ @returns: tuple of parsed arguments and argv suitable for remote runs
1172+
1173+ @raises SystemExit if arguments are malformed, or required arguments
1174+ are not present.
1175+ """
1176+
1177+ parser = argparse.ArgumentParser(description='Run remote tests.')
1178+
1179+ parser.add_argument('-b', '--bench', metavar='BENCH', required=True,
1180+ help='Select the benchmark want to be run for '
1181+ 'test.')
1182+ parser.add_argument('-s', '--serials', metavar='SERIALS',
1183+ help='Comma separate list of device serials under '
1184+ 'test.')
1185+ parser.add_argument('-r', '--remote', metavar='REMOTE',
1186+ default='localhost',
1187+ help='hostname[:port] if the ADB device is connected '
1188+ 'to a remote machine. Ensure this workstation '
1189+ 'is configured for passwordless ssh access as '
1190+ 'users "root" or "adb"')
1191+ parser.add_argument('-m', '--mode', default='little',
1192+ help='Two modes can be chosen, little mode runs on a '
1193+ 'single core of Cortex-A53, while big mode runs '
1194+ 'on single core of Cortex-A57.')
1195+
1196+ return parser.parse_args(argv)
1197+
1198+def main(argv):
1199+ """
1200+ Entry point for test_bench script.
1201+
1202+ @param argv: arguments list
1203+ """
1204+ arguments = _parse_arguments_internal(argv)
1205+
1206+ serials = arguments.serials
1207+ if serials is None:
1208+ result = utils.run(['adb', 'devices'])
1209+ devices = adb_host.ADBHost.parse_device_serials(result.stdout)
1210+ if len(devices) != 1:
1211+ logging.error('Could not detect exactly one device; please select '
1212+ 'one with -s: %s', devices)
1213+ return 1
1214+ serials = devices[0]
1215+
1216+ autotest_path = os.path.dirname(os.path.dirname(
1217+ os.path.realpath(__file__)))
1218+ site_utils_path = os.path.join(autotest_path, 'site_utils')
1219+ realpath = os.path.realpath(__file__)
1220+ site_utils_path = os.path.realpath(site_utils_path)
1221+ host_attributes = {'serials': serials,
1222+ 'os_type': 'android'}
1223+ results_directory = test_runner_utils.create_results_directory(None)
1224+
1225+ bench = arguments.bench
1226+
1227+ benchlist = ['Panorama', 'Skia', 'Dex2oat', 'Hwui', "Synthmark", "Binder"]
1228+
1229+ logging.info('Start testing benchmark on the device...')
1230+
1231+ if bench not in benchlist:
1232+ logging.error('Please select one benchmark from the list below: \n%s',
1233+ '\n'.join(benchlist))
1234+ return 1
1235+
1236+ # Use taskset command to run benchmarks with different CPU core settings.
1237+ #
1238+ # TEST_MODE variable is set to either 7 or 56 for coremask in taskset.
1239+ #
1240+ # While Nexus 6P has 8 cores and 5X has 6 cores. CPU number 0-3 in both
1241+ # devices belongs to Cortex 53, which are slow. CPU number 4-5 in 5X and 4-7
1242+ # in 6P belongs to Cortex 57, which are fast.
1243+ #
1244+ # So we set 7(0x00000111) for little mode, that runs the benchmark on three
1245+ # slow cores; 56(0x00111000) for big mode, that runs the benchmark on two
1246+ # fast and one slow cores.
1247+ os.environ['TEST_MODE'] = '7' if arguments.mode == 'little' else '56'
1248+
1249+ tests = [bench]
1250+
1251+ if test_runner_utils.perform_run_from_autotest_root(
1252+ autotest_path, argv, tests, arguments.remote,
1253+ host_attributes=host_attributes,
1254+ results_directory=results_directory):
1255+ logging.error('Error while testing on device.')
1256+ return 1
1257+
1258+if __name__ == '__main__':
1259+ sys.exit(main(sys.argv[1:]))