# HG changeset patch # User Richard Taylor # Date 1270134335 -3600 # Node ID 80e69f7100f13ab4ed46b4be6b12b24f9f958817 # Parent 153129bf777ec22d3583915b2ed5cc4a863147e8 new FilterComp log filter diff -r 153129bf777e -r 80e69f7100f1 sbsv2/raptor/python/plugins/filter_component.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sbsv2/raptor/python/plugins/filter_component.py Thu Apr 01 16:05:35 2010 +0100 @@ -0,0 +1,96 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# Filter class to print log entries for a selected component +# + +import filter_interface +import sys + +class FilterComp(filter_interface.FilterSAX): + + def __init__(self, params = []): + """parameters to this filter are the path of the bld.inf and some flags. + + The bld.inf path can be a substring of the path to match. For example, + "email" will match an element with bldinf="y:/src/email/group/bld.inf". + + No flags are supported yet; this is for future expansion. + + If no parameters are passed then nothing is printed.""" + self.bldinf = "" + self.flags = "" + + if len(params) > 0: + self.bldinf = params[0] + + if len(params) > 1: + self.flags = params[1] + + super(FilterComp, self).__init__() + + def startDocument(self): + # mark when we are inside an element with bldinf="the selected one" + self.inside = False + # and count nested elements so we can toggle off at the end. + self.nesting = 0 + + def printElementStart(self, name, attributes): + sys.stdout.write("<" + name) + for att,val in attributes.items(): + sys.stdout.write(" " + att + "='" + val + "'") + sys.stdout.write(">") + + def startElement(self, name, attributes): + if self.inside: + self.nesting += 1 + self.printElementStart(name, attributes) + return + + if self.bldinf: + try: + if self.bldinf in attributes["bldinf"]: + self.inside = True + self.nesting = 1 + self.printElementStart(name, attributes) + except KeyError: + pass + + def characters(self, char): + if self.inside: + sys.stdout.write(char) + + def endElement(self, name): + if self.inside: + sys.stdout.write("") + + self.nesting -= 1 + + if self.nesting == 0: + self.inside = False + print + + def endDocument(self): + pass + + def error(self, exception): + print filter_interface.Filter.formatError("FilterComp:" + str(exception)) + + def fatalError(self, exception): + print filter_interface.Filter.formatError("FilterComp:" + str(exception)) + + def warning(self, exception): + print filter_interface.Filter.formatWarning("FilterComp:" + str(exception)) + +# the end diff -r 153129bf777e -r 80e69f7100f1 sbsv2/raptor/python/plugins/filter_tagcount.py --- a/sbsv2/raptor/python/plugins/filter_tagcount.py Thu Apr 01 11:47:09 2010 +0100 +++ b/sbsv2/raptor/python/plugins/filter_tagcount.py Thu Apr 01 16:05:35 2010 +0100 @@ -24,7 +24,6 @@ If no parameters are passed then all tags are reported.""" self.interesting = params - print "counting : ", str(params) super(FilterTagCounter, self).__init__() def startDocument(self): diff -r 153129bf777e -r 80e69f7100f1 sbsv2/raptor/test/smoke_suite/filter_params.py --- a/sbsv2/raptor/test/smoke_suite/filter_params.py Thu Apr 01 11:47:09 2010 +0100 +++ b/sbsv2/raptor/test/smoke_suite/filter_params.py Thu Apr 01 16:05:35 2010 +0100 @@ -72,6 +72,69 @@ t.command = command + "FilterTagCounter[info,clean],FilterTagCounter[info,clean]" t.run() + + # parameters must work with the sbs_filter script as well + + command = "sbs_filter --filters=%s < smoke_suite/test_resources/logexamples/filter_component.log" + t.logfileOption = lambda :"" + t.makefileOption = lambda :"" + + # should still work with no parameters + t.name = "sbs_filter_no_params" + t.command = command % "FilterComp" + t.mustmatch_singleline = [ + ] + t.mustnotmatch_singleline = [ + "[<>]" # no elements should be printed at all as no bld.inf is selected + ] + t.run() + + # should work with an empty parameter list + t.name = "sbs_filter_no_params2" + t.command = command % "FilterComp[]" + t.run() + + # with a parameter + t.name = "sbs_filter_one_param" + t.command = command % "FilterComp[email]" + t.stdout = [ + "email error #1", + "email error #2", + "email warning #1", + "email warning #2", + "", + "/epoc32/data/email_1", + "/epoc32/data/email_2", + "", + "", + "+ make_email", + "email was made fine", + "", + "", + "", + " ", + " ", + " fb email", + " ", + " ", + "" + ] + t.mustmatch_singleline = [] + t.mustnotmatch_singleline = [] + t.warnings = 2 + t.errors = 2 + t.run() + + # with multiple filters + t.name = "sbs_filter_multi" + t.command = command % "FilterComp[txt],FilterTagCounter[file,recipe]" + t.stdout = [] + t.mustmatch_singleline = [ "txt", "^file \d+", "^recipe \d+" ] + t.mustnotmatch_singleline = [ "email" ] + t.warnings = 2 + t.errors = 0 + t.run() + t.name = "filter_params" t.print_result() return t diff -r 153129bf777e -r 80e69f7100f1 sbsv2/raptor/test/smoke_suite/test_resources/logexamples/filter_component.log --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sbsv2/raptor/test/smoke_suite/test_resources/logexamples/filter_component.log Thu Apr 01 16:05:35 2010 +0100 @@ -0,0 +1,42 @@ + + +email error #1 +email error #2 + +txt warning #1 +txt warning #2 + +email warning #1 +email warning #2 + + +/epoc32/data/email_1 +/epoc32/data/email_2 + + + +/epoc32/data/txt_1 +/epoc32/data/txt_2 + + + ++ make_txt +txt was made fine + + + + ++ make_email +email was made fine + + + + + + + fb email + + + + + \ No newline at end of file