diff --git a/mysql-test/lib/My/CoreDump.pm b/mysql-test/lib/My/CoreDump.pm index cfbd267748c..8958b7c4cc7 100644 --- a/mysql-test/lib/My/CoreDump.pm +++ b/mysql-test/lib/My/CoreDump.pm @@ -62,8 +62,6 @@ sub _gdb { /Core was generated by `([^\s\'\`]+)/; my $binary= $1 or return; - $binary= _verify_binpath ($binary, $core_name) or return; - # Create tempfile containing gdb commands my ($tmp, $tmp_name) = tempfile(); print $tmp diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl old mode 100644 new mode 100755 index 533894c14aa..734988e9929 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -374,6 +374,15 @@ ($) main(); +sub is_core_dump { + my $core_path= shift; + my $core_name= basename($core_path); + # Name beginning with core, not ending in .gz, not belonging to Boost, + # or ending with .dmp on Windows + return (($core_name =~ /^core/ and $core_name !~ /\.gz$/ + and $core_path !~ /\/boost_/) + or (IS_WINDOWS and $core_name =~ /\.dmp$/)); +} sub main { # Default, verbosity on @@ -615,6 +624,18 @@ sub main { mtr_print_line(); } + if ($opt_ctest) { + find({ wanted => sub { + my $core_file= $File::Find::name; + + if (is_core_dump($core_file)) { + mtr_report(" - found '$core_file'"); + + My::CoreDump->show($core_file, "", 1); + } + }}, $bindir); + } + print_total_times($opt_parallel) if $opt_report_times; mtr_report_stats("Completed", $completed); @@ -712,10 +733,7 @@ ($$$) my $core_file= $File::Find::name; my $core_name= basename($core_file); - # Name beginning with core, not ending in .gz - if (($core_name =~ /^core/ and $core_name !~ /\.gz$/) - or (IS_WINDOWS and $core_name =~ /\.dmp$/)){ - # Ending with .dmp + if (is_core_dump($core_name)) { mtr_report(" - found '$core_name'", "($num_saved_cores/$opt_max_save_core)"); diff --git a/unittest/gunit/bounded_queue-t.cc b/unittest/gunit/bounded_queue-t.cc index c4652e23fff..87f8df2483a 100644 --- a/unittest/gunit/bounded_queue-t.cc +++ b/unittest/gunit/bounded_queue-t.cc @@ -22,6 +22,7 @@ #include "bounded_queue.h" #include "fake_costmodel.h" #include "filesort_utils.h" +#include "thread_utils.h" #include "my_sys.h" #include "opt_costmodel.h" #include "test_utils.h" @@ -190,7 +191,7 @@ TEST_F(BoundedQueueDeathTest, DieIfNotInitialized) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; Test_element foo= 1; - EXPECT_DEATH_IF_SUPPORTED(m_queue.push(&foo), + MY_EXPECT_DEATH_IF_SUPPORTED(m_queue.push(&foo), ".*Assertion .*is_initialized.*"); } @@ -202,7 +203,7 @@ TEST_F(BoundedQueueDeathTest, DieIfPoppingEmptyQueue) EXPECT_EQ(0, m_queue.init(0, true, test_key_compare, &m_keymaker, m_keys.key_ptrs)); ::testing::FLAGS_gtest_death_test_style = "threadsafe"; - EXPECT_DEATH_IF_SUPPORTED(m_queue.pop(), + MY_EXPECT_DEATH_IF_SUPPORTED(m_queue.pop(), ".*Assertion .*elements > 0.*"); } #endif // !defined(DBUG_OFF) diff --git a/unittest/gunit/bounds_checked_array-t.cc b/unittest/gunit/bounds_checked_array-t.cc index 730520ea32b..ec5565eeec4 100644 --- a/unittest/gunit/bounds_checked_array-t.cc +++ b/unittest/gunit/bounds_checked_array-t.cc @@ -16,6 +16,7 @@ // First include (the generated) my_config.h, to get correct platform defines. #include "my_config.h" #include +#include "thread_utils.h" #include "sql_array.h" @@ -80,7 +81,7 @@ TEST_F(BoundsCheckedArrayDeathTest, BoundsCheckRead) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; int_array= Int_array(c_array, 2); - EXPECT_DEATH_IF_SUPPORTED(some_integer= int_array[5], + MY_EXPECT_DEATH_IF_SUPPORTED(some_integer= int_array[5], ".*Assertion .*n < m_size.*"); } @@ -88,7 +89,7 @@ TEST_F(BoundsCheckedArrayDeathTest, BoundsCheckAssign) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; int_array= Int_array(c_array, 2); - EXPECT_DEATH_IF_SUPPORTED(int_array[5]= some_integer, + MY_EXPECT_DEATH_IF_SUPPORTED(int_array[5]= some_integer, ".*Assertion .*n < m_size.*"); } @@ -97,7 +98,7 @@ TEST_F(BoundsCheckedArrayDeathTest, BoundsCheckPopFront) ::testing::FLAGS_gtest_death_test_style = "threadsafe"; int_array= Int_array(c_array, 1); int_array.pop_front(); - EXPECT_DEATH_IF_SUPPORTED(int_array.pop_front(), + MY_EXPECT_DEATH_IF_SUPPORTED(int_array.pop_front(), ".*Assertion .*m_size > 0.*"); } @@ -105,7 +106,7 @@ TEST_F(BoundsCheckedArrayDeathTest, BoundsCheckResize) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; int_array= Int_array(c_array, 1); - EXPECT_DEATH_IF_SUPPORTED(int_array.resize(2), + MY_EXPECT_DEATH_IF_SUPPORTED(int_array.resize(2), ".*Assertion .*new_size <= m_size.*"); } @@ -115,7 +116,7 @@ TEST_F(BoundsCheckedArrayDeathTest, BoundsCheckResizeAssign) int_array= Int_array(c_array, 2); int_array[1]= some_integer; int_array.resize(1); - EXPECT_DEATH_IF_SUPPORTED(int_array[1]= some_integer, + MY_EXPECT_DEATH_IF_SUPPORTED(int_array[1]= some_integer, ".*Assertion .*n < m_size.*"); } diff --git a/unittest/gunit/dbug-t.cc b/unittest/gunit/dbug-t.cc index 5be08712c12..7487d07ee62 100644 --- a/unittest/gunit/dbug-t.cc +++ b/unittest/gunit/dbug-t.cc @@ -36,7 +36,7 @@ TEST(DebugTest, NoSuicide) TEST(DebugDeathTest, Suicide) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; - EXPECT_DEATH_IF_SUPPORTED(DBUG_SUICIDE(), ""); + MY_EXPECT_DEATH_IF_SUPPORTED(DBUG_SUICIDE(), ""); } #endif diff --git a/unittest/gunit/get_diagnostics-t.cc b/unittest/gunit/get_diagnostics-t.cc index 9f2dce34833..1f5abf98703 100644 --- a/unittest/gunit/get_diagnostics-t.cc +++ b/unittest/gunit/get_diagnostics-t.cc @@ -170,7 +170,7 @@ TEST_F(GetDiagnosticsTestDeathTest, DieWhenUnsettableItem) info->set_which_da(Diagnostics_information::CURRENT_AREA); cmd= new (mem_root) Sql_cmd_get_diagnostics(info); - EXPECT_DEATH(cmd->execute(thd()), ".*Assertion.*srp.*"); + MY_EXPECT_DEATH(cmd->execute(thd()), ".*Assertion.*srp.*"); } #endif // GTEST_HAS_DEATH_TEST && !defined(DBUG_OFF) @@ -474,7 +474,7 @@ TEST_F(GetDiagnosticsTestDeathTest, DiePopDiagnosticsArea) { ::testing::FLAGS_gtest_death_test_style= "threadsafe"; - EXPECT_DEATH(thd()->pop_diagnostics_area(), ".*Assertion.*m_stacked_da*"); + MY_EXPECT_DEATH(thd()->pop_diagnostics_area(), ".*Assertion.*m_stacked_da*"); } #endif // GTEST_HAS_DEATH_TEST && !defined(DBUG_OFF) diff --git a/unittest/gunit/inplace_vector-t.cc b/unittest/gunit/inplace_vector-t.cc index b4cd5a5a817..bebe6199481 100644 --- a/unittest/gunit/inplace_vector-t.cc +++ b/unittest/gunit/inplace_vector-t.cc @@ -49,27 +49,27 @@ typedef InplaceVectorTest InplaceVectorDeathTest; TEST_F(InplaceVectorDeathTest, OutOfBoundsRead) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; - EXPECT_DEATH_IF_SUPPORTED(some_integer= int_10[5], + MY_EXPECT_DEATH_IF_SUPPORTED(some_integer= int_10[5], ".*Assertion .*i < size.*"); } TEST_F(InplaceVectorDeathTest, OutOfBoundsWrite) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; - EXPECT_DEATH_IF_SUPPORTED(int_10[5] = some_integer, + MY_EXPECT_DEATH_IF_SUPPORTED(int_10[5] = some_integer, ".*Assertion .*i < size.*"); } TEST_F(InplaceVectorDeathTest, EmptyBackRead) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; - EXPECT_DEATH_IF_SUPPORTED(some_integer= int_10.back(), + MY_EXPECT_DEATH_IF_SUPPORTED(some_integer= int_10.back(), ".*Assertion .*size.*0.*"); } TEST_F(InplaceVectorDeathTest, EmptyBackWrite) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; - EXPECT_DEATH_IF_SUPPORTED(int_10.back() = 42, + MY_EXPECT_DEATH_IF_SUPPORTED(int_10.back() = 42, ".*Assertion .*size.*0.*"); } diff --git a/unittest/gunit/mdl-t.cc b/unittest/gunit/mdl-t.cc index fdbcc6e11f4..be987807487 100644 --- a/unittest/gunit/mdl-t.cc +++ b/unittest/gunit/mdl-t.cc @@ -269,7 +269,7 @@ TEST_F(MDLDeathTest, DieWhenMTicketsNonempty) MDL_TRANSACTION); EXPECT_FALSE(m_mdl_context.try_acquire_lock(&m_request)); - EXPECT_DEATH(m_mdl_context.destroy(), + MY_EXPECT_DEATH(m_mdl_context.destroy(), ".*Assertion.*MDL_TRANSACTION.*is_empty.*"); m_mdl_context.release_transactional_locks(); } @@ -4595,16 +4595,16 @@ TEST_F(MDLKeyDeathTest, DieWhenNamesAreTooLong) "0123456789012345678901234567890123456789012345678901234567890123" "0123456789"; - EXPECT_DEATH(MDL_key key0(MDL_key::TABLE, too_long_name, ""), + MY_EXPECT_DEATH(MDL_key key0(MDL_key::TABLE, too_long_name, ""), ".*Assertion.*strlen.*"); - EXPECT_DEATH(MDL_key key1(MDL_key::TABLE, "", too_long_name), + MY_EXPECT_DEATH(MDL_key key1(MDL_key::TABLE, "", too_long_name), ".*Assertion.*strlen.*"); MDL_key key2; - EXPECT_DEATH(key2.mdl_key_init(MDL_key::TABLE, too_long_name, ""), + 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), + MY_EXPECT_DEATH(key2.mdl_key_init(MDL_key::TABLE, "", too_long_name), ".*Assertion.*strlen.*"); } diff --git a/unittest/gunit/prealloced_array-t.cc b/unittest/gunit/prealloced_array-t.cc index 5ff8217308a..041037f619a 100644 --- a/unittest/gunit/prealloced_array-t.cc +++ b/unittest/gunit/prealloced_array-t.cc @@ -51,28 +51,28 @@ typedef PreallocedArrayTest PreallocedArrayDeathTest; TEST_F(PreallocedArrayDeathTest, OutOfBoundsRead) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; - EXPECT_DEATH_IF_SUPPORTED(some_integer= int_10[5], + MY_EXPECT_DEATH_IF_SUPPORTED(some_integer= int_10[5], ".*Assertion .*n < size.*"); } TEST_F(PreallocedArrayDeathTest, OutOfBoundsWrite) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; - EXPECT_DEATH_IF_SUPPORTED(int_10[5] = some_integer, + MY_EXPECT_DEATH_IF_SUPPORTED(int_10[5] = some_integer, ".*Assertion .*n < size.*"); } TEST_F(PreallocedArrayDeathTest, EmptyBack) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; - EXPECT_DEATH_IF_SUPPORTED(int_10.back() = 42, + MY_EXPECT_DEATH_IF_SUPPORTED(int_10.back() = 42, ".*Assertion .*n < size.*"); } TEST_F(PreallocedArrayDeathTest, EmptyPopBack) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; - EXPECT_DEATH_IF_SUPPORTED(int_10.pop_back(), + MY_EXPECT_DEATH_IF_SUPPORTED(int_10.pop_back(), ".*Assertion .*!empty.*"); } @@ -80,7 +80,7 @@ TEST_F(PreallocedArrayDeathTest, EmptyErase) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; size_t ix= 0; - EXPECT_DEATH_IF_SUPPORTED(int_10.erase(ix), + MY_EXPECT_DEATH_IF_SUPPORTED(int_10.erase(ix), ".*Assertion .*ix < size.*"); } diff --git a/unittest/gunit/segfault-t.cc b/unittest/gunit/segfault-t.cc index d7c80b688a5..0b511cd5a7a 100644 --- a/unittest/gunit/segfault-t.cc +++ b/unittest/gunit/segfault-t.cc @@ -44,9 +44,9 @@ class FatalSignalDeathTest : public ::testing::Test TEST_F(FatalSignalDeathTest, Abort) { #if defined(_WIN32) - EXPECT_DEATH_IF_SUPPORTED(abort(), ".* UTC - mysqld got exception.*"); + MY_EXPECT_DEATH_IF_SUPPORTED(abort(), ".* UTC - mysqld got exception.*"); #else - EXPECT_DEATH_IF_SUPPORTED(abort(), ".* UTC - mysqld got signal 6.*"); + MY_EXPECT_DEATH_IF_SUPPORTED(abort(), ".* UTC - mysqld got signal 6.*"); #endif } @@ -60,16 +60,16 @@ TEST_F(FatalSignalDeathTest, Segfault) caught by handle_fatal_signal(). We get an empty error message from the gtest library instead. */ - EXPECT_DEATH_IF_SUPPORTED(*pint= 42, ""); + MY_EXPECT_DEATH_IF_SUPPORTED(*pint= 42, ""); #elif defined(__SANITIZE_ADDRESS__) /* AddressSanitizer */ - EXPECT_DEATH_IF_SUPPORTED(*pint= 42, ".*ASAN:(DEADLYSIGNAL|SIGSEGV).*"); + MY_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). */ - EXPECT_DEATH_IF_SUPPORTED(*pint= 42, ".* UTC - mysqld got signal .*"); + MY_EXPECT_DEATH_IF_SUPPORTED(*pint= 42, ".* UTC - mysqld got signal .*"); #endif } diff --git a/unittest/gunit/string-tests.cc b/unittest/gunit/string-tests.cc index a6dbedbdb1c..4dcfd5d92f0 100644 --- a/unittest/gunit/string-tests.cc +++ b/unittest/gunit/string-tests.cc @@ -52,7 +52,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 - EXPECT_DEATH_IF_SUPPORTED(tbl_name.c_ptr(), ".*m_alloced_length >= .*"); + MY_EXPECT_DEATH_IF_SUPPORTED(tbl_name.c_ptr(), ".*m_alloced_length >= .*"); #endif EXPECT_STREQ("aaaaaaa.", tbl_name.c_ptr_safe()); } diff --git a/unittest/gunit/table_cache-t.cc b/unittest/gunit/table_cache-t.cc index 72f2f193643..8ec488732f7 100644 --- a/unittest/gunit/table_cache-t.cc +++ b/unittest/gunit/table_cache-t.cc @@ -202,7 +202,7 @@ TEST_F(TableCacheBasicDeathTest, CacheCreateAndDestroy) // Cache should be not locked after creation #ifdef SAFE_MUTEX - EXPECT_DEATH_IF_SUPPORTED(table_cache.assert_owner(), + MY_EXPECT_DEATH_IF_SUPPORTED(table_cache.assert_owner(), assert_string); #endif table_cache.destroy(); @@ -221,7 +221,7 @@ TEST_F(TableCacheBasicDeathTest, CacheLockAndUnlock) #ifdef SAFE_MUTEX // Cache should not be locked after creation - EXPECT_DEATH_IF_SUPPORTED(table_cache.assert_owner(), + MY_EXPECT_DEATH_IF_SUPPORTED(table_cache.assert_owner(), assert_string); #endif @@ -232,7 +232,7 @@ TEST_F(TableCacheBasicDeathTest, CacheLockAndUnlock) // And get unlocked after we call its unlock() method table_cache.unlock(); #ifdef SAFE_MUTEX - EXPECT_DEATH_IF_SUPPORTED(table_cache.assert_owner(), + MY_EXPECT_DEATH_IF_SUPPORTED(table_cache.assert_owner(), assert_string); #endif @@ -273,9 +273,9 @@ TEST_F(TableCacheBasicDeathTest, ManagerCreateAndDestroy) // And not locked #ifdef SAFE_MUTEX - EXPECT_DEATH_IF_SUPPORTED(cache_1->assert_owner(), + MY_EXPECT_DEATH_IF_SUPPORTED(cache_1->assert_owner(), assert_string); - EXPECT_DEATH_IF_SUPPORTED(cache_2->assert_owner(), + MY_EXPECT_DEATH_IF_SUPPORTED(cache_2->assert_owner(), assert_string); #endif @@ -744,9 +744,9 @@ TEST_F(TableCacheDoubleCacheDeathTest, ManagerLockAndUnlock) { // Nor caches nor LOCK_open should not be locked after initialization #ifdef SAFE_MUTEX - EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.assert_owner_all(), + MY_EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.assert_owner_all(), assert_string); - EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.assert_owner_all_and_tdc(), + MY_EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.assert_owner_all_and_tdc(), assert_string); #endif @@ -768,9 +768,9 @@ TEST_F(TableCacheDoubleCacheDeathTest, ManagerLockAndUnlock) table_cache_manager.unlock_all_and_tdc(); #ifdef SAFE_MUTEX - EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.assert_owner_all(), + MY_EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.assert_owner_all(), assert_string); - EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.assert_owner_all_and_tdc(), + MY_EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.assert_owner_all_and_tdc(), assert_string); #endif } @@ -814,7 +814,7 @@ TEST_F(TableCacheDoubleCacheDeathTest, ManagerFreeTable) // to free all tables for share_1, while some tables // are in use. #ifndef DBUG_OFF - EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.free_table(thd_1, + MY_EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.free_table(thd_1, TDC_RT_REMOVE_ALL, &share_1), ".*Assertion.*is_empty.*"); @@ -848,7 +848,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 - EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.free_table(thd_1, + MY_EXPECT_DEATH_IF_SUPPORTED(table_cache_manager.free_table(thd_1, TDC_RT_REMOVE_NOT_OWN, &share_1), ".*Assertion.*0.*"); diff --git a/unittest/gunit/thd_manager-t.cc b/unittest/gunit/thd_manager-t.cc index f16e5a596f1..58e7af75592 100644 --- a/unittest/gunit/thd_manager-t.cc +++ b/unittest/gunit/thd_manager-t.cc @@ -292,7 +292,7 @@ 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. - EXPECT_DEATH_IF_SUPPORTED(thd_manager->release_thread_id(thread_id), + MY_EXPECT_DEATH_IF_SUPPORTED(thd_manager->release_thread_id(thread_id), ".*Assertion .*1 == num_erased.*"); } #endif diff --git a/unittest/gunit/thread_utils.h b/unittest/gunit/thread_utils.h index 157c3b95647..0219c2178be 100644 --- a/unittest/gunit/thread_utils.h +++ b/unittest/gunit/thread_utils.h @@ -19,6 +19,9 @@ #include #include +#include +#include + namespace thread { /* @@ -92,4 +95,56 @@ class Notification } // namespace thread +class disable_core_dumps_in_scope +{ +private: + disable_core_dumps_in_scope(const disable_core_dumps_in_scope &); + disable_core_dumps_in_scope& operator = (const disable_core_dumps_in_scope &); + + struct rlimit saved_core_rlimit; + +public: + disable_core_dumps_in_scope() + { + int ret= getrlimit(RLIMIT_CORE, &saved_core_rlimit); + if (ret != 0) + { + perror("getrlimit(RLIMIT_CORE) failed"); + assert(ret == 0); + } + + struct rlimit disabled_core_rlimit= saved_core_rlimit; + disabled_core_rlimit.rlim_cur= 0; + + ret= setrlimit(RLIMIT_CORE, &disabled_core_rlimit); + if (ret != 0) + { + perror("setrlimit(RLIMIT_CORE) failed"); + assert(ret == 0); + } + } + + ~disable_core_dumps_in_scope() + { + int ret= setrlimit(RLIMIT_CORE, &saved_core_rlimit); + if (ret != 0) + { + perror("setrlimit(RLIMIT_CORE) failed"); + assert(ret == 0); + } + } +}; + +#define MY_EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ + do { \ + disable_core_dumps_in_scope disable_core_dumps; \ + EXPECT_DEATH_IF_SUPPORTED(statement, regex); \ + } while (0) + +#define MY_EXPECT_DEATH(statement, regex) \ + do { \ + disable_core_dumps_in_scope disable_core_dumps; \ + EXPECT_DEATH(statement, regex); \ + } while (0) + #endif // SQL_THREAD_INCLUDED