Skip to content

Commit e90a0e3

Browse files
author
Christopher Powers
committed
Bug#22662621 UNIT TEST PFS_INSTR_OOM-T LEAKS MEMORY
Clean up failing and crashing unit tests.
1 parent e1786ed commit e90a0e3

File tree

3 files changed

+98
-53
lines changed

3 files changed

+98
-53
lines changed

storage/perfschema/unittest/pfs-t.cc

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -730,23 +730,27 @@ void test_init_disabled()
730730
socket_class_A= find_socket_class(socket_key_A);
731731
ok(socket_class_A != NULL, "socket class A");
732732

733-
/* Pretend thread T-1 is running, and disabled, with thread_instrumentation */
733+
/*
734+
Pretend thread T-1 is running, and disabled, with thread_instrumentation.
735+
Disabled instruments are still created so they can be enabled later.
736+
*/
737+
734738
/* ------------------------------------------------------------------------ */
735739

736740
psi->set_thread(thread_1);
737741
setup_thread(thread_1, false);
738742

739-
/* disabled M-A + disabled T-1: no instrumentation */
743+
/* disabled M-A + disabled T-1: instrumentation */
740744

741745
mutex_class_A->m_enabled= false;
742746
mutex_A1= psi->init_mutex(mutex_key_A, NULL);
743-
ok(mutex_A1 == NULL, "mutex_A1 not instrumented");
747+
ok(mutex_A1 != NULL, "mutex_A1 disabled, instrumented");
744748

745749
/* enabled M-A + disabled T-1: instrumentation (for later) */
746750

747751
mutex_class_A->m_enabled= true;
748752
mutex_A1= psi->init_mutex(mutex_key_A, NULL);
749-
ok(mutex_A1 != NULL, "mutex_A1 instrumented");
753+
ok(mutex_A1 != NULL, "mutex_A1 enabled, instrumented");
750754

751755
/* broken key + disabled T-1: no instrumentation */
752756

@@ -760,13 +764,13 @@ void test_init_disabled()
760764

761765
rwlock_class_A->m_enabled= false;
762766
rwlock_A1= psi->init_rwlock(rwlock_key_A, NULL);
763-
ok(rwlock_A1 == NULL, "rwlock_A1 not instrumented");
767+
ok(rwlock_A1 != NULL, "rwlock_A1 disabled, instrumented");
764768

765769
/* enabled RW-A + disabled T-1: instrumentation (for later) */
766770

767771
rwlock_class_A->m_enabled= true;
768772
rwlock_A1= psi->init_rwlock(rwlock_key_A, NULL);
769-
ok(rwlock_A1 != NULL, "rwlock_A1 instrumented");
773+
ok(rwlock_A1 != NULL, "rwlock_A1 enabled, instrumented");
770774

771775
/* broken key + disabled T-1: no instrumentation */
772776

@@ -780,13 +784,13 @@ void test_init_disabled()
780784

781785
cond_class_A->m_enabled= false;
782786
cond_A1= psi->init_cond(cond_key_A, NULL);
783-
ok(cond_A1 == NULL, "cond_A1 not instrumented");
787+
ok(cond_A1 != NULL, "cond_A1 disabled, instrumented");
784788

785789
/* enabled C-A + disabled T-1: instrumentation (for later) */
786790

787791
cond_class_A->m_enabled= true;
788792
cond_A1= psi->init_cond(cond_key_A, NULL);
789-
ok(cond_A1 != NULL, "cond_A1 instrumented");
793+
ok(cond_A1 != NULL, "cond_A1 enabled, instrumented");
790794

791795
/* broken key + disabled T-1: no instrumentation */
792796

@@ -815,22 +819,22 @@ void test_init_disabled()
815819
file_class_A->m_enabled= true;
816820
psi->create_file(0, "foo", (File) 12);
817821
file_A1= lookup_file_by_name("foo");
818-
ok(file_A1 == NULL, "not instrumented");
822+
ok(file_A1 == NULL, "file_A1 not instrumented");
819823
psi->create_file(99, "foo", (File) 12);
820824
file_A1= lookup_file_by_name("foo");
821-
ok(file_A1 == NULL, "not instrumented");
825+
ok(file_A1 == NULL, "file_A1 not instrumented");
822826

