diff --git a/test/integration/close_connection.cpp b/test/integration/close_connection.cpp index da03a540..2cc7b5ff 100644 --- a/test/integration/close_connection.cpp +++ b/test/integration/close_connection.cpp @@ -15,11 +15,25 @@ using boost::mysql::error_code; namespace { -auto net_samples = create_network_samples({"tcp_sync_errc", "tcp_async_callback"}); +auto net_samples = create_network_samples({ + "tcp_sync_errc", + "tcp_async_callback", + "tcp_ssl_sync_errc", + "tcp_ssl_async_callback", +}); BOOST_AUTO_TEST_SUITE(test_close_connection) -BOOST_MYSQL_NETWORK_TEST(active_connection, network_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(success, network_fixture, all_network_samples()) +{ + setup_and_connect(sample.net); + + // Close successful + conn->close().validate_no_error(); + BOOST_TEST(!conn->is_open()); +} + +BOOST_MYSQL_NETWORK_TEST(double_close, network_fixture, net_samples) { setup_and_connect(sample.net); diff --git a/test/integration/close_statement.cpp b/test/integration/close_statement.cpp index d444d588..851599ad 100644 --- a/test/integration/close_statement.cpp +++ b/test/integration/close_statement.cpp @@ -11,11 +11,9 @@ using namespace boost::mysql::test; namespace { -auto net_samples = create_network_samples({"tcp_sync_errc", "tcp_async_callback"}); - BOOST_AUTO_TEST_SUITE(test_close_statement) -BOOST_MYSQL_NETWORK_TEST(success, network_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(success, network_fixture, all_network_samples()) { setup_and_connect(sample.net); diff --git a/test/integration/connect.cpp b/test/integration/connect.cpp index ec9f83a0..4cbc1975 100644 --- a/test/integration/connect.cpp +++ b/test/integration/connect.cpp @@ -13,16 +13,20 @@ using boost::mysql::error_code; namespace { -auto net_samples = create_network_samples( - {"tcp_sync_errc", "tcp_sync_exc", "tcp_async_callback", "tcp_async_callback_noerrinfo"} -); +auto net_samples = create_network_samples({ + "tcp_sync_errc", + "tcp_async_callback", + "tcp_ssl_sync_errc", + "tcp_ssl_async_callback", +}); BOOST_AUTO_TEST_SUITE(test_connect) // The OK case is already being tested by all other integ tests // that require the connection to be connected -BOOST_MYSQL_NETWORK_TEST(physical_error, network_fixture, net_samples) +// All network variants coverage test +BOOST_MYSQL_NETWORK_TEST(physical_error, network_fixture, all_network_samples()) { setup(sample.net); @@ -32,6 +36,7 @@ BOOST_MYSQL_NETWORK_TEST(physical_error, network_fixture, net_samples) BOOST_TEST(!conn->is_open()); } +// TODO: this should be a unit test BOOST_MYSQL_NETWORK_TEST(physical_ok_handshake_error, network_fixture, net_samples) { setup(sample.net); diff --git a/test/integration/execute_statement.cpp b/test/integration/execute_statement.cpp index a92a0d77..60236e48 100644 --- a/test/integration/execute_statement.cpp +++ b/test/integration/execute_statement.cpp @@ -25,27 +25,16 @@ using boost::mysql::make_execute_params; namespace { -auto net_samples = create_network_samples( - {"tcp_sync_errc", "tcp_sync_exc", "tcp_async_callback", "tcp_async_callback_noerrinfo"} -); +auto net_samples = create_network_samples({ + "tcp_sync_errc", + "tcp_async_callback", +}); BOOST_AUTO_TEST_SUITE(test_execute_statement) BOOST_AUTO_TEST_SUITE(iterator) -BOOST_MYSQL_NETWORK_TEST(ok_no_params, network_fixture, net_samples) -{ - setup_and_connect(sample.net); - // Prepare - conn->prepare_statement("SELECT * FROM empty_table", *stmt).validate_no_error(); - - // Execute - std::forward_list params; - stmt->execute_params(make_execute_params(params), *result).validate_no_error(); - BOOST_TEST(result->base().valid()); -} - -BOOST_MYSQL_NETWORK_TEST(ok_with_params, network_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(success, network_fixture, all_network_samples()) { setup_and_connect(sample.net); @@ -59,6 +48,7 @@ BOOST_MYSQL_NETWORK_TEST(ok_with_params, network_fixture, net_samples) BOOST_TEST(result->base().valid()); } +// TODO: this should be a unit test BOOST_MYSQL_NETWORK_TEST(mismatched_num_params, network_fixture, net_samples) { setup_and_connect(sample.net); @@ -73,7 +63,7 @@ BOOST_MYSQL_NETWORK_TEST(mismatched_num_params, network_fixture, net_samples) .validate_error(errc::wrong_num_params, {"param", "2", "1", "statement", "execute"}); } -BOOST_MYSQL_NETWORK_TEST(server_error, network_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(server_error, network_fixture, all_network_samples()) { setup_and_connect(sample.net); start_transaction(); @@ -98,7 +88,7 @@ BOOST_AUTO_TEST_SUITE_END() // collection is a wrapper around execute_params, so only // a subset of tests are run here BOOST_AUTO_TEST_SUITE(collection) -BOOST_MYSQL_NETWORK_TEST(ok, network_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(ok, network_fixture, all_network_samples()) { setup_and_connect(sample.net); @@ -111,7 +101,7 @@ BOOST_MYSQL_NETWORK_TEST(ok, network_fixture, net_samples) BOOST_TEST(result->base().valid()); } -BOOST_MYSQL_NETWORK_TEST(error, network_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(error, network_fixture, all_network_samples()) { setup_and_connect(sample.net); start_transaction(); @@ -131,7 +121,7 @@ BOOST_MYSQL_NETWORK_TEST(error, network_fixture, net_samples) ); } -// Other containers. We can't use the type-erased functions here +// Other containers BOOST_FIXTURE_TEST_CASE(no_statement_params_variable, tcp_network_fixture) { boost::mysql::tcp_statement stmt; diff --git a/test/integration/handshake.cpp b/test/integration/handshake.cpp index 0a2443fb..fbe4ae8c 100644 --- a/test/integration/handshake.cpp +++ b/test/integration/handshake.cpp @@ -34,26 +34,22 @@ using boost::mysql::tcp_ssl_resultset; namespace { -auto net_samples_ssl = create_network_samples( - {"tcp_ssl_sync_errc", - "tcp_ssl_sync_exc", - "tcp_ssl_async_callback", - "tcp_ssl_async_callback_noerrinfo"} -); +auto net_samples_ssl = create_network_samples({ + "tcp_ssl_sync_errc", + "tcp_ssl_async_callback", +}); -auto net_samples_nossl = create_network_samples( - {"tcp_sync_errc", "tcp_sync_exc", "tcp_async_callback", "tcp_async_callback_noerrinfo"} -); +auto net_samples_nossl = create_network_samples({ + "tcp_sync_errc", + "tcp_async_callback", +}); -// Subset of plaintext variants, to reduce test runtime -auto net_samples_all = create_network_samples( - {"tcp_ssl_sync_errc", - "tcp_ssl_sync_exc", - "tcp_ssl_async_callback", - "tcp_ssl_async_callback_noerrinfo", - "tcp_sync_errc", - "tcp_async_callback"} -); +auto net_samples_both = create_network_samples({ + "tcp_ssl_sync_errc", + "tcp_ssl_async_callback", + "tcp_sync_exc", + "tcp_async_callback_noerrinfo", +}); BOOST_AUTO_TEST_SUITE(test_handshake) @@ -89,21 +85,21 @@ struct handshake_fixture : network_fixture // mysql_native_password BOOST_AUTO_TEST_SUITE(mysql_native_password) -BOOST_MYSQL_NETWORK_TEST(regular_user, handshake_fixture, net_samples_all) +BOOST_MYSQL_NETWORK_TEST(regular_user, handshake_fixture, net_samples_both) { setup_and_physical_connect(sample.net); set_credentials("mysqlnp_user", "mysqlnp_password"); do_handshake_ok(); } -BOOST_MYSQL_NETWORK_TEST(empty_password, handshake_fixture, net_samples_all) +BOOST_MYSQL_NETWORK_TEST(empty_password, handshake_fixture, net_samples_both) { setup_and_physical_connect(sample.net); set_credentials("mysqlnp_empty_password_user", ""); do_handshake_ok(); } -BOOST_MYSQL_NETWORK_TEST(bad_password, handshake_fixture, net_samples_all) +BOOST_MYSQL_NETWORK_TEST(bad_password, handshake_fixture, net_samples_both) { setup_and_physical_connect(sample.net); set_credentials("mysqlnp_user", "bad_password"); @@ -149,7 +145,7 @@ BOOST_MYSQL_NETWORK_TEST(ssl_on_cache_hit, caching_sha2_fixture, net_samples_ssl do_handshake_ok_ssl(); } -BOOST_MYSQL_NETWORK_TEST(ssl_off_cache_hit, caching_sha2_fixture, net_samples_all) +BOOST_MYSQL_NETWORK_TEST(ssl_off_cache_hit, caching_sha2_fixture, net_samples_both) { // As we are sending password hashed, it is OK to not have SSL for this setup_and_physical_connect(sample.net); @@ -166,7 +162,7 @@ BOOST_MYSQL_NETWORK_TEST(ssl_on_cache_miss, caching_sha2_fixture, net_samples_ss do_handshake_ok_ssl(); } -BOOST_MYSQL_NETWORK_TEST(ssl_off_cache_miss, caching_sha2_fixture, net_samples_all) +BOOST_MYSQL_NETWORK_TEST(ssl_off_cache_miss, caching_sha2_fixture, net_samples_both) { // A cache miss would force us send a plaintext password over // a non-TLS connection, so we fail @@ -185,7 +181,7 @@ BOOST_MYSQL_NETWORK_TEST(empty_password_ssl_on_cache_hit, caching_sha2_fixture, do_handshake_ok_ssl(); } -BOOST_MYSQL_NETWORK_TEST(empty_password_ssl_off_cache_hit, caching_sha2_fixture, net_samples_all) +BOOST_MYSQL_NETWORK_TEST(empty_password_ssl_off_cache_hit, caching_sha2_fixture, net_samples_both) { // Empty passwords are allowed over non-TLS connections setup_and_physical_connect(sample.net); @@ -202,7 +198,7 @@ BOOST_MYSQL_NETWORK_TEST(empty_password_ssl_on_cache_miss, caching_sha2_fixture, do_handshake_ok_ssl(); } -BOOST_MYSQL_NETWORK_TEST(empty_password_ssl_off_cache_miss, caching_sha2_fixture, net_samples_all) +BOOST_MYSQL_NETWORK_TEST(empty_password_ssl_off_cache_miss, caching_sha2_fixture, net_samples_both) { // Empty passwords are allowed over non-TLS connections setup_and_physical_connect(sample.net); @@ -303,23 +299,13 @@ BOOST_MYSQL_NETWORK_TEST(custom_certificate_verification_ok, handshake_fixture, BOOST_AUTO_TEST_SUITE_END() // ssl_certificate_validation // Other handshake tests -BOOST_MYSQL_NETWORK_TEST(no_database, handshake_fixture, net_samples_all) +BOOST_MYSQL_NETWORK_TEST(no_database, handshake_fixture, net_samples_both) { setup_and_physical_connect(sample.net); params.set_database(""); do_handshake_ok(); } -BOOST_MYSQL_NETWORK_TEST(bad_database, handshake_fixture, net_samples_all) -{ - setup_and_physical_connect(sample.net); - params.set_database("bad_database"); - conn->handshake(params).validate_error( - errc::dbaccess_denied_error, - {"database", "bad_database"} - ); -} - BOOST_TEST_DECORATOR(*boost::unit_test::label("sha256")) BOOST_MYSQL_NETWORK_TEST(unknown_auth_plugin, handshake_fixture, net_samples_ssl) { @@ -338,7 +324,7 @@ BOOST_MYSQL_NETWORK_TEST(bad_user, handshake_fixture, net_samples_nossl) conn->handshake(params).validate_any_error(); // may be access denied or unknown auth plugin } -BOOST_MYSQL_NETWORK_TEST(ssl_disable, handshake_fixture, net_samples_all) +BOOST_MYSQL_NETWORK_TEST(ssl_disable, handshake_fixture, net_samples_both) { // Both SSL and non-SSL streams will act as non-SSL streams setup_and_physical_connect(sample.net); @@ -384,6 +370,23 @@ BOOST_MYSQL_NETWORK_TEST(ssl_require_ssl_streams, handshake_fixture, net_samples BOOST_TEST(conn->uses_ssl()); } +// Tests run across all network samples +BOOST_MYSQL_NETWORK_TEST(success, handshake_fixture, all_network_samples()) +{ + setup_and_physical_connect(sample.net); + do_handshake_ok(); +} + +BOOST_MYSQL_NETWORK_TEST(error, handshake_fixture, all_network_samples()) +{ + setup_and_physical_connect(sample.net); + params.set_database("bad_database"); + conn->handshake(params).validate_error( + errc::dbaccess_denied_error, + {"database", "bad_database"} + ); +} + BOOST_AUTO_TEST_SUITE_END() // test_handshake } // namespace diff --git a/test/integration/prepare_statement.cpp b/test/integration/prepare_statement.cpp index cdda53c9..00753afe 100644 --- a/test/integration/prepare_statement.cpp +++ b/test/integration/prepare_statement.cpp @@ -23,22 +23,14 @@ using boost::mysql::tcp_statement; namespace { -auto net_samples = create_network_samples( - {"tcp_sync_errc", "tcp_sync_exc", "tcp_async_callback", "tcp_async_callback_noerrinfo"} -); +auto net_samples = create_network_samples({ + "tcp_sync_errc", + "tcp_async_callback", +}); BOOST_AUTO_TEST_SUITE(test_prepare_statement) -BOOST_MYSQL_NETWORK_TEST(ok_no_params, network_fixture, net_samples) -{ - setup_and_connect(sample.net); - conn->prepare_statement("SELECT * FROM empty_table", *stmt).validate_no_error(); - BOOST_TEST_REQUIRE(stmt->base().valid()); - BOOST_TEST(stmt->base().id() > 0u); - BOOST_TEST(stmt->base().num_params() == 0u); -} - -BOOST_MYSQL_NETWORK_TEST(ok_with_params, network_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(success, network_fixture, all_network_samples()) { setup_and_connect(sample.net); conn->prepare_statement("SELECT * FROM empty_table WHERE id IN (?, ?)", *stmt) @@ -48,13 +40,22 @@ BOOST_MYSQL_NETWORK_TEST(ok_with_params, network_fixture, net_samples) BOOST_TEST(stmt->base().num_params() == 2u); } -BOOST_MYSQL_NETWORK_TEST(invalid_statement, network_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(error, network_fixture, all_network_samples()) { setup_and_connect(sample.net); conn->prepare_statement("SELECT * FROM bad_table WHERE id IN (?, ?)", *stmt) .validate_error(errc::no_such_table, {"table", "doesn't exist", "bad_table"}); } +BOOST_MYSQL_NETWORK_TEST(no_params, network_fixture, net_samples) +{ + setup_and_connect(sample.net); + conn->prepare_statement("SELECT * FROM empty_table", *stmt).validate_no_error(); + BOOST_TEST_REQUIRE(stmt->base().valid()); + BOOST_TEST(stmt->base().id() > 0u); + BOOST_TEST(stmt->base().num_params() == 0u); +} + BOOST_AUTO_TEST_SUITE_END() // test_prepare_statement } // namespace diff --git a/test/integration/query.cpp b/test/integration/query.cpp index 0f7d09f7..00bd60de 100644 --- a/test/integration/query.cpp +++ b/test/integration/query.cpp @@ -16,9 +16,10 @@ using boost::mysql::errc; namespace { -auto net_samples = create_network_samples( - {"tcp_sync_errc", "tcp_sync_exc", "tcp_async_callback", "tcp_async_callback_noerrinfo"} -); +auto net_samples = create_network_samples({ + "tcp_sync_errc", + "tcp_async_callback", +}); BOOST_AUTO_TEST_SUITE(test_query) @@ -81,7 +82,7 @@ BOOST_MYSQL_NETWORK_TEST(update_ok, network_fixture, net_samples) BOOST_TEST(updated_value == 52); // initial value was 42 } -BOOST_MYSQL_NETWORK_TEST(select_ok, network_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(select_ok, network_fixture, all_network_samples()) { setup_and_connect(sample.net); @@ -92,7 +93,7 @@ BOOST_MYSQL_NETWORK_TEST(select_ok, network_fixture, net_samples) this->validate_2fields_meta(result->base(), "empty_table"); } -BOOST_MYSQL_NETWORK_TEST(select_error, network_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(select_error, network_fixture, all_network_samples()) { setup_and_connect(sample.net); auto netresult = conn->query("SELECT field_varchar, field_bad FROM one_row_table", *result); diff --git a/test/integration/quit_connection.cpp b/test/integration/quit_connection.cpp index 4fdc5a5d..4df3a2f7 100644 --- a/test/integration/quit_connection.cpp +++ b/test/integration/quit_connection.cpp @@ -12,11 +12,9 @@ using boost::mysql::error_code; namespace { -auto net_samples = create_network_samples({"tcp_sync_errc", "tcp_async_callback"}); - BOOST_AUTO_TEST_SUITE(test_quit_connection) -BOOST_MYSQL_NETWORK_TEST(active_connection, network_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(success, network_fixture, all_network_samples()) { setup_and_connect(sample.net); diff --git a/test/integration/reconnect.cpp b/test/integration/reconnect.cpp index 75874bd2..fe8f98e4 100644 --- a/test/integration/reconnect.cpp +++ b/test/integration/reconnect.cpp @@ -19,10 +19,17 @@ using namespace boost::mysql::test; namespace { -auto net_samples_nossl = create_network_samples({"tcp_sync_errc", "tcp_async_callback"}); -auto net_samples_all = create_network_samples( - {"tcp_sync_errc", "tcp_async_callback", "tcp_ssl_sync_errc", "tcp_ssl_async_callback"} -); +auto net_samples_nossl = create_network_samples({ + "tcp_sync_errc", + "tcp_async_callback", +}); + +auto net_samples_all = create_network_samples({ + "tcp_sync_errc", + "tcp_async_callback", + "tcp_ssl_sync_errc", + "tcp_ssl_async_callback", +}); BOOST_AUTO_TEST_SUITE(test_reconnect) diff --git a/test/integration/resultset.cpp b/test/integration/resultset.cpp index a2f04b51..52e8578a 100644 --- a/test/integration/resultset.cpp +++ b/test/integration/resultset.cpp @@ -92,13 +92,20 @@ std::ostream& operator<<(std::ostream& os, const resultset_sample& input) return os << static_cast(input) << '_' << input.gen->name(); } -resultset_sample net_samples[] = { +resultset_sample net_samples_subset[] = { resultset_sample(get_variant("tcp_sync_errc"), &text_obj), resultset_sample(get_variant("tcp_async_callback"), &text_obj), resultset_sample(get_variant("tcp_sync_exc"), &binary_obj), resultset_sample(get_variant("tcp_async_callback_noerrinfo"), &binary_obj), }; +std::vector net_samples_all = []() { + std::vector res; + for (auto* var : all_variants()) + res.emplace_back(var, &text_obj); + return res; +}(); + struct resultset_fixture : network_fixture { resultset_generator* gen; @@ -118,7 +125,7 @@ struct resultset_fixture : network_fixture BOOST_AUTO_TEST_SUITE(read_one) -BOOST_MYSQL_NETWORK_TEST(no_results, resultset_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(no_results, resultset_fixture, net_samples_subset) { setup_and_connect(sample); generate("SELECT * FROM empty_table"); @@ -137,7 +144,7 @@ BOOST_MYSQL_NETWORK_TEST(no_results, resultset_fixture, net_samples) validate_eof(*result); } -BOOST_MYSQL_NETWORK_TEST(one_row, resultset_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(one_row, resultset_fixture, net_samples_subset) { setup_and_connect(sample); generate("SELECT * FROM one_row_table"); @@ -157,7 +164,7 @@ BOOST_MYSQL_NETWORK_TEST(one_row, resultset_fixture, net_samples) validate_eof(*result); } -BOOST_MYSQL_NETWORK_TEST(two_rows, resultset_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(two_rows, resultset_fixture, net_samples_all) { setup_and_connect(sample); generate("SELECT * FROM two_rows_table"); @@ -187,7 +194,7 @@ BOOST_AUTO_TEST_SUITE_END() // read_one BOOST_AUTO_TEST_SUITE(read_some) -BOOST_MYSQL_NETWORK_TEST(no_results, resultset_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(no_results, resultset_fixture, net_samples_subset) { setup_and_connect(sample); generate("SELECT * FROM empty_table"); @@ -203,7 +210,7 @@ BOOST_MYSQL_NETWORK_TEST(no_results, resultset_fixture, net_samples) validate_eof(*result); } -BOOST_MYSQL_NETWORK_TEST(one_row, resultset_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(one_row, resultset_fixture, net_samples_subset) { setup_and_connect(sample); generate("SELECT * FROM one_row_table"); @@ -224,7 +231,7 @@ BOOST_MYSQL_NETWORK_TEST(one_row, resultset_fixture, net_samples) validate_eof(*result); } -BOOST_MYSQL_NETWORK_TEST(several_rows, resultset_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(several_rows, resultset_fixture, net_samples_all) { setup_and_connect(sample); generate("SELECT * FROM three_rows_table"); @@ -255,7 +262,7 @@ BOOST_MYSQL_NETWORK_TEST(several_rows, resultset_fixture, net_samples) validate_eof(*result); } -BOOST_MYSQL_NETWORK_TEST(several_rows_single_read, resultset_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(several_rows_single_read, resultset_fixture, net_samples_subset) { // make sure the entire result can be read at once params.set_buffer_config(boost::mysql::buffer_params(4096)); @@ -277,7 +284,7 @@ BOOST_AUTO_TEST_SUITE_END() // read_many BOOST_AUTO_TEST_SUITE(read_all) -BOOST_MYSQL_NETWORK_TEST(no_results, resultset_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(no_results, resultset_fixture, net_samples_subset) { setup_and_connect(sample); generate("SELECT * FROM empty_table"); @@ -293,7 +300,7 @@ BOOST_MYSQL_NETWORK_TEST(no_results, resultset_fixture, net_samples) validate_eof(*result); } -BOOST_MYSQL_NETWORK_TEST(one_row, resultset_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(one_row, resultset_fixture, net_samples_subset) { setup_and_connect(sample); generate("SELECT * FROM one_row_table"); @@ -309,7 +316,7 @@ BOOST_MYSQL_NETWORK_TEST(one_row, resultset_fixture, net_samples) validate_eof(*result); } -BOOST_MYSQL_NETWORK_TEST(several_rows, resultset_fixture, net_samples) +BOOST_MYSQL_NETWORK_TEST(several_rows, resultset_fixture, net_samples_all) { setup_and_connect(sample); generate("SELECT * FROM two_rows_table"); diff --git a/test/integration/statement_lifecycle.cpp b/test/integration/statement_lifecycle.cpp index 970748e8..009847d4 100644 --- a/test/integration/statement_lifecycle.cpp +++ b/test/integration/statement_lifecycle.cpp @@ -15,7 +15,10 @@ using boost::mysql::field_view; namespace { -auto net_samples = create_network_samples({"tcp_sync_errc", "tcp_async_callback"}); +auto net_samples = create_network_samples({ + "tcp_sync_errc", + "tcp_async_callback", +}); BOOST_AUTO_TEST_SUITE(test_statement_lifecycle) diff --git a/test/integration/utils/include/integration_test_common.hpp b/test/integration/utils/include/integration_test_common.hpp index 3f5da9ee..d4caedb4 100644 --- a/test/integration/utils/include/integration_test_common.hpp +++ b/test/integration/utils/include/integration_test_common.hpp @@ -165,6 +165,20 @@ inline std::vector create_network_samples(std::initializer_list< return res; } +inline std::vector create_all_network_samples() +{ + std::vector res; + for (auto* var : all_variants()) + res.emplace_back(var); + return res; +} + +inline const std::vector& all_network_samples() +{ + static std::vector res = create_all_network_samples(); + return res; +} + } // namespace test } // namespace mysql } // namespace boost diff --git a/test/integration/utils/src/async_callback.cpp b/test/integration/utils/src/async_callback.cpp index 901ad37e..0b24a34c 100644 --- a/test/integration/utils/src/async_callback.cpp +++ b/test/integration/utils/src/async_callback.cpp @@ -192,17 +192,17 @@ public: const char* variant_name() const override { return "async_callback"; } }; -async_callback_variant tcp_variant; -async_callback_variant tcp_ssl_variant; -async_callback_variant def_compl_variant; -#if BOOST_ASIO_HAS_LOCAL_SOCKETS -async_callback_variant unix_variant; -#endif - } // namespace void boost::mysql::test::add_async_callback(std::vector& output) { + static async_callback_variant tcp_variant; + static async_callback_variant tcp_ssl_variant; + static async_callback_variant def_compl_variant; +#if BOOST_ASIO_HAS_LOCAL_SOCKETS + static async_callback_variant unix_variant; +#endif + output.push_back(&tcp_variant); output.push_back(&tcp_ssl_variant); output.push_back(&def_compl_variant); diff --git a/test/integration/utils/src/async_callback_noerrinfo.cpp b/test/integration/utils/src/async_callback_noerrinfo.cpp index af40ae5a..8bed9b0a 100644 --- a/test/integration/utils/src/async_callback_noerrinfo.cpp +++ b/test/integration/utils/src/async_callback_noerrinfo.cpp @@ -188,13 +188,12 @@ public: const char* variant_name() const override { return "async_callback_noerrinfo"; } }; -async_callback_noerrinfo_variant tcp; -async_callback_noerrinfo_variant tcp_ssl; - } // namespace void boost::mysql::test::add_async_callback_noerrinfo(std::vector& output) { + static async_callback_noerrinfo_variant tcp; + static async_callback_noerrinfo_variant tcp_ssl; output.push_back(&tcp); output.push_back(&tcp_ssl); } \ No newline at end of file diff --git a/test/integration/utils/src/async_coroutine.cpp b/test/integration/utils/src/async_coroutine.cpp index 720e0a20..44e8c9ab 100644 --- a/test/integration/utils/src/async_coroutine.cpp +++ b/test/integration/utils/src/async_coroutine.cpp @@ -189,13 +189,12 @@ public: const char* variant_name() const override { return "async_coroutine"; } }; -async_coroutine_variant tcp; -async_coroutine_variant tcp_ssl; - } // namespace void boost::mysql::test::add_async_coroutine(std::vector& output) { + static async_coroutine_variant tcp; + static async_coroutine_variant tcp_ssl; output.push_back(&tcp); output.push_back(&tcp_ssl); } diff --git a/test/integration/utils/src/async_coroutinecpp20.cpp b/test/integration/utils/src/async_coroutinecpp20.cpp index 2dd87ad8..9b44db2d 100644 --- a/test/integration/utils/src/async_coroutinecpp20.cpp +++ b/test/integration/utils/src/async_coroutinecpp20.cpp @@ -233,19 +233,18 @@ public: const char* variant_name() const override { return "async_coroutinecpp20"; } }; -async_coroutinecpp20_variant tcp; -async_coroutinecpp20_variant tcp_ssl; - } // namespace -#endif - -#if BOOST_ASIO_HAS_CO_AWAIT void boost::mysql::test::add_async_coroutinecpp20(std::vector& output) { + static async_coroutinecpp20_variant tcp; + static async_coroutinecpp20_variant tcp_ssl; output.push_back(&tcp); output.push_back(&tcp_ssl); } + #else + void boost::mysql::test::add_async_coroutinecpp20(std::vector&) {} -#endif \ No newline at end of file + +#endif diff --git a/test/integration/utils/src/async_future.cpp b/test/integration/utils/src/async_future.cpp index 267f2f19..2a1bf641 100644 --- a/test/integration/utils/src/async_future.cpp +++ b/test/integration/utils/src/async_future.cpp @@ -207,13 +207,12 @@ public: const char* variant_name() const override { return "async_future"; } }; -async_future_variant tcp; -async_future_variant tcp_ssl; - } // namespace void boost::mysql::test::add_async_future(std::vector& output) { + static async_future_variant tcp; + static async_future_variant tcp_ssl; output.push_back(&tcp); output.push_back(&tcp_ssl); } \ No newline at end of file diff --git a/test/integration/utils/src/default_completion_tokens.cpp b/test/integration/utils/src/default_completion_tokens.cpp index 47d7cb2a..058dbf07 100644 --- a/test/integration/utils/src/default_completion_tokens.cpp +++ b/test/integration/utils/src/default_completion_tokens.cpp @@ -166,11 +166,10 @@ public: const char* variant_name() const override { return "default_completion_tokens"; } }; -default_completion_tokens_variant obj; - } // namespace void boost::mysql::test::add_default_completion_tokens(std::vector& output) { + static default_completion_tokens_variant obj; output.push_back(&obj); } \ No newline at end of file diff --git a/test/integration/utils/src/sync_errc.cpp b/test/integration/utils/src/sync_errc.cpp index bd2c85f2..19e1fe72 100644 --- a/test/integration/utils/src/sync_errc.cpp +++ b/test/integration/utils/src/sync_errc.cpp @@ -187,17 +187,17 @@ public: const char* variant_name() const override { return "sync_errc"; } }; -sync_errc_variant tcp_variant; -sync_errc_variant tcp_ssl_variant; -sync_errc_variant def_compl_variant; -#if BOOST_ASIO_HAS_LOCAL_SOCKETS -sync_errc_variant unix_variant; -#endif - } // namespace void boost::mysql::test::add_sync_errc(std::vector& output) { + static sync_errc_variant tcp_variant; + static sync_errc_variant tcp_ssl_variant; + static sync_errc_variant def_compl_variant; +#if BOOST_ASIO_HAS_LOCAL_SOCKETS + static sync_errc_variant unix_variant; +#endif + output.push_back(&tcp_variant); output.push_back(&tcp_ssl_variant); output.push_back(&def_compl_variant); diff --git a/test/integration/utils/src/sync_exc.cpp b/test/integration/utils/src/sync_exc.cpp index 7cd44a41..4145a86c 100644 --- a/test/integration/utils/src/sync_exc.cpp +++ b/test/integration/utils/src/sync_exc.cpp @@ -179,14 +179,12 @@ public: const char* variant_name() const override { return "sync_exc"; } }; -sync_exc_variant tcp; -sync_exc_variant tcp_ssl; -// UNIX sockets don't add much value here - } // namespace void boost::mysql::test::add_sync_exc(std::vector& output) { + static sync_exc_variant tcp; + static sync_exc_variant tcp_ssl; output.push_back(&tcp); output.push_back(&tcp_ssl); }