Skip to content

Commit d8e150a

Browse files
committed
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 <[email protected]>
1 parent 23b47b2 commit d8e150a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

run-unit-test-docker.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
# `/usr/share/dbus-1/system.conf`
2424
# TEST_ONLY: Optional, do not run analysis tools
2525
# NO_FORMAT_CODE: Optional, do not run format-code.sh
26+
# NO_CPPCHECK: Optional, do not run cppcheck
2627
# EXTRA_DOCKER_RUN_ARGS: Optional, pass arguments to docker run
2728
# EXTRA_UNIT_TEST_ARGS: Optional, pass arguments to unit-test.py
2829
# INTERACTIVE: Optional, run a bash shell instead of unit-test.py
@@ -42,6 +43,7 @@ TEST_ONLY="${TEST_ONLY:-}"
4243
DBUS_SYS_CONFIG_FILE=${dbus_sys_config_file:-"/usr/share/dbus-1/system.conf"}
4344
MAKEFLAGS="${MAKEFLAGS:-""}"
4445
NO_FORMAT_CODE="${NO_FORMAT_CODE:-}"
46+
NO_CPPCHECK="${NO_CPPCHECK:-}"
4547
INTERACTIVE="${INTERACTIVE:-}"
4648
http_proxy=${http_proxy:-}
4749

@@ -80,7 +82,8 @@ if [ "${INTERACTIVE}" ]; then
8082
UNIT_TEST="/bin/bash"
8183
else
8284
UNIT_TEST="${UNIT_TEST_SCRIPT_DIR}/${UNIT_TEST_PY},-w,${DOCKER_WORKDIR},\
83-
-p,${UNIT_TEST_PKG},-b,$BRANCH,-v${TEST_ONLY:+,-t}${NO_FORMAT_CODE:+,-n}\
85+
-p,${UNIT_TEST_PKG},-b,$BRANCH,\
86+
-v${TEST_ONLY:+,-t}${NO_FORMAT_CODE:+,-n}${NO_CPPCHECK:+,--no-cppcheck}\
8487
${EXTRA_UNIT_TEST_ARGS}"
8588
fi
8689

scripts/unit-test.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,10 @@ def build_dep_tree(name, pkgdir, dep_added, head, branch, dep_tree=None):
373373

374374

375375
def run_cppcheck():
376-
if not os.path.exists(os.path.join("build", "compile_commands.json")):
376+
if (
377+
not os.path.exists(os.path.join("build", "compile_commands.json"))
378+
or NO_CPPCHECK
379+
):
377380
return None
378381

379382
with TemporaryDirectory() as cpp_dir:
@@ -1329,6 +1332,14 @@ def find_file(filename, basedir):
13291332
default=False,
13301333
help="Only run test cases, no other validation",
13311334
)
1335+
parser.add_argument(
1336+
"--no-cppcheck",
1337+
dest="NO_CPPCHECK",
1338+
action="store_true",
1339+
required=False,
1340+
default=False,
1341+
help="Do not run cppcheck",
1342+
)
13321343
arg_inttests = parser.add_mutually_exclusive_group()
13331344
arg_inttests.add_argument(
13341345
"--integration-tests",
@@ -1374,6 +1385,7 @@ def find_file(filename, basedir):
13741385
WORKSPACE = args.WORKSPACE
13751386
UNIT_TEST_PKG = args.PACKAGE
13761387
TEST_ONLY = args.TEST_ONLY
1388+
NO_CPPCHECK = args.NO_CPPCHECK
13771389
INTEGRATION_TEST = args.INTEGRATION_TEST
13781390
BRANCH = args.BRANCH
13791391
FORMAT_CODE = args.FORMAT

0 commit comments

Comments
 (0)