@@ -20,6 +20,11 @@ You should have received a copy of the GNU General Public License
20
20
along with this program; if not, write to the Free Software
21
21
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
22
23
+ #define MY_NAME " log_sink_test"
24
+ #define LOG_COMPONENT_TAG MY_NAME
25
+ // Test override. No non-test components should use a non-approved value here!
26
+ #define LOG_SUBSYSTEM_TAG MY_NAME
27
+
23
28
#include " log_service_imp.h"
24
29
25
30
#include < assert.h>
@@ -29,8 +34,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
29
34
#include < mysql/components/services/log_builtins.h>
30
35
#include < mysql/components/services/log_builtins_filter.h>
31
36
32
- #define MY_NAME " log_sink_test"
33
-
34
37
extern REQUIRES_SERVICE_PLACEHOLDER (registry);
35
38
36
39
REQUIRES_SERVICE_PLACEHOLDER (log_builtins);
@@ -155,6 +158,8 @@ static void test_add_item_log_me(log_filter_ruleset *rs, const char *label,
155
158
.string_value (KEY_PRS_ITEM, " test_me_for_presence" )
156
159
.string_value (KEY_DEL_ITEM, " delete_me_by_rule" )
157
160
.string_value (KEY_PRIO_CHANGE, VAL_PRIO_CHANGE)
161
+ .subsys (LOG_SUBSYSTEM_TAG)
162
+ .component (LOG_COMPONENT_TAG)
158
163
.source_file (MY_NAME)
159
164
.message (" filter_rules: (add_item %s) %d" , label, rs->count - orig_count);
160
165
}
@@ -176,6 +181,8 @@ static int test_if_then_else() {
176
181
.int_value (" wl9651_val3a" , 1 )
177
182
.int_value (" wl9651_val3b" , 2 )
178
183
.int_value (" wl9651_val3c" , 3 )
184
+ .subsys (LOG_SUBSYSTEM_TAG)
185
+ .component (LOG_COMPONENT_TAG)
179
186
.message (" WL#9651 expected: r1-IF, r2-SUCCESS, r3-SUCCESS" );
180
187
LogEvent ()
181
188
.type (LOG_TYPE_ERROR)
@@ -186,6 +193,8 @@ static int test_if_then_else() {
186
193
.int_value (" wl9651_val3a" , 0 )
187
194
.int_value (" wl9651_val3b" , 2 )
188
195
.int_value (" wl9651_val3c" , 3 )
196
+ .subsys (LOG_SUBSYSTEM_TAG)
197
+ .component (LOG_COMPONENT_TAG)
189
198
.message (" WL#9651 expected: r1-ELSEIF1, r2-SUCCESS, r3-FAILURE" );
190
199
LogEvent ()
191
200
.type (LOG_TYPE_ERROR)
@@ -196,6 +205,8 @@ static int test_if_then_else() {
196
205
.int_value (" wl9651_val3a" , 1 )
197
206
.int_value (" wl9651_val3b" , 0 )
198
207
.int_value (" wl9651_val3c" , 3 )
208
+ .subsys (LOG_SUBSYSTEM_TAG)
209
+ .component (LOG_COMPONENT_TAG)
199
210
.message (" WL#9651 expected: r1-ELSEIF2, r2-FAILURE, r3-FAILURE" );
200
211
LogEvent ()
201
212
.type (LOG_TYPE_ERROR)
@@ -206,6 +217,8 @@ static int test_if_then_else() {
206
217
.int_value (" wl9651_val3a" , 1 )
207
218
.int_value (" wl9651_val3b" , 2 )
208
219
.int_value (" wl9651_val3c" , 0 )
220
+ .subsys (LOG_SUBSYSTEM_TAG)
221
+ .component (LOG_COMPONENT_TAG)
209
222
.message (" WL#9651 expected: r1-ELSE, r2-FAILURE, r3-FAILURE" );
210
223
LogEvent ()
211
224
.type (LOG_TYPE_ERROR)
@@ -215,6 +228,8 @@ static int test_if_then_else() {
215
228
.string_value (" wl9651_val2" , " 1" )
216
229
.int_value (" wl9651_val3a" , 1 )
217
230
.int_value (" wl9651_val3c" , 3 )
231
+ .subsys (LOG_SUBSYSTEM_TAG)
232
+ .component (LOG_COMPONENT_TAG)
218
233
.message (" WL#9651 expected: r1-IF, r2-FAILURE, r3-FAILURE" );
219
234
return 0 ;
220
235
}
@@ -468,34 +483,44 @@ static int test_throttle(log_filter_ruleset *rs) {
468
483
.prio (INFORMATION_LEVEL)
469
484
.errcode (ER_PARSER_TRACE)
470
485
.source_line (__LINE__)
486
+ .subsys (LOG_SUBSYSTEM_TAG)
487
+ .component (LOG_COMPONENT_TAG)
471
488
.source_file (MY_NAME)
472
489
.message (
473
490
" below: 3*unknown error per writer == correct. "
474
491
" >3*unknown error per writer == filter fail. "
475
492
" 0*unknown error == " MY_NAME " fail." );
476
493
477
494
if ((log_bf->filter_ruleset_lock (rs, LOG_BUILTINS_LOCK_EXCLUSIVE)) < 0 ) {
495
+ /* purecov: begin inspected */
478
496
LogEvent ()
479
497
.type (LOG_TYPE_ERROR)
480
498
.prio (ERROR_LEVEL)
481
499
.errcode (ER_PARSER_TRACE)
500
+ .subsys (LOG_SUBSYSTEM_TAG)
501
+ .component (LOG_COMPONENT_TAG)
482
502
.message (MY_NAME
483
503
" : could not get a lock on built-in filter's "
484
504
" ruleset (for add)" );
485
505
return -1 ;
506
+ /* purecov: end */
486
507
}
487
508
488
509
orig_count = rs->count ;
489
510
490
511
if ((r = (log_filter_rule *)log_bf->filter_rule_init (rs)) == nullptr ) {
512
+ /* purecov: begin inspected */
491
513
LogEvent ()
492
514
.type (LOG_TYPE_ERROR)
493
515
.prio (ERROR_LEVEL)
494
516
.errcode (ER_PARSER_TRACE)
517
+ .subsys (LOG_SUBSYSTEM_TAG)
518
+ .component (LOG_COMPONENT_TAG)
495
519
.message (MY_NAME
496
520
" : could not init a rule in built-in filter's ruleset" );
497
521
rr = -2 ;
498
522
goto done;
523
+ /* purecov: end */
499
524
}
500
525
501
526
// set up a demo rate-limiter
@@ -523,6 +548,8 @@ static int test_throttle(log_filter_ruleset *rs) {
523
548
.type (LOG_TYPE_ERROR)
524
549
.prio (INFORMATION_LEVEL)
525
550
.errcode (ER_PARSER_TRACE)
551
+ .subsys (LOG_SUBSYSTEM_TAG)
552
+ .component (LOG_COMPONENT_TAG)
526
553
.source_line (__LINE__)
527
554
.source_file (MY_NAME)
528
555
.message (" filter_rules: (throttle: delta in medias res) %d" ,
@@ -535,20 +562,26 @@ static int test_throttle(log_filter_ruleset *rs) {
535
562
LogEvent ()
536
563
.type (LOG_TYPE_ERROR)
537
564
.prio (INFORMATION_LEVEL)
565
+ .subsys (LOG_SUBSYSTEM_TAG)
566
+ .component (LOG_COMPONENT_TAG)
538
567
.source_line (__LINE__)
539
568
.source_file (MY_NAME)
540
569
.lookup (ER_UNKNOWN_ERROR_NUMBER, 1 );
541
570
}
542
571
543
572
if ((log_bf->filter_ruleset_lock (rs, LOG_BUILTINS_LOCK_EXCLUSIVE)) < 0 ) {
573
+ /* purecov: begin inspected */
544
574
LogEvent ()
545
575
.type (LOG_TYPE_ERROR)
546
576
.prio (ERROR_LEVEL)
547
577
.errcode (ER_PARSER_TRACE)
578
+ .subsys (LOG_SUBSYSTEM_TAG)
579
+ .component (LOG_COMPONENT_TAG)
548
580
.message (MY_NAME
549
581
" : could not get a lock on built-in filter's "
550
582
" ruleset (for delete)" );
551
583
return -3 ;
584
+ /* purecov: end */
552
585
}
553
586
554
587
rule_delete (rs, LOG_ITEM_SQL_ERRCODE, nullptr , LOG_FILTER_COND_EQ,
@@ -563,6 +596,8 @@ static int test_throttle(log_filter_ruleset *rs) {
563
596
.type (LOG_TYPE_ERROR)
564
597
.prio (INFORMATION_LEVEL)
565
598
.errcode (ER_PARSER_TRACE)
599
+ .subsys (LOG_SUBSYSTEM_TAG)
600
+ .component (LOG_COMPONENT_TAG)
566
601
.source_line (__LINE__)
567
602
.source_file (MY_NAME)
568
603
.message (" filter_rules: (throttle: delta ex post) %d" ,
@@ -623,6 +658,8 @@ static void banner() {
623
658
.type (LOG_TYPE_ERROR)
624
659
.prio (INFORMATION_LEVEL)
625
660
.errcode (ER_PARSER_TRACE)
661
+ .subsys (LOG_SUBSYSTEM_TAG)
662
+ .component (LOG_COMPONENT_TAG)
626
663
.source_line (__LINE__)
627
664
.source_file (MY_NAME)
628
665
.float_value (" test_float" , 3.1415926927 )
@@ -659,6 +696,8 @@ static void banner() {
659
696
.type (LOG_TYPE_ERROR)
660
697
.prio (INFORMATION_LEVEL)
661
698
.errcode (ER_PARSER_TRACE)
699
+ .subsys (LOG_SUBSYSTEM_TAG)
700
+ .component (LOG_COMPONENT_TAG)
662
701
.message (" item_inconsistent(#%d): %s" , 1 ,
663
702
consistent[-log_bi->item_inconsistent (li)]);
664
703
@@ -669,6 +708,8 @@ static void banner() {
669
708
.type (LOG_TYPE_ERROR)
670
709
.prio (INFORMATION_LEVEL)
671
710
.errcode (ER_PARSER_TRACE)
711
+ .subsys (LOG_SUBSYSTEM_TAG)
712
+ .component (LOG_COMPONENT_TAG)
672
713
.message (" item_inconsistent(#%d): %s" , 2 ,
673
714
consistent[-log_bi->item_inconsistent (li)]);
674
715
@@ -680,6 +721,8 @@ static void banner() {
680
721
.type (LOG_TYPE_ERROR)
681
722
.prio (INFORMATION_LEVEL)
682
723
.errcode (ER_PARSER_TRACE)
724
+ .subsys (LOG_SUBSYSTEM_TAG)
725
+ .component (LOG_COMPONENT_TAG)
683
726
.message (" item_inconsistent(#%d): %s" , 2 ,
684
727
consistent[-log_bi->item_inconsistent (li)]);
685
728
@@ -691,6 +734,8 @@ static void banner() {
691
734
.type (LOG_TYPE_ERROR)
692
735
.prio (INFORMATION_LEVEL)
693
736
.errcode (ER_PARSER_TRACE)
737
+ .subsys (LOG_SUBSYSTEM_TAG)
738
+ .component (LOG_COMPONENT_TAG)
694
739
.message (" item_inconsistent(#%d): %s" , 3 ,
695
740
consistent[-log_bi->item_inconsistent (li)]);
696
741
@@ -704,6 +749,8 @@ static void banner() {
704
749
.type (LOG_TYPE_ERROR)
705
750
.prio (INFORMATION_LEVEL)
706
751
.errcode (ER_PARSER_TRACE)
752
+ .subsys (LOG_SUBSYSTEM_TAG)
753
+ .component (LOG_COMPONENT_TAG)
707
754
.message (" item_inconsistent(#%d): %s" , 4 ,
708
755
consistent[-log_bi->item_inconsistent (li)]);
709
756
@@ -718,6 +765,8 @@ static void banner() {
718
765
.type (LOG_TYPE_ERROR)
719
766
.prio (INFORMATION_LEVEL)
720
767
.errcode (ER_PARSER_TRACE)
768
+ .subsys (LOG_SUBSYSTEM_TAG)
769
+ .component (LOG_COMPONENT_TAG)
721
770
.message (" item_inconsistent(#%d): %s" , 5 ,
722
771
consistent[-log_bi->item_inconsistent (li)]);
723
772
}
0 commit comments