summaryrefslogtreecommitdiffstats
path: root/src/usr/errl/test/errltest.H
blob: 32e798ac4e76b59ce76ae4f3d1adddf29b8948a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/errl/test/errltest.H $                                */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2011,2019                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#ifndef __ERRLTEST_H
#define __ERRLTEST_H

/**
 *  @file errltest.H
 *
 *  @brief Test case for Error Logging
*/

#include <cxxtest/TestSuite.H>
#include <errl/errlmanager.H>
#include <errl/errlentry.H>
#include <errl/errlreasoncodes.H>
#include <trace/trace.H>
#include <hbotcompid.H>

#include <errl/errludtarget.H>
#include <targeting/common/target.H>
#include <targeting/namedtarget.H>
#include <targeting/common/iterators/rangefilter.H>
#include <targeting/common/predicates/predicates.H>
#include <hwas/common/hwasCallout.H>
#include <hwas/common/deconfigGard.H>
#include <targeting/common/utilFilter.H>

#include "../../trace/entry.H"
#include "../errlentry_consts.H"

#define TEST_SEVERITY       ERRORLOG::ERRL_SEV_INFORMATIONAL


#define TEST_USR_8BIT_1    0x80
#define TEST_USR_8BIT_2    0x93

#define TEST_USR_16BIT_1    0x8000
#define TEST_USR_16BIT_2    0x9003

#define TEST_USR_32BIT_1     0x80000001
#define TEST_USR_32BIT_2     0x90000003

#define TEST_USR_64BIT_1    0x8000000000000001
#define TEST_USR_64BIT_2    0x9000000000000003


namespace ERRORLOG
{

class ErrlTest: public CxxTest::TestSuite
{
public:


    /**
     * @brief Test error log creation
     *  - Create an error log
     *  - Verify data of created log
     *  - Commit an error log
     *  - Delete an error log
     */
    void testErrl1(void)
    {
        bool fOK;
        ERRORLOG::ErrlUD * pffdc;

        // An example that shows how to use macros to stuff data into
        // the two 64-bit user data parameters in the error log.
        // l_userData1 = 16bit(0):l_bit8_1:l_bit8_2:l_32bit_1
        uint8_t l_8bit_1 = TEST_USR_8BIT_1;      // 0x80
        uint8_t l_8bit_2 = TEST_USR_8BIT_2;      // 0x93
        uint32_t l_32bit_1 = TEST_USR_32BIT_1;   // 0x80000001
        uint64_t l_userData1 =
          TWO_UINT32_TO_UINT64( TO_UINT32(TWO_UINT8_TO_UINT16(l_8bit_1, l_8bit_2)), l_32bit_1);
            // yields 0x0000809380000001


        // l_userData2 = l_16bit_1:l_16bit_2:l_32bit_2
        uint16_t l_16bit_1 = TEST_USR_16BIT_1;  // 0x8000
        uint16_t l_16bit_2 = TEST_USR_16BIT_2;  // 0x9003
        uint32_t l_32bit_2 = TEST_USR_32BIT_2;  // 0x90000003
        uint64_t l_userData2 = TWO_UINT16_ONE_UINT32_TO_UINT64(l_16bit_1, l_16bit_2, l_32bit_2);
            // yields 0x8000900390000003



        do
        {
            /*@
             * @errortype
             * @reasoncode  ERRORLOG::ERRL_TEST_REASON_CODE
             * @severity    ERRORLOG::ERRL_SEV_INFORMATIONAL
             * @moduleid    ERRORLOG::ERRL_TEST_MOD_ID
             * @devdesc     Errl test. Error with non-decoded string
             *              and lots of trace buffers.
             */

            // Create an error log
            errlHndl_t l_err = new ERRORLOG::ErrlEntry(
                                    ERRORLOG::ERRL_SEV_INFORMATIONAL,
                                    ERRORLOG::ERRL_TEST_MOD_ID,
                                    ERRORLOG::ERRL_TEST_REASON_CODE,
                                    l_userData1,
                                    l_userData2);

            // These addFFDC() calls return a pointer to class ERRORLOG::ErrlFFDC
            // but errlffdc.H is not publicly includable to give me the definition
            // for it.  addFFDC() should return a Boolean indication of success.

            // really short user data
            const char * pch = "A";
            pffdc = l_err->addFFDC( DEVFW_COMP_ID, pch, strlen( pch ), 0, 0);
            if ( NULL == pffdc )
            {
                TS_FAIL("testErrl1: addFFDC() output NULL pointer");
                break;
            }

            // Append data to something already added.
            pch = " test-user-data-string";
            l_err->appendToFFDC( pffdc, pch, strlen(pch) );

            // Collect trace
            fOK = l_err->collectTrace(  "INITSVC" );
            if( !fOK )
            {
                TS_FAIL( "collectTrace(INITSVC) rets false." );
                break;
            }

            // Assuming trace buffers are 0x800 in size, and you're going
            // after a trace buffer that has wrapped, then a size almost as
            // big as the buffer will exercise the wrapping code in
            // trace::getBuffer()
            fOK = l_err->collectTrace(  "XSCOM" , 0x7D0 );
            if( !fOK )
            {
                TS_FAIL( "collectTrace(XSCOM) rets false." );
                break;
            }

            fOK = l_err->collectTrace(  "UNKNOWN"  );
            if( fOK )
            {
                TS_FAIL( "collectTrace(UNKNOWN) rets true" );
                break;
            }

            fOK = l_err->collectTrace("TARG",
                                      sizeof(TRACE::trace_buf_head_t)-2);
            if( fOK )
            {
                // expect an error, buffer not big enough
                TS_FAIL( "collectTrace(TARG,38) rets true" );
                break;
            }

            fOK = l_err->collectTrace("TARG",
                                      sizeof(TRACE::trace_buf_head_t));
            if( !fOK )
            {
                // Buffer is big enough for the header only. It is
                // supposed to work, although not terribly useful.
                TS_FAIL( "collectTrace(TARG,40) rets false" );
                break;
            }

            // sizeof( trace_buf_head_t ) + n bytes such that a single trace
            // entry cannot fit into.
            uint64_t l_cb = sizeof(TRACE::trace_buf_head_t) +
                            (sizeof(TRACE::trace_bin_entry_t)/2);
            fOK = l_err->collectTrace( "TARG", l_cb );
            if( !fOK )
            {
                // cb is big enough for the header only, but no
                // room for any entries.
                TS_FAIL( "collectTrace(TARG,l_cb) rets false", l_cb );
                break;
            }

            // Normal buffer sizes are 0x800 (2048), so passing
            // something bigger is not expected to be an error.
            fOK = l_err->collectTrace(  "TARG" , 4003 );
            if( !fOK )
            {
                TS_FAIL( "collectTrace(TARG,4003) rets false" );
                break;
            }


            // Add null data.
            pffdc = l_err->addFFDC( ERRL_COMP_ID, NULL, 0,  9, 10 );
            if ( NULL != pffdc )
            {
                TS_FAIL("testErrl1: addFFDC() returned non null");
                break;
            }

            // Verify log data
            if (l_err->sev() != ERRORLOG::ERRL_SEV_INFORMATIONAL)
            {
                TS_FAIL("testErrl1: createErrlLog() returns incorrect severity!");
                break;
            }

            if (l_err->reasonCode() != ERRORLOG::ERRL_TEST_REASON_CODE)
            {
                TS_FAIL("testErrl1: createErrlLog() returns incorrect reason code!");
                break;
            }

            if (l_err->eventType() != ERRORLOG::ERRL_ETYPE_NOT_APPLICABLE)
            {
                TS_FAIL("testErrl1: createErrlLog() returns incorrect event type!");
                break;
            }

            if (l_err->subSys() != ERRORLOG::EPUB_FIRMWARE_SUBSYS )
            {
                TS_FAIL("testErrl1: createErrlLog() returns incorrect sub system!");
                break;
            }

            if (l_err->srcType() != ERRORLOG::SRC_ERR_INFO)
            {
                TS_FAIL("testErrl1: createErrlLog() returns incorrect SRC type!");
                break;
            }

            if (l_err->termState() != ERRORLOG::TERM_STATE_UNKNOWN)
            {
                TS_FAIL("testErrl1: termState() returns incorrect term state!");
                break;
            }



            // Commit error log with different component ID.
            errlCommit(l_err, CXXTEST_COMP_ID);

            // Make sure error log has been deleted by manager
            if (l_err != NULL)
            {
                TS_FAIL("testErrl1: commitErrLog() did not delete error!");
                break;
            }

        }
        while(0);
    }

