| Puthikorn Voravootivat | 5b39e1d | 2017-12-08 15:21:53 -0800 | [diff] [blame^] | 1 | # Copyright (c) 2017 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 | |
| 5 | from autotest_lib.client.cros.power import power_dashboard |
| 6 | |
| 7 | class ServerTestDashboard(power_dashboard.BaseDashboard): |
| 8 | """Dashboard class for autotests that run on server side. |
| 9 | """ |
| 10 | |
| 11 | def __init__(self, logger, testname, host, resultsdir=None, uploadurl=None): |
| 12 | """Create ServerTestDashboard objects. |
| 13 | |
| 14 | Args: |
| 15 | logger: object that store the log. This will get convert to |
| 16 | dictionary by self._convert() |
| 17 | testname: name of current test |
| 18 | resultsdir: directory to save the power json |
| 19 | uploadurl: url to upload power data |
| 20 | host: autotest_lib.server.hosts.cros_host.CrosHost object of DUT |
| 21 | """ |
| 22 | |
| 23 | self._host = host |
| 24 | super(ServerTestDashboard, self).__init__(logger, testname, resultsdir, |
| 25 | uploadurl) |
| 26 | |
| 27 | def _create_dut_info_dict(self, power_rails): |
| 28 | """Create a dictionary that contain information of the DUT. |
| 29 | |
| 30 | Args: |
| 31 | power_rails: list of measured power rails |
| 32 | |
| 33 | Returns: |
| 34 | DUT info dictionary |
| 35 | """ |
| 36 | dut_info_dict = { |
| 37 | 'board': self._host.get_board().replace('board:', ''), |
| 38 | 'version': { |
| 39 | 'hw': self._host.get_hardware_revision(), |
| 40 | 'milestone': self._host.get_chromeos_release_milestone(), |
| 41 | 'os': self._host.get_release_version(), |
| 42 | 'channel': self._host.get_channel(), |
| 43 | 'firmware': self._host.get_firmware_version(), |
| 44 | 'ec': self._host.get_ec_version(), |
| 45 | 'kernel': self._host.get_kernel_version(), |
| 46 | }, |
| 47 | 'sku' : { |
| 48 | 'cpu': self._host.get_cpu_name(), |
| 49 | 'memory_size': self._host.get_mem_total_gb(), |
| 50 | 'storage_size': self._host.get_disk_size_gb(), |
| 51 | 'display_resolution': self._host.get_screen_resolution(), |
| 52 | }, |
| 53 | 'ina': { |
| 54 | 'version': 0, |
| 55 | 'ina': power_rails, |
| 56 | }, |
| 57 | 'note': '', |
| 58 | } |
| 59 | |
| 60 | if self._host.has_battery(): |
| 61 | # Round the battery size to nearest tenth because it is fluctuated |
| 62 | # for platform without battery nominal voltage data. |
| 63 | dut_info_dict['sku']['battery_size'] = round( |
| 64 | self._host.get_battery_size(), 1) |
| 65 | dut_info_dict['sku']['battery_shutdown_percent'] = \ |
| 66 | self._host.get_low_battery_shutdown_percent() |
| 67 | return dut_info_dict |
| 68 | |