Skip to content

Commit

Permalink
Test analyzer with asan and ubsan
Browse files Browse the repository at this point in the history
Closes #13
  • Loading branch information
mephi42 committed Aug 12, 2024
1 parent c2a2ebf commit 1130a5a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
run: PATH=/usr/lib/ccache:$PATH ./ci
--skip-repair
-DVALGRIND_CONFIGURE_FLAGS=--disable-dependency-tracking
--sanitize

- name: Smoke test
run: python3 -m pip install --user dist/wheelhouse/*.whl &&
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jobs:
run: PATH=/usr/lib/ccache:$PATH ./ci
--skip-repair
-DVALGRIND_CONFIGURE_FLAGS=--disable-dependency-tracking
--sanitize

- name: Smoke test
run: python3 -m pip install --user dist/wheelhouse/*.whl &&
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ target_compile_options(
-Wconversion
-Wdate-time
-Wformat-security
-Wno-maybe-uninitialized
-pedantic
-Werror
-fstack-protector-strong
Expand Down
21 changes: 18 additions & 3 deletions ci
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def get_python_version(python):
)


def run_in_venv(venv, args):
def run_in_venv(venv, args, env=None):
subprocess.check_call(
[os.path.join(basedir, "run-in-venv"), venv, *args], cwd=basedir
[os.path.join(basedir, "run-in-venv"), venv, *args], cwd=basedir, env=env
)


Expand Down Expand Up @@ -142,6 +142,7 @@ def main():
"--wheel-dir",
default=os.path.join(basedir, "dist", "wheelhouse"),
)
parser.add_argument("--sanitize", action="store_true")
args, build_args = parser.parse_known_args()
if args.host != platform.machine():
build_args.extend(
Expand All @@ -150,6 +151,8 @@ def main():
f"-DCMAKE_SYSTEM_PROCESSOR={args.host}",
)
)
if args.sanitize:
build_args.append("-DCMAKE_CXX_FLAGS=-fsanitize=address,undefined")
build = os.path.join(basedir, "build", f"{platform.system()}-{args.host}")
build_prefix = "" if args.host_python is None else "build-"
cross_prefix = "" if args.host_python is None else "cross-"
Expand All @@ -166,7 +169,19 @@ def main():
*build_args,
],
)
run_in_venv(venv, ["python", "-m", "unittest", "discover"])
if args.sanitize:
test_env = {
**os.environ,
"ASAN_OPTIONS": "detect_leaks=0",
"LD_PRELOAD": subprocess.check_output(
[os.environ.get("CC", "cc"), "-print-file-name=libasan.so"]
)
.strip()
.decode(),
}
else:
test_env = None
run_in_venv(venv, ["python", "-m", "unittest", "discover"], env=test_env)
build_wheel(
venv,
args.build_type,
Expand Down

0 comments on commit 1130a5a

Please sign in to comment.