    /**
     * @brief Test error log parameter settings
     */
    void testErrl2(void)
    {
        // An example that shows how to use macros to stuff data into
        // the two 64-bit user data parameters in the error log.
        // l_userData1 = l_bit32_1:l_bit32_2
        uint32_t l_32bit_1 = TEST_USR_32BIT_1;
        uint32_t l_32bit_2 = TEST_USR_32BIT_2;
        uint64_t l_userData1 = TWO_UINT32_TO_UINT64(l_32bit_1, l_32bit_2);

        // l_userData2 = 24bit(0):l_8bit_1:16bit(0):l_16bit_1
        uint8_t l_8bit_1 = TEST_USR_8BIT_1;
        uint16_t l_16bit_1 = TEST_USR_16BIT_1;
        uint64_t l_userData2 =
                TWO_UINT32_TO_UINT64(TO_UINT32(l_8bit_1), TO_UINT32(l_16bit_1));

        // Create an error log
        errlHndl_t l_err = new ERRORLOG::ErrlEntry(
                                ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                ERRORLOG::ERRL_TEST_MOD_ID,
                                ERRORLOG::ERRL_TEST_REASON_CODE,
                                l_userData1,
                                l_userData2);

        // Set and verify log data
        l_err->setSev(ERRORLOG::ERRL_SEV_UNKNOWN);
        l_err->setEventType(ERRORLOG::ERRL_ETYPE_CAPACITY_UPGRADE);
        l_err->setSubSys(ERRORLOG::EPUB_UNKNOWN);
        l_err->setSrcType(ERRORLOG::SRC_ERR_INFO);
        l_err->setTermState(ERRORLOG::TERM_STATE_NO_FLAGS);

        if (l_err->sev() != ERRORLOG::ERRL_SEV_UNKNOWN)
        {
            TS_FAIL("testErrl2: setSev() fails!");
        }
        else if (l_err->eventType() != ERRORLOG::ERRL_ETYPE_CAPACITY_UPGRADE)
        {
            TS_FAIL("testErrl2: setEventType() fails!");
        }
        else if (l_err->subSys() != ERRORLOG::EPUB_UNKNOWN)
        {
            TS_FAIL("testErrl2: setSubSys() fails!");
        }
        else if (l_err->srcType() != ERRORLOG::SRC_ERR_INFO)
        {
            TS_FAIL("testErrl2: setSrcType() fails!");
        }
        else if (l_err->termState() != ERRORLOG::TERM_STATE_NO_FLAGS)
        {
             TS_FAIL("testErrl2: setTermState() fails!");
        }

        // Delete the log
        delete l_err;
        l_err = NULL;
    }

