Skip to content

Commit

Permalink
PS-5363 (Merge MySQL 8.0.17): revert gunit MY_EXPECT_DEATH/MY_EXPECT_…
Browse files Browse the repository at this point in the history
…DEATH_IF_SUPPORTED

The effect of these macros is implemented by upstream 0e79c78 in
8.0.17, rendering them obsolete.
  • Loading branch information
laurynas-biveinis authored and percona-ysorokin committed Oct 15, 2019
1 parent 76956d8 commit 629210c
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 118 deletions.
21 changes: 10 additions & 11 deletions unittest/gunit/bounds_checked_array-t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <algorithm>

#include "sql/sql_array.h"
#include "thread_utils.h"

namespace bounds_check_array_unittest {

Expand Down Expand Up @@ -74,39 +73,39 @@ typedef BoundsCheckedArray BoundsCheckedArrayDeathTest;
TEST_F(BoundsCheckedArrayDeathTest, BoundsCheckRead) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
int_array = Int_array(c_array, 2);
MY_EXPECT_DEATH_IF_SUPPORTED(some_integer = int_array[5],
".*Assertion .*n < m_size.*");
EXPECT_DEATH_IF_SUPPORTED(some_integer = int_array[5],
".*Assertion .*n < m_size.*");
}

TEST_F(BoundsCheckedArrayDeathTest, BoundsCheckAssign) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
int_array = Int_array(c_array, 2);
MY_EXPECT_DEATH_IF_SUPPORTED(int_array[5] = some_integer,
".*Assertion .*n < m_size.*");
EXPECT_DEATH_IF_SUPPORTED(int_array[5] = some_integer,
".*Assertion .*n < m_size.*");
}

TEST_F(BoundsCheckedArrayDeathTest, BoundsCheckPopFront) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
int_array = Int_array(c_array, 1);
int_array.pop_front();
MY_EXPECT_DEATH_IF_SUPPORTED(int_array.pop_front(),
".*Assertion .*m_size > 0.*");
EXPECT_DEATH_IF_SUPPORTED(int_array.pop_front(),
".*Assertion .*m_size > 0.*");
}

TEST_F(BoundsCheckedArrayDeathTest, BoundsCheckResize) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
int_array = Int_array(c_array, 1);
MY_EXPECT_DEATH_IF_SUPPORTED(int_array.resize(2),
".*Assertion .*new_size <= m_size.*");
EXPECT_DEATH_IF_SUPPORTED(int_array.resize(2),
".*Assertion .*new_size <= m_size.*");
}

TEST_F(BoundsCheckedArrayDeathTest, BoundsCheckResizeAssign) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
int_array = Int_array(c_array, 2);
int_array[1] = some_integer;
int_array.resize(1);
MY_EXPECT_DEATH_IF_SUPPORTED(int_array[1] = some_integer,
".*Assertion .*n < m_size.*");
EXPECT_DEATH_IF_SUPPORTED(int_array[1] = some_integer,
".*Assertion .*n < m_size.*");
}

#endif // !defined(DBUG_OFF)
Expand Down
2 changes: 1 addition & 1 deletion unittest/gunit/dbug-t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ TEST(DebugTest, NoSuicide) { DBUG_SUICIDE(); }
#else
TEST(DebugDeathTest, Suicide) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
MY_EXPECT_DEATH_IF_SUPPORTED(DBUG_SUICIDE(), "");
EXPECT_DEATH_IF_SUPPORTED(DBUG_SUICIDE(), "");
}
#endif

Expand Down
5 changes: 2 additions & 3 deletions unittest/gunit/get_diagnostics-t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "sql/sql_class.h"
#include "sql/sql_get_diagnostics.h"
#include "unittest/gunit/test_utils.h"
#include "unittest/gunit/thread_utils.h"