823827
/* disabled S-A + disabled T-1: no instrumentation */
824828

825829
socket_class_A->m_enabled= false;
826830
socket_A1= psi->init_socket(socket_key_A, NULL, NULL, 0);
827-
ok(socket_A1 == NULL, "socket_A1 not instrumented");
831+
ok(socket_A1 != NULL, "socket_A1 disabled, instrumented");
828832

829833
/* enabled S-A + disabled T-1: instrumentation (for later) */
830834

831835
socket_class_A->m_enabled= true;
832836
socket_A1= psi->init_socket(socket_key_A, NULL, NULL, 0);
833-
ok(socket_A1 != NULL, "socket_A1 instrumented");
837+
ok(socket_A1 != NULL, "socket_A1 enabled, instrumented");
834838

835839
/* broken key + disabled T-1: no instrumentation */
836840

@@ -849,85 +853,85 @@ void test_init_disabled()
849853

850854
mutex_class_A->m_enabled= false;
851855
mutex_A1= psi->init_mutex(mutex_key_A, NULL);
852-
ok(mutex_A1 == NULL, "not instrumented");
856+
ok(mutex_A1 != NULL, "mutex_A1 disabled, instrumented");
853857

854858
/* enabled M-A + enabled T-1: instrumentation */
855859

856860
mutex_class_A->m_enabled= true;
857861
mutex_A1= psi->init_mutex(mutex_key_A, NULL);
858-
ok(mutex_A1 != NULL, "instrumented");
862+
ok(mutex_A1 != NULL, "mutex_A1 enabled, instrumented");
859863
psi->destroy_mutex(mutex_A1);
860864

861865
/* broken key + enabled T-1: no instrumentation */
862866

863867
mutex_class_A->m_enabled= true;
864868
mutex_A1= psi->init_mutex(0, NULL);
865-
ok(mutex_A1 == NULL, "not instrumented");
869+
ok(mutex_A1 == NULL, "mutex_A1 not instrumented");
866870
mutex_A1= psi->init_mutex(99, NULL);
867-
ok(mutex_A1 == NULL, "not instrumented");
871+
ok(mutex_A1 == NULL, "mutex_A1 not instrumented");
868872

869873
/* disabled RW-A + enabled T-1: no instrumentation */
870874

871875
rwlock_class_A->m_enabled= false;
872876
rwlock_A1= psi->init_rwlock(rwlock_key_A, NULL);
873-
ok(rwlock_A1 == NULL, "not instrumented");
877+
ok(rwlock_A1 != NULL, "rwlock_A1 disabled, instrumented");
874878

875879
/* enabled RW-A + enabled T-1: instrumentation */
876880

877881
rwlock_class_A->m_enabled= true;
878882
rwlock_A1= psi->init_rwlock(rwlock_key_A, NULL);
879-
ok(rwlock_A1 != NULL, "instrumented");
883+
ok(rwlock_A1 != NULL, "rwlock_A1 enabled, instrumented");
880884
psi->destroy_rwlock(rwlock_A1);
881885

882886
/* broken key + enabled T-1: no instrumentation */
883887

884888
rwlock_class_A->m_enabled= true;
885889
rwlock_A1= psi->init_rwlock(0, NULL);
886-
ok(rwlock_A1 == NULL, "not instrumented");
890+
ok(rwlock_A1 == NULL, "rwlock_A1 not instrumented");
887891
rwlock_A1= psi->init_rwlock(99, NULL);
888-
ok(rwlock_A1 == NULL, "not instrumented");
892+
ok(rwlock_A1 == NULL, "rwlock_A1 not instrumented");
889893

890894
/* disabled C-A + enabled T-1: no instrumentation */
891895

892896
cond_class_A->m_enabled= false;
893897
cond_A1= psi->init_cond(cond_key_A, NULL);
894-
ok(cond_A1 == NULL, "not instrumented");
898+
ok(cond_A1 != NULL, "cond_A1 disabled, instrumented");
895899