    /**
     * @brief Test callouts
     */
    void testErrl3(void)
    {
        TS_TRACE( "test testErrl3");
#if 1
        // these tests deconfigure and gard targets. and even tho they
        //  restore their state after the tests, since the cxxtests are
        //  all run in parallel, during the time that a target is non-
        //  functional due to this test, another test may be running that
        //  might be adversly affected.
        // tests are left in the code so that a developer can enable them
        //  to test these specific functions - just keep in mind that there
        //  could be side effects in other cxxtests.
        TS_TRACE( " - SKIPPING -- other tests could be adversly affected");
#else
        do
        {
            // find some ex units that we can play with
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);

            TARGETING::PredicateCTM predEx(TARGETING::CLASS_UNIT,
                                                TARGETING::TYPE_EX);
            TARGETING::PredicateHwas predFunctional;
            predFunctional.poweredOn(true).present(true).functional(true);
            TARGETING::PredicatePostfixExpr checkExpr;
            checkExpr.push(&predEx).push(&predFunctional).And();
            TARGETING::TargetHandleList pExList;
            TARGETING::targetService().getAssociated( pExList, pSys,
                TARGETING::TargetService::CHILD, TARGETING::TargetService::ALL,
                &checkExpr );

            if (pExList.empty())
            {
                TS_FAIL("testErrl3: empty pExList");
                break;
            }
            TARGETING::TargetHandle_t pTarget = *pExList.begin();

            errlHndl_t gard_errl = NULL;
            HWAS::DeconfigGard::DeconfigureRecords_t l_deconfigRecords;
            HWAS::DeconfigGard::GardRecords_t l_gardRecords;
            uint32_t deconfigCount = 0;
            uint32_t gardCount = 0;

            // make sure there aren't any existing deconfigure or gard records
            gard_errl = HWAS::theDeconfigGard()._getDeconfigureRecords(NULL,
                    l_deconfigRecords);
            if (gard_errl)
            {
                TS_FAIL("testErrl3: Error from _getDeconfigureRecords");
                errlCommit(gard_errl,HWAS_COMP_ID);
                break;
            }
            if (l_deconfigRecords.size() != 0)
            {
                TS_TRACE("testErrl3: %d existing Deconfigure Records, "
                            "skipping test", l_deconfigRecords.size());
                break;
            }

            gard_errl = HWAS::theDeconfigGard().getGardRecords(
                    NULL, l_gardRecords);
            if (gard_errl)
            {
                TS_FAIL("testErrl3: Error from getGardRecords");
                errlCommit(gard_errl,HWAS_COMP_ID);
                break;
            }
            if (l_gardRecords.size() != 0)
            {
                TS_TRACE("testErrl3: %d existing GARD Records, "
                            "skipping test", l_gardRecords.size());
                break;
            }

            // Create an error log
            errlHndl_t errl = new ERRORLOG::ErrlEntry(
                                    ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                    ERRORLOG::ERRL_TEST_MOD_ID,
                                    ERRORLOG::ERRL_TEST_REASON_CODE);

            // test the different callout types
            TS_TRACE("test callout target %.8X", TARGETING::get_huid(pTarget));
            ERRORLOG::ErrlUserDetailsTarget(pTarget).addToLog(errl);

            errl->addHwCallout(pTarget,
                    HWAS::SRCI_PRIORITY_LOW,
                    HWAS::DELAYED_DECONFIG,
                    HWAS::GARD_Fatal);
            deconfigCount++;
            gardCount++;

            errlCommit(errl, CXXTEST_COMP_ID);
            errl = new ERRORLOG::ErrlEntry(
                                    ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                    ERRORLOG::ERRL_TEST_MOD_ID,
                                    ERRORLOG::ERRL_TEST_REASON_CODE);

            errl->addHwCallout(pTarget,
                    HWAS::SRCI_PRIORITY_MED,
                    HWAS::DELAYED_DECONFIG,
                    HWAS::GARD_NULL);

            errlCommit(errl, CXXTEST_COMP_ID);
            errl = new ERRORLOG::ErrlEntry(
                                    ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                    ERRORLOG::ERRL_TEST_MOD_ID,
                                    ERRORLOG::ERRL_TEST_REASON_CODE);

            errl->addHwCallout(TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL,
                    HWAS::SRCI_PRIORITY_LOW,
                    HWAS::NO_DECONFIG,
                    HWAS::GARD_PHYP);
            gardCount++;

            errlCommit(errl, CXXTEST_COMP_ID);
            errl = new ERRORLOG::ErrlEntry(
                                    ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                    ERRORLOG::ERRL_TEST_MOD_ID,
                                    ERRORLOG::ERRL_TEST_REASON_CODE);

            errl->addHwCallout(TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL,
                    HWAS::SRCI_PRIORITY_MED,
                    HWAS::DELAYED_DECONFIG,
                    HWAS::GARD_NULL);
            deconfigCount++;

            errlCommit(errl, CXXTEST_COMP_ID);

            errl = new ERRORLOG::ErrlEntry(
                                    ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                    ERRORLOG::ERRL_TEST_MOD_ID,
                                    ERRORLOG::ERRL_TEST_REASON_CODE);

            errl->addProcedureCallout(
                    HWAS::EPUB_PRC_MEMORY_PLUGGING_ERROR,
                    HWAS::SRCI_PRIORITY_HIGH);

            errlCommit(errl, CXXTEST_COMP_ID);


            errl = new ERRORLOG::ErrlEntry(
                                    ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                    ERRORLOG::ERRL_TEST_MOD_ID,
                                    ERRORLOG::ERRL_TEST_REASON_CODE);

            errl->addClockCallout(
                pExList[0],
                HWAS::TODCLK_TYPE,
                HWAS::SRCI_PRIORITY_MED);

            // Clock callout using deconfig/GARD parameters
            errl->addClockCallout(
                pExList[0],
                HWAS::TODCLK_TYPE,
                HWAS::SRCI_PRIORITY_HIGH,
                HWAS::NO_DECONFIG,
                HWAS::GARD_NULL);

            // Part callout using deconfig/GARD parameters
            errl->addPartCallout(
                pExList[0],
                HWAS::PNOR_PART_TYPE,
                HWAS::SRCI_PRIORITY_HIGH,
                HWAS::NO_DECONFIG,
                HWAS::GARD_NULL);


            if (pExList.size() > 1)
            {
                errl->addBusCallout(
                    pExList[0],
                    pExList[1],
                    HWAS::A_BUS_TYPE,
                    HWAS::SRCI_PRIORITY_LOW);
            }

            errlCommit(errl, CXXTEST_COMP_ID);

            // confirm there are the correct number of deconfig and gard records
            gard_errl = HWAS::theDeconfigGard().getGardRecords(
                    NULL, l_gardRecords);
            if (gard_errl)
            {
                TS_FAIL("testCallout: Error from getGardRecords");
                errlCommit(gard_errl,HWAS_COMP_ID);
            }
            else if (l_gardRecords.size() != gardCount)
            {
                TS_TRACE("testCallout: %d GARD Records, expected %d",
                            l_gardRecords.size(), gardCount);
            }

            gard_errl = HWAS::theDeconfigGard()._getDeconfigureRecords(NULL,
                    l_deconfigRecords);
            if (gard_errl)
            {
                TS_FAIL("testCallout: Error from _getDeconfigureRecords");
                errlCommit(gard_errl,HWAS_COMP_ID);
            }
            else if (l_deconfigRecords.size() != deconfigCount)
            {
                TS_FAIL("testCallout: %d Deconfigure Records, expected %d",
                            l_deconfigRecords.size(), deconfigCount);
            }

            // delete these deconfigure and gard records
            HWAS::theDeconfigGard().clearDeconfigureRecords(NULL);
            gard_errl = HWAS::theDeconfigGard().clearGardRecords(NULL);
            if (gard_errl)
            {
                errlCommit(gard_errl,HWAS_COMP_ID);
                TS_FAIL("testCallout: Error from clearGardRecords");
            }
            TS_TRACE( "testErrl3 done");

        }
        while(0);
#endif
    }

