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