diff --git a/spec/support/shared/contexts/metasploit/framework/spec/constants/cleaner.rb b/spec/support/shared/contexts/metasploit/framework/spec/constants/cleaner.rb index 345552c8d6190..767c604625540 100644 --- a/spec/support/shared/contexts/metasploit/framework/spec/constants/cleaner.rb +++ b/spec/support/shared/contexts/metasploit/framework/spec/constants/cleaner.rb @@ -1,6 +1,8 @@ # Use in a context to clean up the constants that are created by the module loader. RSpec.shared_context 'Metasploit::Framework::Spec::Constants cleaner' do after(:example) do + $stderr.puts "cleaning constants" Metasploit::Framework::Spec::Constants.clean + $stderr.puts "constants cleaned" end -end \ No newline at end of file +end diff --git a/spec/support/shared/contexts/msf/framework/threads/cleaner.rb b/spec/support/shared/contexts/msf/framework/threads/cleaner.rb index 758fd0988bd48..b2c6c62acf2a1 100644 --- a/spec/support/shared/contexts/msf/framework/threads/cleaner.rb +++ b/spec/support/shared/contexts/msf/framework/threads/cleaner.rb @@ -1,5 +1,6 @@ RSpec.shared_context 'Msf::Framework#threads cleaner' do |options = {}| after(:example) do |example| + $stderr.puts "starting to kill threads" if options.fetch(:verify_cleanup_required, true) && !framework.threads? fail RuntimeError.new( "framework.threads was never initialized. There are no threads to clean up. " \ @@ -11,14 +12,24 @@ # explicitly kill threads so that they don't exhaust connection pool thread_manager = framework.threads + $stderr.puts "starting to kill threads" thread_manager.each do |thread| + puts "-----------------------------------------------------" + thread_deets = "thread=#{thread} - name=#{thread[:tm_name]} --- backtrace=#{thread.backtrace ? thread.backtrace.join("\n") : 'no backtrace'} ---" + $stderr.puts "killing thread #{thread_deets}" thread.kill + $stderr.puts "Waiting to join" # ensure killed thread is cleaned up by VM thread.join + $stderr.puts "Joined on thread" + $stderr.puts end + $stderr.puts "Killing thread manager monitor" thread_manager.monitor.kill # ensure killed thread is cleaned up by VM + $stderr.puts "Joining killed thread monitor" thread_manager.monitor.join + $stderr.puts "successfully joined thread monitor" end end diff --git a/spec/support/shared/contexts/msf/simple/framework.rb b/spec/support/shared/contexts/msf/simple/framework.rb index 8d7bc31e8868f..6a0982fce09bf 100644 --- a/spec/support/shared/contexts/msf/simple/framework.rb +++ b/spec/support/shared/contexts/msf/simple/framework.rb @@ -23,6 +23,8 @@ end after(:example) do + $stderr.puts "before cleaning framework path" FileUtils.rm_rf(dummy_pathname) + $stderr.puts "after cleaning framework path" end end