checker: Allow disabling common checks in program.

- If two checks have the same class name, only run the one in
the program directory. This allows the program to override or
disable (by providing an empty class) the check.

BUG=chromium:1093822
TEST=CQ

Change-Id: I95d421d611f175c53339072659920a53485b389d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/config/+/2722631
Commit-Queue: Bhanu Prakash Maiya <bhanumaiya@google.com>
Auto-Submit: Andrew Lamb <andrewlamb@chromium.org>
Reviewed-by: Sean McAllister <smcallis@google.com>
Reviewed-by: Bhanu Prakash Maiya <bhanumaiya@google.com>
diff --git a/payload_utils/checker.py b/payload_utils/checker.py
index 3b1ee60..9c6e49f 100755
--- a/payload_utils/checker.py
+++ b/payload_utils/checker.py
@@ -56,16 +56,20 @@
   program_checks_dir = os.path.join(os.path.dirname(args.program), '../checks')
 
   constraint_suite_directories = [
-      COMMON_CHECKS_PATH,
       program_checks_dir,
+      COMMON_CHECKS_PATH,
   ]
 
-  constraint_suites = []
+  # If two suites have the same name, only run the one in the program directory.
+  # This allows programs to override common suites.
+  constraint_suites = {}
   for directory in constraint_suite_directories:
-    constraint_suites.extend(
-        constraint_suite_discovery.discover_suites(directory))
+    for suite in constraint_suite_discovery.discover_suites(directory):
+      suite_name = suite.__class__.__name__
+      if suite_name not in constraint_suites:
+        constraint_suites[suite_name] = suite
 
-  for suite in constraint_suites:
+  for suite in constraint_suites.values():
     suite.run_checks(
         program_config=program_config,
         project_config=project_config,