gooftool: Add component verification command.
This is for use in SMT. A white list of components are
checked against the supported component set specified in
the component_db -- this lets us check that components
both exist and are recognized, without forcing a specific
bom configuration check.
BUG=chrome-os-partner:7950
TEST=run 'gooftool component_verification' on a DUT
Change-Id: I0a62caa2928063cea3309bca0fe5cc0591ad5cde
Reviewed-on: https://gerrit.chromium.org/gerrit/23813
Tested-by: Tammo Spalink <tammo@chromium.org>
Reviewed-by: Jon Salz <jsalz@chromium.org>
Commit-Ready: Tammo Spalink <tammo@chromium.org>
diff --git a/py/gooftool.py b/py/gooftool.py
index ff08eac..9c86875 100755
--- a/py/gooftool.py
+++ b/py/gooftool.py
@@ -133,6 +133,50 @@
help='Path to the HWID database.')
+@Command('verify_components',
+ _hwdb_path_cmd_arg,
+ CmdArg('comp_white_list', nargs='*'))
+def VerifyComponents(options):
+ """Verify that probable components all match entries in the component_db.
+
+ Probe for each component class in the comp_white_list and verify
+ that a corresponding match exists in the component_db -- make sure
+ that these components are present, that they have been approved, but
+ do not check against any specific BOM/HWID configurations.
+ """
+ hwdb = hwid_tool.ReadDatastore(options.hwdb_path)
+ if not options.comp_white_list:
+ sys.exit('ERROR: no component white list specified; possible choices:\n %s'
+ % '\n '.join(sorted(hwdb.comp_db.registry)))
+ for comp_class in options.comp_white_list:
+ if comp_class not in hwdb.comp_db.registry:
+ sys.exit('ERROR: specified white list component class %r does not exist'
+ ' in the component DB.' % comp_class)
+ probe_results = probe.Probe(target_comp_classes=options.comp_white_list,
+ probe_volatile=False, probe_initial_config=False)
+ probe_val_map = hwid_tool.CalcCompDbProbeValMap(hwdb.comp_db)
+ errors = []
+ matches = []
+ for comp_class in sorted(options.comp_white_list):
+ probe_val = probe_results.found_components.get(comp_class, None)
+ if probe_val is not None:
+ comp_name = probe_val_map.get(probe_val, None)
+ if comp_name is not None:
+ matches.append(comp_name)
+ else:
+ errors.append('unsupported %r component found with probe result'
+ ' %r (no matching name in the component DB)' %
+ (comp_class, probe_val))
+ else:
+ errors.append('missing %r component' % comp_class)
+ if errors:
+ print '\n'.join(errors)
+ sys.exit('component verification FAILURE')
+ else:
+ print 'component verification SUCCESS'
+ print 'found components:\n %s' % '\n '.join(matches)
+
+
@Command('verify_hwid',
_hwdb_path_cmd_arg)
def VerifyHwid(options):