1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include <fcntl.h> 17 #include <hwext/gtest-ext.h> 18 #include <hwext/gtest-tag.h> 19 #include <string> 20 #include <unordered_map> 21 22 #include "memory_plugin_result.pb.h" 23 #include "htrace_mem_parser.h" 24 #include "memory_plugin_result.pbreader.h" 25 #include "parser/common_types.h" 26 #include "trace_streamer_selector.h" 27 #include "process_filter.h" 28 29 using namespace testing::ext; 30 using namespace SysTuning::TraceStreamer; 31 32 namespace SysTuning { 33 namespace TraceStreamer { 34 int64_t MEM_KB = 1024; 35 int64_t MEM_RSS_KB = 512; 36 int64_t MEM_ANON_KB = 128; 37 int64_t MEM_FILE_KB = 2048; 38 39 class HtraceMemParserTest : public ::testing::Test { 40 public: SetUp()41 void SetUp() 42 { 43 stream_.InitFilter(); 44 45 dataSeg_.dataType = DATA_SOURCE_TYPE_MEM; 46 dataSeg_.clockId = TS_CLOCK_REALTIME; 47 dataSeg_.status = TS_PARSE_STATUS_PARSED; 48 dataSeg_.timeStamp = 1616439852302; 49 } 50 TearDown()51 void TearDown() 52 { 53 if (access(dbPath_.c_str(), F_OK) == 0) { 54 remove(dbPath_.c_str()); 55 } 56 } 57 SetProcessesinfo(MemoryData & tracePacket,uint32_t pid,std::string name)58 std::string SetProcessesinfo(MemoryData& tracePacket, uint32_t pid, std::string name) 59 { 60 std::string memStrMsg = ""; 61 ProcessMemoryInfo* memoryInfo = tracePacket.add_processesinfo(); 62 if (memoryInfo == nullptr || (name == "Process1" && tracePacket.processesinfo_size() != 1) || 63 (name == "Process2" && tracePacket.processesinfo_size() != 2)) { 64 return memStrMsg; 65 } 66 67 memoryInfo->set_pid(pid); 68 memoryInfo->set_name(name); 69 memoryInfo->set_vm_size_kb(MEM_KB); 70 memoryInfo->set_vm_rss_kb(MEM_RSS_KB); 71 memoryInfo->set_rss_anon_kb(MEM_ANON_KB); 72 memoryInfo->set_rss_file_kb(MEM_FILE_KB); 73 74 tracePacket.SerializeToString(&memStrMsg); 75 return memStrMsg; 76 } 77 78 public: 79 SysTuning::TraceStreamer::TraceStreamerSelector stream_ = {}; 80 const std::string dbPath_ = "../../test/resource/out.db"; 81 HtraceDataSegment dataSeg_; 82 }; 83 84 /** 85 * @tc.name: ParseMemParse 86 * @tc.desc: Parse MemoryData object and export database 87 * @tc.type: FUNC 88 */ 89 HWTEST_F(HtraceMemParserTest, ParseMemParse, TestSize.Level1) 90 { 91 TS_LOGI("test16-1"); 92 HtraceMemParser* memParser = new HtraceMemParser(stream_.traceDataCache_.get(), stream_.streamFilters_.get()); 93 94 MemoryData tracePacket; 95 ProcessMemoryInfo* memoryInfo = tracePacket.add_processesinfo(); 96 EXPECT_TRUE(memoryInfo != nullptr); 97 int32_t size = tracePacket.processesinfo_size(); 98 EXPECT_TRUE(size == 1); 99 100 std::string memStrMsg = ""; 101 tracePacket.SerializeToString(&memStrMsg); 102 ProtoReader::BytesView memBytesView(reinterpret_cast<const uint8_t*>(memStrMsg.data()), memStrMsg.size()); 103 dataSeg_.protoData = memBytesView; 104 105 memParser->Parse(dataSeg_, dataSeg_.timeStamp, dataSeg_.clockId); 106 memParser->Finish(); 107 stream_.traceDataCache_->ExportDatabase(dbPath_); 108 109 EXPECT_TRUE(access(dbPath_.c_str(), F_OK) == 0); 110 tracePacket.clear_processesinfo(); 111 delete memParser; 112 113 auto eventCount = stream_.traceDataCache_->GetConstStatAndInfo().GetValue(TRACE_MEMORY, STAT_EVENT_RECEIVED); 114 EXPECT_TRUE(1 == eventCount); 115 } 116 117 /** 118 * @tc.name: ParseMemParseTestMeasureDataSize 119 * @tc.desc: Parse MemoryData object and count StatInfo 120 * @tc.type: FUNC 121 */ 122 HWTEST_F(HtraceMemParserTest, ParseMemParseTestMeasureDataSize, TestSize.Level1) 123 { 124 TS_LOGI("test16-2"); 125 HtraceMemParser* memParser = new HtraceMemParser(stream_.traceDataCache_.get(), stream_.streamFilters_.get()); 126 127 MemoryData tracePacket; 128 const uint32_t pid = 12; 129 std::string memStrMsg = SetProcessesinfo(tracePacket, pid, "Process1"); 130 EXPECT_TRUE(memStrMsg != ""); 131 ProtoReader::BytesView memBytesView(reinterpret_cast<const uint8_t*>(memStrMsg.data()), memStrMsg.size()); 132 dataSeg_.protoData = memBytesView; 133 134 memParser->Parse(dataSeg_, dataSeg_.timeStamp, dataSeg_.clockId); 135 memParser->Finish(); 136 stream_.traceDataCache_->ExportDatabase(dbPath_); 137 138 EXPECT_TRUE(access(dbPath_.c_str(), F_OK) == 0); 139 tracePacket.clear_processesinfo(); 140 delete memParser; 141 142 auto eventCount = stream_.traceDataCache_->GetConstStatAndInfo().GetValue(TRACE_MEMORY, STAT_EVENT_RECEIVED); 143 EXPECT_TRUE(1 == eventCount); 144 145 EXPECT_TRUE(stream_.traceDataCache_->GetConstProcessData(1).pid_ == pid); 146 auto processMeasureData = stream_.traceDataCache_->GetConstProcessMeasureData(); 147 EXPECT_EQ(processMeasureData.Size(), MEM_PURG_SUM * 1); 148 EXPECT_EQ(stream_.traceDataCache_->GetConstProcessData().size(), 2); 149 150 for (auto i = 0; i < MEM_PURG_SUM; i++) { 151 if (processMeasureData.filterIdDeque_[i] == memParser->memNameDictMap_.at(MEM_VM_SIZE)) { 152 EXPECT_TRUE(processMeasureData.valuesDeque_[i] == MEM_KB); 153 } else if (processMeasureData.filterIdDeque_[i] == memParser->memNameDictMap_.at(MEM_VM_RSS)) { 154 EXPECT_TRUE(processMeasureData.valuesDeque_[i] == MEM_RSS_KB); 155 } else if (processMeasureData.filterIdDeque_[i] == memParser->memNameDictMap_.at(MEM_VM_ANON)) { 156 EXPECT_TRUE(processMeasureData.valuesDeque_[i] == MEM_ANON_KB); 157 } else if (processMeasureData.filterIdDeque_[i] == memParser->memNameDictMap_.at(MEM_RSS_FILE)) { 158 EXPECT_TRUE(processMeasureData.valuesDeque_[i] == MEM_FILE_KB); 159 } 160 } 161 } 162 163 /** 164 * @tc.name: ParseMemParseTestMutiMeasureData 165 * @tc.desc: Parse muti MemoryData object and count StatInfo 166 * @tc.type: FUNC 167 */ 168 HWTEST_F(HtraceMemParserTest, ParseMemParseTestMutiMeasureData, TestSize.Level1) 169 { 170 TS_LOGI("test16-3"); 171 HtraceMemParser* memParser = new HtraceMemParser(stream_.traceDataCache_.get(), stream_.streamFilters_.get()); 172 173 MemoryData tracePacket; 174 const uint32_t pid = 12; 175 const uint32_t pid2 = 13; 176 std::string memStrMsg = SetProcessesinfo(tracePacket, pid, "Process1"); 177 memStrMsg = SetProcessesinfo(tracePacket, pid2, "Process2"); 178 ProtoReader::BytesView memBytesView(reinterpret_cast<const uint8_t*>(memStrMsg.data()), memStrMsg.size()); 179 dataSeg_.protoData = memBytesView; 180 181 memParser->Parse(dataSeg_, dataSeg_.timeStamp, dataSeg_.clockId); 182 memParser->Finish(); 183 stream_.traceDataCache_->ExportDatabase(dbPath_); 184 185 EXPECT_TRUE(access(dbPath_.c_str(), F_OK) == 0); 186 tracePacket.clear_processesinfo(); 187 delete memParser; 188 189 auto eventCount = stream_.traceDataCache_->GetConstStatAndInfo().GetValue(TRACE_MEMORY, STAT_EVENT_RECEIVED); 190 EXPECT_TRUE(1 == eventCount); 191 192 EXPECT_TRUE(stream_.traceDataCache_->GetConstProcessData(1).pid_ == pid); 193 EXPECT_TRUE(stream_.traceDataCache_->GetConstProcessData(2).pid_ == pid2); 194 } 195 196 /** 197 * @tc.name: ParseMultiEmptyProcessMemoryInfo 198 * @tc.desc: Parse muti Empty ProcessMemoryInfo object and count StatInfo 199 * @tc.type: FUNC 200 */ 201 HWTEST_F(HtraceMemParserTest, ParseMultiEmptyProcessMemoryInfo, TestSize.Level1) 202 { 203 TS_LOGI("test16-4"); 204 HtraceMemParser* memParser = new HtraceMemParser(stream_.traceDataCache_.get(), stream_.streamFilters_.get()); 205 206 MemoryData tracePacket; 207 ProcessMemoryInfo* memoryInfo = tracePacket.add_processesinfo(); 208 EXPECT_TRUE(memoryInfo != nullptr); 209 int32_t size = tracePacket.processesinfo_size(); 210 EXPECT_TRUE(size == 1); 211 212 ProcessMemoryInfo* memoryInfo2 = tracePacket.add_processesinfo(); 213 EXPECT_TRUE(memoryInfo2 != nullptr); 214 size = tracePacket.processesinfo_size(); 215 EXPECT_TRUE(size == 2); 216 217 std::string memStrMsg = ""; 218 tracePacket.SerializeToString(&memStrMsg); 219 ProtoReader::BytesView memBytesView(reinterpret_cast<const uint8_t*>(memStrMsg.data()), memStrMsg.size()); 220 dataSeg_.protoData = memBytesView; 221 222 memParser->Parse(dataSeg_, dataSeg_.timeStamp, dataSeg_.clockId); 223 memParser->Finish(); 224 stream_.traceDataCache_->ExportDatabase(dbPath_); 225 226 EXPECT_TRUE(access(dbPath_.c_str(), F_OK) == 0); 227 tracePacket.clear_processesinfo(); 228 delete memParser; 229 230 auto eventCount = stream_.traceDataCache_->GetConstStatAndInfo().GetValue(TRACE_MEMORY, STAT_EVENT_RECEIVED); 231 EXPECT_TRUE(1 == eventCount); 232 233 EXPECT_TRUE(stream_.traceDataCache_->GetConstProcessMeasureData().Size() == MEM_PURG_SUM * 2); 234 } 235 236 /** 237 * @tc.name: ParseEmptyMemoryData 238 * @tc.desc: Parse Empty MemoryData 239 * @tc.type: FUNC 240 */ 241 HWTEST_F(HtraceMemParserTest, ParseEmptyMemoryData, TestSize.Level1) 242 { 243 TS_LOGI("test16-5"); 244 HtraceMemParser* memParser = new HtraceMemParser(stream_.traceDataCache_.get(), stream_.streamFilters_.get()); 245 246 MemoryData tracePacket; 247 int32_t size = tracePacket.processesinfo_size(); 248 EXPECT_TRUE(size == 0); 249 uint64_t timeStamp = 1616439852302; 250 BuiltinClocks clock = TS_CLOCK_REALTIME; 251 252 std::string memStrMsg = ""; 253 tracePacket.SerializeToString(&memStrMsg); 254 ProtoReader::BytesView memBytesView(reinterpret_cast<const uint8_t*>(memStrMsg.data()), memStrMsg.size()); 255 dataSeg_.protoData = memBytesView; 256 257 memParser->Parse(dataSeg_, dataSeg_.timeStamp, dataSeg_.clockId); 258 memParser->Finish(); 259 delete memParser; 260 261 auto eventCount = stream_.traceDataCache_->GetConstStatAndInfo().GetValue(TRACE_MEMORY, STAT_EVENT_RECEIVED); 262 EXPECT_TRUE(0 == eventCount); 263 } 264 265 /** 266 * @tc.name: ParseAshmemInfo 267 * @tc.desc: Parse Ashmem Info 268 * @tc.type: FUNC 269 */ 270 HWTEST_F(HtraceMemParserTest, ParseAshmemInfo, TestSize.Level1) 271 { 272 TS_LOGI("test16-6"); 273 HtraceMemParser* memParser = new HtraceMemParser(stream_.traceDataCache_.get(), stream_.streamFilters_.get()); 274 275 MemoryData tracePacket; 276 AshmemInfo* ashmemInfo = tracePacket.add_ashmeminfo(); 277 EXPECT_TRUE(ashmemInfo != nullptr); 278 int32_t size = tracePacket.ashmeminfo_size(); 279 EXPECT_TRUE(size == 1); 280 281 int32_t id = 0; 282 int64_t time = 1616439852302; 283 int32_t pid = 6; 284 int32_t adj = 6; 285 int32_t fd = 6; 286 int64_t purged = 6; 287 uint64_t setSize = 6; 288 int64_t refCount = 6; 289 ashmemInfo->set_id(id); 290 ashmemInfo->set_time(time); 291 ashmemInfo->set_pid(pid); 292 ashmemInfo->set_adj(adj); 293 ashmemInfo->set_fd(fd); 294 ashmemInfo->set_purged(purged); 295 ashmemInfo->set_size(setSize); 296 ashmemInfo->set_ref_count(refCount); 297 298 std::string memStrMsg = ""; 299 tracePacket.SerializeToString(&memStrMsg); 300 ProtoReader::BytesView memBytesView(reinterpret_cast<const uint8_t*>(memStrMsg.data()), memStrMsg.size()); 301 dataSeg_.protoData = memBytesView; 302 303 memParser->Parse(dataSeg_, dataSeg_.timeStamp, dataSeg_.clockId); 304 memParser->Finish(); 305 stream_.traceDataCache_->ExportDatabase(dbPath_); 306 307 EXPECT_TRUE(access(dbPath_.c_str(), F_OK) == 0); 308 tracePacket.clear_processesinfo(); 309 delete memParser; 310 EXPECT_EQ(stream_.traceDataCache_->GetConstAshMemData().ids_[0], id); 311 EXPECT_EQ(stream_.traceDataCache_->GetConstAshMemData().adjs_[0], adj); 312 EXPECT_EQ(stream_.traceDataCache_->GetConstAshMemData().times_[0], time); 313 } 314 315 /** 316 * @tc.name: ParseDmaMemInfo 317 * @tc.desc: Parse DmaMem Info 318 * @tc.type: FUNC 319 */ 320 HWTEST_F(HtraceMemParserTest, ParseDmaMemInfo, TestSize.Level1) 321 { 322 TS_LOGI("test16-7"); 323 HtraceMemParser* memParser = new HtraceMemParser(stream_.traceDataCache_.get(), stream_.streamFilters_.get()); 324 325 MemoryData tracePacket; 326 DmaInfo* dmaInfo = tracePacket.add_dmainfo(); 327 EXPECT_TRUE(dmaInfo != nullptr); 328 int32_t size = tracePacket.dmainfo_size(); 329 EXPECT_TRUE(size == 1); 330 331 uint64_t setSize = 7; 332 int32_t pid = 7; 333 int32_t ino = 7; 334 int32_t fd = 7; 335 int64_t expPid = 7; 336 dmaInfo->set_size(setSize); 337 dmaInfo->set_pid(pid); 338 dmaInfo->set_ino(ino); 339 dmaInfo->set_fd(fd); 340 dmaInfo->set_exp_pid(expPid); 341 342 std::string memStrMsg = ""; 343 tracePacket.SerializeToString(&memStrMsg); 344 ProtoReader::BytesView memBytesView(reinterpret_cast<const uint8_t*>(memStrMsg.data()), memStrMsg.size()); 345 dataSeg_.protoData = memBytesView; 346 347 memParser->Parse(dataSeg_, dataSeg_.timeStamp, dataSeg_.clockId); 348 memParser->Finish(); 349 stream_.traceDataCache_->ExportDatabase(dbPath_); 350 351 EXPECT_TRUE(access(dbPath_.c_str(), F_OK) == 0); 352 tracePacket.clear_processesinfo(); 353 delete memParser; 354 EXPECT_EQ(stream_.traceDataCache_->GetConstDmaMemData().inos_[0], ino); 355 EXPECT_EQ(stream_.traceDataCache_->GetConstDmaMemData().fds_[0], fd); 356 EXPECT_EQ(stream_.traceDataCache_->GetConstDmaMemData().expPids_[0], expPid); 357 } 358 359 /** 360 * @tc.name: ParseGpuProcessMemInfo 361 * @tc.desc: Parse GpuProcessMem Info 362 * @tc.type: FUNC 363 */ 364 HWTEST_F(HtraceMemParserTest, ParseGpuProcessMemInfo, TestSize.Level1) 365 { 366 TS_LOGI("test16-8"); 367 HtraceMemParser* memParser = new HtraceMemParser(stream_.traceDataCache_.get(), stream_.streamFilters_.get()); 368 369 MemoryData tracePacket; 370 GpuMemoryInfo* gpuMemoryInfo = tracePacket.add_gpumemoryinfo(); 371 372 int32_t allGpuSize = 0; 373 gpuMemoryInfo->set_all_gpu_size(allGpuSize); 374 375 std::string memStrMsg = ""; 376 tracePacket.SerializeToString(&memStrMsg); 377 ProtoReader::BytesView memBytesView(reinterpret_cast<const uint8_t*>(memStrMsg.data()), memStrMsg.size()); 378 dataSeg_.protoData = memBytesView; 379 380 memParser->Parse(dataSeg_, dataSeg_.timeStamp, dataSeg_.clockId); 381 memParser->Finish(); 382 stream_.traceDataCache_->ExportDatabase(dbPath_); 383 384 EXPECT_TRUE(access(dbPath_.c_str(), F_OK) == 0); 385 tracePacket.clear_processesinfo(); 386 delete memParser; 387 EXPECT_EQ(0, allGpuSize); 388 } 389 390 /** 391 * @tc.name: ParseGpuWindowMemInfo 392 * @tc.desc: Parse GpuWindowMem Info 393 * @tc.type: FUNC 394 */ 395 HWTEST_F(HtraceMemParserTest, ParseGpuWindowMemInfo, TestSize.Level1) 396 { 397 TS_LOGI("test16-9"); 398 HtraceMemParser* memParser = new HtraceMemParser(stream_.traceDataCache_.get(), stream_.streamFilters_.get()); 399 400 MemoryData tracePacket; 401 GpuDumpInfo* gpuDumpInfo = tracePacket.add_gpudumpinfo(); 402 403 std::string memStrMsg = ""; 404 tracePacket.SerializeToString(&memStrMsg); 405 ProtoReader::BytesView memBytesView(reinterpret_cast<const uint8_t*>(memStrMsg.data()), memStrMsg.size()); 406 dataSeg_.protoData = memBytesView; 407 408 memParser->Parse(dataSeg_, dataSeg_.timeStamp, dataSeg_.clockId); 409 memParser->Finish(); 410 stream_.traceDataCache_->ExportDatabase(dbPath_); 411 412 EXPECT_TRUE(access(dbPath_.c_str(), F_OK) == 0); 413 tracePacket.clear_processesinfo(); 414 delete memParser; 415 EXPECT_EQ(stream_.traceDataCache_->GetConstGpuWindowMemData().Size(), 0); 416 } 417 418 /** 419 * @tc.name: AshMemDeduplicateTest 420 * @tc.desc: AshMem Deduplicate Test 421 * @tc.type: FUNC 422 */ 423 HWTEST_F(HtraceMemParserTest, AshMemDeduplicateTest, TestSize.Level1) 424 { 425 TS_LOGI("test16-10"); 426 427 HtraceMemParser* memParser = new HtraceMemParser(stream_.traceDataCache_.get(), stream_.streamFilters_.get()); 428 uint32_t adj = 6; 429 uint32_t fd = 6; 430 DataIndex ashmemNameId = stream_.traceDataCache_->GetDataIndex("xxx"); 431 uint64_t size = 222; 432 uint64_t refCount = 3; 433 uint64_t purged = 1; 434 435 struct DeduplicateVar { 436 uint64_t timeStamp; 437 uint64_t pid; 438 std::string_view pidName; 439 uint32_t ashmemId; 440 uint64_t time; 441 }; 442 vector<DeduplicateVar> stubVars = { 443 {1616439852302, 1, "aaa", 1, 1}, {1616439852302, 1, "aaa", 1, 1}, {1616439852302, 1, "aaa", 2, 2}, 444 {1616439852302, 2, "bbb", 1, 1}, {1616439852302, 2, "bbb", 2, 2}, {1616439852302, 3, "ccc", 1, 1}, 445 {1616439852302, 3, "ccc", 2, 2}, {1616439852302, 3, "ccc", 2, 2}, 446 447 {1616439855302, 1, "aaa", 1, 1}, {1616439855302, 1, "aaa", 1, 1}, {1616439855302, 2, "bbb", 2, 2}, 448 {1616439855302, 3, "ccc", 2, 2}, 449 }; 450 for (auto& m : stubVars) { 451 auto ipid = stream_.streamFilters_->processFilter_->UpdateOrCreateProcessWithName(m.pid, m.pidName); 452 stream_.traceDataCache_->GetAshMemData()->AppendNewData(ipid, m.timeStamp, adj, fd, ashmemNameId, size, 0, 453 m.ashmemId, m.time, refCount, purged, 0); 454 } 455 456 memParser->AshMemDeduplicate(); 457 458 auto ashMemData = stream_.traceDataCache_->GetConstAshMemData(); 459 EXPECT_EQ(ashMemData.Flags()[0], 0); 460 EXPECT_EQ(ashMemData.Flags()[1], 1); 461 EXPECT_EQ(ashMemData.Flags()[2], 0); 462 EXPECT_EQ(ashMemData.Flags()[3], 2); 463 EXPECT_EQ(ashMemData.Flags()[4], 2); 464 EXPECT_EQ(ashMemData.Flags()[5], 2); 465 EXPECT_EQ(ashMemData.Flags()[6], 2); 466 EXPECT_EQ(ashMemData.Flags()[7], 1); 467 EXPECT_EQ(ashMemData.Flags()[8], 0); 468 EXPECT_EQ(ashMemData.Flags()[9], 1); 469 EXPECT_EQ(ashMemData.Flags()[10], 0); 470 EXPECT_EQ(ashMemData.Flags()[11], 2); 471 } 472 473 /** 474 * @tc.name: DmaMemDeduplicateTest 475 * @tc.desc: DmaMem Deduplicate Test 476 * @tc.type: FUNC 477 */ 478 HWTEST_F(HtraceMemParserTest, DmaMemDeduplicateTest, TestSize.Level1) 479 { 480 TS_LOGI("test16-11"); 481 482 HtraceMemParser* memParser = new HtraceMemParser(stream_.traceDataCache_.get(), stream_.streamFilters_.get()); 483 uint32_t fd = 6; 484 uint64_t size = 222; 485 uint64_t expPid = 5; 486 DataIndex expTaskCommId = stream_.traceDataCache_->GetDataIndex("aaa"); 487 DataIndex bufNameId = stream_.traceDataCache_->GetDataIndex("bbb"); 488 DataIndex expNameId = stream_.traceDataCache_->GetDataIndex("ccc"); 489 490 struct DeduplicateVar { 491 uint64_t timeStamp; 492 uint64_t pid; 493 std::string_view pidName; 494 uint32_t ino; 495 }; 496 vector<DeduplicateVar> stubVars = { 497 {1616439852302, 1, "render_service", 1}, 498 {1616439852302, 1, "render_service", 1}, 499 {1616439852302, 1, "render_service", 2}, 500 {1616439852302, 2, "app", 1}, 501 {1616439852302, 2, "app", 2}, 502 {1616439852302, 3, "composer_host", 1}, 503 {1616439852302, 3, "composer_host", 2}, 504 {1616439852302, 3, "composer_host", 2}, 505 {1616439855302, 1, "render_service", 1}, 506 {1616439855302, 1, "render_service", 2}, 507 {1616439855302, 3, "composer_host", 2}, 508 {1616439855302, 3, "composer_host", 2}, 509 }; 510 for (auto& m : stubVars) { 511 auto ipid = stream_.streamFilters_->processFilter_->UpdateOrCreateProcessWithName(m.pid, m.pidName); 512 stream_.traceDataCache_->GetDmaMemData()->AppendNewData(ipid, m.timeStamp, fd, size, m.ino, expPid, 513 expTaskCommId, bufNameId, expNameId, 0); 514 } 515 516 memParser->DmaMemDeduplicate(); 517 518 auto DmaData = stream_.traceDataCache_->GetConstDmaMemData(); 519 EXPECT_EQ(DmaData.Flags()[0], 2); 520 EXPECT_EQ(DmaData.Flags()[1], 1); 521 EXPECT_EQ(DmaData.Flags()[2], 2); 522 EXPECT_EQ(DmaData.Flags()[3], 0); 523 EXPECT_EQ(DmaData.Flags()[4], 0); 524 EXPECT_EQ(DmaData.Flags()[5], 2); 525 EXPECT_EQ(DmaData.Flags()[6], 2); 526 EXPECT_EQ(DmaData.Flags()[7], 1); 527 EXPECT_EQ(DmaData.Flags()[8], 0); 528 EXPECT_EQ(DmaData.Flags()[9], 0); 529 EXPECT_EQ(DmaData.Flags()[10], 2); 530 EXPECT_EQ(DmaData.Flags()[11], 1); 531 } 532 533 } // namespace TraceStreamer 534 } // namespace SysTuning 535