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