    /**
     * @brief Test callouts
     */
    void testErrl4(void)
    {
        TS_TRACE( "test testErrl4");
#if 1
        // these tests deconfigure and gard targets. and even tho they
        //  restore their state after the tests, since the cxxtests are
        //  all run in parallel, during the time that a target is non-
        //  functional due to this test, another test may be running that
        //  might be adversly affected.
        // tests are left in the code so that a developer can enable them
        //  to test these specific functions - just keep in mind that there
        //  could be side effects in other cxxtests.
        TS_TRACE( " - SKIPPING -- other tests could be adversly affected");
#else
        do
        {
            // find a ex unit that we can play with
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);

            TARGETING::PredicateCTM predEx(TARGETING::CLASS_UNIT,
                                            TARGETING::TYPE_EX);
            TARGETING::PredicateHwas predFunctional;
            predFunctional.poweredOn(true).present(true).functional(true);
            TARGETING::PredicatePostfixExpr checkExpr;
            checkExpr.push(&predEx).push(&predFunctional).And();

            TARGETING::TargetHandleList pExList;
            TARGETING::targetService().getAssociated( pExList, pSys,
                TARGETING::TargetService::CHILD, TARGETING::TargetService::ALL,
                &checkExpr );

            if (pExList.empty())
            {
                TS_FAIL("test callout: empty pExList");
                break;
            }

            TARGETING::TargetHandle_t l_target = *pExList.begin();

            TARGETING::PredicateCTM l_L4s(TARGETING::CLASS_UNIT,
                                          TARGETING::TYPE_L4);

            TARGETING::TargetRangeFilter pL4(
                    TARGETING::targetService().begin(),
                    TARGETING::targetService().end(),
                    &l_L4s);

            // Create an error log
            errlHndl_t errl = new ERRORLOG::ErrlEntry(
                                    ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                    ERRORLOG::ERRL_TEST_MOD_ID,
                                    ERRORLOG::ERRL_TEST_REASON_CODE);

            // test the different callout types
            TS_TRACE( "test callout pEx %p", l_target);
            ERRORLOG::ErrlUserDetailsTarget(l_target).addToLog(errl);

            errl->addHwCallout(*pL4,
                    HWAS::SRCI_PRIORITY_HIGH,
                    HWAS::DECONFIG,
                    HWAS::GARD_NULL);

            // make this one high too - should end up with B120 src
            // as the first high priority callout is mem subsys
            errl->addHwCallout( l_target,
                    HWAS::SRCI_PRIORITY_HIGH,
                    HWAS::DECONFIG,
                    HWAS::GARD_NULL);

            errl->addProcedureCallout(
                    HWAS::EPUB_PRC_HB_CODE,
                    HWAS::SRCI_PRIORITY_HIGH);

            errlCommit(errl, CXXTEST_COMP_ID);

            TS_TRACE( "testErrl4 done");

        }
        while(0);
#endif
    }

    /**
     * @brief Test callouts
     */
    void testErrlr5(void)
    {
        TS_TRACE( "test testErrl5");
#if 1
        // these tests deconfigure and gard targets. and even tho they
        //  restore their state after the tests, since the cxxtests are
        //  all run in parallel, during the time that a target is non-
        //  functional due to this test, another test may be running that
        //  might be adversly affected.
        // tests are left in the code so that a developer can enable them
        //  to test these specific functions - just keep in mind that there
        //  could be side effects in other cxxtests.
        TS_TRACE( " - SKIPPING -- other tests could be adversly affected");
#else
        do
        {
            // find a ex unit that we can play with
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);

            TARGETING::PredicateCTM predEx(TARGETING::CLASS_UNIT,
                                            TARGETING::TYPE_EX);
            TARGETING::PredicateHwas predFunctional;
            predFunctional.poweredOn(true).present(true).functional(true);
            TARGETING::PredicatePostfixExpr checkExpr;
            checkExpr.push(&predEx).push(&predFunctional).And();

            TARGETING::TargetHandleList pExList;
            TARGETING::targetService().getAssociated( pExList, pSys,
                TARGETING::TargetService::CHILD, TARGETING::TargetService::ALL,
                &checkExpr );

            if (pExList.empty())
            {
                TS_FAIL("test callout: empty pExList");
                break;
            }

            TARGETING::TargetHandle_t l_target = *pExList.begin();

            // find a membuf target
            TARGETING::PredicateCTM membufChipFilter(
                    TARGETING::CLASS_CHIP,TARGETING::TYPE_MEMBUF);
            TARGETING::TargetRangeFilter pMembuf(
                    TARGETING::targetService().begin(),
                    TARGETING::targetService().end(),
                    &membufChipFilter);

            // Create an error log
            errlHndl_t errl = new ERRORLOG::ErrlEntry(
                                    ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                    ERRORLOG::ERRL_TEST_MOD_ID,
                                    ERRORLOG::ERRL_TEST_REASON_CODE);

            // test the different callout types
            TS_TRACE( "test callout pEx %p", l_target);
            ERRORLOG::ErrlUserDetailsTarget(l_target).addToLog(errl);

            errl->addHwCallout(*pMembuf,
                    HWAS::SRCI_PRIORITY_HIGH,
                    HWAS::DECONFIG,
                    HWAS::GARD_NULL);

            errl->addHwCallout(TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL,
                    HWAS::SRCI_PRIORITY_LOW,
                    HWAS::DECONFIG,
                    HWAS::GARD_NULL);

            errl->addProcedureCallout(
                    HWAS::EPUB_PRC_MEMORY_PLUGGING_ERROR,
                    HWAS::SRCI_PRIORITY_MED );

            errlCommit(errl, CXXTEST_COMP_ID);

            TS_TRACE( "testErrl5 done");

        }
        while(0);
