diff options
author | Zhizhou Yang <zhizhouy@google.com> | 2020-01-15 16:25:04 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-01-30 00:33:44 +0000 |
commit | 5534af8f4f31df22ca307e3e3faa16487fa3d2d2 (patch) | |
tree | 771f9865e956551c7c70c3de99fad0b72aef52ce /crosperf/experiment_file_unittest.py | |
parent | 658d77957b84def71c77d25229df9845fdb7ee9c (diff) | |
download | toolchain-utils-5534af8f4f31df22ca307e3e3faa16487fa3d2d2.tar.gz |
crosperf: migration to python 3
This patch migrates crosperf and its utils to python 3.
TEST=Passed presubmit check; tested with simple experiment locally.
BUG=chromium:1011676
Change-Id: Ib2a9f9c7cf6a1bb1d0b42a1dd3d9e3cbb4d70a36
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2003796
Tested-by: Zhizhou Yang <zhizhouy@google.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Caroline Tice <cmtice@chromium.org>
Commit-Queue: Zhizhou Yang <zhizhouy@google.com>
Auto-Submit: Zhizhou Yang <zhizhouy@google.com>
Diffstat (limited to 'crosperf/experiment_file_unittest.py')
-rwxr-xr-x | crosperf/experiment_file_unittest.py | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/crosperf/experiment_file_unittest.py b/crosperf/experiment_file_unittest.py index 12b68223..0d4e1e67 100755 --- a/crosperf/experiment_file_unittest.py +++ b/crosperf/experiment_file_unittest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. @@ -147,13 +147,13 @@ benchmark: PageCycler { } label: image1 { -\tremote: chromeos-alex3 \tchromeos_image: /usr/local/google/cros_image1.bin +\tremote: chromeos-alex3 } label: image2 { -\tremote: chromeos-lumpy1 \tchromeos_image: /usr/local/google/cros_image2.bin +\tremote: chromeos-lumpy1 }\n\n""" @@ -161,7 +161,7 @@ class ExperimentFileTest(unittest.TestCase): """The main class for Experiment File test.""" def testLoadExperimentFile1(self): - input_file = io.BytesIO(EXPERIMENT_FILE_1) + input_file = io.StringIO(EXPERIMENT_FILE_1) experiment_file = ExperimentFile(input_file) global_settings = experiment_file.GetGlobalSettings() self.assertEqual(global_settings.GetField('remote'), ['chromeos-alex3']) @@ -181,7 +181,7 @@ class ExperimentFileTest(unittest.TestCase): self.assertEqual(label_settings[0].GetField('remote'), ['chromeos-alex3']) def testOverrideSetting(self): - input_file = io.BytesIO(EXPERIMENT_FILE_2) + input_file = io.StringIO(EXPERIMENT_FILE_2) experiment_file = ExperimentFile(input_file) global_settings = experiment_file.GetGlobalSettings() self.assertEqual(global_settings.GetField('remote'), ['chromeos-alex3']) @@ -194,11 +194,11 @@ class ExperimentFileTest(unittest.TestCase): self.assertEqual(benchmark_settings[1].GetField('iterations'), 2) def testDuplicateLabel(self): - input_file = io.BytesIO(EXPERIMENT_FILE_3) + input_file = io.StringIO(EXPERIMENT_FILE_3) self.assertRaises(Exception, ExperimentFile, input_file) def testDuplicateBenchmark(self): - input_file = io.BytesIO(EXPERIMENT_FILE_4) + input_file = io.StringIO(EXPERIMENT_FILE_4) experiment_file = ExperimentFile(input_file) benchmark_settings = experiment_file.GetSettings('benchmark') self.assertEqual(benchmark_settings[0].name, 'webrtc') @@ -209,13 +209,13 @@ class ExperimentFileTest(unittest.TestCase): '--story-tag-filter=smoothness') def testCanonicalize(self): - input_file = io.BytesIO(EXPERIMENT_FILE_1) + input_file = io.StringIO(EXPERIMENT_FILE_1) experiment_file = ExperimentFile(input_file) res = experiment_file.Canonicalize() self.assertEqual(res, OUTPUT_FILE) def testLoadDutConfigExperimentFile_Good(self): - input_file = io.BytesIO(DUT_CONFIG_EXPERIMENT_FILE_GOOD) + input_file = io.StringIO(DUT_CONFIG_EXPERIMENT_FILE_GOOD) experiment_file = ExperimentFile(input_file) global_settings = experiment_file.GetGlobalSettings() self.assertEqual(global_settings.GetField('turbostat'), False) @@ -228,22 +228,21 @@ class ExperimentFileTest(unittest.TestCase): self.assertEqual(global_settings.GetField('top_interval'), 5) def testLoadDutConfigExperimentFile_WrongGovernor(self): - input_file = io.BytesIO(DUT_CONFIG_EXPERIMENT_FILE_BAD_GOV) + input_file = io.StringIO(DUT_CONFIG_EXPERIMENT_FILE_BAD_GOV) with self.assertRaises(RuntimeError) as msg: ExperimentFile(input_file) - self.assertRegexpMatches( - str(msg.exception), 'governor: misspelled_governor') - self.assertRegexpMatches( + self.assertRegex(str(msg.exception), 'governor: misspelled_governor') + self.assertRegex( str(msg.exception), "Invalid enum value for field 'governor'." r' Must be one of \(performance, powersave, userspace, ondemand,' r' conservative, schedutils, sched, interactive\)') def testLoadDutConfigExperimentFile_WrongCpuUsage(self): - input_file = io.BytesIO(DUT_CONFIG_EXPERIMENT_FILE_BAD_CPUUSE) + input_file = io.StringIO(DUT_CONFIG_EXPERIMENT_FILE_BAD_CPUUSE) with self.assertRaises(RuntimeError) as msg: ExperimentFile(input_file) - self.assertRegexpMatches(str(msg.exception), 'cpu_usage: unknown') - self.assertRegexpMatches( + self.assertRegex(str(msg.exception), 'cpu_usage: unknown') + self.assertRegex( str(msg.exception), "Invalid enum value for field 'cpu_usage'." r' Must be one of \(all, big_only, little_only, exclusive_cores\)') |