896900
/* enabled C-A + enabled T-1: instrumentation */
897901

898902
cond_class_A->m_enabled= true;
899903
cond_A1= psi->init_cond(cond_key_A, NULL);
900-
ok(cond_A1 != NULL, "instrumented");
904+
ok(cond_A1 != NULL, "cond_A1 enabled, instrumented");
901905
psi->destroy_cond(cond_A1);
902906

903907
/* broken key + enabled T-1: no instrumentation */
904908

905909
cond_class_A->m_enabled= true;
906910
cond_A1= psi->init_cond(0, NULL);
907-
ok(cond_A1 == NULL, "not instrumented");
911+
ok(cond_A1 == NULL, "cond_A1 not instrumented");
908912
cond_A1= psi->init_cond(99, NULL);
909-
ok(cond_A1 == NULL, "not instrumented");
913+
ok(cond_A1 == NULL, "cond_A1 not instrumented");
910914

911915
/* disabled F-A + enabled T-1: no instrumentation */
912916

913917
file_class_A->m_enabled= false;
914918
psi->create_file(file_key_A, "foo", (File) 12);
915919
file_A1= lookup_file_by_name("foo");
916-
ok(file_A1 == NULL, "not instrumented");
920+
ok(file_A1 == NULL, "file_A1 not instrumented");
917921

918922
/* enabled F-A + open failed + enabled T-1: no instrumentation */
919923

920924
file_class_A->m_enabled= true;
921925
psi->create_file(file_key_A, "foo", (File) -1);
922926
file_A1= lookup_file_by_name("foo");
923-
ok(file_A1 == NULL, "not instrumented");
927+
ok(file_A1 == NULL, "file_A1 not instrumented");
924928

925929
/* enabled F-A + out-of-descriptors + enabled T-1: no instrumentation */
926930

927931
file_class_A->m_enabled= true;
928932
psi->create_file(file_key_A, "foo", (File) 65000);
929933
file_A1= lookup_file_by_name("foo");
930-
ok(file_A1 == NULL, "not instrumented");
934+
ok(file_A1 == NULL, "file_A1 not instrumented");
931935
ok(file_handle_lost == 1, "lost a file handle");
932936
file_handle_lost= 0;
933937

@@ -951,22 +955,22 @@ void test_init_disabled()
951955
/* disabled S-A + enabled T-1: no instrumentation */
952956

953957
socket_class_A->m_enabled= false;
954-
ok(socket_A1 == NULL, "not instrumented");
958+
ok(socket_A1 == NULL, "socket_A1 not instrumented");
955959

956960
/* enabled S-A + enabled T-1: instrumentation */
957961

958962
socket_class_A->m_enabled= true;
959963
socket_A1= psi->init_socket(socket_key_A, NULL, NULL, 0);
960-
ok(socket_A1 != NULL, "instrumented");
964+
ok(socket_A1 != NULL, "socket_A1 instrumented");
961965
psi->destroy_socket(socket_A1);
962966

963967
/* broken key + enabled T-1: no instrumentation */
964968

965969
socket_class_A->m_enabled= true;
966970
socket_A1= psi->init_socket(0, NULL, NULL, 0);
967-
ok(socket_A1 == NULL, "not instrumented");
971+
ok(socket_A1 == NULL, "socket_A1 not instrumented");
968972
socket_A1= psi->init_socket(99, NULL, NULL, 0);
969-
ok(socket_A1 == NULL, "not instrumented");
973+
ok(socket_A1 == NULL, "socket_A1 not instrumented");
970974

971975
/* Pretend the running thread is not instrumented */
972976
/* ---------------------------------------------- */
@@ -977,13 +981,13 @@ void test_init_disabled()
977981

978982
mutex_class_A->m_enabled= false;
979983
mutex_A1= psi->init_mutex(mutex_key_A, NULL);
980-
ok(mutex_A1 == NULL, "mutex_A1 not instrumented");
984+
ok(mutex_A1 != NULL, "mutex_A1 disabled, instrumented");
981985

