Skip to content

Commit a2e8df2

Browse files
authored
Merge a9f45c9 into 2531376
2 parents 2531376 + a9f45c9 commit a2e8df2

File tree

16 files changed

+533
-30
lines changed

16 files changed

+533
-30
lines changed

.github/workflows/clt_nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Nightly tests
2-
run-name: Nightly tests ${{ github.sha }}
2+
run-name: 🌙 Nightly tests ${{ github.sha }}
33

44
on:
55
schedule:

.github/workflows/nightly_dumps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Nightly testing of supported versions of mysqldump and elasticdump
2-
run-name: Nightly tests of mysqldump and elasticdump ${{ github.sha }}
2+
run-name: 🌙 Nightly tests of mysqldump and elasticdump ${{ github.sha }}
33

44
on:
55
schedule:
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Nightly memleaks tests
2+
run-name: 🌙 Nightly memleaks tests ${{ github.sha }}
3+
4+
on:
5+
schedule:
6+
- cron: '00 20 * * *'
7+
push:
8+
paths:
9+
- '.github/workflows/nightly_memleaks.yml'
10+
11+
# cancels the previous workflow run when a new one appears in the same branch (e.g. master or a PR's branch)
12+
concurrency:
13+
group: nightly_memleaks_${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
memleaks:
18+
name: Memleak tests
19+
runs-on: ubuntu-22.04
20+
defaults:
21+
run:
22+
shell: bash
23+
timeout-minutes: 300
24+
container:
25+
image: manticoresearch/manticore_valgrind:jammy
26+
env:
27+
DIAGNOSTIC: 1
28+
VERBOSE: 1
29+
CTEST_CONFIGURATION_TYPE: "RelWithDebInfo"
30+
UNITY_BUILD: 1
31+
CACHEB: "../cache"
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v3
35+
with:
36+
token: ${{ secrets.GITHUB_TOKEN }}
37+
set-safe-directory: true
38+
- name: Check out cache before building
39+
uses: actions/cache/[email protected]
40+
with:
41+
path: cache
42+
key: build_linux_debug_x86_64
43+
- name: memcheck.sh
44+
run: |
45+
mysqld &
46+
bash memcheck.sh
47+
- name: Upload build artifacts
48+
if: always()
49+
continue-on-error: true
50+
uses: manticoresoftware/upload_artifact_with_retries@v4
51+
with:
52+
name: memleaks_${{ github.sha }}
53+
path: build/Testing
54+

cmake/GetVCPKG.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ prepend_prefix ( ${_VCACHE} )
3636
unset ( vcpkg_params )
3737
if (CMAKE_CROSSCOMPILING)
3838
set ( vcpkg_params "--triplet=${_VCARCH}-${_TARGET}" )
39+
set ( ENV{VCPKG_OVERLAY_TRIPLETS} "${MANTICORE_SOURCE_DIR}/dist/build_dockers/cross/triplets" )
3940
endif()
4041

4142
set ( ENV{MANTICORE_SOURCE_DIR} "${MANTICORE_SOURCE_DIR}" )
4243
set ( ENV{VCPKG_DEFAULT_BINARY_CACHE} "${CACHEB}/vcpkg" )
43-
set ( ENV{VCPKG_OVERLAY_TRIPLETS} "${MANTICORE_SOURCE_DIR}/dist/build_dockers/cross/triplets" )
4444

4545
if (NOT EXISTS ENV{VCPKG_DEFAULT_BINARY_CACHE})
4646
file ( MAKE_DIRECTORY "$ENV{VCPKG_DEFAULT_BINARY_CACHE}" )

memcheck.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
# Run memcheck.
3+
# This script can be run on the host, or in the docker
4+
5+
chmod +x valgrind
6+
mkdir -p build
7+
cd build
8+
9+
[[ -z "${CACHEB}" ]] && export CACHEB=../cache
10+
[[ ! -e "${CACHEB}" ]] && mkdir -p ${CACHEB}
11+
[[ -z "${uid}" ]] && export uid=`id -u`
12+
[[ -z "${gid}" ]] && export gid=`id -g`
13+
trap "chown -R $uid:$gid ." EXIT
14+
15+
export CTEST_CONFIGURATION_TYPE=RelWithDebInfo
16+
export CTEST_CMAKE_GENERATOR=Ninja
17+
export XTRA_FLAGS="CMAKE_C_COMPILER=/usr/bin/clang-16;CMAKE_CXX_COMPILER=/usr/bin/clang++-16"
18+
19+
export NO_TESTS=1
20+
time ctest -VV -S ../misc/ctest/memcheck.cmake
21+
src/searchd --mockstack | tail -n +6 > stack.txt
22+
23+
source stack.txt
24+
#export MEMORYCHECK_COMMAND_OPTIONS='--tool=memcheck --leak-check=full --track-origins=yes --time-stamp=yes'
25+
export MANTICORE_THREADS_EX='2/1+2/1'
26+
export NO_TESTS=0
27+
rm -f Testing/Temporary/MemoryChecker.*.log
28+
time ctest -V -S ../misc/ctest/memcheck.cmake
29+
find Testing/Temporary/MemoryChecker.*.log -size 0 -delete
30+
31+
# Analysis of memory leak reports
32+
echo "Analyzing memory leak reports..."
33+
LEAK_FOUND=0
34+
LEAK_PATTERNS=(definitely invalid uninitialized)
35+
36+
# Function to check for memory leaks in a file
37+
check_leaks() {
38+
local file=$1
39+
local test_num=$(basename "$file" | sed -E 's/MemoryChecker\.([0-9]+)\.log/\1/')
40+
41+
for pattern in "${LEAK_PATTERNS[@]}"; do
42+
if grep -i "$pattern" "$file" > /dev/null; then
43+
echo "$pattern DETECTED in test_$test_num"
44+
cat "$file"
45+
LEAK_FOUND=1
46+
fi
47+
done
48+
}
49+
50+
# Process all memory checker log files
51+
for log_file in Testing/Temporary/MemoryChecker.*.log; do
52+
if [ -f "$log_file" ]; then
53+
check_leaks "$log_file"
54+
fi
55+
done
56+
57+
if [ $LEAK_FOUND -eq 1 ]; then
58+
echo "Memory leaks were detected. Check the logs above for details."
59+
exit 1
60+
else
61+
echo "No memory leaks detected."
62+
exit 0
63+
fi

memdocker.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
#Run shell in valgrind docker
3+
4+
# Use environment variable BUILD_DOCKER if set, otherwise use default value
5+
BUILD_DOCKER=${BUILD_DOCKER:-manticoresearch/manticore_valgrind:jammy}
6+
CONFIG=RelWithDebInfo
7+
WORKDIR=/work
8+
9+
docker run --rm -it \
10+
-v $(pwd):$WORKDIR \
11+
-e uid=`id -u` \
12+
-e gid=`id -g` \
13+
-e DIAGNOSTIC=1 \
14+
-e VERBOSE=1 \
15+
-e CACHEB=$CACHEB \
16+
-e CTEST_CONFIGURATION_TYPE=$CONFIG \
17+
-e UNITY_BUILD=1 \
18+
$BUILD_DOCKER /bin/bash

misc/ctest/memcheck.cmake

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ set ( LIBS_BUNDLE "$ENV{LIBS_BUNDLE}" )
88
set ( CTEST_REGEX "$ENV{CTEST_REGEX}" )
99
set ( SEARCHD_CLI_EXTRA "$ENV{SEARCHD_CLI_EXTRA}" )
1010
set ( XTRA_FLAGS "$ENV{XTRA_FLAGS}" )
11+
set ( NO_TESTS "$ENV{NO_TESTS}" )
12+
set ( UNITY_BUILD "$ENV{UNITY_BUILD}" )
1113
set_property ( GLOBAL PROPERTY Label P$ENV{CI_PIPELINE_ID} J$ENV{CI_JOB_ID} )
1214

1315
if (NOT CTEST_CMAKE_GENERATOR)
@@ -25,7 +27,10 @@ endif ()
2527
# just reference line for manual configuration
2628
# cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_ODBC=1 -DWITH_RE2=1 -DWITH_STEMMER=1 -DWITH_POSTGRESQL=0 -DWITH_EXPAT=1 -DWITH_SSL=1 -DTEST_SPECIAL_EXTERNAL=1 -DDISABLE_MEMROUTINES=1 -DCMAKE_C_COMPILER=/usr/bin/clang-12 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-12 ..
2729
# common test options
28-
set ( CONFIG_OPTIONS "WITH_ODBC=1;WITH_RE2=1;WITH_STEMMER=1;WITH_POSTGRESQL=0;WITH_EXPAT=1;WITH_SSL=1;TEST_SPECIAL_EXTERNAL=1;DISABLE_MEMROUTINES=1" )
30+
set ( CONFIG_OPTIONS "WITH_ODBC=1;WITH_RE2=1;WITH_STEMMER=1;WITH_POSTGRESQL=0;WITH_EXPAT=1;WITH_SSL=1;TEST_SPECIAL_EXTERNAL=1;DISABLE_MEMROUTINES=1;DISABLE_PERFETTO=1" )
31+
if (UNITY_BUILD)
32+
LIST ( APPEND CONFIG_OPTIONS "CMAKE_UNITY_BUILD=${UNITY_BUILD}" )
33+
endif ()
2934
set ( CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}/build" )
3035

3136
if ( LIBS_BUNDLE )
@@ -68,15 +73,12 @@ set ( CTEST_CUSTOM_WARNING_EXCEPTION ".*flexsphinx.*" )
6873

6974
# Do the test suite
7075
ctest_start ( "Continuous" )
71-
ctest_update ()
7276
ctest_configure ()
7377
ctest_build ()
7478

75-
if ( CTEST_REGEX )
76-
# ctest_test ( RETURN_VALUE retcode INCLUDE "${CTEST_REGEX}" REPEAT UNTIL_PASS:${RETRIES})
77-
else()
78-
# ctest_test ( RETURN_VALUE retcode REPEAT UNTIL_PASS:${RETRIES})
79-
endif()
79+
if (NO_TESTS)
80+
return ()
81+
endif ()
8082

8183
if ( WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND )
8284
set (ENV{vlg} "${CTEST_MEMORYCHECK_COMMAND}")
@@ -93,8 +95,6 @@ if ( WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND )
9395
endif ()
9496
endif ( WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND )
9597

96-
ctest_submit ()
97-
9898
if ( retcode )
9999
MESSAGE ( STATUS "tests failed with ${retcode} code, but we don't fail as it is memcheck pass" )
100100
endif ()

0 commit comments

Comments
 (0)