perf testsuite: python 3 fixes

There are a few errors when trying to run the performance testsuite with
Python 3.  This commit fixes them.

In Python 2, it was possible to use relative imports (importing a module
relative to the current one).  In Python 3 it isn't.  So I use
absolute_import from the __future__ module, which allows Python 2 to
behave like Python 3, and use the Python 3 syntax.

In Python 3, dict.iterkeys doesn't exist anymore.  Using dict.keys is a
good compromise in this case.

gdb/testsuite/ChangeLog:

	* gdb.perf/lib/perftest/perftest.py: Change relative imports to
	absolute.
	(SingleStatisticTestResult.report): Use dict.keys instead of
	dict.iterkeys.
This commit is contained in:
Simon Marchi 2016-01-08 10:22:17 -05:00
parent 2f99e8fc9c
commit 582a1b0064
3 changed files with 17 additions and 7 deletions

View File

@ -1,3 +1,10 @@
2016-01-08 Simon Marchi <simon.marchi@ericsson.com>
* gdb.perf/lib/perftest/perftest.py: Change relative imports to
absolute.
(SingleStatisticTestResult.report): Use dict.keys instead of
dict.iterkeys.
2016-01-06 Pedro Alves <palves@redhat.com> 2016-01-06 Pedro Alves <palves@redhat.com>
* gdb.python/py-infthread.exp: Fix typo. Expect t0.num to be 1. * gdb.python/py-infthread.exp: Fix typo. Expect t0.num to be 1.

View File

@ -13,12 +13,15 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import testresult from __future__ import absolute_import
import reporter
from measure import Measure import perftest.testresult as testresult
from measure import MeasurementCpuTime import perftest.reporter as reporter
from measure import MeasurementWallTime from perftest.measure import Measure
from measure import MeasurementVmSize from perftest.measure import MeasurementCpuTime
from perftest.measure import MeasurementWallTime
from perftest.measure import MeasurementVmSize
class TestCase(object): class TestCase(object):
"""Base class of all performance testing cases. """Base class of all performance testing cases.

View File

@ -42,7 +42,7 @@ class SingleStatisticTestResult(TestResult):
def report(self, reporter, name): def report(self, reporter, name):
reporter.start() reporter.start()
for key in sorted(self.results.iterkeys()): for key in sorted(self.results.keys()):
reporter.report(name, key, self.results[key]) reporter.report(name, key, self.results[key])
reporter.end() reporter.end()