From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E5ECAA0561; Mon, 20 Apr 2020 07:24:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DBD151D173; Mon, 20 Apr 2020 07:24:26 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 2AA8C1C293 for ; Mon, 20 Apr 2020 07:24:25 +0200 (CEST) IronPort-SDR: 7nGGB081fdINF/9+t4ICv1lO7BV6la6GwmJ2AwH6rnVq4Y++jYmJevnDRACFVNCTMqZRF8cVu5 /jiABu7tU7ow== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2020 22:24:24 -0700 IronPort-SDR: kQp8Lau2J+Oc1/Bn8UNrTWdsPcXehQtEx+XFBV4M3oizBTWQVE6oruOwkOGc2+on8gP00wTjbs lBjaAEFseY5A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,405,1580803200"; d="scan'208";a="456264723" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga006.fm.intel.com with ESMTP; 19 Apr 2020 22:24:23 -0700 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 19 Apr 2020 22:24:23 -0700 Received: from shsmsx105.ccr.corp.intel.com (10.239.4.158) by fmsmsx120.amr.corp.intel.com (10.18.124.208) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 19 Apr 2020 22:24:23 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.129]) by SHSMSX105.ccr.corp.intel.com ([169.254.11.213]) with mapi id 14.03.0439.000; Mon, 20 Apr 2020 13:24:20 +0800 From: "Tu, Lijuan" To: "Mo, YufengX" , "dts@dpdk.org" , "Yao, Lei A" CC: "Mo, YufengX" Thread-Topic: [dts] [PATCH V1 1/1] tests/power_pstate: python3 support and script optimize Thread-Index: AQHWFrGK2cDghkiFR0usCjzgOH7pX6iBenjw Date: Mon, 20 Apr 2020 05:24:20 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BC0D330@SHSMSX101.ccr.corp.intel.com> References: <20200420012029.3588-1-yufengx.mo@intel.com> <20200420012029.3588-2-yufengx.mo@intel.com> In-Reply-To: <20200420012029.3588-2-yufengx.mo@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V1 1/1] tests/power_pstate: python3 support and script optimize X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Applied, thanks > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of yufengmx > Sent: Monday, April 20, 2020 9:20 AM > To: dts@dpdk.org; Yao, Lei A > Cc: Mo, YufengX > Subject: [dts] [PATCH V1 1/1] tests/power_pstate: python3 support and > script optimize >=20 >=20 > #. python3 support. > #. use ^C to take the place of killall. > #. unify session method name. > #. unify exception catch process. >=20 > Signed-off-by: yufengmx > --- > tests/TestSuite_power_pstate.py | 72 +++++++++++++++++++-------------- > 1 file changed, 42 insertions(+), 30 deletions(-) >=20 > diff --git a/tests/TestSuite_power_pstate.py > b/tests/TestSuite_power_pstate.py index 67ddae5..7ee6c8f 100644 > --- a/tests/TestSuite_power_pstate.py > +++ b/tests/TestSuite_power_pstate.py > @@ -1,6 +1,6 @@ > # BSD LICENSE > # > -# Copyright(c) 2010-2019 Intel Corporation. All rights reserved. > +# Copyright(c) 2010-2020 Intel Corporation. All rights reserved. > # All rights reserved. > # > # Redistribution and use in source and binary forms, with or without @@ = - > 31,19 +31,21 @@ >=20 > import os > import time > -import random > import json > import shutil > +import traceback > from collections import Counter > from pprint import pformat >=20 > # import dts libs > from test_case import TestCase > +from exception import VerifyFailure > from utils import create_mask >=20 >=20 > -class TestPowerPbf(TestCase): > +class TestPowerPstate(TestCase): >=20 > + @property > def timestamp(self): > curTime =3D time.localtime() > timestamp =3D "%04d%02d%02d_%02d-%02d-%02d" % ( @@ -60,7 +62,7 > @@ class TestPowerPbf(TestCase): >=20 > @property > def output_path(self): > - suiteName =3D self.__class__.__name__[4:].lower() > + suiteName =3D self.suite_name > if self.logger.log_path.startswith(os.sep): > output_path =3D os.path.join(self.logger.log_path, suiteName= ) > else: > @@ -94,10 +96,8 @@ class TestPowerPbf(TestCase): > for item in cmds: > expected_items =3D item[1] > if expected_items and isinstance(expected_items, (list, tupl= e)): > - check_output =3D True > expected_str =3D expected_items[0] or '# ' > else: > - check_output =3D False > expected_str =3D expected_items or '# ' >=20 > try: > @@ -120,10 +120,10 @@ class TestPowerPbf(TestCase): >=20 > return outputs >=20 > - def d_console(self, cmds): > + def d_con(self, cmds): > return self.execute_cmds(cmds, con_name=3D'dut') >=20 > - def d_a_console(self, cmds): > + def d_a_con(self, cmds): > return self.execute_cmds(cmds, con_name=3D'dut_alt') >=20 > def get_cores_mask(self, config=3D'all'): > @@ -133,9 +133,13 @@ class TestPowerPbf(TestCase): > mask =3D create_mask(self.dut.get_core_list(config, socket=3Dpor= t_socket)) > return mask >=20 > + @property > + def memory_channels(self): > + return self.dut.get_memory_channels() > + > def create_powermonitor_folder(self): > cmd =3D 'mkdir -p {0}; chmod 777 {0}'.format('/tmp/powermonitor'= ) > - self.d_console(cmd) > + self.d_con(cmd) >=20 > def prepare_binary(self, name): > example_dir =3D "examples/" + name @@ -144,7 +148,7 @@ class > TestPowerPbf(TestCase): > self.verify("No such" not in out, "Compilation error") > binary_dir =3D os.path.join(self.target_dir, example_dir, 'build= ') > cmd =3D ["ls -F {0} | grep '*'".format(binary_dir), '# ', 5] > - exec_file =3D self.d_a_console(cmd) > + exec_file =3D self.d_a_con(cmd) > binary_file =3D os.path.join(binary_dir, exec_file[:-1]) > return binary_file >=20 > @@ -152,19 +156,24 @@ class TestPowerPbf(TestCase): > self.create_powermonitor_folder() > # set up vm power binary process setting > self.vm_power_mgr =3D self.prepare_binary('vm_power_manager') > + self.is_mgr_on =3D None >=20 > def start_vm_power_mgr(self): > config =3D "1S/4C/1T" > - eal_option =3D '-c {0} -n {1} --file-prefix=3Dvmpower --no-pci'.= format( > + option =3D '-v -c {0} -n {1} --file-prefix=3Dvmpower > + --no-pci'.format( > self.get_cores_mask(config), > self.memory_channels) > prompt =3D 'vmpower>' > - cmd =3D [' '.join([self.vm_power_mgr, eal_option]), prompt, 30] > - output =3D self.d_console(cmd) > + cmd =3D [' '.join([self.vm_power_mgr, option]), prompt, 30] > + output =3D self.d_con(cmd) > + self.is_mgr_on =3D True > return output >=20 > def close_vm_power_mgr(self): > - output =3D self.d_console('quit') > + if not self.is_mgr_on: > + return > + output =3D self.d_con('quit') > + self.is_mgr_on =3D False > return output >=20 > def __preset_single_core_json_cmd(self, core_index, unit, name): > @@ -179,11 +188,11 @@ class TestPowerPbf(TestCase): > json_file =3D os.sep.join([self.output_path, json_name]) > with open(json_file, 'w') as fp: > json.dump(command, fp, indent=3D4, separators=3D(',', ': '), > - encoding=3D"utf-8", sort_keys=3DTrue) > + sort_keys=3DTrue) > fp.write(os.linesep) > self.dut.session.copy_file_to(json_file, self.target_dir) > # save a backup json file to retrace test command > - backup_file =3D json_file + self.timestamp() > + backup_file =3D json_file + self.timestamp > shutil.move(json_file, backup_file) > # send action JSON file to vm_power_mgr's fifo channel > cmd =3D 'cat {0}/{2} > /tmp/powermonitor/fifo{1}'.format( > @@ -204,18 +213,17 @@ class TestPowerPbf(TestCase): > for core_index in _cores: > cmds.append( > self.__preset_single_core_json_cmd(core_index, unit, nam= e)) > - self.d_a_console(';'.join(cmds)) > + self.d_a_con(';'.join(cmds)) >=20 > def get_sys_power_driver(self): > drv_file =3D "/sys/devices/system/cpu/cpu0/cpufreq/scaling_drive= r" > - output =3D self.d_a_console('cat ' + drv_file) > + output =3D self.d_a_con('cat ' + drv_file) > if not output: > msg =3D 'unknown power driver' > self.verify(False, msg) > drv_name =3D output.splitlines()[0].strip() > return drv_name >=20 > - @property > def is_hyper_threading(self): > cpu_index =3D list(self.cpu_info.keys())[-1] > core_num =3D self.cpu_info[cpu_index].get('core') > @@ -224,18 +232,18 @@ class TestPowerPbf(TestCase): > def get_core_scaling_max_freq(self, core_index): > cpu_attr =3D '/sys/devices/system/cpu/cpu{0}/cpufreq/scaling_max= _freq' > cmd =3D 'cat ' + cpu_attr.format(core_index) > - output =3D self.d_a_console(cmd) > + output =3D self.d_a_con(cmd) > return int(output) >=20 > def get_core_scaling_min_freq(self, core_index): > cpu_attr =3D '/sys/devices/system/cpu/cpu{0}/cpufreq/scaling_min= _freq' > cmd =3D 'cat ' + cpu_attr.format(core_index) > - output =3D self.d_a_console(cmd) > + output =3D self.d_a_con(cmd) > return int(output) >=20 > def get_no_turbo_max(self): > cmd =3D 'rdmsr -p 1 0x0CE -f 15:8 -d' > - output =3D self.d_a_console(cmd) > + output =3D self.d_a_con(cmd) > freq =3D output.strip() + '00000' > return int(freq) >=20 > @@ -256,7 +264,7 @@ class TestPowerPbf(TestCase): > cmds =3D [] > for cpu_id in sorted(cpu_info.keys()): > cmds.append('cat {0}'.format(freq(cpu_id, key_value))) > - output =3D self.d_a_console(';'.join(cmds)) > + output =3D self.d_a_con(';'.join(cmds)) > freqs =3D [int(item) for item in output.splitlines()] > for index, cpu_id in enumerate(sorted(cpu_info.keys())): > cpu_info[cpu_id][key_value] =3D freqs[index] @@ -289,11 = +297,11 > @@ class TestPowerPbf(TestCase): >=20 > def verify_hyper_threading(self): > msg =3D "power pstate should work under hyper threading close st= atus" > - self.verify(not self.is_hyper_threading, msg) > + self.verify(not self.is_hyper_threading(), msg) >=20 > def verify_pstate_basic_action(self): > ''' > - random select cpu core to run testing > + select cpu core to run testing > Send different command to power sample: > Command Steps: > ENABLE_TURBO > @@ -304,6 +312,7 @@ class TestPowerPbf(TestCase): > SCALE_DOWN > Check the CPU frequency is changed accordingly in this list > ''' > + except_content =3D None > try: > self.start_vm_power_mgr() > # select one core to run testing @@ -323,10 +332,14 @@ class > TestPowerPbf(TestCase): > # test cpu core frequency change with unit command > for test_item in test_items: > self.check_core_freq_for_unit(*test_item) > - self.close_vm_power_mgr() > except Exception as e: > + self.logger.error(traceback.format_exc()) > + except_content =3D e > + finally: > self.close_vm_power_mgr() > - raise Exception(e) > + > + if except_content: > + raise VerifyFailure(except_content) > # > # Test cases. > # > @@ -338,12 +351,11 @@ class TestPowerPbf(TestCase): > # get ports information > self.dut_ports =3D self.dut.get_ports() > self.verify(len(self.dut_ports) >=3D 1, "Insufficient ports") > - self.d_a_console('modprobe msr') > + self.d_a_con('modprobe msr') > # get dut node cores information > self.dut.init_core_list_uncached_linux() > self.cpu_info =3D self.get_all_cpu_attrs() > - self.logger.info(pformat(self.cpu_info)) > - self.memory_channels =3D self.dut.get_memory_channels() > + self.logger.debug(pformat(self.cpu_info)) > self.verify_power_driver() > self.verify_hyper_threading() > self.init_test_binary_file() > -- > 2.21.0