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/run-unit-test-docker.sh b/run-unit-test-docker.sh
index 95f0e33..5ac7a67 100755
--- a/run-unit-test-docker.sh
+++ b/run-unit-test-docker.sh
@@ -23,6 +23,7 @@
# `/usr/share/dbus-1/system.conf`
# TEST_ONLY: Optional, do not run analysis tools
# NO_FORMAT_CODE: Optional, do not run format-code.sh
+# NO_CPPCHECK: Optional, do not run cppcheck
# EXTRA_DOCKER_RUN_ARGS: Optional, pass arguments to docker run
# EXTRA_UNIT_TEST_ARGS: Optional, pass arguments to unit-test.py
# INTERACTIVE: Optional, run a bash shell instead of unit-test.py
@@ -42,6 +43,7 @@
DBUS_SYS_CONFIG_FILE=${dbus_sys_config_file:-"/usr/share/dbus-1/system.conf"}
MAKEFLAGS="${MAKEFLAGS:-""}"
NO_FORMAT_CODE="${NO_FORMAT_CODE:-}"
+NO_CPPCHECK="${NO_CPPCHECK:-}"
INTERACTIVE="${INTERACTIVE:-}"
http_proxy=${http_proxy:-}
@@ -80,7 +82,8 @@
UNIT_TEST="/bin/bash"
else
UNIT_TEST="${UNIT_TEST_SCRIPT_DIR}/${UNIT_TEST_PY},-w,${DOCKER_WORKDIR},\
--p,${UNIT_TEST_PKG},-b,$BRANCH,-v${TEST_ONLY:+,-t}${NO_FORMAT_CODE:+,-n}\
+-p,${UNIT_TEST_PKG},-b,$BRANCH,\
+-v${TEST_ONLY:+,-t}${NO_FORMAT_CODE:+,-n}${NO_CPPCHECK:+,--no-cppcheck}\
${EXTRA_UNIT_TEST_ARGS}"
fi
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