summaryrefslogtreecommitdiffstats
path: root/src/usr/targeting/common/test/testcommontargeting.H
blob: d94315d41ad76ef23db9fc53237dc9668e1adcb5 (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
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/targeting/common/test/testcommontargeting.H $         */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2011,2014              */
/*                                                                        */
/* p1                                                                     */
/*                                                                        */
/* Object Code Only (OCO) source materials                                */
/* Licensed Internal Code Source Materials                                */
/* IBM HostBoot Licensed Internal Code                                    */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#ifndef __TARGETING_COMMON_TESTCOMMONTARGETING_H
#define __TARGETING_COMMON_TESTCOMMONTARGETING_H

/**
 *  @file targeting/common/test/testtargeting.H
 *
 *  @brief All common unit tests for the targeting infrastructure
 */

//******************************************************************************
// Includes
//******************************************************************************

// STD
#include <stdio.h>
#include <sys/time.h>

// CXXTEST
#include <hwpf/plat/fapiPlatAttributeService.H>
#include <fapiReturnCode.H>
#include <fapiAttributeIds.H>
#include <fapiAttributeService.H>
#include <targeting/common/error.H>

// This component
#include <targeting/common/commontargeting.H>
#include <targeting/common/trace.H>
#include "unittest.H"

namespace TARGETING {
extern void dumpAllAttributes(TARG_TD_t,uint32_t);
extern TARG_TD_t g_trac_targeting;
};

class CommonTargetingTestSuite: public CxxTest::TestSuite
{
  public:
      /**
       *  @brief Test a portion of the debug code wich
       *  prints out the entity path types
       */
      void testEntityPathElementTypeAsString()
      {
#ifndef CONTEXT_x86_nfp
          // test_ep.H is generated by xmltohb.pl
          #include <test_ep.H>
#endif
      }
      /**
       *  @brief Test the TargetService class (except debug cases)
     */
    void testTargetServiceClass()
    {
        //@fixme - found a Data Storage Exception that needs to be fixed (Task
        // RTC 35625)
        return;

        TARG_TS_TRACE(ENTER_MRK "testTargetServiceClass" );

        using namespace TARGETING;

        TargetService& l_targetService = targetService();

        l_targetService.init();

        // Post init
        // Test: void masterProcChipTarget(
        //          TargetHandleList& o_masterProcChipTarget) const;

        Target* l_pMasterProcChipTargetHandle = NULL;
        (void) l_targetService.masterProcChipTargetHandle(
            l_pMasterProcChipTargetHandle);

        if (   l_pMasterProcChipTargetHandle
               == MASTER_PROCESSOR_CHIP_TARGET_SENTINEL)
        {
            TARG_TS_FAIL("Post init; master proc chip target handle should not "
                    "be the sentinel value");
        }

        if (l_pMasterProcChipTargetHandle == NULL)
        {
            TARG_TS_FAIL("Post init; master proc chip target handle should not "
                    "be the NULL value");
        }

        ScomSwitches l_switches = {0};
        l_switches =
          l_pMasterProcChipTargetHandle->getAttr<ATTR_SCOM_SWITCHES>();
        if(   l_switches.useFsiScom != 0
              || l_switches.useXscom != 1
              || l_switches.useInbandScom != 0
              || l_switches.reserved != 0)
        {
            TARG_TS_FAIL("SCOM Switches stuct was not correct (%d, %d, %d, %d)",
                    l_switches.useFsiScom, l_switches.useXscom,
                    l_switches.useInbandScom ,
                    l_switches.reserved);
        }

        if (   l_pMasterProcChipTargetHandle->getAttr<ATTR_CLASS> ()
               != CLASS_CHIP)
        {
            TARG_TS_FAIL("Post init; master proc chip target handle was not of "
                    "chip class");
        }

        if (   l_pMasterProcChipTargetHandle->getAttr<ATTR_TYPE> ()
               != TYPE_PROC)
        {
            TARG_TS_FAIL("Post init; master proc chip target handle was not of "
                    "proc type");
        }

        // Post init
        // Test: void getTopLevelTarget(Target*& o_targetHandle) const;

        Target* l_pTopLevel = NULL;
        (void) l_targetService.getTopLevelTarget(l_pTopLevel);
        if (l_pTopLevel == NULL)
        {
            TARG_TS_FAIL("Top level handle was NULL when initialization "
                    "complete");
        }

        if (l_pTopLevel->getAttr<ATTR_CLASS> () != CLASS_SYS)
        {
            TARG_TS_FAIL("Post init; top level target class != CLASS_SYS");
        }

        // Post init
        // Test: void exists(
        //           const EntityPath& i_entityPath,
        //               bool&       o_exists) const;
        bool l_exists = false;
        (void) l_targetService.exists(
                                      l_pTopLevel->getAttr<ATTR_PHYS_PATH> (), l_exists);

        if (l_exists != true)
        {
            TARG_TS_FAIL("Expected top level target to exist");
        }

        // Post init
        // Test: Target* toTarget(
        //     const EntityPath& i_entityPath) const;

        Target* l_pInverseTarget = NULL;
        l_pInverseTarget = l_targetService.toTarget(
                                                    l_pTopLevel->getAttr<ATTR_PHYS_PATH> ());

        if (l_pInverseTarget != l_pTopLevel)
        {
            TARG_TS_FAIL("Expected to get the original target");
        }

        // Post init
        // Tested API: Target* toTarget(
        //     const EntityPath& i_entityPath) const;
        // Behavior: Given an arbitrary target, I should be able to take its
        //     affinity path and convert it to the original target
        PredicateCTM mbaPredicate(CLASS_UNIT,TYPE_MBA);
        TargetRangeFilter mbaFilter(
            targetService().begin(),
            targetService().end(),
            &mbaPredicate);
        for(;mbaFilter;++mbaFilter)
        {
            Target* pCandidate = l_targetService.toTarget(
                mbaFilter->getAttr<ATTR_AFFINITY_PATH>());
            if (pCandidate != *mbaFilter)
            {
                TARG_TS_FAIL("Failed to convert MBA target's affinity path "
                             "back to original target");
            }
            break;
        }

        // Post init
        // Test: void getAssociated(
        // const Target*           i_pTarget,
        //      ASSOCIATION_TYPE  i_type,
        //      RECURSION_LEVEL   i_recursionLevel,
        //      TargetHandleList& o_list) const;

        TargetHandleList l_list;
        (void) l_targetService.getAssociated(
                                             l_list,
                                             l_pTopLevel,
                                             TARGETING::TargetService::CHILD,
                                             TARGETING::TargetService::IMMEDIATE);
        if (!l_list.size())
        {
            TARG_TS_FAIL("Should have found some child elements" );
        }

        // Verify child of given target has a parent that is the original
        // target

        TargetHandleList l_parentList;
        (void) l_targetService.getAssociated(
                                             l_parentList,
                                             l_list[0],
                                             TARGETING::TargetService::PARENT,
                                             TARGETING::TargetService::IMMEDIATE);

        if (l_parentList.size() != 1)
        {
            TARG_TS_FAIL("Should have found a parent element" );
        }

        if (l_parentList[0] != l_pTopLevel)
        {
            TARG_TS_FAIL("Parent handle should have matched original target "
                    "handle" );
        }

        (void) l_targetService.getAssociated(
                                             l_list,
                                             l_pTopLevel,
                                             TARGETING::TargetService::CHILD_BY_AFFINITY,
                                             TARGETING::TargetService::IMMEDIATE);

        if (!l_list.size())
        {
            TARG_TS_FAIL("Should have found some child elements" );
        }

        (void) l_targetService.getAssociated(
                                             l_list,
                                             l_pTopLevel,
                                             TARGETING::TargetService::CHILD_BY_AFFINITY,
                                             TARGETING::TargetService::ALL);

        if (!l_list.size())
        {
            TARG_TS_FAIL("Should have found more child elements" );
        }

        l_targetService.dump();

        TARG_TS_TRACE(EXIT_MRK "testTargetServiceClass" );
    }

    /**
     *  @test Tests the EntityPath class (except debug cases)
     */
    void testEntityPathClass(void)
    {
        TARG_TS_TRACE(ENTER_MRK "testEntityPathClass" );

        using namespace TARGETING;

        EntityPath l_defaultPath;
        if(l_defaultPath.size() != 0)
        {
            TARG_TS_FAIL("Default entity path's size was not 0");
        }

        if(l_defaultPath.type() != EntityPath::PATH_NA)
        {
            TARG_TS_FAIL("Default entity path's type was not PATH_NA");
        }

        EntityPath l_nonDefaultPath(EntityPath::PATH_PHYSICAL);
        if(l_nonDefaultPath.size() != 0)
        {
            TARG_TS_FAIL("Non-default entity path's size was not 0");
        }

        if(l_nonDefaultPath.type() != EntityPath::PATH_PHYSICAL)
        {
            TARG_TS_FAIL("Non-default entity path's type was not "
                    "EntityPath::PATH_PHYSICAL");
        }

        l_defaultPath.setType(EntityPath::PATH_AFFINITY);
        if(l_defaultPath.type() != EntityPath::PATH_AFFINITY)
        {
            TARG_TS_FAIL("Default entity path's type was not "
                    "EntityPath::PATH_AFFINITY after setting");
        }

        l_defaultPath.setType(EntityPath::PATH_PHYSICAL);
        if(!(l_defaultPath == l_nonDefaultPath))
        {
            TARG_TS_FAIL("Default entity path should have been equal to "
                    "the non-default entity path");
        }

        if(!l_defaultPath.equals(l_nonDefaultPath,0))
        {
            TARG_TS_FAIL("Default entity path should have been equal to "
                    "the non-default entity path (equals API)");
        }

        l_defaultPath.addLast(TYPE_PROC,0);
        if(l_defaultPath == l_nonDefaultPath)
        {
            TARG_TS_FAIL("Default entity path should NOT have been equal to "
                    "the non-default entity path");
        }

        if(l_defaultPath.equals(l_nonDefaultPath,1))
        {
            TARG_TS_FAIL("Default entity path should NOT have been equal to "
                    "the non-default entity path (equals API, comparing 1 "
                    "element)");
        }

        if(l_defaultPath.size() != 1)
        {
            TARG_TS_FAIL("Default entity path should have had one path element"
                    "after adding PROC0");
        }

        l_nonDefaultPath.addLast(TYPE_PROC,0);
        if(! (l_defaultPath == l_nonDefaultPath) )
        {
            TARG_TS_FAIL("Default entity path should have been equal to "
                    "the non-default entity path since they now"
                    "both have the same 1 path element");
        }

        l_defaultPath.addLast(TYPE_MBA,1).addLast(TYPE_L4,2);
        if(l_defaultPath.size() != 3)
        {
            TARG_TS_FAIL("Default entity path should have had two path elements"
                    "after adding MBA1 and L4");
        }

        if( (l_defaultPath[0].type != TYPE_PROC)
            || (l_defaultPath[0].instance != 0)
            || (l_defaultPath[1].type != TYPE_MBA)
            || (l_defaultPath[1].instance != 1)
            || (l_defaultPath[2].type != TYPE_L4)
            || (l_defaultPath[2].instance != 2))
        {
            TARG_TS_FAIL("Default entity path should have had correct 3 path "
                    "elements");
        }

        l_defaultPath.removeLast();
        if(l_defaultPath.size() != 2)
        {
            TARG_TS_FAIL("Default entity path should have had two path elements"
                    "after removing L4");
        }

        if( (l_defaultPath[0].type != TYPE_PROC)
            || (l_defaultPath[0].instance != 0)
            || (l_defaultPath[1].type != TYPE_MBA)
            || (l_defaultPath[1].instance != 1))
        {
            TARG_TS_FAIL("Default entity path should have had correct 2 path "
                    "elements");
        }


        l_nonDefaultPath.addLast(TYPE_MBA,1).addLast(TYPE_L4,2);

        // Default now has proc/mba/
        // Non-default now has proc/mba/l4
        if(l_defaultPath == l_nonDefaultPath)
        {
            TARG_TS_FAIL("Default entity path should NOT have been equal to "
                    "the non-default entity path since they now"
                    "have different number of path elements");
        }

        if( !l_defaultPath.equals(l_nonDefaultPath,2) )
        {
            TARG_TS_FAIL("Default entity path should have been equal to "
                    "the non-default entity path since they have the same"
                    "first two path elements");
        }

        l_defaultPath.removeLast().removeLast();
        if(l_defaultPath.size() != 0)
        {
            TARG_TS_FAIL("Default entity path should have had no path element"
                    "after removing MBA1 and PROC0");
        }

        TargetService& l_targetService = targetService();
        l_targetService.init();

        EntityPath l_realPath(EntityPath::PATH_PHYSICAL);
        l_realPath.addLast(TYPE_SYS,0).addLast(TYPE_NODE,0)
          .addLast(TYPE_PROC,0);

        Target* l_pTarget = l_realPath.operator->();
        if(l_pTarget == NULL)
        {
            TARG_TS_FAIL("Real entity path should have mapped to an existing "
                    "target");
        }

        EntityPath l_path(EntityPath::PATH_PHYSICAL);
        l_path.addLast(TYPE_SYS,0);
        EntityPath l_changedPath = l_path.copyRemoveLast();
        if(   (l_changedPath.size() != 0)
              || (l_path.size() != 1))
        {
            TARG_TS_FAIL("Const entity path should not have been altered in "
                    "const add test");
        }

        l_changedPath = l_path.copyAddLast(TYPE_NODE,0);
        if(   (l_changedPath.size() != 2)
              || (l_path.size() != 1))
        {
            TARG_TS_FAIL("Const entity path should not have been altered "
                    "in const add test");
        }

        TARG_TS_TRACE(EXIT_MRK "testEntityPathClass" );
    }

    /**
     *  @test Tests the EntityPath class (except debug cases)
     */
    void testTargetClass(void)
    {


        TARG_TS_TRACE(ENTER_MRK "testTargetClass" );

        using namespace TARGETING;
        TargetService& l_targetService = targetService();
        l_targetService.init();

        EntityPath l_realPath(EntityPath::PATH_PHYSICAL);
        l_realPath.addLast(TYPE_SYS,0).addLast(TYPE_NODE,0)
          .addLast(TYPE_PROC,0);
        l_realPath.dump();

        Target* l_pTarget = l_realPath.operator->();
        if(l_pTarget == NULL)
        {
            TARG_TS_FAIL("Failed to convert entity path to initial target");
        }

        CLASS l_class = l_pTarget->getAttr<ATTR_CLASS>();
        if(l_class != CLASS_CHIP)
        {
            TARG_TS_FAIL("Failed to get the class attribute");
        }

        l_class = CLASS_NA;
        if( !l_pTarget->tryGetAttr<ATTR_CLASS>(l_class) )
        {
            TARG_TS_FAIL("Failed to get the class attribute");
        }

        if(l_class != CLASS_CHIP)
        {
            TARG_TS_FAIL("Failed to try/get the class attribute");
        }

        attrToString<ATTR_CLASS>(l_class);

        uint8_t l_scom = 0;
        if( l_pTarget->tryGetAttr<ATTR_DUMMY_RO>(l_scom) )
        {
            TARG_TS_FAIL("ATTR_DUMMY_RO attribute should not have been available "
                    "to read");
        }

        if(l_scom != 0)
        {
            TARG_TS_FAIL("Failed ! try/get should not have set the SCOM attribute");
        }

        l_scom = 5;
        if( l_pTarget->trySetAttr<ATTR_DUMMY_WO>(l_scom) )
        {
            TARG_TS_FAIL("ATTR_DUMMY_WO attribute should not have been available "
                    "to write");
        }

        if(l_scom != 5)
        {
            TARG_TS_FAIL("SCOM attribute should not have been altered in the "
                    "failed write");
        }

        DUMMY_RW_ATTR l_wo;
        memset(l_wo,0x00,sizeof(l_wo));
        l_wo[0][1][2] = 6;
        if( !l_pTarget->trySetAttr<ATTR_DUMMY_RW>(l_wo) )
        {
            TARG_TS_FAIL("ATTR_DUMMY_RW should have been available for write");
        }

        if(l_wo[0][1][2] != 6)
        {
            TARG_TS_FAIL("ATTR_DUMMY_RW local attribute should not have been "
                    "altered in the successful write");
        }

        DUMMY_RW_ATTR l_read;
        l_pTarget->tryGetAttr<ATTR_DUMMY_RW>(l_read);
        if(memcmp(l_read,l_wo,sizeof(l_read)))
        {
            TARG_TS_FAIL("Failed to read back the correct ATTR_DUMMY_RW");
        }

        DUMMY_RW_ATTR l_setWo;
        memset(l_setWo,0x00,sizeof(l_setWo));
        l_setWo[0][2][4] = 9;
        l_pTarget->setAttr<ATTR_DUMMY_RW>(l_setWo);
        if(l_setWo[0][2][4] != 9)
        {
            TARG_TS_FAIL("ATTR_DUMMY_RW local attribute should not have been "
                    "altered in the successful setAttr");
        }

        DUMMY_RW_ATTR l_setWoVerify;
        l_pTarget->tryGetAttr<ATTR_DUMMY_RW>(l_setWoVerify);
        if(memcmp(l_setWoVerify,l_setWo,sizeof(l_setWoVerify)))
        {
            TARG_TS_FAIL("ATTR_DUMMY_RW read should have matched prior write");
        }

        memset(l_setWo,0x05,sizeof(l_setWo));
        l_pTarget->setAttr<ATTR_DUMMY_RW>(l_setWo);

        TARG_TS_TRACE(EXIT_MRK "testTargetClass" );
    }

    void testPredicateHwas()
    {

        TARG_TS_TRACE(ENTER_MRK "testPredicateHwas" );

        do {

        using namespace TARGETING;
        TargetService& l_targetService = targetService();

        // Get top level (system) target
        Target* l_pTopLevel = NULL;
        (void) l_targetService.getTopLevelTarget(l_pTopLevel);
        if (l_pTopLevel == NULL)
        {
            TARG_TS_FAIL("Top level handle was NULL when initialization "
                    "complete");
            break;
        }

        PredicateHwas hwasPredicate;

        ATTR_HWAS_STATE_type savedHwasState
            = l_pTopLevel->getAttr<ATTR_HWAS_STATE>();

        // Test: Given a target with any HWAS state, default HWAS predicate
        //     should return a match
        for(size_t i=0; i<32; ++i)
        {
            ATTR_HWAS_STATE_type sweepHwasState
                = { static_cast<uint8_t>(i&8),
                    static_cast<uint8_t>(i&4),
                    static_cast<uint8_t>(i&2),
                    static_cast<uint8_t>(i&1) };
            l_pTopLevel->setAttr<ATTR_HWAS_STATE>(sweepHwasState);

            if(!hwasPredicate(l_pTopLevel))
            {
                TARG_TS_FAIL("Expected default HWAS predicate to match the "
                    "target's HWAS state, using i = %d",i);
            }
        }

        // Test: Given a target with cleared HWAS state of functional, predicate
        //    looking for functional should return false
        hwasPredicate.reset().functional(true);
        ATTR_HWAS_STATE_type nonFunctionalHwasState = {0};
        l_pTopLevel->setAttr<ATTR_HWAS_STATE>(nonFunctionalHwasState);
        if(hwasPredicate(l_pTopLevel))
        {
            TARG_TS_FAIL("Expected HWAS functional predicate not to match the "
                "target's cleared HWAS state");
        }

        // Test: Having previously not matched a target, resetting the HWAS
        //     predicate should match the target again
        hwasPredicate.reset();
        if(!hwasPredicate(l_pTopLevel))
        {
            TARG_TS_FAIL("Expected HWAS reset predicate to match the "
                "target's functional HWAS state");
        }

        // Test: Given a target with HWAS state of functional, predicate
        //    looking for functional should return true
        hwasPredicate.reset().functional(true);
        ATTR_HWAS_STATE_type functionalHwasState = {0};
        functionalHwasState.functional = true;
        l_pTopLevel->setAttr<ATTR_HWAS_STATE>(functionalHwasState);
        if(!hwasPredicate(l_pTopLevel))
        {
            TARG_TS_FAIL("Expected HWAS functional predicate to match the "
                "target's functional HWAS state");
        }

        // Test: Given a target with HWAS state of non-functional, predicate
        //    looking for non-functional should return true
        hwasPredicate.reset().functional(false);
        l_pTopLevel->setAttr<ATTR_HWAS_STATE>(nonFunctionalHwasState);
        if(!hwasPredicate(l_pTopLevel))
        {
            TARG_TS_FAIL("Expected HWAS non-functional predicate to match the "
                "target's non-functional HWAS state");
        }

        // Test: Given a predicate looking for target whose HWAS state
        //     exactly matches all configurable HWAS states, filter should
        //     return true
        hwasPredicate.reset().poweredOn(true).present(true).functional(false);
        hwasPredicate.dumpFunctional(false);

        ATTR_HWAS_STATE_type allHwasState = {0, true,true,false,false};
        l_pTopLevel->setAttr<ATTR_HWAS_STATE>(allHwasState);
        if(!hwasPredicate(l_pTopLevel))
        {
            TARG_TS_FAIL("Expected setting HWAS predicate to match the "
                "target's similarly configured HWAS state");
        }

        // Test: Given a predicate looking for target whose HWAS state
        //     exactly matches all but 1 configurable HWAS states, filter
        //     should return false
        allHwasState.dumpfunctional = true;
        l_pTopLevel->setAttr<ATTR_HWAS_STATE>(allHwasState);
        if(hwasPredicate(l_pTopLevel))
        {
            TARG_TS_FAIL("Expected HWAS predicate not to match the target's "
                "all-but-1 matching HWAS state configuration");
        }

        // Restore state.
        l_pTopLevel->setAttr<ATTR_HWAS_STATE>(savedHwasState);

        } while(0);

        TARG_TS_TRACE(EXIT_MRK "testPredicateHwas" );
    }

    void testPredicateHwasChanged()
    {
        TARG_TS_TRACE(ENTER_MRK "testPredicateHwasChanged" );

        do {

        using namespace TARGETING;
        TargetService& l_targetService = targetService();

        // Get master proc chip to work with
        Target* l_pTarget = NULL;
        (void) l_targetService.masterProcChipTargetHandle(l_pTarget);
        if (l_pTarget == NULL)
        {
            TARG_TS_FAIL("MasterProcChipTarget handle was NULL");
            break;
        }

        PredicateHwasChanged hwasChangedPredicate;

        ATTR_HWAS_STATE_CHANGED_FLAG_type savedHwasChangedState =
            l_pTarget->getAttr<ATTR_HWAS_STATE_CHANGED_FLAG>();

        // Test: Given a target with any HWAS state, default HWAS predicate
        //     should return a match
        for(size_t i=0; i<32; ++i)
        {
            ATTR_HWAS_STATE_CHANGED_FLAG_type sweepState
                = { static_cast<uint8_t>(i&1) };
            l_pTarget->setAttr<ATTR_HWAS_STATE_CHANGED_FLAG>(sweepState);

            if(!hwasChangedPredicate(l_pTarget))
            {
                TARG_TS_FAIL("Expected default HWAS predicate to match the "
                    "target's HWAS state, using i = %d",i);
            }
        }

        // Test: Given a target with cleared HWAS GARD bit, predicate
        //    looking for GARD bit should return false
        hwasChangedPredicate.reset().changedBit(HWAS_CHANGED_BIT_GARD, true);
        ATTR_HWAS_STATE_CHANGED_FLAG_type noGardHwasChangedBit = 0;
        l_pTarget->setAttr<ATTR_HWAS_STATE_CHANGED_FLAG>(noGardHwasChangedBit);
        if(hwasChangedPredicate(l_pTarget))
        {
            TARG_TS_FAIL("Expected HWAS predicate not to match the "
                "target's cleared HWAS GARD bit");
        }

        // Test: Having previously not matched a target, resetting the HWAS
        //     predicate should match the target again
        hwasChangedPredicate.reset();
        if(!hwasChangedPredicate(l_pTarget))
        {
            TARG_TS_FAIL("Expected HWAS reset predicate to match the "
                "target's HWAS state");
        }

        // Test: Given a target with set HWAS GARD bit, predicate
        //    looking for GARD bit should return true
        hwasChangedPredicate.reset().changedBit(HWAS_CHANGED_BIT_GARD, true);
        //ATTR_HWAS_STATE_CHANGED_FLAG_type functionalHwasChangedState =
        //HWAS_CHANGED_BIT_GARD;
        l_pTarget->setAttr<ATTR_HWAS_STATE_CHANGED_FLAG>(HWAS_CHANGED_BIT_GARD);
        if(!hwasChangedPredicate(l_pTarget))
        {
            TARG_TS_FAIL("Expected HWAS GARD bit predicate to match the "
                "target's GARD bit HWAS state");
        }

        // Test: Given a target with cleared HWAS GARD bit, predicate
        //    looking for cleared GARD bit should return true
        hwasChangedPredicate.reset().changedBit(HWAS_CHANGED_BIT_GARD, false);
        l_pTarget->setAttr<ATTR_HWAS_STATE_CHANGED_FLAG>(0);
        if(!hwasChangedPredicate(l_pTarget))
        {
            TARG_TS_FAIL("Expected HWAS cleared GARD bit predicate to match "
                "the target's cleared GARD bit HWAS state");
        }

        // Test: Given a target with all cleared HWAS bits, predicate
        //    looking for all false should return true
        hwasChangedPredicate.reset().allChangesApplied(false);
        l_pTarget->setAttr<ATTR_HWAS_STATE_CHANGED_FLAG>(0);
        if(!hwasChangedPredicate(l_pTarget))
        {
            TARG_TS_FAIL("Expected HWAS all cleared predicate to match the "
                "target's all cleared HWAS state");
        }

        // Test: Given a target with all set HWAS bits, predicate
        //    looking for all set should return true
        hwasChangedPredicate.reset().allChangesApplied(true);
        l_pTarget->setAttr<ATTR_HWAS_STATE_CHANGED_FLAG>
            (l_pTarget->getAttr<ATTR_HWAS_STATE_CHANGED_SUBSCRIPTION_MASK>());
        if(!hwasChangedPredicate(l_pTarget))
        {
            TARG_TS_FAIL("Expected HWAS all set predicate to match the "
                "target's all set HWAS state");
        }

        // Restore state.
        l_pTarget->setAttr<ATTR_HWAS_STATE_CHANGED_FLAG>
                (savedHwasChangedState);

        } while(0);

        TARG_TS_TRACE(EXIT_MRK "testPredicateHwasChanged" );
    }

    void testPredicateCtm()
    {

        TARG_TS_TRACE(ENTER_MRK "testPredicateCtm" );

        using namespace TARGETING;
        TargetService& l_targetService = targetService();

        // Get top level (system) target
        Target* l_pTopLevel = NULL;
        (void) l_targetService.getTopLevelTarget(l_pTopLevel);
        if (l_pTopLevel == NULL)
        {
            TARG_TS_FAIL("Top level handle was NULL when initialization "
                    "complete");
        }

        PredicateCTM l_allWild;
        if( ! l_allWild(l_pTopLevel) )
        {
            TARG_TS_FAIL("CTM all wildcards filter should have matched system "
                    "target");
        }

        PredicateCTM l_typeModelWild(CLASS_SYS);
        if( ! l_typeModelWild(l_pTopLevel) )
        {
            TARG_TS_FAIL("CTM class sys, remaining wildcards filter should have "
                    "matched system ");
        }

        PredicateCTM l_modelWild(CLASS_SYS,TYPE_SYS);
        if( ! l_modelWild(l_pTopLevel) )
        {
            TARG_TS_FAIL("CTM class sys, type sys, remaining wildcards filter "
                    "should have matched system ");
        }

        PredicateCTM l_noWild(CLASS_SYS,TYPE_SYS,MODEL_POWER8);
        if( ! l_noWild(l_pTopLevel) )
        {
            TARG_TS_FAIL("CTM class sys, type sys, model power8 should have "
                    "matched system ");
        }

        PredicateCTM l_classWild(CLASS_NA,TYPE_SYS,MODEL_POWER8);
        if( ! l_classWild(l_pTopLevel) )
        {
            TARG_TS_FAIL("CTM class wild, type sys, model power8 should have "
                    "matched system ");
        }

        PredicateCTM l_typeWild(CLASS_SYS,TYPE_NA,MODEL_POWER8);
        if( ! l_typeWild(l_pTopLevel) )
        {
            TARG_TS_FAIL("CTM class sys, wild, model power8 should have "
                    "matched system ");
        }

        PredicateCTM l_classModelWild(CLASS_NA,TYPE_SYS,MODEL_NA);
        if( ! l_classModelWild(l_pTopLevel) )
        {
            TARG_TS_FAIL("CTM wild, type sys, wild should have "
                    "matched system ");
        }

        PredicateCTM l_classTypeWild(CLASS_NA,TYPE_NA,MODEL_NA);
        if( ! l_classTypeWild(l_pTopLevel) )
        {
            TARG_TS_FAIL("CTM wild, wild, model should have "
                    "matched system ");
        }

        PredicateCTM l_chipClass(CLASS_CHIP,TYPE_NA,MODEL_NA);
        if(  l_chipClass(l_pTopLevel) )
        {
            TARG_TS_FAIL("CTM of class chip, wild, wild should not have matched "
                    "matched system ");
        }

#if 0 // Prove copy CTOR/assignment operator is disabled
        PredicateCTM l_ctmLhs;
        PredicateCTM l_ctmRhs;

        l_ctmLhs = l_ctmRhs;

        PredicateCTM l_ctmCtor(l_ctmRhs);
#endif

        PredicateBase* l_pBase = new PredicateCTM(CLASS_SYS);
        delete l_pBase;
        l_pBase = NULL;

        TARG_TS_TRACE(EXIT_MRK "testPredicateCtm" );
    }

    void testPredicatePostfixExpr()
    {

        TARG_TS_TRACE(ENTER_MRK "testPredicatePostfixExpr" );

        using namespace TARGETING;
        TargetService& l_targetService = targetService();

        // Get top level (system) target
        Target* l_pTopLevel = NULL;
        (void) l_targetService.getTopLevelTarget(l_pTopLevel);
        if (l_pTopLevel == NULL)
        {
            TARG_TS_FAIL("Top level handle was NULL when initialization "
                    "complete");
        }

        PredicatePostfixExpr l_alwaysTrueExpr;
        if(!l_alwaysTrueExpr(l_pTopLevel) )
        {
            TARG_TS_FAIL("Always true filter should have matched system");
        }

#if 0
        // Triggers NULL assertion check on push
        l_alwaysTrueExpr.push(NULL);
#endif

#if 0
        // Triggers not enough stack elements assertion when evaluating Not
        l_alwaysTrueExpr.Not();
        if(l_alwaysTrueExpr(l_pTopLevel) )
        {
            TARG_TS_FAIL("Negated always true filter should not have matched "
                    "system");
        }
#endif

#if 0
        // Triggers illegal target assertion
        l_alwaysTrueExpr(NULL);
#endif

#if 0
        // Triggers formatting assertion
        l_alwaysTrueExpr.And();
        l_alwaysTrueExpr(l_pTopLevel);
#endif

#if 0
        // Triggers formatting assertion
        l_alwaysTrueExpr.Or();
        l_alwaysTrueExpr(l_pTopLevel);
#endif

        PredicateCTM l_sysClass(CLASS_SYS);

#if 0
        // Triggers formatting assertion
        l_alwaysTrueExpr.push(&l_sysClass);
        l_alwaysTrueExpr.And();
        l_alwaysTrueExpr(l_pTopLevel);
#endif

#if 0
        // Triggers formatting assertion
        l_alwaysTrueExpr.push(&l_sysClass);
        l_alwaysTrueExpr.Or();
        l_alwaysTrueExpr(l_pTopLevel);
#endif

#if 0
        // Triggers illegal formatting exception
        // != 1 results on stack
        l_alwaysTrueExpr.push(&l_sysClass);
        l_alwaysTrueExpr.push(&l_sysClass);
        l_alwaysTrueExpr.Not();
        l_alwaysTrueExpr(l_pTopLevel);
#endif

        PredicateCTM l_sysType(CLASS_NA,TYPE_SYS);
        PredicateCTM l_power8Model(CLASS_NA,TYPE_NA,MODEL_POWER8);
        PredicatePostfixExpr l_expr;
        l_expr.push(&l_sysClass).push(&l_sysType).And();
        l_expr.push(&l_power8Model).And();

        if(!l_expr(l_pTopLevel) )
        {
            TARG_TS_FAIL("CTM of class sys && type sys && model power8 should "
                    "have matched system");
        }

        l_expr.Not();

        if(l_expr(l_pTopLevel) )
        {
            TARG_TS_FAIL("CTM of class sys && type sys && model power8 should "
                    "npt have matched system after negation");
        }

        l_expr.push(&l_sysClass);
        l_expr.Or();

        if(!l_expr(l_pTopLevel) )
        {
            TARG_TS_FAIL("CTM of class sys && type sys && model power8 should "
                    "have matched system after negation then || sys class");
        }

        PredicatePostfixExpr* l_pExpr = new PredicatePostfixExpr;
        l_pExpr->push(&l_sysClass).push(&l_sysType).And();
        l_pExpr->push(&l_power8Model).And();
        delete (static_cast<PredicateBase*>(l_pExpr));

#if 0
        PredicatePostfixExpr l_lhs;
        PredicatePostfixExpr l_rhs;

        l_lhs = l_rhs;

        PredicatePostfixExpr l_cpCtor(l_rhs);
#endif

        TARG_TS_TRACE(EXIT_MRK "testPredicatePostfixExpr" );
    }

    void testTargetIterator()
    {
        TARG_TS_TRACE(ENTER_MRK "testTargetIterator");

        using namespace TARGETING;
        TargetService& l_targetService = targetService();


        TargetIterator l_pIt;
        if( l_pIt != l_targetService.end() )
        {
            TARG_TS_FAIL("Default TargetIterator should point to past the end "
                    "of container");
        }

        ++l_pIt;
        if( l_pIt != l_targetService.end() )
        {
            TARG_TS_FAIL("Default TargetIterator preincremented should point to "
                    "past the end of container");
        }

        TargetIterator* l_pItNew = new TargetIterator;
        delete l_pItNew;
        l_pItNew = NULL;

        if(*l_pIt != NULL)
        {
            TARG_TS_FAIL("Default TargetIterator dereference should return NULL");
        }

        // Get top level (system) target to verify at least 1 target
        Target* l_pTopLevel = NULL;
        (void) l_targetService.getTopLevelTarget(l_pTopLevel);
        if (l_pTopLevel == NULL)
        {
            TARG_TS_FAIL("Top level handle was NULL when initialization "
                    "complete");
        }

        l_pIt = l_targetService.begin();
        if((*l_pIt) == NULL)
        {
            TARG_TS_FAIL("TargetService begin() should return !NULL");
        }

        CLASS l_class = CLASS_NA;
        if( !l_pIt->tryGetAttr<ATTR_CLASS>(l_class) )
        {
            TARG_TS_FAIL("Failed to get expected class attribute");
        }

        TargetIterator l_rhs = l_targetService.begin();
        if( ! (l_pIt == l_rhs) )
        {
            TARG_TS_FAIL("Iterators should be equal, but aren't");
        }

        l_rhs = l_targetService.begin();
        if( l_pIt != l_rhs )
        {
            TARG_TS_FAIL("Iterators should be equal, but aren't");
        }

        TargetIterator l_rhs2 = l_targetService.begin();
        ++l_rhs2;
        ++l_pIt;
        if( l_pIt != l_rhs2 )
        {
            TARG_TS_FAIL("Iterators should be equal, but aren't");
        }

        l_rhs2++;
        l_pIt++;
        if( l_pIt != l_rhs2 )
        {
            TARG_TS_FAIL("Iterators should be equal, but aren't");
        }

        TargetIterator l_pItClone(l_rhs2);
        if( l_pIt != l_pItClone)
        {
            TARG_TS_FAIL("Iterators should be equal, but aren't");
        }

        if(l_pIt != l_pItClone++)
        {
            TARG_TS_FAIL("Iterators should be equal, but aren't");
        }

        if( (++l_pIt) != l_pItClone)
        {
            TARG_TS_FAIL("Iterators should be equal, but aren't");
        }

        const TargetService& l_constTargetService = targetService();

        ConstTargetIterator l_pConstIt;
        if( l_pConstIt != l_constTargetService.end() )
        {
            TARG_TS_FAIL("Default ConstTargetIterator should point to past the "
                    "end of container");
        }

        l_pConstIt = l_constTargetService.begin();
        if( (*l_pConstIt) == NULL)
        {
            TARG_TS_FAIL("Iterator does not point to valid Target as expected");
        }

        TARG_TS_TRACE(EXIT_MRK "testTargetIterator" );
    }

    void testRangeFilter(void)
    {

        TARG_TS_TRACE(ENTER_MRK "testRangeFilters" );

        using namespace TARGETING;

        TargetRangeFilter* l_pRangeFilter = new TargetRangeFilter(
                                                                  targetService().begin(),
                                                                  targetService().end(),
                                                                  NULL);
        delete l_pRangeFilter;
        l_pRangeFilter = NULL;


        TargetRangeFilter l_f1(
                               targetService().begin(),
                               targetService().end(),
                               NULL);

        Target* l_pBegin = (*l_f1);
        ++l_f1;
        Target* l_pNext = (*l_f1);
        if(   (l_pBegin == NULL)
              || (l_pNext == NULL)
              || (l_pBegin == l_pNext)
              )
        {
            TARG_TS_FAIL("Target* pointed to by Begin/next NULL -or- begin =="
                    "next");
        }

        l_f1.reset();
        if( *l_f1 != l_pBegin )
        {
            TARG_TS_FAIL("Target* after reset should be equal to original");
        }

        l_f1.reset();
        TargetRangeFilter l_f2 = l_f1;
        PredicateCTM l_ctm(CLASS_SYS,TYPE_CORE); // Nonsense CTM
        l_f1.setPredicate(&l_ctm);
        if( *l_f1 == l_pBegin )
        {
            TARG_TS_FAIL("Target* after reset and change of predicate should be"
                    "different than the original");
        }

        PredicateCTM l_ctm1(CLASS_CHIP,TYPE_PROC);

        TargetRangeFilter l_f3(
                               targetService().begin(),
                               targetService().end(),
                               &l_ctm1);
        for(;l_f3;++l_f3)
        {
            if(l_f3->getAttr<ATTR_TYPE>() != TYPE_PROC)
            {
                TARG_TS_FAIL("Should only have returned type proc");
                break;
            }
        }

        TargetIterator l_pIt = targetService().begin();
        ++l_pIt;
        ++l_pIt;

        if(l_pIt == targetService().end())
        {
            TARG_TS_FAIL("Not enough elements for test");
        }

        TargetRangeFilter l_partial(
                                    targetService().begin(),
                                    l_pIt,
                                    NULL);
        int i=0;

        for(; l_partial; ++l_partial)
        {
            i++;
        }

        if(i != 2)
        {
            TARG_TS_FAIL("Should have gotten 2 elements %d",i);
        }

        TARG_TS_TRACE(EXIT_MRK "testRangeFilter" );
    }

    void testComplexFilter(void)
    {

        TARG_TS_TRACE(ENTER_MRK "testComplexFilter" );

        using namespace TARGETING;

        TargetService& l_targetService = targetService();

        TargetRangeFilter f(l_targetService.begin(),
                            l_targetService.end(),
                            NULL);
        int l_count = 0;
        for(; f; ++f, l_count++)
        {
        }

        TARG_TS_TRACE(INF_MRK "Found %d total targets", l_count);

        PredicateCTM l_procs(CLASS_CHIP);
        PredicateCTM l_enclosures(CLASS_ENC);
        PredicatePostfixExpr l_query;
        l_query.push(&l_procs).push(&l_enclosures).Or();

        f.setPredicate(&l_query);
        f.reset();

        l_count = 0;
        for(; f; ++f, ++l_count)
        {
            EntityPath l_path = f->getAttr<ATTR_PHYS_PATH>();
            l_path.dump();
        }

        TARG_TS_TRACE(INF_MRK "Found %d targets that are chips or enclosures ",
                 l_count);

        l_query.Not();
        f.reset();

        l_count = 0;
        for(; f; ++f, ++l_count)
        {
        }

        TARG_TS_TRACE(INF_MRK "Found %d targets that are not chips or "
                 "enclosures",l_count);

        Target* l_pMasterProcChipTargetHandle = NULL;
        (void) l_targetService.masterProcChipTargetHandle(
                                                          l_pMasterProcChipTargetHandle);
        if(l_pMasterProcChipTargetHandle == NULL)
        {
            TARG_TS_FAIL("Master processor chip target not found");
        }

        PredicateCTM l_ex(CLASS_UNIT,TYPE_EX);
        PredicateCTM l_mba(CLASS_UNIT,TYPE_MBA);
        PredicatePostfixExpr l_procquery;
        l_procquery.push(&l_ex).push(&l_mba).Or();

        TargetHandleList l_list;
        (void) targetService().getAssociated(
                                             l_list,
                                             l_pMasterProcChipTargetHandle,
                                             TARGETING::TargetService::CHILD,
                                             TARGETING::TargetService::ALL,
                                             &l_procquery);

        l_count = 0;
        for(uint32_t i=0; i<l_list.size(); ++i, ++l_count)
        {
            EntityPath l_path = l_list[i]->getAttr<ATTR_PHYS_PATH>();
            l_path.dump();
        }

        TARG_TS_TRACE(INF_MRK "Found %d targets that are ex/mba units off "
                 "master processor",l_count);

        TARG_TS_TRACE(EXIT_MRK "testComplexFilter" );
    }

    void testFapiToHbMacros ()
    {

        TARG_TS_TRACE(ENTER_MRK "testFapiToHbMacros" );

        TARG_TS_TRACE(INF_MRK "Now using direct access macros");

        using namespace TARGETING;
        using namespace fapi;

        TargetService& l_targetService = targetService();

        TARGETING::Target* l_pTarget = NULL;
        (void) l_targetService.getTopLevelTarget(l_pTarget);
        if (l_pTarget == NULL)
        {
            TARG_TS_FAIL("Top level handle was NULL when initialization "
                    "complete");
        }

        DUMMY_RW_ATTR l_dummyRw;
        memset(l_dummyRw,0x00,sizeof(l_dummyRw));
        l_pTarget->tryGetAttr<TARGETING::ATTR_DUMMY_RW>(l_dummyRw);
        if(l_dummyRw[0][1][2] != 5)
        {
            TARG_TS_FAIL("l_dummyRw value is %d, not 5 as expected in direct "
                    "attribute access",l_dummyRw[0][1][2]);
        }

        TARGETING::CLASS l_class =
          l_pTarget->getAttr<TARGETING::ATTR_CLASS>();
        if(l_class != TARGETING::CLASS_SYS)
        {
            TARG_TS_FAIL("l_class value is %d, not %d as expected in direct "
                    "attribute access",l_class,TARGETING::CLASS_SYS);
        }

        TARGETING::TYPE l_type = l_pTarget->getAttr<TARGETING::ATTR_TYPE>();
        if(l_type != TARGETING::TYPE_SYS)
        {
            TARG_TS_FAIL("l_type value is %d, not %d as expected in direct "
                    "attribute access",l_type,TARGETING::TYPE_SYS);
        }

        uint64_t l_xscom =
          l_pTarget->getAttr<TARGETING::ATTR_XSCOM_BASE_ADDRESS>();
        if(l_xscom != 0x0003FC0000000000ULL)
        {
            TARG_TS_FAIL("l_xscom value is 0x%016llX, not 0x%016llX as expected in direct "
                    "attribute access",l_xscom,0x0003FC00000000ULL);
        }

        TARG_TS_TRACE(INF_MRK "Now using FAPI get macros");

        memset(l_dummyRw,0x00,sizeof(l_dummyRw));
        fapi::ReturnCode l_rc = FAPI_ATTR_GET(
                                              ATTR_DUMMY_SCRATCH_PLAT_INIT_UINT8, NULL, l_dummyRw);
        if(l_rc != 0)
        {
            TARG_TS_FAIL("Failed to get dummy RW attribute on system target");
        }

        if(l_dummyRw[0][2][4] != 5)
        {
            TARG_TS_FAIL("l_dummyRw value is %d, not 5 as expected",
                    l_dummyRw[0][2][4]);
        }

        TARG_TS_TRACE(INF_MRK "Now using FAPI set macros");

        l_dummyRw[0][2][3] = 6;
        l_rc = FAPI_ATTR_SET(ATTR_DUMMY_SCRATCH_PLAT_INIT_UINT8, NULL,
                             l_dummyRw);
        if(l_rc != 0)
        {
            TARG_TS_FAIL("Failed to write dummy RW attribute on system target");
        }

        memset(l_dummyRw,0x00,sizeof(l_dummyRw));
        l_rc = FAPI_ATTR_GET(ATTR_DUMMY_SCRATCH_PLAT_INIT_UINT8, NULL,
                             l_dummyRw);
        if(l_rc != 0)
        {
            TARG_TS_FAIL("Failed to get dummy RW attribute on system target");
        }

        if(l_dummyRw[0][2][3] != 6)
        {
            TARG_TS_FAIL("l_dummyRw value is %d, not 6 as expected due to a "
                    "prior write",l_dummyRw[0][2][3]);
        }

        TARG_TS_TRACE(INF_MRK "Now using targets without the attribute");

        memset(l_dummyRw,0x00,sizeof(l_dummyRw));
        EntityPath l_realPath(EntityPath::PATH_PHYSICAL);
        l_realPath.addLast(TYPE_SYS,0).addLast(TYPE_NODE,0);
        l_pTarget = l_realPath.operator->();
        if (l_pTarget == NULL)
        {
            TARG_TS_FAIL("Node 0 target handle should not be NULL");
        }

        fapi::Target* l_pFapiTarget = new fapi::Target(
                                                       fapi::TARGET_TYPE_PROC_CHIP, l_pTarget);
        l_rc = FAPI_ATTR_GET(ATTR_DUMMY_SCRATCH_PLAT_INIT_UINT8,
                             l_pFapiTarget , l_dummyRw);
        if(l_rc == 0)
        {
            TARG_TS_FAIL("Should have failed getting the attribute on "
                    "non-supporting target");
        }
        else if(l_rc != FAPI_RC_PLAT_ERR_SEE_DATA)
        {
            TARG_TS_FAIL("Should have been a platform handled error");
        }

        // The error log will get deleted when the ReturnCode is destructed. The
        // error log is not committed here to avoid it getting interpreted as a
        // real problem

        delete l_pFapiTarget;
        l_pFapiTarget = NULL;

        TARG_TS_TRACE(EXIT_MRK "testFapiToHbMacros" );
    }

    void testPodNumericalTypes()
    {
        TARG_TS_TRACE(ENTER_MRK "testPodNumericalTypes" );

        using namespace TARGETING;
        using namespace fapi;

        TargetService& l_targetService = targetService();

        TARGETING::Target* l_pTarget = NULL;
        (void) l_targetService.getTopLevelTarget(l_pTarget);
        if (l_pTarget == NULL)
        {
            TARG_TS_FAIL("Top level handle was NULL when initialization "
                    "complete");
        }

        NUMERIC_POD_TYPE_TEST_ATTR l_pod;
        memset(&l_pod,0x00,sizeof(l_pod));
        if(!l_pTarget->tryGetAttr<TARGETING::ATTR_NUMERIC_POD_TYPE_TEST>(l_pod))
        {
            TARG_TS_FAIL("Numeric POD type not found");
        }
        if(   (l_pod.fsiPath.type() != EntityPath::PATH_PHYSICAL)
           || (l_pod.fsiPath[0].type != TYPE_SYS)
           || (l_pod.fsiPath[0].instance != 0)
           || (l_pod.fsiPath.size() != 1 ) )
        {
            TARG_TS_FAIL("Expected physical:sys-0, got a different result");

        }
        if(l_pod.className != CLASS_CHIP)
        {
            TARG_TS_FAIL("Expected CLASS value of 0x%08X, got 0x%08X",
                    CLASS_CHIP,l_pod.className);
        }
        if(l_pod.uint8 != 0xAB)
        {
             TARG_TS_FAIL("Expected uint8_t value of 0xAB, got 0x%02X",
                  l_pod.uint8);
        }
        if (l_pod.uint16 != 0xABCD)
        {
            TARG_TS_FAIL("Expected uint16_t value of 0xABCD, got 0x%04X",
                l_pod.uint16);
        }
        if (l_pod.uint32 != 0xABCDEF01)
        {
            TARG_TS_FAIL("Expected uint32_t value of 0xABCDEF01, got 0x%08X",
                l_pod.uint32);
        }
        if (l_pod.uint64 != 0xABCDEF0123456789ULL)
        {
            TARG_TS_FAIL("Expected uint64_t value of 0xABCDEF0123456789, got "
                "0x%016llX",
                l_pod.uint64);
        }
        if(l_pod.int8 != -124)
        {
             TARG_TS_FAIL("Expected int8_t value of -124, got %d",
                  l_pod.int8);
        }
        if (l_pod.int16 != -32764)
        {
            TARG_TS_FAIL("Expected int16_t value of -32764, got %d",
                l_pod.int16);
        }
        if (l_pod.int32 != -2147483644)
        {
            TARG_TS_FAIL("Expected int32_t value of -2147483644, got %d",
                l_pod.int32);
        }
        if (l_pod.int64 != -9223372036854775804LL)
        {
            TARG_TS_FAIL("Expected int64_t value of -9223372036854775804, got "
                "%lld",
                l_pod.int64);
        }

        TARG_TS_TRACE(EXIT_MRK "testPodNumericalTypes" );
    }

    void testCentaurs()
    {

        TARG_TS_TRACE(ENTER_MRK "testCentaurs" );

        using namespace TARGETING;

        PredicateCTM l_procChip(CLASS_CHIP,TYPE_PROC,MODEL_VENICE);
        TargetRangeFilter l_filter(
            targetService().begin(),
            targetService().end(),
            &l_procChip);

        PredicateCTM l_memBuf(CLASS_UNIT,TYPE_MEMBUF);
        uint32_t l_count = 0;
        uint32_t l_procs = 0;

        // For each processor
        for(;l_filter;++l_filter)
        {
            l_procs++;

            TargetHandleList l_list;
            (void) targetService().getAssociated(
                l_list,
                *l_filter,
                TARGETING::TargetService::CHILD_BY_AFFINITY,
                TARGETING::TargetService::ALL,
                &l_memBuf);
            l_count += l_list.size();
        }

        if(l_procs)
        {
            if(l_count <= 0)
            {
                TARG_TS_FAIL("Did not find any Centaur chips connected to processors");
            }
            else
            {
                TARG_TS_TRACE("Found %d Centaur chips connected to processors",l_count);
            }
        }

        TARG_TS_TRACE(EXIT_MRK "testCentaurs" );
    }
    /**
     *  @test Tests string attributes
     */
    void testStringAttributes(void)
    {

        TARG_TS_TRACE(ENTER_MRK "testStringAttributes" );

        using namespace TARGETING;

        do {

        TargetService& l_targetService = targetService();

        // Get the top level target for the string attribute tests
        Target* l_pTopLevel = NULL;
        (void) l_targetService.getTopLevelTarget(l_pTopLevel);
        if (l_pTopLevel == NULL)
        {
            TARG_TS_FAIL("ERROR: Can not find top level target; bypassing "
                    "remaining string attribute tests");
            break;
        }

        // TC1: Test NULL string attribute
        // TC1.1: String storage size must match the stated size
        ATTR_TEST_NULL_STRING_type l_nullStringReference = {0};
        ATTR_TEST_NULL_STRING_type l_nullString = {0};
        if(sizeof(l_nullString) != ATTR_TEST_NULL_STRING_max_chars+1)
        {
            TARG_TS_FAIL("ERROR: l_nullString size (%d) "
                    "does not match stated size (%d)",
                    sizeof(l_nullString),
                    ATTR_TEST_NULL_STRING_max_chars+1);
        }

        // TC1.2: String size must be non-zero
        if(sizeof(l_nullString) == 0)
        {
            TARG_TS_FAIL("ERROR: l_nullString size is zero");
        }

        // TC1.3: Must be able to read the string
        if(!l_pTopLevel->tryGetAttr<ATTR_TEST_NULL_STRING>(l_nullString))
        {
            TARG_TS_FAIL("ERROR: Can not read l_nullString attribute");
        }

        // TC1.4: All bytes of the string must match the reference version
        if(memcmp(l_nullStringReference,
                  l_nullString,
                  sizeof(l_nullStringReference)))
        {
            TARG_TS_FAIL("ERROR: l_nullString bytes do not match the reference"
                    "version");
            TARG_BIN("Expected (l_nullStringReference)",
                     l_nullStringReference,sizeof(l_nullStringReference));
            TARG_BIN("Actual (l_nullString)",
                     l_nullString,sizeof(l_nullString));
        }

        // TC1.5: String must equal the empty string by string comparison
        if(strcmp(l_nullString,"") != 0)
        {
            TARG_TS_FAIL("ERROR: l_nullString does not strcmp to the empty string");
            TARG_BIN("Actual (l_nullString)",
                     l_nullString,sizeof(l_nullString));
        }

        // TC2: Test string attribute with only 1 character
        // TC2.1: String storage size must match the stated size
        ATTR_TEST_MIN_STRING_type l_minStringReference = {0};
        l_minStringReference[0] = 'Z';
        ATTR_TEST_MIN_STRING_type l_minString = {0};
        if(sizeof(l_minString) != ATTR_TEST_MIN_STRING_max_chars+1)
        {
            TARG_TS_FAIL("ERROR: l_minString size (%d) "
                    "does not match stated size (%d)",
                    sizeof(l_minString),
                    ATTR_TEST_MIN_STRING_max_chars+1);
        }

        // TC2.2: String size must be non-zero
        if(sizeof(l_minString) == 0)
        {
            TARG_TS_FAIL("ERROR: l_minString size is zero");
        }

        // TC2.3: Must be able to read the string
        if(!l_pTopLevel->tryGetAttr<ATTR_TEST_MIN_STRING>(l_minString))
        {
            TARG_TS_FAIL("ERROR: Can not read l_minString attribute");
        }

        // TC2.4: All bytes in string must match the reference string
        if(memcmp(l_minStringReference,
                  l_minString,
                  sizeof(l_minStringReference)))
        {
            TARG_TS_FAIL("ERROR l_minString bytes do not match the reference "
                    "version");
            TARG_BIN("Expected (l_minStringReference)",
                     l_minStringReference,sizeof(l_minStringReference));
            TARG_BIN("Actual (l_minString)",
                     l_minString,sizeof(l_minString));
       }

        // TC2.5: String must equal "Z" by comparison
        if(strcmp(l_minString,l_minStringReference) != 0)
        {
            TARG_TS_FAIL("ERROR l_minString does not strcmp to the reference "
                    "string");
            TARG_BIN("Actual (l_minString)",
                     l_minString,sizeof(l_minString));
        }

        // TC3: Test string with maximum number of characters (including NULL)
        // TC3.1: String storage size must match the stated size
        ATTR_TEST_MAX_STRING_type l_maxStringReference = {0};
        l_maxStringReference[0] = 'a';
        l_maxStringReference[1] = 'b';
        l_maxStringReference[2] = 'c';
        ATTR_TEST_MAX_STRING_type l_maxString = {0};
        if(sizeof(l_maxString) != ATTR_TEST_MAX_STRING_max_chars+1)
        {
            TARG_TS_FAIL("ERROR: l_maxString size (%d) "
                    "does not match stated size (%d)",
                    sizeof(l_maxString),
                    ATTR_TEST_MAX_STRING_max_chars+1);
        }

        // TC3.2: String storage size must be non-zero
        if(sizeof(l_maxString) == 0)
        {
            TARG_TS_FAIL("ERROR: l_maxString storage size is zero");
        }

        // TC3.3: Must be able to read the string
        if(!l_pTopLevel->tryGetAttr<ATTR_TEST_MAX_STRING>(l_maxString))
        {
            TARG_TS_FAIL("ERROR: Could not read l_maxString");
        }

        // TC3.4: All bytes in string must match the reference
        if(memcmp(l_maxStringReference,
                  l_maxString,
                  sizeof(l_maxStringReference)))
        {
            TARG_TS_FAIL("ERROR: l_maxString bytes do not match the reference "
                    "version");
            TARG_BIN("Expected (l_maxStringReference)",
                     l_maxStringReference,sizeof(l_maxStringReference));
            TARG_BIN("Actual (l_maxString)",
                     l_maxString,sizeof(l_maxString));
       }

        // TC3.5: String must equal "abc" by comparison
        if(strcmp(l_maxString,l_maxStringReference) != 0)
        {
            TARG_TS_FAIL("ERROR: l_maxString does not strcmp to the reference "
                    "string");
            TARG_BIN("Actual (l_maxString)",
                     l_maxString,sizeof(l_maxString));
        }

        // TC4: Test string with no supplied default value
        // TC4.1: String storage size must match stated size
        ATTR_TEST_NO_DEFAULT_STRING_type l_noDefaultStringReference = {0};
        ATTR_TEST_NO_DEFAULT_STRING_type l_noDefaultString = {0};
        if(sizeof(l_noDefaultString) != ATTR_TEST_NO_DEFAULT_STRING_max_chars+1)
        {
            TARG_TS_FAIL("ERROR: l_noDefaultString size (%d) "
                    "does not match stated size (%d)",
                    sizeof(l_noDefaultString),
                    ATTR_TEST_NO_DEFAULT_STRING_max_chars+1);
        }

        // TC4.2: String storage size must be non-zero
        if(sizeof(l_noDefaultString) == 0)
        {
            TARG_TS_FAIL("ERROR: l_noDefaultString storage size is zero");
        }

        // TC4.3: Must be able to read the string
        if(!l_pTopLevel->tryGetAttr<ATTR_TEST_NO_DEFAULT_STRING>(
                l_noDefaultString))
        {
            TARG_TS_FAIL("ERROR: Could not read l_noDefaultString");
        }

        // TC4.4: All bytes in string must match the reference
        if(memcmp(l_noDefaultStringReference,
                  l_noDefaultString,
                  sizeof(l_noDefaultStringReference)))
        {
            TARG_TS_FAIL("ERROR: l_noDefaultString bytes do not match the "
                    "reference");
            TARG_BIN("Expected (l_noDefaultStringReference)",
                     l_noDefaultStringReference,
                     sizeof(l_noDefaultStringReference));
            TARG_BIN("Actual (l_noDefaultString)",
                     l_noDefaultString,sizeof(l_noDefaultString));
        }

        // TC4.5: String must equal empty string by comparison
        if(strcmp(l_noDefaultString,l_noDefaultStringReference) != 0)
        {
            TARG_TS_FAIL("ERROR: l_noDefaultString does not strcmp to the reference "
                    "string");
            TARG_BIN("Actual (l_noDefaultString)",
                     l_noDefaultString,sizeof(l_noDefaultString));
        }

        // TC5: Write string and read back
        // TC5.1: Must be able to write the string
        ATTR_TEST_NO_DEFAULT_STRING_type l_writeString = {0};
        strcpy(l_writeString,"aabbcc");
        if(!l_pTopLevel->trySetAttr<ATTR_TEST_NO_DEFAULT_STRING>(l_writeString))
        {
            TARG_TS_FAIL("ERROR: Could not write l_writeString");
        }

        ATTR_TEST_NO_DEFAULT_STRING_type l_readString = {0};
        if(!l_pTopLevel->tryGetAttr<ATTR_TEST_NO_DEFAULT_STRING>(l_readString))
        {
            TARG_TS_FAIL("ERROR: Could not read l_readString");
        }

        if(strcmp(l_writeString,l_readString) != 0)
        {
            TARG_TS_FAIL("ERROR: String does not match what was written");
            TARG_BIN("Expected (l_writeString)",
                     l_writeString,
                     sizeof(l_writeString));
            TARG_BIN("Actual (l_readString)",
                     l_readString,
                     sizeof(l_readString));
        }

        } while(0);

        TARG_TS_TRACE(EXIT_MRK "testStringAttributes" );
    }

    void testL4s()
    {
        TARG_TS_TRACE(ENTER_MRK "testL4s" );

        using namespace TARGETING;

        PredicateCTM l_procChip(CLASS_CHIP,TYPE_PROC,MODEL_MURANO);
        TargetRangeFilter l_filter(
            targetService().begin(),
            targetService().end(),
            &l_procChip);

        PredicateCTM l_L4s(CLASS_UNIT,TYPE_L4);
        uint32_t l_count = 0;
        uint32_t l_procs = 0;

        // There should be 16 L4s as children of the
        // 16 processors
        for(;l_filter;++l_filter)
        {
            l_procs++;

            TargetHandleList l_list;
            (void) targetService().getAssociated(
                l_list,
                *l_filter,
                TARGETING::TargetService::CHILD_BY_AFFINITY,
                TARGETING::TargetService::ALL,
                &l_L4s);
            l_count += l_list.size();
        }

        // 4 processors -- 4 L4 units per processor
        uint32_t  total = 4 * l_procs;

        if(l_procs)
        {
            if( l_count != total )
            {
                TARG_TS_FAIL("Did not find any L4 targets identified "
                              "with child affinity to the processors");
            }
            else
            {
                TARG_TS_TRACE("Found %d L4 targets with child affinity to "
                               "the processors", l_count);
            }
        }

        l_count = 0;

        PredicateCTM l_mcsChip(CLASS_UNIT,TYPE_MCS,MODEL_MURANO);
        TargetRangeFilter l_filter2(
            targetService().begin(),
            targetService().end(),
           &l_mcsChip);

        uint32_t l_MCS = 0;

        // L4 is also a child of the MCS
        for(;l_filter2;++l_filter2)
        {
            l_MCS++;

            TargetHandleList l_list;
            (void) targetService().getAssociated(
                l_list,
                *l_filter2,
                TARGETING::TargetService::CHILD_BY_AFFINITY,
                TARGETING::TargetService::ALL,
                &l_L4s);
            l_count += l_list.size();
        }

        // 1  L4 uint per MCS uint
        total = l_MCS;

        if(l_MCS)
        {
            if(l_count != total )
            {
                TARG_TS_FAIL("Did not find any L4 targets connected to MCS");
            }
            else
            {
                TARG_TS_TRACE("Found %d L4 targets connected to MCS",l_count);
            }
        }

        PredicateCTM l_nodes(CLASS_ENC,TYPE_NODE,MODEL_POWER8);
        TargetRangeFilter l_filter3(
            targetService().begin(),
            targetService().end(),
            &l_nodes);

        uint32_t l_node = 0;
        l_count = 0;
        // L4 is also a child of the NODE
        for(;l_filter3;++l_filter3)
        {
            l_node++;

            TargetHandleList l_list;
            (void) targetService().getAssociated(
                l_list,
                *l_filter3,
                TARGETING::TargetService::CHILD_BY_AFFINITY,
                TARGETING::TargetService::ALL,
                &l_L4s);
            l_count += l_list.size();
        }

        // 1 L4 per MCS * number of nodes
        total = l_node * l_MCS;

        if(l_node)
        {
            if(l_count != total )
            {
                TARG_TS_FAIL("Did not find any L4 targets "
                             "with child affinity to the node");
            }
            else
            {
                TARG_TS_TRACE("Found %d L4 targets with child "
                              "affinity to the node",l_count);
            }
        }

        PredicateCTM l_membufs(CLASS_CHIP,TYPE_MEMBUF,MODEL_CENTAUR);
        TargetRangeFilter l_filter4(
            targetService().begin(),
            targetService().end(),
            &l_membufs);

        int l_membuf = 0;
        l_count = 0;
        // L4 is also a child of the NODE
        for(;l_filter4;++l_filter4)
        {
            l_membuf++;

            TargetHandleList l_list;
            (void) targetService().getAssociated(
                l_list,
                *l_filter4,
                TARGETING::TargetService::CHILD_BY_AFFINITY,
                TARGETING::TargetService::ALL,
                &l_L4s);
            l_count += l_list.size();
        }

        // 1 L4 per membuf
        total = l_membuf;

        if(l_membuf)
        {
            if(l_count != total )
            {
                TARG_TS_TRACE("\n\nDid not find any L4 targets "
                             "with child affinity to the membuf target\n\n");
            }
            else
            {
                TARG_TS_TRACE("\n\nFound %d L4 targets with child "
                              "affinity to the membuf\n\n",l_count);
            }
        }

        TARG_TS_TRACE(EXIT_MRK "testL4s" );
    }


};

#endif // __TARGETING_COMMON_TESTCOMMONTARGETING_H
OpenPOWER on IntegriCloud