unit-test: Add ability to skip cppcheck

Now you can run openbmc-build-scripts/run-unit-test-docker.sh with
`NO_CPPCHECK=1` to skip cppcheck

We need this mechanizm in case cppcheck hangs. This problem can occur
when compiling with the BOOST_NO_RTTI and BOOST_NO_TYPEID flags.

Tested:
- Run `run-unit-test-docker.sh` as before, verify cppcheck runs
- Run `NO_CPPCHECK=1 run-unit-test-docker.sh`, verify cppcheck is
skipped

Change-Id: Ib1b246dc932b3b36334bfbe51934c206bdeb936f
Signed-off-by: Ewelina Walkusz <ewelinax.walkusz@intel.com>
diff --git a/scripts/unit-test.py b/scripts/unit-test.py
index e5ee8e2..0dbb403 100755
--- a/scripts/unit-test.py
+++ b/scripts/unit-test.py
@@ -373,7 +373,10 @@
 
 
 def run_cppcheck():
-    if not os.path.exists(os.path.join("build", "compile_commands.json")):
+    if (
+        not os.path.exists(os.path.join("build", "compile_commands.json"))
+        or NO_CPPCHECK
+    ):
         return None
 
     with TemporaryDirectory() as cpp_dir:
@@ -1329,6 +1332,14 @@
         default=False,
         help="Only run test cases, no other validation",
     )
+    parser.add_argument(
+        "--no-cppcheck",
+        dest="NO_CPPCHECK",
+        action="store_true",
+        required=False,
+        default=False,
+        help="Do not run cppcheck",
+    )
     arg_inttests = parser.add_mutually_exclusive_group()
     arg_inttests.add_argument(
         "--integration-tests",
@@ -1374,6 +1385,7 @@
     WORKSPACE = args.WORKSPACE
     UNIT_TEST_PKG = args.PACKAGE
     TEST_ONLY = args.TEST_ONLY
+    NO_CPPCHECK = args.NO_CPPCHECK
     INTEGRATION_TEST = args.INTEGRATION_TEST
     BRANCH = args.BRANCH
     FORMAT_CODE = args.FORMAT