mirror of
https://github.com/boostorg/mysql.git
synced 2025-05-12 14:11:41 +00:00
Added basic memcheck
This commit is contained in:
parent
30c22f1279
commit
767b79a6f6
@ -93,3 +93,5 @@ endif()
|
||||
if(_MYSQL_TESTING_ENABLED)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
|
||||
|
2
CTestConfig.cmake
Normal file
2
CTestConfig.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE ${CMAKE_SOURCE_DIR}/test/common/valgrind_suppressions.txt)
|
||||
set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "--error-exitcode=1")
|
6
TODO.txt
6
TODO.txt
@ -1,6 +1,9 @@
|
||||
Sanitize
|
||||
Rework tests so they are called directly from CMake
|
||||
Valgrindize
|
||||
Don't run memtest only tests on regular run
|
||||
Make ctest print the memory problems
|
||||
More robust valgrind_make_initialized...
|
||||
Refactor CMake
|
||||
Bad serialize(value.value) somewhere
|
||||
Copy operations for handshake
|
||||
Test zero dates
|
||||
@ -39,6 +42,7 @@ Usability
|
||||
connection::run_sql that hides the resultset concept
|
||||
Consider if header-only is a good idea
|
||||
Technical debt
|
||||
Formatting
|
||||
Random input tests
|
||||
Code coverage
|
||||
Test dashboard
|
||||
|
@ -47,3 +47,7 @@ foreach(EXAMPLE_NAME ${MYSQL_EXAMPLES})
|
||||
set_tests_properties(${TEST_NAME} PROPERTIES FIXTURES_REQUIRED mysql_examples_fixture)
|
||||
endforeach()
|
||||
|
||||
set_tests_properties(
|
||||
mysql_example_query_async_coroutines
|
||||
PROPERTIES LABELS "NoMemcheck"
|
||||
)
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "boost/mysql/detail/protocol/constants.hpp"
|
||||
#include <boost/asio/yield.hpp>
|
||||
|
||||
#include <valgrind/memcheck.h>
|
||||
|
||||
namespace boost {
|
||||
namespace mysql {
|
||||
namespace detail {
|
||||
@ -22,6 +24,11 @@ inline std::uint32_t compute_size_to_write(
|
||||
));
|
||||
}
|
||||
|
||||
inline void mark_as_initialized(boost::asio::const_buffer buff)
|
||||
{
|
||||
VALGRIND_MAKE_MEM_DEFINED(buff.data(), buff.size());
|
||||
}
|
||||
|
||||
} // detail
|
||||
} // mysql
|
||||
} // boost
|
||||
@ -170,11 +177,13 @@ void boost::mysql::detail::channel<AsyncStream>::read(
|
||||
do
|
||||
{
|
||||
read_impl(boost::asio::buffer(header_buffer_), code);
|
||||
mark_as_initialized(boost::asio::buffer(header_buffer_));
|
||||
if (code) return;
|
||||
code = process_header_read(size_to_read);
|
||||
if (code) return;
|
||||
buffer.resize(buffer.size() + size_to_read);
|
||||
read_impl(boost::asio::buffer(buffer.data() + transferred_size, size_to_read), code);
|
||||
mark_as_initialized(boost::asio::buffer(buffer.data() + transferred_size, size_to_read));
|
||||
if (code) return;
|
||||
transferred_size += size_to_read;
|
||||
} while (size_to_read == MAX_PACKET_SIZE);
|
||||
@ -263,6 +272,7 @@ boost::mysql::detail::channel<AsyncStream>::async_read(
|
||||
boost::asio::buffer(stream_.header_buffer_),
|
||||
std::move(*this)
|
||||
);
|
||||
mark_as_initialized(boost::asio::buffer(stream_.header_buffer_));
|
||||
|
||||
code = stream_.process_header_read(size_to_read);
|
||||
if (code)
|
||||
@ -277,6 +287,7 @@ boost::mysql::detail::channel<AsyncStream>::async_read(
|
||||
boost::asio::buffer(buffer_.data() + total_transferred_size_, size_to_read),
|
||||
std::move(*this)
|
||||
);
|
||||
mark_as_initialized(boost::asio::buffer(buffer_.data() + total_transferred_size_, bytes_transferred));
|
||||
|
||||
total_transferred_size_ += bytes_transferred;
|
||||
} while (bytes_transferred == MAX_PACKET_SIZE);
|
||||
|
@ -98,6 +98,17 @@ add_test(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/mysql_integrationtests
|
||||
"--gtest_filter=-*RequiresSha256*" # Exclude anything using SHA256
|
||||
)
|
||||
set_tests_properties(
|
||||
mysql_integrationtests
|
||||
PROPERTIES LABELS "NoMemcheck"
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME mysql_integrationtests_memcheck
|
||||
COMMAND
|
||||
${CMAKE_CURRENT_BINARY_DIR}/mysql_integrationtests
|
||||
"--gtest_filter=-*RequiresSha256*:*sslrequire*:*coroutine*"
|
||||
)
|
||||
|
||||
if (NOT DEFINED ENV{MYSQL_SKIP_DB_SETUP})
|
||||
add_test(
|
||||
@ -116,6 +127,10 @@ if (NOT DEFINED ENV{MYSQL_SKIP_DB_SETUP})
|
||||
mysql_integrationtests
|
||||
PROPERTIES FIXTURES_REQUIRED mysql_integrationtests_setup
|
||||
)
|
||||
set_tests_properties(
|
||||
mysql_integrationtests_memcheck
|
||||
PROPERTIES FIXTURES_REQUIRED mysql_integrationtests_setup
|
||||
)
|
||||
endif()
|
||||
|
||||
# SHA256 tests
|
||||
@ -144,4 +159,11 @@ if (DEFINED ENV{MYSQL_HAS_SHA256})
|
||||
mysql_integrationtests_sha256
|
||||
PROPERTIES FIXTURES_REQUIRED mysql_integrationtests_sha256_fixture
|
||||
)
|
||||
|
||||
set_tests_properties(
|
||||
mysql_integrationtests_sha256
|
||||
mysql_integrationtests_sha256_setup
|
||||
PROPERTIES LABELS "NoMemcheck"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
105
test/common/valgrind_suppressions.txt
Normal file
105
test/common/valgrind_suppressions.txt
Normal file
@ -0,0 +1,105 @@
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Cond
|
||||
...
|
||||
obj:/*/libssl.so*
|
||||
...
|
||||
}
|
||||
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Value8
|
||||
...
|
||||
obj:/*/libssl.so*
|
||||
...
|
||||
}
|
||||
|
||||
{
|
||||
libssl_internal_threads
|
||||
Memcheck:Cond
|
||||
...
|
||||
obj:/*libcrypto.so*
|
||||
}
|
||||
|
||||
{
|
||||
libssl_internal_threads
|
||||
Memcheck:Value8
|
||||
...
|
||||
obj:/*libcrypto.so*
|
||||
}
|
||||
|
||||
{
|
||||
asio_ssl_handshake_sync
|
||||
Memcheck:Param
|
||||
sendmsg(msg.msg_iov[0])
|
||||
...
|
||||
fun:_ZN5boost4asio3ssl6stream*handshake*
|
||||
fun:_ZN5boost5mysql6detail7channel*ssl_handshake*
|
||||
...
|
||||
}
|
||||
|
||||
{
|
||||
asio_ssl_handshake_async
|
||||
Memcheck:Param
|
||||
sendmsg(msg.msg_iov[0])
|
||||
...
|
||||
fun:_ZN5boost4asio3ssl6detail5io_op*
|
||||
fun:_ZN5boost4asio3ssl6detail8async_io*
|
||||
}
|
||||
|
||||
{
|
||||
asio_ssl_handshake_async
|
||||
Memcheck:Param
|
||||
sendmsg(msg.msg_iov[0])
|
||||
...
|
||||
fun:_ZN5boost4asio*async_write_some*ssl*io_op*handshake_op*
|
||||
}
|
||||
|
||||
{
|
||||
gtest_print_nonprintable_object
|
||||
Memcheck:Value8
|
||||
...
|
||||
fun:_ZN7testing9internal220PrintBytesInObjectToEPKhmPSo
|
||||
...
|
||||
}
|
||||
|
||||
{
|
||||
gtest_print_nonprintable_object
|
||||
Memcheck:Cond
|
||||
...
|
||||
fun:_ZN7testing9internal220PrintBytesInObjectToEPKhmPSo
|
||||
...
|
||||
}
|
||||
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Cond
|
||||
...
|
||||
obj:/*python3*
|
||||
...
|
||||
}
|
||||
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Value8
|
||||
...
|
||||
obj:/*python3*
|
||||
...
|
||||
}
|
||||
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Addr4
|
||||
...
|
||||
obj:/*python3*
|
||||
...
|
||||
}
|
||||
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: all
|
||||
...
|
||||
obj:/*python3*
|
||||
...
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user