Skip to content

Commit 94ba3ff

Browse files
committed
Add simpler sanitizer test
Signed-off-by: Evgeny Malygin <[email protected]>
1 parent 8c8af57 commit 94ba3ff

File tree

3 files changed

+49
-68
lines changed

3 files changed

+49
-68
lines changed

.github/workflows/dependencies.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ on:
1212
- cron: "10 0 * * *"
1313

1414
concurrency:
15-
group: deps-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
16-
cancel-in-progress: true
15+
group: global
16+
cancel-in-progress: false
1717

1818
jobs:
1919
build_dependencies:

.github/workflows/sanitize.yaml

+22-66
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,36 @@
1-
name: Sanitize with AddressSanitizer, MemorySanitizer, ThreadSanitizer and UndefinedBehaviorSanitizer.
1+
name: Sanitize
22

33
on:
44
pull_request_review:
55
types: [submitted]
6+
pull_request:
7+
branches:
8+
- main
69

710
concurrency:
811
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
912
cancel-in-progress: true
1013

1114
jobs:
12-
build_dependencies:
13-
name: Build deps [ubuntu]
14-
runs-on: ubuntu-latest
15-
if: github.event.review.state == 'APPROVED'
15+
get_dependencies:
16+
name: "Dependencies"
17+
uses: ./.github/workflows/dependencies.yaml
18+
19+
build_and_run_sanitizer:
20+
name: ${{ matrix.mode }}
21+
needs: get_dependencies
22+
strategy:
23+
matrix:
24+
mode: ["asan", "msan", "tsan", "ubsan"]
25+
fail-fast: false
26+
runs-on: ubuntu-22.04
1627
steps:
1728
- uses: actions/checkout@v4
18-
- name: Get dependencies hash
19-
id: get-hash
20-
run: echo "deps_hash=`cat docker/build_deps.sh | shasum`" >> $GITHUB_OUTPUT
21-
- name: Cache lookup
22-
uses: actions/cache/restore@v4
23-
id: cache-lookup
24-
with:
25-
path: deps
26-
key: deps-${{ steps.get-hash.outputs.deps_hash }}
27-
lookup-only: true
28-
- name: Set up dependencies
29-
if: steps.cache-lookup.outputs.cache-hit != 'true'
30-
run: |
31-
sudo apt-get update
32-
sudo apt-get install -qy build-essential \
33-
gdb \
34-
curl \
35-
python3.10 \
36-
python3-pip \
37-
cmake \
38-
ninja-build \
39-
pkg-config \
40-
bison \
41-
libfl-dev \
42-
libbenchmark-dev \
43-
libgmock-dev \
44-
libz-dev
45-
- name: Fetch & Build non packaged dependencies
46-
if: steps.cache-lookup.outputs.cache-hit != 'true'
47-
run: |
48-
mkdir -p deps
49-
cd deps
50-
../docker/build_deps.sh
51-
- name: Cache save
52-
if: steps.cache-lookup.outputs.cache-hit != 'true'
53-
uses: actions/cache/save@v4
29+
- uses: actions/cache/restore@v4
5430
with:
5531
path: deps
56-
key: deps-${{ steps.get-hash.outputs.deps_hash }}
57-
58-
run_asan:
59-
needs: build_dependencies
60-
uses: ./.github/workflows/sanitizer-check.yaml
61-
with:
62-
sanitizer-name: 'asan'
63-
64-
run_msan:
65-
needs: build_dependencies
66-
uses: ./.github/workflows/sanitizer-check.yaml
67-
with:
68-
sanitizer-name: 'msan'
69-
70-
run_tsan:
71-
needs: build_dependencies
72-
uses: ./.github/workflows/sanitizer-check.yaml
73-
with:
74-
sanitizer-name: 'tsan'
75-
76-
run_ubsan:
77-
needs: build_dependencies
78-
uses: ./.github/workflows/sanitizer-check.yaml
79-
with:
80-
sanitizer-name: 'ubsan'
32+
key: ${{ needs.get_dependencies.outputs.cache_key }}
33+
- name: Build [${{ matrix.mode }}]
34+
run: ${{ github.workspace }}/.github/workflows/sanitizers/build_sanitizer.sh ${{ matrix.mode }}
35+
- name: UT [c++,${{ matrix.mode }}]
36+
run: ${{ github.workspace }}/cmake.bld/Linux/run-unittests.sh

src/groups/mqb/mqbc/mqbc_clusterstate.t.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,30 @@ static void test1_partitionIdExtractor()
6969
}
7070
}
7171

72+
static void test2_sanitizer()
73+
{
74+
bslma::Allocator *alloc = bmqtst::TestHelperUtil::allocator();
75+
76+
const char pattern[] = "^\\S+\\.([0-9]+)\\.\\S+\\.\\S+$";
77+
78+
bdlpcre::RegEx regex(alloc);
79+
bsl::string error(alloc);
80+
size_t errorOffset;
81+
BSLA_MAYBE_UNUSED const int rc = regex.prepare(
82+
&error,
83+
&errorOffset,
84+
pattern,
85+
bdlpcre::RegEx::k_FLAG_JIT);
86+
BMQTST_ASSERT_EQ(rc, 0);
87+
BMQTST_ASSERT(regex.isPrepared());
88+
89+
bsl::string str("test.123.test.test", alloc);
90+
bsl::vector<bslstl::StringRef> result(alloc);
91+
const int rc = regex.match(&result,
92+
str.data(),
93+
str.length());
94+
}
95+
7296
// ============================================================================
7397
// MAIN PROGRAM
7498
// ----------------------------------------------------------------------------
@@ -79,6 +103,7 @@ int main(int argc, char* argv[])
79103

80104
switch (_testCase) {
81105
case 0:
106+
case 2: test2_sanitizer(); break;
82107
case 1: test1_partitionIdExtractor(); break;
83108
default: {
84109
cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl;

0 commit comments

Comments
 (0)