Skip to content

Commit

Permalink
[build] Clean up cpp/ unit test build variants
Browse files Browse the repository at this point in the history
- Run unit tests with UBSAN
- And ASAN / GC_EVERY_ALLOC+ASAN as appropriate
  • Loading branch information
Andy C committed Nov 11, 2022
1 parent fd9ee51 commit 4350ec5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
3 changes: 2 additions & 1 deletion build/ninja_lib.py
Expand Up @@ -76,7 +76,8 @@ def log(msg, *args):

SMALL_TEST_MATRIX = [
('cxx', 'asan'),
('clang', 'coverage', '-D CPP_UNIT_TEST'),
('cxx', 'ubsan'),
('clang', 'coverage'),
]


Expand Down
7 changes: 4 additions & 3 deletions cpp/NINJA_subgraph.py
Expand Up @@ -9,9 +9,10 @@

# Some tests use #ifndef CPP_UNIT_TEST to disable circular dependencies on
# generated code
CPP_UNIT = [
CPP_UNIT_MATRIX = [
('cxx', 'dbg', '-D CPP_UNIT_TEST'),
('cxx', 'asan', '-D CPP_UNIT_TEST'),
('cxx', 'ubsan', '-D CPP_UNIT_TEST'),
('clang', 'coverage', '-D CPP_UNIT_TEST'),
]

Expand All @@ -31,7 +32,7 @@ def NinjaGraph(ru):
'//cpp/leaky_core',
'//mycpp/runtime',
],
matrix = CPP_UNIT)
matrix = ninja_lib.SMALL_TEST_MATRIX)

ru.cc_binary(
'cpp/core_test.cc',
Expand Down Expand Up @@ -99,4 +100,4 @@ def NinjaGraph(ru):
'//frontend/arg_types',
'//mycpp/runtime',
],
matrix = CPP_UNIT)
matrix = CPP_UNIT_MATRIX)
18 changes: 11 additions & 7 deletions cpp/TEST.sh
Expand Up @@ -56,19 +56,22 @@ pre-build() {
unit() {
### Run unit tests in this dir; used by test/cpp-unit.sh

run-one-test cpp/gc_binding_test '' ubsan
run-one-test cpp/gc_binding_test '' gcevery
run-one-test cpp/core_test '' gcevery

# Need -D CPP_UNIT_TEST
run-one-test cpp/core_test '' ubsan
run-one-test cpp/core_test '' gcevery

run-special-test cpp/leaky_core_test '' ''
run-special-test cpp/leaky_core_test '' asan
# Doesn't run with GC_EVERY_ALLOC
run-one-test cpp/leaky_core_test '' ubsan
run-one-test cpp/leaky_core_test '' asan

run-special-test cpp/leaky_flag_spec_test '' ''
# Need -D CPP_UNIT_TEST
run-special-test cpp/leaky_flag_spec_test '' ubsan
run-special-test cpp/leaky_flag_spec_test '' asan

# Runs in different dir
leaky-binding-test '' ''
leaky-binding-test '' ubsan
leaky-binding-test '' asan
}

Expand All @@ -79,8 +82,9 @@ coverage() {

run-one-test cpp/gc_binding_test clang coverage
run-one-test cpp/core_test clang coverage
run-one-test cpp/leaky_core_test clang coverage

run-special-test cpp/leaky_core_test clang coverage
# Need -D CPP_UNIT_TEST
run-special-test cpp/leaky_flag_spec_test clang coverage

leaky-binding-test clang coverage
Expand Down

0 comments on commit 4350ec5

Please sign in to comment.