Skip to content

Commit 1135520

Browse files
authored
run more tests in sanitizer workflows (danmar#5744)
1 parent 22613dc commit 1135520

4 files changed

Lines changed: 86 additions & 11 deletions

File tree

.github/workflows/asan.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: Install missing software on ubuntu
4343
run: |
4444
sudo apt-get update
45-
sudo apt-get install -y cmake make libpcre3-dev libboost-container-dev
45+
sudo apt-get install -y cmake make libpcre3-dev libboost-container-dev libxml2-utils
4646
4747
- name: Install clang
4848
run: |
@@ -59,6 +59,12 @@ jobs:
5959
modules: 'qtcharts'
6060
cache: true
6161

62+
- name: Install missing Python packages
63+
run: |
64+
python3 -m pip install pip --upgrade
65+
python3 -m pip install pytest
66+
python3 -m pip install pytest-timeout
67+
6268
# TODO: disable all warnings
6369
- name: CMake
6470
run: |
@@ -78,6 +84,22 @@ jobs:
7884
- name: Run tests
7985
run: ./cmake.output/bin/testrunner
8086

87+
- name: Run cfg tests
88+
run: |
89+
cmake --build cmake.output --target checkcfg -- -j $(nproc)
90+
91+
# TODO: we should use CTest instead to parallelize tests but the start-up overhead will slow things down
92+
- name: Run CTest
93+
if: false
94+
run: |
95+
ctest --test-dir cmake.output --output-on-failure -j$(nproc)
96+
97+
- name: Run test/cli
98+
run: |
99+
pwd=$(pwd)
100+
cd test/cli
101+
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv test-*.py
102+
81103
- name: Generate dependencies
82104
if: false
83105
run: |

.github/workflows/tsan.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: Install missing software on ubuntu
4343
run: |
4444
sudo apt-get update
45-
sudo apt-get install -y cmake make libpcre3-dev libboost-container-dev
45+
sudo apt-get install -y cmake make libpcre3-dev libboost-container-dev libxml2-utils
4646
4747
- name: Install clang
4848
run: |
@@ -59,6 +59,12 @@ jobs:
5959
modules: 'qtcharts'
6060
cache: true
6161

62+
- name: Install missing Python packages
63+
run: |
64+
python3 -m pip install pip --upgrade
65+
python3 -m pip install pytest
66+
python3 -m pip install pytest-timeout
67+
6268
- name: CMake
6369
run: |
6470
cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=Off -DWITH_QCHART=Off -DUSE_MATCHCOMPILER=Verify -DANALYZE_THREAD=On -DUSE_THREADS=On -DENABLE_CHECK_INTERNAL=On -DUSE_BOOST=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=Off -DDISABLE_DMAKE=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
@@ -77,6 +83,22 @@ jobs:
7783
- name: Run tests
7884
run: ./cmake.output/bin/testrunner
7985

86+
- name: Run cfg tests
87+
run: |
88+
cmake --build cmake.output --target checkcfg -- -j $(nproc)
89+
90+
# TODO: we should use CTest instead to parallelize tests but the start-up overhead will slow things down
91+
- name: Run CTest
92+
if: false
93+
run: |
94+
ctest --test-dir cmake.output --output-on-failure -j$(nproc)
95+
96+
- name: Run test/cli
97+
run: |
98+
pwd=$(pwd)
99+
cd test/cli
100+
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv test-*.py
101+
80102
- name: Generate dependencies
81103
if: false
82104
run: |

.github/workflows/ubsan.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: Install missing software on ubuntu
4343
run: |
4444
sudo apt-get update
45-
sudo apt-get install -y cmake make libpcre3-dev libboost-container-dev
45+
sudo apt-get install -y cmake make libpcre3-dev libboost-container-dev libxml2-utils
4646
4747
- name: Install clang
4848
run: |
@@ -58,6 +58,12 @@ jobs:
5858
modules: 'qtcharts'
5959
cache: true
6060

61+
- name: Install missing Python packages
62+
run: |
63+
python3 -m pip install pip --upgrade
64+
python3 -m pip install pytest
65+
python3 -m pip install pytest-timeout
66+
6167
# TODO: disable warnings
6268
- name: CMake
6369
run: |
@@ -77,6 +83,22 @@ jobs:
7783
- name: Run tests
7884
run: ./cmake.output/bin/testrunner
7985

86+
- name: Run cfg tests
87+
run: |
88+
cmake --build cmake.output --target checkcfg -- -j $(nproc)
89+
90+
# TODO: we should use CTest instead to parallelize tests but the start-up overhead will slow things down
91+
- name: Run CTest
92+
if: false
93+
run: |
94+
ctest --test-dir cmake.output --output-on-failure -j$(nproc)
95+
96+
- name: Run test/cli
97+
run: |
98+
pwd=$(pwd)
99+
cd test/cli
100+
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv test-*.py
101+
80102
- name: Generate dependencies
81103
run: |
82104
# make sure auto-generated GUI files exist

test/cli/testutils.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,23 @@ def __lookup_cppcheck_exe():
5151
if sys.platform == "win32":
5252
exe_name += ".exe"
5353

54-
for base in (script_path + '/../../', './'):
55-
for path in ('', 'bin/', 'bin/debug/'):
56-
exe_path = base + path + exe_name
57-
if os.path.isfile(exe_path):
58-
print("using '{}'".format(exe_path))
59-
return exe_path
60-
61-
return None
54+
exe_path = None
55+
56+
if 'TEST_CPPCHECK_EXE_LOOKUP_PATH' in os.environ:
57+
lookup_paths = [os.environ['TEST_CPPCHECK_EXE_LOOKUP_PATH']]
58+
else:
59+
lookup_paths = [os.path.join(script_path, '..', '..'), '.']
60+
61+
for base in lookup_paths:
62+
for path in ('', 'bin', os.path.join('bin', 'debug')):
63+
tmp_exe_path = os.path.join(base, path, exe_name)
64+
if os.path.isfile(tmp_exe_path):
65+
exe_path = tmp_exe_path
66+
break
67+
68+
if exe_path:
69+
print("using '{}'".format(exe_path))
70+
return exe_path
6271

6372

6473
# Run Cppcheck with args

0 commit comments

Comments
 (0)