Skip to content

Commit

Permalink
add test with ASAN (#1118)
Browse files Browse the repository at this point in the history
  • Loading branch information
satoren authored Jul 13, 2023
1 parent af5a515 commit 15cdc14
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 9 deletions.
5 changes: 5 additions & 0 deletions doc/Building.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ Rewrites mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/

Builds and runs the `mediasoup-worker-test` binary at `worker/out/Release/` (or at `worker/out/Debug/` if the "MEDIASOUP_BUILDTYPE" environment variable is set to "Debug"), which uses [Catch2](https://github.com/catchorg/Catch2) to run test units located at `worker/test/` folder.


### 'make test-asan'

Run test with Address Sanitizer.

### `make tidy`

Runs [clang-tidy](http://clang.llvm.org/extra/clang-tidy/) and performs C++ code checks following `worker/.clang-tidy` rules.
Expand Down
6 changes: 6 additions & 0 deletions worker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ endif
lint \
format \
test \
test-asan \
tidy \
fuzzer \
fuzzer-run-all \
Expand Down Expand Up @@ -225,6 +226,11 @@ else
$(BUILD_DIR)/mediasoup-worker-test --invisibles --use-colour=yes $(MEDIASOUP_TEST_TAGS)
endif

test-asan: setup
$(MESON) compile -C $(BUILD_DIR) -j $(CORES) mediasoup-worker-test-asan
$(MESON) install -C $(BUILD_DIR) --no-rebuild --tags mediasoup-worker-test-asan
ASAN_OPTIONS=detect_leaks=1 $(BUILD_DIR)/mediasoup-worker-test-asan --invisibles --use-colour=yes $(MEDIASOUP_TEST_TAGS)

tidy:
$(PYTHON) ./scripts/clang-tidy.py \
-clang-tidy-binary=./scripts/node_modules/.bin/clang-tidy \
Expand Down
49 changes: 40 additions & 9 deletions worker/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,7 @@ executable(
cpp_args: cpp_args + ['-DMS_EXECUTABLE'],
)

mediasoup_worker_test = executable(
'mediasoup-worker-test',
build_by_default: false,
install: true,
install_tag: 'mediasoup-worker-test',
dependencies: dependencies + [
catch2_proj.get_variable('catch2_dep'),
],
sources: common_sources + [
test_sources = [
'test/src/tests.cpp',
'test/src/PayloadChannel/TestPayloadChannelNotification.cpp',
'test/src/PayloadChannel/TestPayloadChannelRequest.cpp',
Expand Down Expand Up @@ -333,7 +325,17 @@ mediasoup_worker_test = executable(
'test/src/Utils/TestJson.cpp',
'test/src/Utils/TestString.cpp',
'test/src/Utils/TestTime.cpp',
]

mediasoup_worker_test = executable(
'mediasoup-worker-test',
build_by_default: false,
install: true,
install_tag: 'mediasoup-worker-test',
dependencies: dependencies + [
catch2_proj.get_variable('catch2_dep'),
],
sources: common_sources + test_sources,
include_directories: include_directories(
'include',
'test/include',
Expand All @@ -350,6 +352,35 @@ test(
workdir: meson.project_source_root(),
)

mediasoup_worker_test_asan = executable(
'mediasoup-worker-test-asan',
build_by_default: false,
install: true,
install_tag: 'mediasoup-worker-test-asan',
dependencies: dependencies + [
catch2_proj.get_variable('catch2_dep'),
],
sources: common_sources + test_sources,
include_directories: include_directories(
'include',
'test/include',
),
cpp_args: cpp_args + [
'-DMS_LOG_STD',
'-DMS_TEST',
'-fsanitize=address',
],
link_args: [
'-fsanitize=address',
],
)

test(
'mediasoup-worker-test-asan',
mediasoup_worker_test_asan,
workdir: meson.project_source_root(),
)

executable(
'mediasoup-worker-fuzzer',
build_by_default: false,
Expand Down

0 comments on commit 15cdc14

Please sign in to comment.