registration code: don't allow dummy registration code in PVT only

CL:1276026 inhibit dummy regcode in all phases.  This is not very
convenient for early builds.  Allow this code in non-PVT builds.
If dummy code is detected, and it's allowed in current phase, a warning
will be logged.  If it's not allowed, an exception will be thrown.

Also add argument '--allow_dummy' to regcode.py.

BUG=b:117463731
TEST=manual

Change-Id: I6ec60754c7ca3f53c3630f1ff2bf269e1b7b3ae2
Reviewed-on: https://chromium-review.googlesource.com/1398101
Commit-Ready: Wei-Han Chen <stimim@chromium.org>
Tested-by: Wei-Han Chen <stimim@chromium.org>
Reviewed-by: Chun-Tsen Kuo <chuntsen@chromium.org>
diff --git a/py/tools/regcode.py b/py/tools/regcode.py
index d84997d..e7d808a 100755
--- a/py/tools/regcode.py
+++ b/py/tools/regcode.py
@@ -98,7 +98,10 @@
     CmdArg(
         '--project', '-b', metavar='PROJECT',
         help=('Project to check (default: probed project name if run on DUT; '
-              'board name in .default_board if in chroot)')))
+              'board name in .default_board if in chroot)')),
+    CmdArg(
+        '--allow_dummy', action='store_true',
+        help='Allow dummy regcode (regcode containing "__TESTING__")'))
 def Check(options):
   if not options.project:
     if sys_utils.InChroot():
@@ -131,7 +134,8 @@
         sys.exit(1)
 
     try:
-      registration_codes.CheckRegistrationCode(code, code_type, options.project)
+      registration_codes.CheckRegistrationCode(code, code_type, options.project,
+                                               options.allow_dummy)
       logging.info('%s: success', code_type)
     except registration_codes.RegistrationCodeException as e:
       success = False