#endif
    }

    /**
     * @brief Test ECIDs in callouts
     */
    void testErrl6(void)
    {
        TS_TRACE( "test testErrl6");
#if 1
        //  all run in parallel, during the time that a target is non-
        //  functional due to this test, another test may be running that
        //  might be adversly affected.
        //  tests are left in the code so that a developer can enable them
        //  to test these specific functions - just keep in mind that there
        //  could be side effects in other cxxtests.
        TS_TRACE( " - SKIPPING -- other tests could be adversly affected");
#else
        do
        {
            // find a ex unit that we can play with
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);

            TARGETING::PredicateCTM predEx(TARGETING::CLASS_UNIT,
                                           TARGETING::TYPE_EX);
            TARGETING::PredicateHwas predFunctional;
            predFunctional.poweredOn(true).present(true).functional(true);
            TARGETING::PredicatePostfixExpr checkExpr;
            checkExpr.push(&predEx).push(&predFunctional).And();

            TARGETING::TargetHandleList pExList;
            TARGETING::targetService().getAssociated( pExList, pSys,
                TARGETING::TargetService::CHILD, TARGETING::TargetService::ALL,
                &checkExpr );

            if (pExList.empty())
            {
                TS_FAIL("test callout: empty pExList");
                break;
            }

            TARGETING::TargetHandle_t l_target = *pExList.begin();

            // find a membuf target
            TARGETING::PredicateCTM membufChipFilter(
                TARGETING::CLASS_CHIP,TARGETING::TYPE_MEMBUF);
            TARGETING::TargetRangeFilter pMembuf(
                TARGETING::targetService().begin(),
                TARGETING::targetService().end(),
                &membufChipFilter);

            // Create an error log
            errlHndl_t errl = new ERRORLOG::ErrlEntry(
                                    ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                    ERRORLOG::ERRL_TEST_MOD_ID,
                                    ERRORLOG::ERRL_TEST_REASON_CODE);

            TS_TRACE( "test callout pEx %p", l_target);
            ERRORLOG::ErrlUserDetailsTarget(l_target).addToLog(errl);

            //HW callout with Membuf target, after ECID has been read.
            // ECID should be present
            errl->addHwCallout(*pMembuf,
                   HWAS::SRCI_PRIORITY_HIGH,
                   HWAS::NO_DECONFIG,
                   HWAS::GARD_NULL);
            uint64_t l_ecid[2];
            (*pMembuf)->tryGetAttr<TARGETING::ATTR_ECID>(l_ecid);
            bool correctECID = containsEcidData(errl,l_ecid);
            if(!correctECID)
            {
                TS_FAIL("testErrl6: ECID value incorrect from target %p",
                       (*pMembuf));
                break;
            }

            errlCommit(errl, CXXTEST_COMP_ID);
            errl = new ERRORLOG::ErrlEntry(
                            ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                            ERRORLOG::ERRL_TEST_MOD_ID,
                            ERRORLOG::ERRL_TEST_REASON_CODE);


            //Hw callout with non-proc and non-membuf target before
            // ECID has been read. ECID should be present for parent target.
            // We have to find the parent target, and get the ecid value
            // before calling the containsEcidData() checker function.
            const TARGETING::Target* l_parentTarget = getParentChip(l_target);
            (l_parentTarget)->tryGetAttr<TARGETING::ATTR_ECID>(l_ecid);

            errl->addHwCallout(l_target,
                   HWAS::SRCI_PRIORITY_HIGH,
                   HWAS::NO_DECONFIG,
                   HWAS::GARD_NULL);
            correctECID = containsEcidData(errl,l_ecid);
            if(!correctECID)
            {
                TS_FAIL("testErrl6: ECID value incorrect from target %p",
                       (l_target));
                break;
            }

            errlCommit(errl,CXXTEST_COMP_ID);

            TS_TRACE("testErrl6 done");
        }
        while(0);