982986
/* enabled M-A + unknown thread: instrumentation (for later) */
983987

984988
mutex_class_A->m_enabled= true;
985989
mutex_A1= psi->init_mutex(mutex_key_A, NULL);
986-
ok(mutex_A1 != NULL, "mutex_A1 instrumented");
990+
ok(mutex_A1 != NULL, "mutex_A1 enabled, instrumented");
987991

988992
/* broken key + unknown thread: no instrumentation */
989993

@@ -997,13 +1001,13 @@ void test_init_disabled()
9971001

9981002
rwlock_class_A->m_enabled= false;
9991003
rwlock_A1= psi->init_rwlock(rwlock_key_A, NULL);
1000-
ok(rwlock_A1 == NULL, "rwlock_A1 not instrumented");
1004+
ok(rwlock_A1 != NULL, "rwlock_A1 disabled, instrumented");
10011005

10021006
/* enabled RW-A + unknown thread: instrumentation (for later) */
10031007

10041008
rwlock_class_A->m_enabled= true;
10051009
rwlock_A1= psi->init_rwlock(rwlock_key_A, NULL);
1006-
ok(rwlock_A1 != NULL, "rwlock_A1 instrumented");
1010+
ok(rwlock_A1 != NULL, "rwlock_A1 enabled, instrumented");
10071011

10081012
/* broken key + unknown thread: no instrumentation */
10091013

@@ -1017,13 +1021,13 @@ void test_init_disabled()
10171021

10181022
cond_class_A->m_enabled= false;
10191023
cond_A1= psi->init_cond(cond_key_A, NULL);
1020-
ok(cond_A1 == NULL, "cond_A1 not instrumented");
1024+
ok(cond_A1 != NULL, "cond_A1 disabled, instrumented");
10211025

10221026
/* enabled C-A + unknown thread: instrumentation (for later) */
10231027

10241028
cond_class_A->m_enabled= true;
10251029
cond_A1= psi->init_cond(cond_key_A, NULL);
1026-
ok(cond_A1 != NULL, "cond_A1 instrumented");
1030+
ok(cond_A1 != NULL, "cond_A1 enabled, instrumented");
10271031

10281032
/* broken key + unknown thread: no instrumentation */
10291033

@@ -1038,14 +1042,14 @@ void test_init_disabled()
10381042
file_class_A->m_enabled= false;
10391043
psi->create_file(file_key_A, "foo", (File) 12);
10401044
file_A1= lookup_file_by_name("foo");
1041-
ok(file_A1 == NULL, "not instrumented");
1045+
ok(file_A1 == NULL, "file_A1 not instrumented");
10421046

10431047
/* enabled F-A + unknown thread: no instrumentation */
10441048

10451049
file_class_A->m_enabled= true;
10461050
psi->create_file(file_key_A, "foo", (File) 12);
10471051
file_A1= lookup_file_by_name("foo");
1048-
ok(file_A1 == NULL, "not instrumented");
1052+
ok(file_A1 == NULL, "file_A1 not instrumented");
10491053

10501054
/* broken key + unknown thread: no instrumentation */
10511055

@@ -1061,13 +1065,13 @@ void test_init_disabled()
10611065

10621066
socket_class_A->m_enabled= false;
10631067
socket_A1= psi->init_socket(socket_key_A, NULL, NULL, 0);
1064-
ok(socket_A1 == NULL, "socket_A1 not instrumented");
1068+
ok(socket_A1 != NULL, "socket_A1 disabled, instrumented");
10651069

10661070
/* enabled S-A + unknown thread: instrumentation (for later) */
10671071

10681072
socket_class_A->m_enabled= true;
10691073
socket_A1= psi->init_socket(socket_key_A, NULL, NULL, 0);
1070-
ok(socket_A1 != NULL, "socket_A1 instrumented");
1074+
ok(socket_A1 != NULL, "socket_A1 enabled, instrumented");
10711075

10721076
/* broken key + unknown thread: no instrumentation */
10731077

0 commit comments

Comments
 (0)