namespace get_diagnostics_unittest {

Expand Down Expand Up @@ -156,7 +155,7 @@ TEST_F(GetDiagnosticsTestDeathTest, DieWhenUnsettableItem) {
info->set_which_da(Diagnostics_information::CURRENT_AREA);
cmd = new (mem_root) Sql_cmd_get_diagnostics(info);

MY_EXPECT_DEATH(cmd->execute(thd()), ".*Assertion.*srp.*");
EXPECT_DEATH(cmd->execute(thd()), ".*Assertion.*srp.*");
}
#endif // GTEST_HAS_DEATH_TEST && !defined(DBUG_OFF)

Expand Down Expand Up @@ -440,7 +439,7 @@ TEST_F(GetDiagnosticsTest, PushPopDiagnosticsArea) {
TEST_F(GetDiagnosticsTestDeathTest, DiePopDiagnosticsArea) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";

MY_EXPECT_DEATH(thd()->pop_diagnostics_area(), ".*Assertion.*m_stacked_da*");
EXPECT_DEATH(thd()->pop_diagnostics_area(), ".*Assertion.*m_stacked_da*");
}
#endif // GTEST_HAS_DEATH_TEST && !defined(DBUG_OFF)

Expand Down
15 changes: 7 additions & 8 deletions unittest/gunit/inplace_vector-t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <algorithm>

#include "sql/inplace_vector.h"
#include "thread_utils.h"

namespace inplace_vector_unittest {

Expand All @@ -51,24 +50,24 @@ typedef InplaceVectorTest InplaceVectorDeathTest;

TEST_F(InplaceVectorDeathTest, OutOfBoundsRead) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
MY_EXPECT_DEATH_IF_SUPPORTED(some_integer = int_10[5],
".*Assertion .*i < size.*");
EXPECT_DEATH_IF_SUPPORTED(some_integer = int_10[5],
".*Assertion .*i < size.*");
}

TEST_F(InplaceVectorDeathTest, OutOfBoundsWrite) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
MY_EXPECT_DEATH_IF_SUPPORTED(int_10[5] = some_integer,
".*Assertion .*i < size.*");
EXPECT_DEATH_IF_SUPPORTED(int_10[5] = some_integer,
".*Assertion .*i < size.*");
}

TEST_F(InplaceVectorDeathTest, EmptyBackRead) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
MY_EXPECT_DEATH_IF_SUPPORTED(some_integer = int_10.back(),
".*Assertion .*size.*0.*");
EXPECT_DEATH_IF_SUPPORTED(some_integer = int_10.back(),
".*Assertion .*size.*0.*");
}
TEST_F(InplaceVectorDeathTest, EmptyBackWrite) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
MY_EXPECT_DEATH_IF_SUPPORTED(int_10.back() = 42, ".*Assertion .*size.*0.*");
EXPECT_DEATH_IF_SUPPORTED(int_10.back() = 42, ".*Assertion .*size.*0.*");
}

#endif // DBUG_OFF
Expand Down
20 changes: 10 additions & 10 deletions unittest/gunit/mdl-t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ TEST_F(MDLDeathTest, DieWhenMTicketsNonempty) {
MDL_TRANSACTION);

