def __init__(self, description='none given', test=None, root=None, parent=None, level=message.ERROR, queue='threaded', **kwargs): self.commit_level = level self.abv = activityBlockVersion(**kwargs) # init default filter self.filter_fn = self.filter self.root = root or mdbDefault().root self.parent = parent or mdbDefault().parent # add to list of instances mdb.instances.append(self) # psuedo singleton if mdb.instance is None: try: _queue = getattr(self.queue, queue) except AttributeError: message.fatal('No mdb queue type %(queue)s', queue=queue) message.information('Using queue %(queue)s', queue=queue) mdb.instance = _queue(self.abv, self.root, self.parent, description, test) # install callback message.emit_cbs.add('mdb emit', 1, self.add, None) message.debug('hello ...')
def __init__(self, xml) : try : self.xml = libxml2.parseFile(xml) except : message.fatal('unable to read regression file %(xml)s because %(excpt)s', xml=xml, excpt=sys.exc_info()[1]) return for idx, node in enumerate(self.xml.xpathEval('//*')) : try : node.setProp('nid', 'id-' + str(idx)) except : message.debug('setProp failed for %(tag)s', tag=node.name)
def __init__(self, xml): try: self.xml = libxml2.parseFile(xml) except: message.fatal( 'unable to read regression file %(xml)s because %(excpt)s', xml=xml, excpt=sys.exc_info()[1]) return for idx, node in enumerate(self.xml.xpathEval('//*')): try: node.setProp('nid', 'id-' + str(idx)) except: message.debug('setProp failed for %(tag)s', tag=node.name)
def __init__(self, log_ids=[], test_ids=[], xml=None, threshold=0, robust=False, previous=None) : 'log_ids is a list of regression roots' self.log_ids = log_ids s_log_ids = ','.join(map(str, log_ids)) self.tests = mdb.connection().row_cursor() if log_ids : # create table of individual runs, but not root node as this may have already summarised coverage self.tests.execute('CREATE TEMPORARY TABLE '+self.invs+' AS SELECT l1.*, goal_id AS master FROM log AS l0 JOIN log AS l1 ON (l0.log_id = l1.root) LEFT OUTER JOIN master ON (l1.log_id = master.log_id) WHERE l1.root IN ('+s_log_ids+');') self.tests.execute('SELECT count(*) AS children FROM '+self.invs) children = self.tests.fetchone().children if children : message.information('%(log_ids)s %(has)s %(children)d children', log_ids=s_log_ids, children=children, has='have' if len(log_ids) > 1 else 'has') # append individual runs as given by test_ids if xml : xml_ids = xml.xml.xpath('/optimize/test/log_id/text()') else : xml_ids=[] if test_ids or xml_ids : s_test_ids = ','.join(map(str, test_ids+xml_ids)) create = ('INSERT INTO '+self.invs) if log_ids else ('CREATE TEMPORARY TABLE '+self.invs+' AS') self.tests.execute(create+' SELECT log.*, IFNULL(goal_id, goal.log_id) AS master FROM log LEFT OUTER JOIN master ON (log.log_id = master.log_id) LEFT OUTER JOIN goal ON (log.log_id = goal.log_id) WHERE log.log_id IN ('+s_test_ids+') GROUP BY log_id;') self.tests.execute('SELECT count(*) AS tests FROM '+self.invs) tests = self.tests.fetchone().tests if tests < 1 : message.fatal('no tests') message.information('starting with %(count)d tests in table %(table)s', count=tests, table=self.invs) # check congruency self.cvg = mdb.connection().row_cursor() rows=self.cvg.execute("SELECT md5_self AS md5, 'md5_self' AS type, invs.master, invs.root FROM point JOIN "+self.invs+" AS invs ON (invs.master = point.log_id AND point.parent IS NULL) GROUP BY md5;") md5 = self.cvg.fetchall() if not md5 : message.fatal('no master') elif len(md5) > 1 : message.fatal('md5 of multiple masters do not match') else : message.debug('md5 query returns %(rows)d', rows=rows) self.master = mdb.accessor(md5=md5[0]) self.cvg.execute("SELECT DISTINCT(md5_axes) AS md5, 'md5_axes' AS type, invs.master, invs.root FROM point JOIN "+self.invs+" AS invs ON (invs.master = point.log_id AND point.parent IS NULL) GROUP BY md5;") md5 = self.cvg.fetchall() if len(md5) > 1 : message.fatal('md5 of multiple axis masters do not match') self.master.axes = md5[0] # create status table, collating goal & hits self.cvg.execute('CREATE TEMPORARY TABLE '+self.covg+' (bucket_id INTEGER NOT NULL PRIMARY KEY, goal INTEGER, hits INTEGER, total_hits INTEGER, rhits INTEGER, max_hits INTEGER, tests INTEGER);') try : self.threshold = float(threshold) except : self.threshold = 0.0 message.warning('cannot convert threshold value given "%(arg)s" to float because %(exception)s, using %(threshold)2.1f', arg=threshold, exception=sys.exc_info()[0], threshold=self.threshold) self.robust = robust self.previous = previous
def __init__(self, log_ids=[], test_ids=[], xml=None, threshold=0, robust=False, previous=None): 'log_ids is a list of regression roots' self.log_ids = log_ids s_log_ids = ','.join(map(str, log_ids)) self.tests = mdb.connection().row_cursor() if log_ids: # create table of individual runs, but not root node as this may have already summarised coverage self.tests.execute( 'CREATE TEMPORARY TABLE ' + self.invs + ' AS SELECT l1.*, goal_id AS master FROM log AS l0 JOIN log AS l1 ON (l0.log_id = l1.root) LEFT OUTER JOIN master ON (l1.log_id = master.log_id) WHERE l1.root IN (' + s_log_ids + ');') self.tests.execute('SELECT count(*) AS children FROM ' + self.invs) children = self.tests.fetchone().children if children: message.information( '%(log_ids)s %(has)s %(children)d children', log_ids=s_log_ids, children=children, has='have' if len(log_ids) > 1 else 'has') # append individual runs as given by test_ids if xml: xml_ids = xml.xml.xpath('/optimize/test/log_id/text()') else: xml_ids = [] if test_ids or xml_ids: s_test_ids = ','.join(map(str, test_ids + xml_ids)) create = ('INSERT INTO ' + self.invs) if log_ids else ('CREATE TEMPORARY TABLE ' + self.invs + ' AS') self.tests.execute( create + ' SELECT log.*, IFNULL(goal_id, goal.log_id) AS master FROM log LEFT OUTER JOIN master ON (log.log_id = master.log_id) LEFT OUTER JOIN goal ON (log.log_id = goal.log_id) WHERE log.log_id IN (' + s_test_ids + ') GROUP BY log_id;') self.tests.execute('SELECT count(*) AS tests FROM ' + self.invs) tests = self.tests.fetchone().tests if tests < 1: message.fatal('no tests') message.information('starting with %(count)d tests in table %(table)s', count=tests, table=self.invs) # check congruency self.cvg = mdb.connection().row_cursor() rows = self.cvg.execute( "SELECT md5_self AS md5, 'md5_self' AS type, invs.master, invs.root FROM point JOIN " + self.invs + " AS invs ON (invs.master = point.log_id AND point.parent IS NULL) GROUP BY md5;" ) md5 = self.cvg.fetchall() if not md5: message.fatal('no master') elif len(md5) > 1: message.fatal('md5 of multiple masters do not match') else: message.debug('md5 query returns %(rows)d', rows=rows) self.master = mdb.accessor(md5=md5[0]) self.cvg.execute( "SELECT DISTINCT(md5_axes) AS md5, 'md5_axes' AS type, invs.master, invs.root FROM point JOIN " + self.invs + " AS invs ON (invs.master = point.log_id AND point.parent IS NULL) GROUP BY md5;" ) md5 = self.cvg.fetchall() if len(md5) > 1: message.fatal('md5 of multiple axis masters do not match') self.master.axes = md5[0] # create status table, collating goal & hits self.cvg.execute( 'CREATE TEMPORARY TABLE ' + self.covg + ' (bucket_id INTEGER NOT NULL PRIMARY KEY, goal INTEGER, hits INTEGER, total_hits INTEGER, rhits INTEGER, max_hits INTEGER, tests INTEGER);' ) try: self.threshold = float(threshold) except: self.threshold = 0.0 message.warning( 'cannot convert threshold value given "%(arg)s" to float because %(exception)s, using %(threshold)2.1f', arg=threshold, exception=sys.exc_info()[0], threshold=self.threshold) self.robust = robust self.previous = previous
def prologue(self): message.fatal('a fatal %(c)d', c=69) message.note('a note')
def fatal(self): 'Should not be executed' message.fatal('Should not be executed')
def fatal(self) : 'Should not be executed' message.fatal('Should not be executed')
################################################################################ if not options.order: options.order = [ 'cvg', ] if options.regression is None: # presume leftover args are ids options.regression = values regressions = to_list(options.regression) tests = to_list(options.test) if not regressions and not tests: message.fatal('No invocations provided') message.information('optimizing begins') ################################################################################ coverage.messages.hush_creation() optimize_opts = {'threshold': options.threshold, 'robust': options.robust} def iteration(ordering, iter_cnt=1, xml=None): # use current optimization group if this is not first iteration order = ordering[0] message.note('Iteration %(iter_cnt)d uses "%(order)s"', **locals()) if xml: opt = database.optimize.options[order](xml=xml, **optimize_opts)
return values ################################################################################ if not options.order : options.order = ['cvg', ] if options.regression is None : # presume leftover args are ids options.regression = values regressions = to_list(options.regression) tests = to_list(options.test) if not regressions and not tests : message.fatal('No invocations provided') message.information('optimizing begins') ################################################################################ coverage.messages.hush_creation() optimize_opts = {'threshold' : options.threshold, 'robust' : options.robust} def iteration(ordering, iter_cnt=1, xml=None) : # use current optimization group if this is not first iteration order = ordering[0] message.note('Iteration %(iter_cnt)d uses "%(order)s"', **locals()) if xml : opt = database.optimize.options[order](xml=xml, **optimize_opts) else :
def prologue(self) : message.fatal('a fatal %(c)d', c=69) message.note('a note')