]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.perf/lib/perftest/reporter.py
1 # Copyright (C) 2013-2015 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 class Reporter(object):
17 """Base class of reporter to report test results in a certain format.
19 Subclass, which is specific to a report format, should overwrite
20 methods report, start and end.
23 def __init__(self
, append
):
24 """Constructor of Reporter.
26 attribute append is used to determine whether to append or
31 def report(self
, *args
):
32 raise NotImplementedError("Abstract Method:report.")
35 """Invoked when reporting is started."""
36 raise NotImplementedError("Abstract Method:start.")
39 """Invoked when reporting is done.
41 It must be overridden to do some cleanups, such as closing file
44 raise NotImplementedError("Abstract Method:end.")
46 class TextReporter(Reporter
):
47 """Report results in a plain text file 'perftest.log'."""
49 def __init__(self
, append
):
50 super (TextReporter
, self
).__init
__(Reporter(append
))
53 def report(self
, *args
):
54 self
.txt_log
.write(' '.join(str(arg
) for arg
in args
))
55 self
.txt_log
.write('\n')
59 self
.txt_log
= open ("perftest.log", 'a+');
61 self
.txt_log
= open ("perftest.log", 'w');