@@ -924,14 +924,16 @@ struct ProfilingTimestampPacketsTest : public ::testing::Test {
924924 ev->timestampPacketContainer ->add (node);
925925 }
926926
927- void addTimestampNodeMultiOsContext (int globalStart[16 ], int globalEnd[16 ], uint32_t size) {
927+ void addTimestampNodeMultiOsContext (int globalStart[16 ], int globalEnd[16 ], int contextStart[ 16 ], int contextEnd[ 16 ], uint32_t size) {
928928 auto node = new MockTagNode<TimestampPacketStorage>();
929929 auto timestampPacketStorage = new TimestampPacketStorage ();
930930 timestampPacketStorage->packetsUsed = size;
931931
932932 for (uint32_t i = 0u ; i < timestampPacketStorage->packetsUsed ; ++i) {
933933 timestampPacketStorage->packets [i].globalStart = globalStart[i];
934934 timestampPacketStorage->packets [i].globalEnd = globalEnd[i];
935+ timestampPacketStorage->packets [i].contextStart = contextStart[i];
936+ timestampPacketStorage->packets [i].contextEnd = contextEnd[i];
935937 }
936938
937939 node->tagForCpuAccess = timestampPacketStorage;
@@ -981,8 +983,10 @@ TEST_F(ProfilingTimestampPacketsTest, givenTimestampsPacketContainerWithOneEleme
981983TEST_F (ProfilingTimestampPacketsTest, givenMultiOsContextCapableSetToTrueWhenCalcProfilingDataIsCalledThenCorrectedValuesAreReturned) {
982984 int globalStart[16 ] = {0 };
983985 int globalEnd[16 ] = {0 };
986+ int contextStart[16 ] = {0 };
987+ int contextEnd[16 ] = {0 };
984988 initTimestampNodeMultiOsContextData (globalStart, globalEnd, 16u );
985- addTimestampNodeMultiOsContext (globalStart, globalEnd, 16u );
989+ addTimestampNodeMultiOsContext (globalStart, globalEnd, contextStart, contextEnd, 16u );
986990 auto &device = reinterpret_cast <MockDevice &>(cmdQ->getDevice ());
987991 auto &csr = device.getUltCommandStreamReceiver <DEFAULT_TEST_FAMILY_NAME>();
988992 csr.multiOsContextCapable = true ;
@@ -992,6 +996,41 @@ TEST_F(ProfilingTimestampPacketsTest, givenMultiOsContextCapableSetToTrueWhenCal
992996 EXPECT_EQ (350u , ev->getEndTimeStamp ());
993997}
994998
999+ TEST_F (ProfilingTimestampPacketsTest, givenPrintTimestampPacketContentsSetWhenCalcProfilingDataThenTimeStampsArePrinted) {
1000+ DebugManagerStateRestore restorer;
1001+ DebugManager.flags .PrintTimestampPacketContents .set (true );
1002+ testing::internal::CaptureStdout ();
1003+
1004+ auto &device = reinterpret_cast <MockDevice &>(cmdQ->getDevice ());
1005+ auto &csr = device.getUltCommandStreamReceiver <DEFAULT_TEST_FAMILY_NAME>();
1006+ csr.multiOsContextCapable = true ;
1007+
1008+ int globalStart[16 ] = {0 };
1009+ int globalEnd[16 ] = {0 };
1010+ int contextStart[16 ] = {0 };
1011+ int contextEnd[16 ] = {0 };
1012+ for (int i = 0 ; i < 16 ; i++) {
1013+ globalStart[i] = 2 * i;
1014+ globalEnd[i] = 500 * i;
1015+ contextStart[i] = 7 * i;
1016+ contextEnd[i] = 94 * i;
1017+ }
1018+ addTimestampNodeMultiOsContext (globalStart, globalEnd, contextStart, contextEnd, 16u );
1019+
1020+ ev->calcProfilingData ();
1021+
1022+ std::string output = testing::internal::GetCapturedStdout ();
1023+ std::stringstream expected;
1024+ for (int i = 0 ; i < 16 ; i++) {
1025+ expected << " Timestamp 0, packet " << i << " : "
1026+ << " global start: " << globalStart[i] << " , "
1027+ << " global end: " << globalEnd[i] << " , "
1028+ << " context start: " << contextStart[i] << " , "
1029+ << " context end: " << contextEnd[i] << std::endl;
1030+ }
1031+ EXPECT_EQ (0 , output.compare (expected.str ().c_str ()));
1032+ }
1033+
9951034TEST_F (ProfilingTimestampPacketsTest, givenTimestampsPacketContainerWithThreeElementsWhenCalculatingProfilingThenTimesAreTakenFromProperPacket) {
9961035 addTimestampNode (10 , 11 , 12 );
9971036 addTimestampNode (1 , 21 , 22 );
0 commit comments