--- a/sbsv2/raptor/bin/sbs_filter.py Fri Mar 26 12:02:49 2010 +0000
+++ b/sbsv2/raptor/bin/sbs_filter.py Thu Apr 01 11:47:09 2010 +0100
@@ -58,7 +58,7 @@
raptor_params = raptor.BuildStats(the_raptor)
# Open the requested plugins using the pluginbox
- the_raptor.out.open(raptor_params, the_raptor.filterList.split(','), pbox)
+ the_raptor.out.open(raptor_params, the_raptor.filterList, pbox)
except Exception, e:
sys.stderr.write("error: problem while creating filters %s\n" % str(e))
--- a/sbsv2/raptor/python/filter_list.py Fri Mar 26 12:02:49 2010 +0000
+++ b/sbsv2/raptor/python/filter_list.py Thu Apr 01 11:47:09 2010 +0100
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+# Copyright (c) 2008-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"
@@ -19,6 +19,7 @@
import os
import sys
import raptor
+import re
import filter_interface
import pluginbox
import traceback
@@ -64,8 +65,24 @@
"""Nothing to do for stdout"""
return True
-
-
+def SplitList(listString):
+ """turn a CLI filter string into a list of (class, param) pairs.
+
+ for example, "foo[a,b],bar[c,d]"
+
+ becomes [ ("foo", ["a","b"]) , ("bar", ["c","d"]) ]
+ """
+ matches = re.findall("(\w+)(\[([^\[\]]*)\])?,?", listString)
+
+ pairs = []
+ for m in matches:
+ classname = m[0]
+ if len(m[2]) > 0:
+ pairs.append( (classname, m[2].split(",")) )
+ else:
+ pairs.append( (classname, []) )
+ return pairs
+
class FilterList(filter_interface.Filter):
def __init__(self):
@@ -81,13 +98,19 @@
# Find all the filter plugins
self.pbox = pbox
possiblefilters = self.pbox.classesof(filter_interface.Filter)
+ # turn "filternames" into a list of (classname, parameters) pairs
+ filterCalls = SplitList(filternames)
+ # look for each filter class in the box
unfound = []
self.filters = []
- for f in filternames:
+ for (f, params) in filterCalls:
unfound.append(f) # unfound unless we find it
for pl in possiblefilters:
if pl.__name__.upper() == f.upper():
- self.filters.append(pl())
+ if params:
+ self.filters.append(pl(params))
+ else:
+ self.filters.append(pl())
unfound = unfound[:-1]
if unfound != []:
raise ValueError("requested filters not found: %s \
--- a/sbsv2/raptor/python/plugins/filter_tagcount.py Fri Mar 26 12:02:49 2010 +0000
+++ b/sbsv2/raptor/python/plugins/filter_tagcount.py Thu Apr 01 11:47:09 2010 +0100
@@ -19,6 +19,14 @@
class FilterTagCounter(filter_interface.FilterSAX):
+ def __init__(self, params = []):
+ """parameters to this filter are the names of tags to print.
+
+ If no parameters are passed then all tags are reported."""
+ self.interesting = params
+ print "counting : ", str(params)
+ super(FilterTagCounter, self).__init__()
+
def startDocument(self):
# for each element name count the number of occurences
# and the amount of body text contained.
@@ -55,7 +63,8 @@
# report
print "\nsummary:"
for name,nos in sorted(self.count.items()):
- print name, nos[0], nos[1]
+ if name in self.interesting or len(self.interesting) == 0:
+ print name, nos[0], nos[1]
print "\nparsing:"
print "errors =", self.errors
--- a/sbsv2/raptor/python/raptor.py Fri Mar 26 12:02:49 2010 +0000
+++ b/sbsv2/raptor/python/raptor.py Thu Apr 01 11:47:09 2010 +0100
@@ -1096,7 +1096,7 @@
self.raptor_params = BuildStats(self)
# Open the requested plugins using the pluginbox
- self.out.open(self.raptor_params, self.filterList.split(','), self.pbox)
+ self.out.open(self.raptor_params, self.filterList, self.pbox)
# log header
self.out.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n")
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sbsv2/raptor/test/smoke_suite/filter_params.py Thu Apr 01 11:47:09 2010 +0100
@@ -0,0 +1,77 @@
+#
+# 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:
+#
+
+from raptor_tests import SmokeTest
+
+def run():
+
+ t = SmokeTest()
+ t.description = "Test the passing of parameters to log filters"
+
+ command = "sbs -b smoke_suite/test_resources/simple/bld.inf -c armv5_urel --filters="
+
+ # no parameters means count all tags
+ t.name = "filter_params_all_tags"
+ t.command = command + "FilterTagCounter"
+ t.mustmatch_singleline = [
+ "^info \d+ \d+",
+ "^whatlog \d+ \d+",
+ "^clean \d+ \d+"
+ ]
+ t.run()
+
+ # empty parameter lists are valid
+ t.name = "filter_params_all_tags2"
+ t.command = command + "FilterTagCounter[]"
+ t.run()
+
+ # parameters mean report only those tags
+ t.name = "filter_params_info"
+ t.command = command + "FilterTagCounter[info]"
+ t.mustmatch_singleline = [
+ "^info \d+ \d+"
+ ]
+ t.mustnotmatch_singleline = [
+ "^whatlog \d+ \d+",
+ "^clean \d+ \d+"
+ ]
+ t.run()
+
+ # multiple parameters are valid
+ t.name = "filter_params_info_clean"
+ t.command = command + "FilterTagCounter[info,clean]"
+ t.mustmatch_singleline = [
+ "^info \d+ \d+",
+ "^clean \d+ \d+"
+ ]
+ t.mustnotmatch_singleline = [
+ "^whatlog \d+ \d+"
+ ]
+ t.run()
+
+ # using the same filter with different parameters is valid
+ t.name = "filter_params_info_clean2"
+ t.command = command + "FilterTagCounter[info],FilterTagCounter[clean]"
+ t.run()
+
+ # using the same filter with the same parameters is valid too
+ t.name = "filter_params_info_clean3"
+ t.command = command + "FilterTagCounter[info,clean],FilterTagCounter[info,clean]"
+ t.run()
+
+ t.name = "filter_params"
+ t.print_result()
+ return t