#endif
    }
    bool containsEcidData(errlHndl_t &i_errl, uint64_t* i_ecidOrig)
    {
        TS_TRACE("containsEcidData errlogId 0x%.8x",i_errl->eid());
        bool l_dataMatching = false;
        uint32_t* l_ecid_data = NULL;

        // look thru the errlog for any Attribute UserDetail sections
        //  to find the ecid data, check that it matches the
        //  expected value and return true or false.
        for(std::vector<ERRORLOG::ErrlUD*>::const_iterator
                it = i_errl->iv_SectionVector.begin();
                it != i_errl->iv_SectionVector.end();
                it++ )
        {
            l_ecid_data = (uint32_t *)((*it)->iv_pData);

            //look for an ATTR_ECID section
            if((ERRL_COMP_ID     == (*it)->iv_header.iv_compId) &&
               (1                == (*it)->iv_header.iv_ver) &&
               (ERRORLOG::ERRL_UDT_ATTRIBUTE == (*it)->iv_header.iv_sst) &&
               (TARGETING::ATTR_ECID         == l_ecid_data[0])
              )
            {
                uint64_t l_ecidCompare[2] = {l_ecid_data[1],l_ecid_data[3]};
                l_ecidCompare[0] = (l_ecidCompare[0] << 32) | l_ecid_data[2];
                l_ecidCompare[1] = (l_ecidCompare[1] << 32) | l_ecid_data[4];
                if((l_ecidCompare[0] == i_ecidOrig[0]) &&
                   (l_ecidCompare[1] == i_ecidOrig[1]))
                {
                    l_dataMatching = true;
                    break;
                }
            }
        }

        TS_TRACE("containsEcidData");
        return l_dataMatching;
    }

   /**
     * @brief Test CORE callout
     */
    void testErrl7(void)
    {
        TS_TRACE( "test testErrl7");
#if 1
        // these tests deconfigure and gard targets. and even tho they
        //  restore their state after the tests, since the cxxtests are
        //  all run in parallel, during the time that a target is non-
        //  functional due to this test, another test may be running that
        //  might be adversly affected.
        // tests are left in the code so that a developer can enable them
        //  to test these specific functions - just keep in mind that there
        //  could be side effects in other cxxtests.
        TS_TRACE( " - SKIPPING -- other tests could be adversly affected");
#else
        do
        {
            // find a core unit that we can play with
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);

            TARGETING::PredicateCTM predCore(TARGETING::CLASS_UNIT,
                                           TARGETING::TYPE_CORE);
            TARGETING::PredicateHwas predFunctional;
            predFunctional.poweredOn(true).present(true).functional(true);
            TARGETING::PredicatePostfixExpr checkExpr;
            checkExpr.push(&predCore).push(&predFunctional).And();

            TARGETING::TargetHandleList l_coreList;
            TARGETING::targetService().getAssociated( l_coreList, pSys,
                TARGETING::TargetService::CHILD, TARGETING::TargetService::ALL,
                &checkExpr );

            if (l_coreList.empty())
            {
                TS_FAIL("test callout: empty l_coreList");
                break;
            }

            TARGETING::TargetHandle_t l_target = *l_coreList.begin();

            // Create an error log
            errlHndl_t errl = new ERRORLOG::ErrlEntry(
                                    ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                    ERRORLOG::ERRL_TEST_MOD_ID,
                                    ERRORLOG::ERRL_TEST_REASON_CODE);

            // test the different callout types
            TS_TRACE( "test callout l_core %p", l_target);
            ERRORLOG::ErrlUserDetailsTarget(l_target).addToLog(errl);

            errl->addHwCallout(l_target,
                    HWAS::SRCI_PRIORITY_HIGH,
                    HWAS::DECONFIG,
                    HWAS::GARD_User_Manual);

            errlCommit(errl, CXXTEST_COMP_ID);

            TS_TRACE("testErrl7 done");
        }
        while(0);
