1diff --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 range(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 range(2): 169+ f.write('Test %d:\n' % i) 170+ total_time = 0 171+ # Run benchmark for several times for accurancy 172+ for j in range(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 240index 000000000..d1837e042 241--- /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 363index 000000000..db2a29cde 364--- /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) 470diff --git a/server/site_tests/android_SetDevice/android_SetDevice.py b/server/site_tests/android_SetDevice/android_SetDevice.py 471new file mode 100644 472index 000000000..7a7134d58 473--- /dev/null 474+++ b/server/site_tests/android_SetDevice/android_SetDevice.py 475@@ -0,0 +1,77 @@ 476+# Set device modes such as cpu frequency 477+from __future__ import print_function 478+ 479+import logging 480+import os 481+import re 482+import time 483+ 484+from autotest_lib.server import test 485+ 486+def _get_cat_value(result): 487+ return result.stdout.split('\n')[0] 488+ 489+class android_SetDevice(test.test): 490+ version = 1 491+ 492+ def run_once(self, host=None): 493+ self.client = host 494+ 495+ # Disable GPU 496+ self.client.run('setprop debug.rs.default-GPU-driver 1') 497+ 498+ # Freeze system 499+ # Stop perfd, mpdecision and thermal-engine to ensure setting runs 500+ # without unexpected errors. 501+ self.client.run('stop thermal-engine') 502+ self.client.run('stop mpdecision') 503+ self.client.run('stop perfd') 504+ 505+ # Set airplane mode on the device 506+ self.client.run('settings put global airplane_mode_on 1') 507+ 508+ print('Setting frequency on the device...') 509+ frequency = os.getenv('FREQUENCY') 510+ 511+ # Get number of cores on device 512+ result = self.client.run('ls /sys/devices/system/cpu/ ' 513+ '| grep cpu[0-9].*') 514+ cores = result.stdout.splitlines() 515+ for core in cores: 516+ if core.startswith('cpu'): 517+ # First set all cores online 518+ online = os.path.join('/sys/devices/system/cpu', core, 'online') 519+ online_status = _get_cat_value(self.client.run('cat %s' % online)) 520+ if online_status == '0': 521+ self.client.run('echo %s > %s' % ('1', online)) 522+ 523+ freq_path = os.path.join('/sys/devices/system/cpu', core, 524+ 'cpufreq') 525+ 526+ # Check if the frequency user entered is legal or not. 527+ available_freq = self.client.run('cat %s/' 528+ 'scaling_available_frequencies' 529+ % (freq_path)) 530+ available_freq_list = _get_cat_value(available_freq).split() 531+ 532+ if frequency not in available_freq_list: 533+ raise ValueError('Wrong freqeuncy input, ' 534+ 'please select from: \n%s' 535+ % (' '.join(available_freq_list))) 536+ 537+ # Set frequency 538+ self.client.run('echo %s > %s/scaling_min_freq' 539+ % (frequency, freq_path)) 540+ self.client.run('echo %s > %s/scaling_max_freq' 541+ % (frequency, freq_path)) 542+ 543+ # Sleep for 2 seconds, let device update the frequency. 544+ time.sleep(2) 545+ 546+ # Get current frequency 547+ freq = self.client.run('cat %s/cpuinfo_cur_freq' % freq_path) 548+ f = _get_cat_value(freq) 549+ if f != frequency: 550+ raise RuntimeError('Expected frequency for %s to be %s, ' 551+ 'but is %s' % (core, frequency, f)) 552+ print('CPU frequency has been set to %s' % (frequency)) 553diff --git a/server/site_tests/android_SetDevice/control b/server/site_tests/android_SetDevice/control 554new file mode 100644 555index 000000000..85163706d 556--- /dev/null 557+++ b/server/site_tests/android_SetDevice/control 558@@ -0,0 +1,19 @@ 559+# Control 560+ 561+NAME = "SetDevice" 562+AUTHOR = "Zhizhou Yang" 563+ATTRIBUTES = "suite:android_toolchain_benchmark" 564+TIME = "MEDIUM" 565+TEST_CATEGORY = "Functional" 566+TEST_CLASS = "application" 567+TEST_TYPE = "server" 568+ 569+DOC = """ 570+Set the core frequency and which core online for devices. 571+""" 572+ 573+def run_set_device_test(machine): 574+ host = hosts.create_host(machine) 575+ job.run_test("android_SetDevice", host=host) 576+ 577+parallel_simple(run_set_device_test, machines) 578diff --git a/server/site_tests/android_Skia/android_Skia.py b/server/site_tests/android_Skia/android_Skia.py 579new file mode 100644 580index 000000000..fc8d09dab 581--- /dev/null 582+++ b/server/site_tests/android_Skia/android_Skia.py 583@@ -0,0 +1,65 @@ 584+# Tests for android Skia 585+from __future__ import print_function 586+ 587+import bench_config 588+import logging 589+import os 590+import re 591+ 592+from autotest_lib.server import test 593+ 594+class android_Skia(test.test): 595+ version = 1 596+ 597+ def run_once(self, host=None): 598+ self.client = host 599+ 600+ out_dir = os.path.join(bench_config.android_home, 601+ 'out/target/product/' + bench_config.product) 602+ 603+ # Set binary directories 604+ lib_dir = os.path.join(out_dir, 'system/lib/libskia.so') 605+ lib_dir_DUT = '/system/lib/libskia.so' 606+ lib64_dir = os.path.join(out_dir, 'system/lib64/libskia.so') 607+ lib64_dir_DUT = '/system/lib64/libskia.so' 608+ bench_dir = os.path.join(out_dir, 609+ 'data/nativetest64/', 610+ 'skia_nanobench/skia_nanobench') 611+ bench_dir_DUT = '/data/local/tmp/skia_nanobench' 612+ 613+ # Push binary to the device 614+ print('Pushing Skia benchmark onto device!') 615+ host.send_file(bench_dir, bench_dir_DUT, delete_dest=True) 616+ host.send_file(lib_dir, lib_dir_DUT, delete_dest=True) 617+ host.send_file(lib64_dir, lib64_dir_DUT, delete_dest=True) 618+ 619+ # Make sure the binary is executable 620+ self.client.run('chmod u+x ' + bench_dir_DUT) 621+ 622+ # Set resource directory 623+ resource_dir = os.path.join(bench_config.real_skia_dir, 'resources') 624+ resource_dir_DUT = '/data/local/tmp/skia_resources/' 625+ 626+ # Push binary to the device 627+ print('Pushing Skia resources onto device!') 628+ host.send_file(resource_dir, resource_dir_DUT, delete_dest=True) 629+ 630+ # Run tests 631+ print('Running tests on the device...') 632+ try: 633+ self.client.run('taskset %s ./data/local/tmp/skia_nanobench' 634+ ' --outResultsFile /data/local/tmp/bench_result' 635+ ' --samples 25' 636+ ' --config nonrendering' 637+ % os.getenv('TEST_MODE')) 638+ except: 639+ # Ignore Abort caused failure 640+ None 641+ 642+ # Pull result from the device 643+ out_dir = bench_config.bench_suite_dir 644+ result_dir_DUT = '/data/local/tmp/bench_result' 645+ 646+ host.get_file(result_dir_DUT, out_dir, delete_dest=True) 647+ 648+ print('Result has been pulled back to file bench_result!') 649diff --git a/server/site_tests/android_Skia/bench_config.py b/server/site_tests/android_Skia/bench_config.py 650new file mode 100644 651index 000000000..5d38d452f 652--- /dev/null 653+++ b/server/site_tests/android_Skia/bench_config.py 654@@ -0,0 +1,19 @@ 655+#!/bin/bash/python 656+import os 657+ 658+home = os.environ["HOME"] 659+ 660+android_home = os.getenv("ANDROID_HOME", 661+ default=os.path.join(home, 662+ 'android_source/master-googleplex/')) 663+bench_suite_dir = os.getenv('BENCH_SUITE_DIR', 664+ default=os.path.join(android_home, 665+ 'benchtoolchain')) 666+ 667+skia_dir = 'external/skia' 668+ 669+real_skia_dir = os.path.join(android_home, skia_dir) 670+ 671+out_dir = os.path.join(android_home, 'out') 672+ 673+product = os.getenv("PRODUCT", default="generic") 674diff --git a/server/site_tests/android_Skia/control b/server/site_tests/android_Skia/control 675new file mode 100644 676index 000000000..e38195a8c 677--- /dev/null 678+++ b/server/site_tests/android_Skia/control 679@@ -0,0 +1,19 @@ 680+#Control 681+ 682+NAME = "Skia" 683+AUTHOR = "Zhizhou Yang" 684+ATTRIBUTES = "suite:android_toolchain_benchmark" 685+TIME = "MEDIUM" 686+TEST_CATEGORY = "Functional" 687+TEST_CLASS = "library" 688+TEST_TYPE = "server" 689+ 690+DOC = """ 691+ 692+""" 693+ 694+def run_skia_test(machine): 695+ host = hosts.create_host(machine) 696+ job.run_test("android_Skia", host=host) 697+ 698+parallel_simple(run_skia_test, machines) 699diff --git a/server/site_tests/android_Synthmark/android_Synthmark.py b/server/site_tests/android_Synthmark/android_Synthmark.py 700new file mode 100644 701index 000000000..b317bd0f3 702--- /dev/null 703+++ b/server/site_tests/android_Synthmark/android_Synthmark.py 704@@ -0,0 +1,48 @@ 705+# Tests for android Synthmark 706+from __future__ import print_function 707+ 708+import bench_config 709+import logging 710+import os 711+import re 712+ 713+from autotest_lib.server import test 714+ 715+class android_Synthmark(test.test): 716+ version = 1 717+ 718+ def run_once(self, host=None): 719+ self.client = host 720+ 721+ out_dir = os.path.join(bench_config.android_home, 722+ 'out/target/product/' + bench_config.product) 723+ 724+ # Set binary directories 725+ bench_dir = os.path.join(out_dir, 726+ 'symbols/system/bin/synthmark') 727+ bench_dir_DUT = '/data/local/tmp/synthmark' 728+ 729+ # Push binary to the device 730+ print('Pushing binaries of Synthmark benchmark onto device!') 731+ host.send_file(bench_dir, bench_dir_DUT, delete_dest=True) 732+ 733+ # Make sure the binary is executable 734+ self.client.run('chmod u+x ' + bench_dir_DUT) 735+ 736+ print('Running tests on the device...') 737+ # First run creates bench_result 738+ self.client.run('taskset %s /data/local/tmp/synthmark' 739+ ' > /data/local/tmp/bench_result' 740+ % os.getenv('TEST_MODE')) 741+ # Next 4 runs add to bench_result 742+ for i in range(4): 743+ self.client.run('taskset %s /data/local/tmp/synthmark' 744+ ' >> /data/local/tmp/bench_result' 745+ % os.getenv('TEST_MODE')) 746+ 747+ # Pull result from the device 748+ out_dir = bench_config.bench_suite_dir 749+ result_dir_DUT = '/data/local/tmp/bench_result' 750+ 751+ host.get_file(result_dir_DUT, out_dir, delete_dest=True) 752+ print('Result has been pulled back to file bench_result!') 753diff --git a/server/site_tests/android_Synthmark/bench_config.py b/server/site_tests/android_Synthmark/bench_config.py 754new file mode 100644 755index 000000000..7d7aacacd 756--- /dev/null 757+++ b/server/site_tests/android_Synthmark/bench_config.py 758@@ -0,0 +1,19 @@ 759+#!/bin/bash/python 760+import os 761+ 762+home = os.environ["HOME"] 763+ 764+android_home = os.getenv("ANDROID_HOME", 765+ default=os.path.join(home, 766+ 'android_source/master-googleplex/')) 767+bench_suite_dir = os.getenv('BENCH_SUITE_DIR', 768+ default=os.path.join(android_home, 769+ 'benchtoolchain')) 770+ 771+synthmark_dir = 'synthmark' 772+ 773+real_synthmark_dir = os.path.join(android_home, synthmark_dir) 774+ 775+out_dir = os.path.join(android_home, 'out') 776+ 777+product = os.getenv("PRODUCT", default="generic") 778diff --git a/server/site_tests/android_Synthmark/control b/server/site_tests/android_Synthmark/control 779new file mode 100644 780index 000000000..144766351 781--- /dev/null 782+++ b/server/site_tests/android_Synthmark/control 783@@ -0,0 +1,19 @@ 784+#Control 785+ 786+NAME = "Synthmark" 787+AUTHOR = "Zhizhou Yang" 788+ATTRIBUTES = "suite:android_toolchain_benchmark" 789+TIME = "MEDIUM" 790+TEST_CATEGORY = "Functional" 791+TEST_CLASS = "application" 792+TEST_TYPE = "server" 793+ 794+DOC = """ 795+ 796+""" 797+ 798+def run_synthmark_test(machine): 799+ host = hosts.create_host(machine) 800+ job.run_test("android_Synthmark", host=host) 801+ 802+parallel_simple(run_synthmark_test, machines) 803diff --git a/site_utils/set_device.py b/site_utils/set_device.py 804new file mode 100755 805index 000000000..abb8a8dcc 806--- /dev/null 807+++ b/site_utils/set_device.py 808@@ -0,0 +1,110 @@ 809+#!/usr/bin/python 810+from __future__ import print_function 811+ 812+import argparse 813+import common 814+import logging 815+import os 816+import sys 817+ 818+# Turn the logging level to INFO before importing other autotest code, to avoid 819+# having failed import logging messages confuse the test_droid user. 820+logging.basicConfig(level=logging.INFO) 821+ 822+# Unfortunately, autotest depends on external packages for assorted 823+# functionality regardless of whether or not it is needed in a particular 824+# context. Since we can't depend on people to import these utilities in any 825+# principled way, we dynamically download code before any autotest imports. 826+try: 827+ import chromite.lib.terminal # pylint: disable=unused-import 828+ import django.http # pylint: disable=unused-import 829+except ImportError: 830+ # Ensure the chromite site-package is installed. 831+ import subprocess 832+ build_externals_path = os.path.join( 833+ os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 834+ 'utils', 'build_externals.py') 835+ subprocess.check_call([build_externals_path, '--names_to_check', 836+ 'chromiterepo', 'django']) 837+ # Restart the script so python now finds the autotest site-packages. 838+ sys.exit(os.execv(__file__, sys.argv)) 839+ 840+from autotest_lib.client.common_lib import utils 841+from autotest_lib.server.hosts import adb_host 842+from autotest_lib.site_utils import test_runner_utils 843+from autotest_lib.site_utils import tester_feedback 844+ 845+def _parse_arguments_internal(argv): 846+ """ 847+ Parse command line arguments 848+ 849+ @param argv: argument list to parse 850+ 851+ @returns: tuple of parsed arguments and argv suitable for remote runs 852+ 853+ @raises SystemExit if arguments are malformed, or required arguments 854+ are not present. 855+ """ 856+ 857+ parser = argparse.ArgumentParser(description='Set device cpu cores and ' 858+ 'frequency.') 859+ 860+ parser.add_argument('-s', '--serials', metavar='SERIALS', 861+ help='Comma separate list of device serials under ' 862+ 'test.') 863+ parser.add_argument('-r', '--remote', metavar='REMOTE', 864+ default='localhost', 865+ help='hostname[:port] if the ADB device is connected ' 866+ 'to a remote machine. Ensure this workstation ' 867+ 'is configured for passwordless ssh access as ' 868+ 'users "root" or "adb"') 869+ parser.add_argument('-q', '--frequency', type=int, default=960000, 870+ help='Specify the CPU frequency of the device, lower ' 871+ 'frequency will slow down the performance but ' 872+ 'reduce noise.') 873+ 874+ return parser.parse_args(argv) 875+ 876+def main(argv): 877+ """ 878+ Entry point for set_device script. 879+ 880+ @param argv: arguments list 881+ """ 882+ arguments = _parse_arguments_internal(argv) 883+ 884+ serials = arguments.serials 885+ if serials is None: 886+ result = utils.run(['adb', 'devices']) 887+ devices = adb_host.ADBHost.parse_device_serials(result.stdout) 888+ if len(devices) != 1: 889+ logging.error('Could not detect exactly one device; please select ' 890+ 'one with -s: %s', devices) 891+ return 1 892+ serials = devices[0] 893+ 894+ autotest_path = os.path.dirname(os.path.dirname( 895+ os.path.realpath(__file__))) 896+ site_utils_path = os.path.join(autotest_path, 'site_utils') 897+ realpath = os.path.realpath(__file__) 898+ site_utils_path = os.path.realpath(site_utils_path) 899+ host_attributes = {'serials': serials, 900+ 'os_type': 'android'} 901+ results_directory = test_runner_utils.create_results_directory(None) 902+ 903+ logging.info('Start setting CPU frequency on the device...') 904+ 905+ os.environ['FREQUENCY'] = str(arguments.frequency) 906+ 907+ set_device = ['SetDevice'] 908+ if test_runner_utils.perform_run_from_autotest_root( 909+ autotest_path, argv, set_device, arguments.remote, 910+ host_attributes=host_attributes, 911+ results_directory=results_directory): 912+ logging.error('Error while setting device!') 913+ return 1 914+ 915+ return 0 916+ 917+if __name__ == '__main__': 918+ sys.exit(main(sys.argv[1:])) 919diff --git a/site_utils/test_bench.py b/site_utils/test_bench.py 920new file mode 100755 921index 000000000..4d0773ad9 922--- /dev/null 923+++ b/site_utils/test_bench.py 924@@ -0,0 +1,133 @@ 925+#!/usr/bin/python 926+from __future__ import print_function 927+ 928+import argparse 929+import common 930+import logging 931+import os 932+import sys 933+ 934+# Turn the logging level to INFO before importing other autotest 935+# code, to avoid having failed import logging messages confuse the 936+# test_droid user. 937+logging.basicConfig(level=logging.INFO) 938+ 939+# Unfortunately, autotest depends on external packages for assorted 940+# functionality regardless of whether or not it is needed in a particular 941+# context. 942+# Since we can't depend on people to import these utilities in any principled 943+# way, we dynamically download code before any autotest imports. 944+try: 945+ import chromite.lib.terminal # pylint: disable=unused-import 946+ import django.http # pylint: disable=unused-import 947+except ImportError: 948+ # Ensure the chromite site-package is installed. 949+ import subprocess 950+ build_externals_path = os.path.join( 951+ os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 952+ 'utils', 'build_externals.py') 953+ subprocess.check_call([build_externals_path, '--names_to_check', 954+ 'chromiterepo', 'django']) 955+ # Restart the script so python now finds the autotest site-packages. 956+ sys.exit(os.execv(__file__, sys.argv)) 957+ 958+from autotest_lib.client.common_lib import utils 959+from autotest_lib.server.hosts import adb_host 960+from autotest_lib.site_utils import test_runner_utils 961+from autotest_lib.site_utils import tester_feedback 962+ 963+def _parse_arguments_internal(argv): 964+ """ 965+ Parse command line arguments 966+ 967+ @param argv: argument list to parse 968+ 969+ @returns: tuple of parsed arguments and argv suitable for remote runs 970+ 971+ @raises SystemExit if arguments are malformed, or required arguments 972+ are not present. 973+ """ 974+ 975+ parser = argparse.ArgumentParser(description='Run remote tests.') 976+ 977+ parser.add_argument('-b', '--bench', metavar='BENCH', required=True, 978+ help='Select the benchmark want to be run for ' 979+ 'test.') 980+ parser.add_argument('-s', '--serials', metavar='SERIALS', 981+ help='Comma separate list of device serials under ' 982+ 'test.') 983+ parser.add_argument('-r', '--remote', metavar='REMOTE', 984+ default='localhost', 985+ help='hostname[:port] if the ADB device is connected ' 986+ 'to a remote machine. Ensure this workstation ' 987+ 'is configured for passwordless ssh access as ' 988+ 'users "root" or "adb"') 989+ parser.add_argument('-m', '--mode', default='little', 990+ help='Two modes can be chosen, little mode runs on a ' 991+ 'single core of Cortex-A53, while big mode runs ' 992+ 'on single core of Cortex-A57.') 993+ 994+ return parser.parse_args(argv) 995+ 996+def main(argv): 997+ """ 998+ Entry point for test_bench script. 999+ 1000+ @param argv: arguments list 1001+ """ 1002+ arguments = _parse_arguments_internal(argv) 1003+ 1004+ serials = arguments.serials 1005+ if serials is None: 1006+ result = utils.run(['adb', 'devices']) 1007+ devices = adb_host.ADBHost.parse_device_serials(result.stdout) 1008+ if len(devices) != 1: 1009+ logging.error('Could not detect exactly one device; please select ' 1010+ 'one with -s: %s', devices) 1011+ return 1 1012+ serials = devices[0] 1013+ 1014+ autotest_path = os.path.dirname(os.path.dirname( 1015+ os.path.realpath(__file__))) 1016+ site_utils_path = os.path.join(autotest_path, 'site_utils') 1017+ realpath = os.path.realpath(__file__) 1018+ site_utils_path = os.path.realpath(site_utils_path) 1019+ host_attributes = {'serials': serials, 1020+ 'os_type': 'android'} 1021+ results_directory = test_runner_utils.create_results_directory(None) 1022+ 1023+ bench = arguments.bench 1024+ 1025+ benchlist = ['Panorama', 'Skia', 'Dex2oat', 'Hwui', "Synthmark", "Binder"] 1026+ 1027+ logging.info('Start testing benchmark on the device...') 1028+ 1029+ if bench not in benchlist: 1030+ logging.error('Please select one benchmark from the list below: \n%s', 1031+ '\n'.join(benchlist)) 1032+ return 1 1033+ 1034+ # Use taskset command to run benchmarks with different CPU core settings. 1035+ # 1036+ # TEST_MODE variable is set to either 7 or 56 for coremask in taskset. 1037+ # 1038+ # While Nexus 6P has 8 cores and 5X has 6 cores. CPU number 0-3 in both 1039+ # devices belongs to Cortex 53, which are slow. CPU number 4-5 in 5X and 4-7 1040+ # in 6P belongs to Cortex 57, which are fast. 1041+ # 1042+ # So we set 7(0x00000111) for little mode, that runs the benchmark on three 1043+ # slow cores; 56(0x00111000) for big mode, that runs the benchmark on two 1044+ # fast and one slow cores. 1045+ os.environ['TEST_MODE'] = '7' if arguments.mode == 'little' else '56' 1046+ 1047+ tests = [bench] 1048+ 1049+ if test_runner_utils.perform_run_from_autotest_root( 1050+ autotest_path, argv, tests, arguments.remote, 1051+ host_attributes=host_attributes, 1052+ results_directory=results_directory): 1053+ logging.error('Error while testing on device.') 1054+ return 1 1055+ 1056+if __name__ == '__main__': 1057+ sys.exit(main(sys.argv[1:])) 1058