diff --git a/t/pt-pmp/pt-pmp-threads.t b/t/pt-pmp/pt-pmp-threads.t new file mode 100644 index 00000000..201a7685 --- /dev/null +++ b/t/pt-pmp/pt-pmp-threads.t @@ -0,0 +1,42 @@ +#!/usr/bin/env perl + +BEGIN { + die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n" + unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH}; + unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib"; +}; + +use strict; +use warnings FATAL => 'all'; +use English qw(-no_match_vars); + +use PerconaTest; +use Test::More; + +my $sample = "$trunk/t/pt-pmp/samples/stacktrace001.in"; + +ok( + no_diff( + "$trunk/bin/pt-pmp -t ^25 $sample", + "t/pt-pmp/samples/stacktrace001_t25.out", + ), + '-t ^25 prints stack traces for threads those numbers start from 25' +) or diag($test_diff); + +ok( + no_diff( + "$trunk/bin/pt-pmp -t 21201,23846 $sample", + "t/pt-pmp/samples/stacktrace001_t21201_23846.out", + ), + '-t 21201,23846 prints stack traces for threads 21201,23846' +) or diag($test_diff); + +ok( + no_diff( + "$trunk/bin/pt-pmp -t 21201,237.8 $sample", + "t/pt-pmp/samples/stacktrace001_t21201_237_8.out", + ), + '-t 21201,237.8 prints stack traces for threads 21201, 23798, 23728' +) or diag($test_diff); + +done_testing; diff --git a/t/pt-pmp/samples/stacktrace001_t21201_237_8.out b/t/pt-pmp/samples/stacktrace001_t21201_237_8.out new file mode 100644 index 00000000..a1401757 --- /dev/null +++ b/t/pt-pmp/samples/stacktrace001_t21201_237_8.out @@ -0,0 +1 @@ + 3 __lll_mutex_lock_wait(libpthread.so.0),_L_mutex_lock_1133(libpthread.so.0),pthread_mutex_lock(libpthread.so.0),safe_mutex_lock,open_table,open_tables,open_and_lock_tables,mysql_execute_command,mysql_parse,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) diff --git a/t/pt-pmp/samples/stacktrace001_t21201_23846.out b/t/pt-pmp/samples/stacktrace001_t21201_23846.out new file mode 100644 index 00000000..10e3bdaa --- /dev/null +++ b/t/pt-pmp/samples/stacktrace001_t21201_23846.out @@ -0,0 +1,2 @@ + 1 __lll_mutex_lock_wait(libpthread.so.0),_L_mutex_lock_1133(libpthread.so.0),pthread_mutex_lock(libpthread.so.0),safe_mutex_lock,open_table,open_tables,open_and_lock_tables,mysql_execute_command,mysql_parse,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 1 __lll_mutex_lock_wait(libpthread.so.0),_L_mutex_lock_1133(libpthread.so.0),pthread_mutex_lock(libpthread.so.0),safe_mutex_lock,close_thread_tables,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) diff --git a/t/pt-pmp/samples/stacktrace001_t25.out b/t/pt-pmp/samples/stacktrace001_t25.out new file mode 100644 index 00000000..4262c617 --- /dev/null +++ b/t/pt-pmp/samples/stacktrace001_t25.out @@ -0,0 +1,4 @@ + 7 read(libpthread.so.0),vio_read(unistd.h:35),my_real_read,my_net_read,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 2 pthread_cond_wait,safe_cond_wait,end_thread,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 1 __lll_mutex_lock_wait(libpthread.so.0),_L_mutex_lock_1133(libpthread.so.0),pthread_mutex_lock(libpthread.so.0),safe_mutex_lock,open_table,open_tables,open_and_lock_tables,mysql_execute_command,mysql_parse,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6) + 1 __lll_mutex_lock_wait(libpthread.so.0),_L_mutex_lock_1133(libpthread.so.0),pthread_mutex_lock(libpthread.so.0),safe_mutex_lock,close_thread_tables,dispatch_command,handle_one_connection,start_thread(libpthread.so.0),clone(libc.so.6)