1# Copyright 2018 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5AUTHOR = "puthik"
6NAME = "power_Dashboard.fast"
7TIME = "MEDIUM"
8TEST_CATEGORY = "Stress"
9TEST_CLASS = "suite"
10TEST_TYPE = "server"
11
12DOC = """
13Sequence to make sure that power_Dashboard tests work fine.
14"""
15
16import datetime
17from autotest_lib.client.common_lib import utils
18
19# Need separate list for client and server test due to how these test work.
20CLIENT_TESTS = [
21    ('power_Standby', {
22        'tag' : '36sec', 'sample_hours' : 0.01, 'test_hours' : 0.01,
23        'bypass_check' : True}),
24    ('power_LoadTest', {
25        'tag' : 'fast', 'loop_time' : 180, 'loop_count' : 1,
26        'test_low_batt_p' : 6, 'check_network': False, 'ac_ok' : True,
27        'gaia_login' : False}),
28    ('power_Idle', {
29        'tag' : 'fast', 'warmup_secs' : 2, 'idle_secs' : 10}),
30    ('power_VideoPlayback', {
31        'tag' : 'fast', 'secs_per_video' : 10, 'fast' : True }),
32    ('power_VideoPlayback', {
33        'tag' : 'sw_decoder_fast', 'use_hw_decode' : False,
34        'secs_per_video' : 10, 'fast' : True }),
35    ('power_Display', {
36        'tag' : 'fast', 'secs_per_page' : 2}),
37    ('power_WebGL', {
38        'tag' : 'fast', 'duration' : 10}),
39]
40
41# Tagged test name and sweetberry interval
42SWEETBERRY_TESTS = [
43    ('power_Standby.36sec', 1),
44    ('power_LoadTest.fast', 1),
45    ('power_Idle.fast', 1),
46    ('power_VideoPlayback.fast', 1),
47    ('power_VideoPlayback.sw_decoder_fast', 1),
48    ('power_Display.fast', 1),
49    ('power_WebGL.fast', 1),
50]
51
52POWERLOG_TESTNAME = 'power_PowerlogWrapper'
53
54# Workaround to make it compatible with moblab autotest UI.
55global args_dict
56try:
57    args_dict
58except NameError:
59    args_dict = utils.args_to_dict(args)
60
61# Use time as pdash_note if not supplied to track all tests in same suite.
62pdash_note = args_dict.get('pdash_note',
63                           NAME + '_' + datetime.datetime.utcnow().isoformat())
64sweetberry_serial = args_dict.get('sweetberry_serial', None)
65
66def run_client_test(machine):
67    client = hosts.create_host(machine)
68    client_at = autotest.Autotest(client)
69    for test, argv in CLIENT_TESTS:
70        client.reboot()
71        argv['pdash_note'] = pdash_note
72        client_at.run_test(test, **argv)
73
74def run_sweetberry_wrapper_test(machine):
75    client = hosts.create_host(machine)
76    for test, sweetberry_interval in SWEETBERRY_TESTS:
77        client.reboot()
78        argv = {
79            'pdash_note': pdash_note,
80            'test': test,
81            'sweetberry_interval': sweetberry_interval,
82        }
83        job.run_test(POWERLOG_TESTNAME, host=client, config=argv, tag=test)
84
85
86if sweetberry_serial:
87    parallel_simple(run_sweetberry_wrapper_test, machines)
88else:
89    job.parallel_on_machines(run_client_test, machines)
90