#endif
    }
        /**
     *  @brief Test No Gard on Informational error logs
     */
    void testdeconfigNoGardInformational()
    {
#if 1
        // these tests deconfigure and gard targets. and even tho they
        //  restore their state after the tests, since the cxxtests are
        //  all run in parallel, during the time that a target is non-
        //  functional due to this test, another test may be running that
        //  might be adversly affected.
        // tests are left in the code so that a developer can enable them
        //  to test these specific functions - just keep in mind that there
        //  could be side effects in other cxxtests.
        TS_TRACE( " - SKIPPING -- other tests could be adversly affected");
#else
        do
        {
            // find a ex unit that we can play with
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);

            TARGETING::PredicateCTM predEx(TARGETING::CLASS_UNIT, TARGETING::TYPE_EX);
            TARGETING::PredicateHwas predFunctional;
            predFunctional.poweredOn(true).present(true).functional(true);
            TARGETING::PredicatePostfixExpr checkExpr;
            checkExpr.push(&predEx).push(&predFunctional).And();
            TARGETING::TargetHandleList pExList;
            TARGETING::targetService().getAssociated( pExList, pSys,
                TARGETING::TargetService::CHILD, TARGETING::TargetService::ALL, &checkExpr );

            if (pExList.empty())
            {
                TS_FAIL("testdeconfigNoGardInformational: empty pExList");
                break;
            }

            errlHndl_t errl = NULL;
            HWAS::DeconfigGard::DeconfigureRecords_t l_deconfigRecords;
            HWAS::DeconfigGard::GardRecords_t l_gardRecords;
            HWAS::DeconfigGard::DeconfigureRecords_t l_deconfigRecordsAfter;
            HWAS::DeconfigGard::GardRecords_t l_gardRecordsAfter;

            // make sure there aren't any existing deconfigure or gard records
            errl = HWAS::theDeconfigGard()._getDeconfigureRecords(NULL,
                    l_deconfigRecords);
            if (errl)
            {
                TS_FAIL("testdeconfigNoGardInformational: Error from "
                    "_getDeconfigureRecords");
                errlCommit(errl,HWAS_COMP_ID);
                break;
            }
            if (l_deconfigRecords.size() != 0)
            {
                TS_INFO("testdeconfigNoGardInformational: %d existing "
                    "Deconfigure Records, skipping test",
                    l_deconfigRecords.size());
                break;
            }

            errl = HWAS::theDeconfigGard().getGardRecords(
                    NULL, l_gardRecords);
            if (errl)
            {
                TS_FAIL("testdeconfigNoGardInformational: Error from "
                    "getGardRecords");
                errlCommit(errl,HWAS_COMP_ID);
                break;
            }
            if (l_gardRecords.size() != 0)
            {
                TS_INFO("testdeconfigNoGardInformational: %d existing "
                    "GARD Records, skipping test", l_gardRecords.size());
                break;
            }

            errl = new ERRORLOG::ErrlEntry(
                                    ERRORLOG::ERRL_SEV_INFORMATIONAL,
                                    ERRORLOG::ERRL_TEST_MOD_ID,
                                    ERRORLOG::ERRL_TEST_REASON_CODE);


            // Part callout using deconfig/GARD parameters
            errl->addHwCallout(
                pExList[0],
                HWAS::SRCI_PRIORITY_LOW,
                HWAS::DECONFIG,
                HWAS::GARD_Fatal);

            errlCommit(errl, CXXTEST_COMP_ID);

            // Flush out errorlogs so we make sure deconfigs/gards are logged
            // before we check for them
            ERRORLOG::ErrlManager::callFlushErrorLogs();

            // Check gard and deconfigs - should be none.
            errlHndl_t gard_errl = NULL;

            gard_errl = HWAS::theDeconfigGard()._getDeconfigureRecords(NULL,
                        l_deconfigRecordsAfter);

            if (gard_errl)
            {
                TS_FAIL("testdeconfigNoGardInformational: Error from "
                    "_getDeconfigureRecords - post deconfigs");
                errlCommit(errl,HWAS_COMP_ID);
                break;
            }
            if (l_deconfigRecordsAfter.size() != l_deconfigRecords.size())
            {
                TS_INFO("testdeconfigNoGardInformational: %d "
                    "Deconfigure Records, expecting none. TEST FAILED",
                    l_deconfigRecordsAfter.size());
                TS_FAIL("testdeconfigNoGardInformational: Deconfig records "
                    "present, expecting none.");
                break;
            }

            gard_errl = HWAS::theDeconfigGard().getGardRecords(
                    NULL, l_gardRecordsAfter);

            if (gard_errl)
            {
                TS_FAIL("testdeconfigNoGardInformational: Error from "
                    "getGardRecords - post deconfigs");
                errlCommit(errl,HWAS_COMP_ID);
                break;
            }
            if (l_gardRecords.size() != l_gardRecordsAfter.size())
            {
                TS_INFO("testdeconfigNoGardInformational: %d GARD Records "
                    "present, expecting none. TEST FAILED",
                    l_gardRecordsAfter.size());
                TS_FAIL("testdeconfigNoGardInformational: GARD records "
                    "present, expecting none.");
                break;
            }
        }while(0);