EXPECT_FALSE(m_mdl_context.try_acquire_lock(&m_request));
MY_EXPECT_DEATH(m_mdl_context.destroy(),
".*Assertion.*m_ticket_store.*is_empty.*");
EXPECT_DEATH(m_mdl_context.destroy(),
".*Assertion.*m_ticket_store.*is_empty.*");
m_mdl_context.release_transactional_locks();
}
#endif // GTEST_HAS_DEATH_TEST && !defined(DBUG_OFF)
Expand Down Expand Up @@ -4262,17 +4262,17 @@ TEST_F(MDLKeyDeathTest, DieWhenNamesAreTooLong) {
"0123456789012345678901234567890123456789012345678901234567890123"
"0123456789";

MY_EXPECT_DEATH(MDL_key key0(MDL_key::TABLE, too_long_name, ""),
".*Assertion.*strlen.*");
MY_EXPECT_DEATH(MDL_key key1(MDL_key::TABLE, "", too_long_name),
".*Assertion.*strlen.*");
EXPECT_DEATH(MDL_key key0(MDL_key::TABLE, too_long_name, ""),
".*Assertion.*strlen.*");
EXPECT_DEATH(MDL_key key1(MDL_key::TABLE, "", too_long_name),
".*Assertion.*strlen.*");

MDL_key key2;

MY_EXPECT_DEATH(key2.mdl_key_init(MDL_key::TABLE, too_long_name, ""),
".*Assertion.*strlen.*");
MY_EXPECT_DEATH(key2.mdl_key_init(MDL_key::TABLE, "", too_long_name),
".*Assertion.*strlen.*");
EXPECT_DEATH(key2.mdl_key_init(MDL_key::TABLE, too_long_name, ""),
".*Assertion.*strlen.*");
EXPECT_DEATH(key2.mdl_key_init(MDL_key::TABLE, "", too_long_name),
".*Assertion.*strlen.*");
}
#endif // GTEST_HAS_DEATH_TEST && !defined(DBUG_OFF)

Expand Down
15 changes: 7 additions & 8 deletions unittest/gunit/prealloced_array-t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <memory>

#include "prealloced_array.h"
#include "thread_utils.h"

namespace prealloced_array_unittest {

Expand All @@ -54,30 +53,30 @@ typedef PreallocedArrayTest PreallocedArrayDeathTest;

TEST_F(PreallocedArrayDeathTest, OutOfBoundsRead) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
MY_EXPECT_DEATH_IF_SUPPORTED(some_integer = int_10[5],
".*Assertion .*n < size.*");
EXPECT_DEATH_IF_SUPPORTED(some_integer = int_10[5],
".*Assertion .*n < size.*");
}

TEST_F(PreallocedArrayDeathTest, OutOfBoundsWrite) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
MY_EXPECT_DEATH_IF_SUPPORTED(int_10[5] = some_integer,
".*Assertion .*n < size.*");
EXPECT_DEATH_IF_SUPPORTED(int_10[5] = some_integer,
".*Assertion .*n < size.*");
}

TEST_F(PreallocedArrayDeathTest, EmptyBack) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
MY_EXPECT_DEATH_IF_SUPPORTED(int_10.back() = 42, ".*Assertion .*n < size.*");
EXPECT_DEATH_IF_SUPPORTED(int_10.back() = 42, ".*Assertion .*n < size.*");
}

TEST_F(PreallocedArrayDeathTest, EmptyPopBack) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
MY_EXPECT_DEATH_IF_SUPPORTED(int_10.pop_back(), ".*Assertion .*!empty.*");
EXPECT_DEATH_IF_SUPPORTED(int_10.pop_back(), ".*Assertion .*!empty.*");
}

TEST_F(PreallocedArrayDeathTest, EmptyErase) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
size_t ix = 0;
MY_EXPECT_DEATH_IF_SUPPORTED(int_10.erase(ix), ".*Assertion .*ix < size.*");
EXPECT_DEATH_IF_SUPPORTED(int_10.erase(ix), ".*Assertion .*ix < size.*");
}

#endif // DBUG_OFF
Expand Down
11 changes: 5 additions & 6 deletions unittest/gunit/segfault-t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "my_inttypes.h"
#include "my_stacktrace.h"
#include "unittest/gunit/test_utils.h"
#include "unittest/gunit/thread_utils.h"

