1*444fa1c0Saustinfcui #include <attn/ti_handler.hpp> 2*444fa1c0Saustinfcui #include <util/trace.hpp> 3*444fa1c0Saustinfcui 4*444fa1c0Saustinfcui #include <map> 5*444fa1c0Saustinfcui #include <string> 6*444fa1c0Saustinfcui 7*444fa1c0Saustinfcui #include "gtest/gtest.h" 8*444fa1c0Saustinfcui 9*444fa1c0Saustinfcui namespace 10*444fa1c0Saustinfcui { 11*444fa1c0Saustinfcui uint8_t tiInfo[0x58] = { 12*444fa1c0Saustinfcui 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 13*444fa1c0Saustinfcui 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 14*444fa1c0Saustinfcui 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 15*444fa1c0Saustinfcui 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 16*444fa1c0Saustinfcui 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 17*444fa1c0Saustinfcui 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 18*444fa1c0Saustinfcui 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 19*444fa1c0Saustinfcui 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b}; 20*444fa1c0Saustinfcui } // namespace 21*444fa1c0Saustinfcui 22*444fa1c0Saustinfcui TEST(TiHandler, TestSet1) 23*444fa1c0Saustinfcui { 24*444fa1c0Saustinfcui trace::inf("TestSet1: will test ti handler."); 25*444fa1c0Saustinfcui 26*444fa1c0Saustinfcui std::map<std::string, std::string> tiMap; 27*444fa1c0Saustinfcui attn::TiDataArea* tiData = (attn::TiDataArea*)tiInfo; 28*444fa1c0Saustinfcui 29*444fa1c0Saustinfcui trace::inf("Set values in tiData to the map by parsePhypOpalTiInfo()."); 30*444fa1c0Saustinfcui attn::parsePhypOpalTiInfo(tiMap, tiData); 31*444fa1c0Saustinfcui 32*444fa1c0Saustinfcui // tiAreaValid, offset: 0x00, size: 1, 0x2c 33*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x00 TI Area Valid"], "2c"); 34*444fa1c0Saustinfcui // command, offset: 0x01, size: 1, 0x2d 35*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x01 Command"], "2d"); 36*444fa1c0Saustinfcui // numDataBytes, offset: 0x02, size: 2, 0x2e 0x2f 37*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x02 Num. Data Bytes"], "2e2f"); 38*444fa1c0Saustinfcui // reserved1, offset: 0x04, size: 1, 0x30 39*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x04 Reserved"], "30"); 40*444fa1c0Saustinfcui // hardwareDumpType, offset: 0x06, size: 2, 0x32 0x33 41*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x06 HWDump Type"], "3233"); 42*444fa1c0Saustinfcui // srcFormat, offset: 0x08, size: 1, 0x34 43*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x08 SRC Format"], "34"); 44*444fa1c0Saustinfcui // srcFlags, offset: 0x09, size: 1, 0x35 45*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x09 SRC Flags"], "35"); 46*444fa1c0Saustinfcui // numAsciiWords, offset: 0x0a, size: 1, 0x36 47*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x0a Num. ASCII Words"], "36"); 48*444fa1c0Saustinfcui // numHexWords, offset: 0x0b, size: 1, 0x37 49*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x0b Num. Hex Words"], "37"); 50*444fa1c0Saustinfcui // lenSrc, offset: 0x0e, size: 2, 0x3a 0x3b 51*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x0e Length of SRC"], "3a3b"); 52*444fa1c0Saustinfcui // srcWord12HbWord0, offset: 0x10, size: 4, 0x3c 0x3d 0x3e 0x3f 53*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x10 SRC Word 12"], "3c3d3e3f"); 54*444fa1c0Saustinfcui // srcWord13HbWord2, offset: 0x14, size: 4, 0x40 0x41 0x42 0x43 55*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x14 SRC Word 13"], "40414243"); 56*444fa1c0Saustinfcui // srcWord14HbWord3, offset: 0x18, size: 4, 0x44 0x45 0x46 0x47 57*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x18 SRC Word 14"], "44454647"); 58*444fa1c0Saustinfcui // srcWord15HbWord4, offset: 0x1c, size: 4, 0x48 0x49 0x4a 0x4b 59*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x1c SRC Word 15"], "48494a4b"); 60*444fa1c0Saustinfcui // srcWord16HbWord5, offset: 0x20, size: 4, 0x4c 0x4d 0x4e 0x4f 61*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x20 SRC Word 16"], "4c4d4e4f"); 62*444fa1c0Saustinfcui // srcWord17HbWord6, offset: 0x24, size: 4, 0x50 0x51 0x52 0x53 63*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x24 SRC Word 17"], "50515253"); 64*444fa1c0Saustinfcui // srcWord18HbWord7, offset: 0x28, size: 4, 0x54 0x55 0x56 0x57 65*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x28 SRC Word 18"], "54555657"); 66*444fa1c0Saustinfcui // srcWord19HbWord8, offset: 0x2c, size: 4, 0x00 0x01 0x02 0x03 67*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x2c SRC Word 19"], "00010203"); 68*444fa1c0Saustinfcui // asciiData0, offset: 0x30, size: 4, 0x04 0x05 0x06 0x07 69*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x30 ASCII Data"], "04050607"); 70*444fa1c0Saustinfcui // asciiData1, offset: 0x34, size: 4, 0x08 0x09 0x0a 0x0b 71*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x34 ASCII Data"], "08090a0b"); 72*444fa1c0Saustinfcui // asciiData2, offset: 0x38, size: 4, 0x0c 0x0d 0x0e 0x0f 73*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x38 ASCII Data"], "0c0d0e0f"); 74*444fa1c0Saustinfcui // asciiData3, offset: 0x3c, size: 4, 0x10 0x11 0x12 0x13 75*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x3c ASCII Data"], "10111213"); 76*444fa1c0Saustinfcui // asciiData4, offset: 0x40, size: 4, 0x14 0x15 0x16 0x17 77*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x40 ASCII Data"], "14151617"); 78*444fa1c0Saustinfcui // asciiData5, offset: 0x44, size: 4, 0x18 0x19 0x1a 0x1b 79*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x44 ASCII Data"], "18191a1b"); 80*444fa1c0Saustinfcui // asciiData6, offset: 0x48, size: 4, 0x1c 0x1d 0x1e 0x1f 81*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x48 ASCII Data"], "1c1d1e1f"); 82*444fa1c0Saustinfcui // asciiData7, offset: 0x4c, size: 4, 0x20 0x21 0x22 0x23 83*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x4c ASCII Data"], "20212223"); 84*444fa1c0Saustinfcui // location, offset: 0x50, size: 1, 0x24 85*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x50 Location"], "24"); 86*444fa1c0Saustinfcui // codeSection, offset: 0x51, size: 1, 0x25 87*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x51 Code Sections"], "25"); 88*444fa1c0Saustinfcui // additionalSize, offset: 0x52, size: 1, 0x26 89*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x52 Additional Size"], "26"); 90*444fa1c0Saustinfcui // andData, offset: 0x53, size: 1, 0x27 91*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x53 Additional Data"], "27"); 92*444fa1c0Saustinfcui } 93*444fa1c0Saustinfcui 94*444fa1c0Saustinfcui TEST(TiHandler, TestSet2) 95*444fa1c0Saustinfcui { 96*444fa1c0Saustinfcui trace::inf("TestSet2: will test ti handler."); 97*444fa1c0Saustinfcui 98*444fa1c0Saustinfcui attn::TiDataArea* tiData = nullptr; 99*444fa1c0Saustinfcui std::map<std::string, std::string> tiMap; 100*444fa1c0Saustinfcui 101*444fa1c0Saustinfcui // Use the pre-defined array as test data. 102*444fa1c0Saustinfcui tiData = (attn::TiDataArea*)tiInfo; 103*444fa1c0Saustinfcui 104*444fa1c0Saustinfcui trace::inf("Set values in tiData to the map by defaultHbTiInfo()."); 105*444fa1c0Saustinfcui attn::parseHbTiInfo(tiMap, tiData); 106*444fa1c0Saustinfcui 107*444fa1c0Saustinfcui // tiAreaValid, offset: 0x00, size: 1, 0x2c 108*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x00 TI Area Valid"], "2c"); 109*444fa1c0Saustinfcui // reserved1, offset: 0x04, size: 1, 0x30 110*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x04 Reserved"], "30"); 111*444fa1c0Saustinfcui // hbTerminateType, offset: 0x05, size: 1, 0x31 112*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x05 HB_Term. Type"], "31"); 113*444fa1c0Saustinfcui // hbDumpFlag, offset: 0x0c, size: 1, 0x38 114*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x0c HB Dump Flag"], "38"); 115*444fa1c0Saustinfcui // source, offset: 0x0d, size: 1, 0x39 116*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x0d Source"], "39"); 117*444fa1c0Saustinfcui // srcWord12HbWord0, offset: 0x10, size: 4, 0x3c 0x3d 0x3e 0x3f 118*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x10 HB Word 0"], "3c3d3e3f"); 119*444fa1c0Saustinfcui // srcWord13HbWord2, offset: 0x14, size: 4, 0x40 0x41 0x42 0x43 120*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x14 HB Word 2"], "40414243"); 121*444fa1c0Saustinfcui // srcWord14HbWord3, offset: 0x18, size: 4, 0x44 0x45 0x46 0x47 122*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x18 HB Word 3"], "44454647"); 123*444fa1c0Saustinfcui // srcWord15HbWord4, offset: 0x1c, size: 4, 0x48 0x49 0x4a 0x4b 124*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x1c HB Word 4"], "48494a4b"); 125*444fa1c0Saustinfcui // srcWord16HbWord5, offset: 0x20, size: 4, 0x4c 0x4d 0x4e 0x4f 126*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x20 HB Word 5"], "4c4d4e4f"); 127*444fa1c0Saustinfcui // srcWord17HbWord6, offset: 0x24, size: 4, 0x50 0x51 0x52 0x53 128*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x24 HB Word 6"], "50515253"); 129*444fa1c0Saustinfcui // srcWord18HbWord7, offset: 0x28, size: 4, 0x54 0x55 0x56 0x57 130*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x28 HB Word 7"], "54555657"); 131*444fa1c0Saustinfcui // srcWord19HbWord8, offset: 0x2c, size: 4, 0x00 0x01 0x02 0x03 132*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x2c HB Word 8"], "00010203"); 133*444fa1c0Saustinfcui // asciiData0, offset: 0x30, size: 4, 0x04 0x05 0x06 0x07 134*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x30 error_data"], "04050607"); 135*444fa1c0Saustinfcui // asciiData1, offset: 0x34, size: 4, 0x08 0x09 0x0a 0x0b 136*444fa1c0Saustinfcui EXPECT_EQ(tiMap["0x34 EID"], "08090a0b"); 137*444fa1c0Saustinfcui } 138