#endif
    }

   /**
     * @brief Guarantee TARGET_TO_SUBSYS_TABLE is in order
     */
    void testErrl_subsysOrder(void)
    {
        // TARGET_TO_SUBSYS_TABLE must be sorted by type, this
        //  test ensures that is true
        TARGETING::TYPE l_lastType = TARGET_TO_SUBSYS_TABLE[0].xType;
        for( size_t i = 1; //start on 2nd entry
             i < (sizeof(TARGET_TO_SUBSYS_TABLE)/
                  sizeof(TARGET_TO_SUBSYS_TABLE[0]));
             i++ )
        {
            if( TARGET_TO_SUBSYS_TABLE[i].xType < l_lastType )
            {
                TS_FAIL( "testErrl_subsysOrder> %d is out of order",
                         TARGET_TO_SUBSYS_TABLE[i].xType );
            }
            l_lastType = TARGET_TO_SUBSYS_TABLE[i].xType;
        }
    }


    /**
     * @brief Guarantee non-visible logs do not post callouts
     */
    void testErrl_hidecallouts(void)
    {
        // Find a non-master core that is currently functional
        TARGETING::TargetHandleList l_cores;
        TARGETING::getAllChiplets( l_cores, TARGETING::TYPE_CORE, true );
        TARGETING::Target* l_victim = nullptr;
        const TARGETING::Target* l_master = TARGETING::getMasterCore();
        for( auto c : l_cores )
        {
            if( c != l_master )
            {
                l_victim = c;
                break;
            }
        }
        if( l_victim == nullptr )
        {
            TS_FAIL( "Could not find a non-master core" );
            return;
        }

        // Create an informational log
        errlHndl_t l_err = nullptr;
        l_err = new ERRORLOG::ErrlEntry(
                                        ERRORLOG::ERRL_SEV_INFORMATIONAL,
                                        ERRORLOG::ERRL_TEST_MOD_ID,
                                        ERRORLOG::ERRL_TEST_REASON_CODE,
                                        0x494E464F, //INFO
                                        0 );
        // Add a callout with deconfig and gard
        l_err->addHwCallout( l_victim,
                             HWAS::SRCI_PRIORITY_HIGH,
                             HWAS::DECONFIG,
                             HWAS::GARD_Fatal );
        // Commit the log
        errlCommit(l_err,CXXTEST_COMP_ID);

        // Verify that the target wasn't actually deconfigured
        TARGETING::ATTR_HWAS_STATE_type l_state =
          l_victim->getAttr<TARGETING::ATTR_HWAS_STATE>();
        if( !l_state.functional )
        {
            TS_FAIL( "Info log incorrectly caused deconfig" );
        }


        // Create a recovered log
        l_err = new ERRORLOG::ErrlEntry(
                                        ERRORLOG::ERRL_SEV_RECOVERED,
                                        ERRORLOG::ERRL_TEST_MOD_ID,
                                        ERRORLOG::ERRL_TEST_REASON_CODE,
                                        0x52454300, //REC
                                        0 );
        // Add a callout with deconfig and gard
        l_err->addHwCallout( l_victim,
                             HWAS::SRCI_PRIORITY_HIGH,
                             HWAS::DECONFIG,
                             HWAS::GARD_Fatal );
        // Commit the log
        errlCommit(l_err,CXXTEST_COMP_ID);

        // Verify that the target wasn't actually deconfigured
        l_state =
          l_victim->getAttr<TARGETING::ATTR_HWAS_STATE>();
        if( !l_state.functional )
        {
            TS_FAIL( "Recovered log incorrectly caused deconfig" );
        }
    }

    /**
     * @brief Verify subsystem mapping
     *
     * Simple test for now that targets test for defects in this area
     * Can be expanded on later if time permits
     */
    void testErrl_verifySubsystem(void)
    {
        errlHndl_t l_err = nullptr;
        l_err = new ERRORLOG::ErrlEntry(
                                        ERRORLOG::ERRL_SEV_INFORMATIONAL,
                                        ERRORLOG::ERRL_TEST_MOD_ID,
                                        ERRORLOG::ERRL_TEST_REASON_CODE,
                                        0x494E464F, //INFO
                                        0);
        // Simple test for now to verify correct subsys comes back
        // for MC target type
        epubSubSystem_t l_subsys = l_err->getSubSystem(TARGETING::TYPE_MC);
        if(l_subsys != EPUB_MEMORY_SUBSYS)
        {
            TS_FAIL( "Incorrect subsystem type returned for TYPE_MC" );
        }
        else
        {
            TS_INFO( "Correct subsystem type returned for TYPE_MC!" );
        }

        l_subsys = l_err->getSubSystem(TARGETING::TYPE_SMPGROUP);
        if(l_subsys != EPUB_CEC_HDW_SUBSYS)
        {
            TS_FAIL( "Incorrect subsystem type returned for TYPE_SMPGROUP" );
        }
        else
        {
            TS_INFO( "Correct subsystem type returned for TYPE_SMPGROUP!" );
        }
        // Delete the log
        delete l_err;
        l_err = NULL;
    }

    /**
     * @brief Ensure all callouts have a SUBSYS mapping
     *
     */
    void testErrl_ensureSubsystemMapping(void)
    {
        // dummy log to call non-static methods with
        errlHndl_t l_err = new ERRORLOG::ErrlEntry(
                ERRORLOG::ERRL_SEV_INFORMATIONAL,
                ERRORLOG::ERRL_TEST_MOD_ID,
                ERRORLOG::ERRL_TEST_REASON_CODE,
                0x494E464F, //INFO
                0);

        // Walk through every BUS_TYPE
        for( busTypeEnum bus = (busTypeEnum)(NO_BUS_TYPE+1);
             bus < LAST_BUS_TYPE;
             bus = (busTypeEnum)(bus+1) )
        {
            if( l_err->getSubSystem(bus) == EPUB_MISC_UNKNOWN )
            {
                TS_FAIL( "No subsystem returned for BUS_TYPE %d", bus );
            }
        }

        // Walk through every PART_TYPE
        for( partTypeEnum part = (partTypeEnum)(NO_PART_TYPE+1);
             part < LAST_PART_TYPE;
             part = (partTypeEnum)(part+1) )
        {
            if( l_err->getSubSystem(part) == EPUB_MISC_UNKNOWN )
            {
                TS_FAIL( "No subsystem returned for PART_TYPE %d", part );
            }
        }

        // Walk through every SENSOR_TYPE
        for( sensorTypeEnum sensor = (sensorTypeEnum)(UNKNOWN_SENSOR+1);
             sensor < LAST_SENSOR_TYPE;
             sensor = (sensorTypeEnum)(sensor+1) )
        {
            if( l_err->getSubSystem(sensor) == EPUB_MISC_UNKNOWN )
            {
                TS_FAIL( "No subsystem returned for SENSOR_TYPE %d", sensor );
            }
        }

        // Note - Can't loop over epubProcedureID because the values are
        //  sparsely populated

    }


};
}

#endif

OpenPOWER on IntegriCloud