namespace segfault_unittest {

Expand All @@ -47,9 +46,9 @@ class FatalSignalDeathTest : public ::testing::Test {

TEST_F(FatalSignalDeathTest, Abort) {
#if defined(_WIN32)
MY_EXPECT_DEATH_IF_SUPPORTED(abort(), ".* UTC - mysqld got exception.*");
EXPECT_DEATH_IF_SUPPORTED(abort(), ".* UTC - mysqld got exception.*");
#else
MY_EXPECT_DEATH_IF_SUPPORTED(abort(), ".* UTC - mysqld got signal 6.*");
EXPECT_DEATH_IF_SUPPORTED(abort(), ".* UTC - mysqld got signal 6.*");
#endif
}

Expand All @@ -61,16 +60,16 @@ TEST_F(FatalSignalDeathTest, Segfault) {
caught by handle_fatal_signal(). We get an empty error message from the
gtest library instead.
*/
MY_EXPECT_DEATH_IF_SUPPORTED(*pint = 42, "");
EXPECT_DEATH_IF_SUPPORTED(*pint = 42, "");
#elif defined(__SANITIZE_ADDRESS__)
/* AddressSanitizer */
MY_EXPECT_DEATH_IF_SUPPORTED(*pint = 42, ".*ASAN:(DEADLYSIGNAL|SIGSEGV).*");
EXPECT_DEATH_IF_SUPPORTED(*pint = 42, ".*ASAN:(DEADLYSIGNAL|SIGSEGV).*");
#else
/*
On most platforms we get SIGSEGV == 11, but SIGBUS == 10 is also possible.
And on Mac OsX we can get SIGILL == 4 (but only in optmized mode).
*/
MY_EXPECT_DEATH_IF_SUPPORTED(*pint = 42, ".* UTC - mysqld got signal .*");
EXPECT_DEATH_IF_SUPPORTED(*pint = 42, ".* UTC - mysqld got signal .*");
#endif
}

Expand Down
4 changes: 1 addition & 3 deletions unittest/gunit/string-tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#include "thread_utils.h"

extern CHARSET_INFO *system_charset_info;

TEST(StringTest, EmptyString) {
Expand Down Expand Up @@ -50,7 +48,7 @@ TEST(StringDeathTest, AppendEmptyString) {
tbl_name.append(String(table_name, system_charset_info));
// We now have eight characters, c_ptr() is not safe.
#ifndef DBUG_OFF
MY_EXPECT_DEATH_IF_SUPPORTED(tbl_name.c_ptr(), ".*m_alloced_length >= .*");
EXPECT_DEATH_IF_SUPPORTED(tbl_name.c_ptr(), ".*m_alloced_length >= .*");
#endif
EXPECT_STREQ("aaaaaaa.", tbl_name.c_ptr_safe());
}
Expand Down
31 changes: 15 additions & 16 deletions unittest/gunit/table_cache-t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "sql/table_cache.h"
#include "storage/example/ha_example.h"
#include "unittest/gunit/test_utils.h"
#include "unittest/gunit/thread_utils.h"

/*
We need example_hton to be able short-cut creation of example
Expand Down Expand Up @@ -185,7 +184,7 @@ TEST_F(TableCacheBasicDeathTest, CacheCreateAndDestroy) {

// Cache should be not locked after creation
#ifdef SAFE_MUTEX
MY_EXPECT_DEATH_IF_SUPPORTED(table_cache.assert_owner(), assert_string);
EXPECT_DEATH_IF_SUPPORTED(table_cache.assert_owner(), assert_string);
#endif
table_cache.destroy();
}
Expand All @@ -201,7 +200,7 @@ TEST_F(TableCacheBasicDeathTest, CacheLockAndUnlock) {

#ifdef SAFE_MUTEX
// Cache should not be locked after creation
MY_EXPECT_DEATH_IF_SUPPORTED(table_cache.assert_owner(), assert_string);
EXPECT_DEATH_IF_SUPPORTED(table_cache.assert_owner(), assert_string);
#endif

// And get locked after we call its lock() method
Expand All @@ -211,7 +210,7 @@ TEST_F(TableCacheBasicDeathTest, CacheLockAndUnlock) {
// And get unlocked after we call its unlock() method
table_cache.unlock();
#ifdef SAFE_MUTEX
MY_EXPECT_DEATH_IF_SUPPORTED(table_cache.assert_owner(), assert_string);
EXPECT_DEATH_IF_SUPPORTED(table_cache.assert_owner(), assert_string);
#endif

table_cache.destroy();
Expand Down Expand Up @@ -249,8 +248,8 @@ TEST_F(TableCacheBasicDeathTest, ManagerCreateAndDestroy) {

// And not locked
#ifdef SAFE_MUTEX
MY_EXPECT_DEATH_IF_SUPPORTED(cache_1->assert_owner(), assert_string);
MY_EXPECT_DEATH_IF_SUPPORTED(cache_2->assert_owner(), assert_string);
EXPECT_DEATH_IF_SUPPORTED(cache_1->assert_owner(), assert_string);
EXPECT_DEATH_IF_SUPPORTED(cache_2->assert_owner(), assert_string);
#endif

table_cache_manager.destroy();
Expand Down Expand Up @@ -677,10 +676,10 @@ TEST_F(TableCacheDoubleCacheTest, ManagerCachedTables) {
TEST_F(TableCacheDoubleCacheDeathTest, ManagerLockAndUnlock) {
// Nor caches nor LOCK_open should not be locked after initialization
#ifdef SAFE_MUTEX
MY_EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.assert_owner_all(),
assert_string);
MY_EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.assert_owner_all_and_tdc(),
assert_string);
EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.assert_owner_all(),
assert_string);
EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.assert_owner_all_and_tdc(),
assert_string);
#endif

// And get locked after we call its lock_all_and_tdc() method.
Expand All @@ -701,10 +700,10 @@ TEST_F(TableCacheDoubleCacheDeathTest, ManagerLockAndUnlock) {
table_cache_manager.unlock_all_and_tdc();

#ifdef SAFE_MUTEX
MY_EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.assert_owner_all(),
assert_string);
MY_EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.assert_owner_all_and_tdc(),
assert_string);
EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.assert_owner_all(),
assert_string);
EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.assert_owner_all_and_tdc(),
assert_string);
#endif
}

Expand Down Expand Up @@ -751,7 +750,7 @@ TEST_F(TableCacheDoubleCacheDeathTest, ManagerFreeTable) {
// to free all tables for share_1, while some tables
// are in use.
#ifndef DBUG_OFF
MY_EXPECT_DEATH_IF_SUPPORTED(
EXPECT_DEATH_IF_SUPPORTED(
table_cache_manager.free_table(thd_1, TDC_RT_REMOVE_ALL, &share_1),
".*Assertion.*is_empty.*");
#endif
Expand Down Expand Up @@ -789,7 +788,7 @@ TEST_F(TableCacheDoubleCacheDeathTest, ManagerFreeTable) {
// to free all not own TABLEs for share_1, while thd_2
// has a TABLE object for it in used
#ifndef DBUG_OFF
MY_EXPECT_DEATH_IF_SUPPORTED(
EXPECT_DEATH_IF_SUPPORTED(
table_cache_manager.free_table(thd_1, TDC_RT_REMOVE_NOT_OWN, &share_1),
".*Assertion.*0.*");
#endif
Expand Down
4 changes: 2 additions & 2 deletions unittest/gunit/thd_manager-t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ TEST_F(ThreadManagerTest, ThreadIDDeathTest) {
my_thread_id thread_id = thd_manager->get_new_thread_id();
thd_manager->release_thread_id(thread_id);
// Releasing the same ID twice should assert.
MY_EXPECT_DEATH_IF_SUPPORTED(thd_manager->release_thread_id(thread_id),
".*Assertion .*1 == num_erased.*");
EXPECT_DEATH_IF_SUPPORTED(thd_manager->release_thread_id(thread_id),
".*Assertion .*1 == num_erased.*");
}
#endif

Expand Down
Loading

0 comments on commit 629210c

Please sign in to comment.