Home | History | Annotate | Download | only in test
      1 #!/usr/bin/python -i
      2 """Inspector for parser_result.store from specified scenerio package.
      3 
      4 Load in parser_result.store as 'sto' and launch interactive interp.
      5 Define some helper functions as required.
      6 """
      7 
      8 import optparse, os, sys
      9 from os import path
     10 import common
     11 from autotest_lib.tko.parsers.test import scenario_base
     12 
     13 
     14 usage = 'usage: %prog [options] scenario_dirpath'
     15 parser = optparse.OptionParser(usage=usage)
     16 parser.add_option("-w", action="store_true", dest="open_for_write")
     17 
     18 (options, args) = parser.parse_args()
     19 if len(args) < 1:
     20     parser.print_help()
     21     sys.exit(1)
     22 
     23 scenario_dirpath = path.normpath(args[0])
     24 if not path.exists(scenario_dirpath) or not path.isdir(scenario_dirpath):
     25     print 'Invalid scenarios_dirpath:', scenario_dirpath
     26     parser.print_help()
     27     sys.exit(1)
     28 
     29 sto = scenario_base.load_parser_result_store(
     30     scenario_dirpath, options.open_for_write)
     31 
     32 
     33 def compare(left_tag, right_tag):
     34     missing = set([left_tag, right_tag]).difference(sto.keys())
     35     if missing:
     36         print 'Store does not have the following tag(s): ', ','.join(missing)
     37         print 'Doing nothing.'
     38         return
     39 
     40     for diffline in scenario_base.compare_parser_results(
     41         sto[left_tag], sto[right_tag]):
     42         print diffline
     43