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 <hwext/gtest-ext.h> 17 #include <hwext/gtest-tag.h> 18 19 #include "common_types.pb.h" 20 #include "plugin_service.h" 21 #include "plugin_service.ipc.h" 22 #include "profiler_data_repeater.h" 23 #include "profiler_service_types.pb.h" 24 #include "socket_context.h" 25 26 using namespace testing::ext; 27 28 namespace { 29 class PluginClientTest final : public IPluginServiceClient { 30 public: OnGetCommandResponse(SocketContext & context,::GetCommandResponse & response)31 bool OnGetCommandResponse(SocketContext& context, ::GetCommandResponse& response) override 32 { 33 return true; 34 } 35 }; 36 37 class UnitTestPluginService : public testing::Test { 38 public: SetUpTestCase()39 static void SetUpTestCase() {} TearDownTestCase()40 static void TearDownTestCase() {} 41 SetUp()42 void SetUp() 43 { 44 pluginService_ = std::make_unique<PluginService>(); 45 usleep(100000); // sleep for 100000 us. 46 pluginClient_ = std::make_unique<PluginClientTest>(); 47 } 48 TearDown()49 void TearDown() 50 { 51 pluginClient_ = nullptr; 52 pluginService_ = nullptr; 53 } 54 55 public: 56 std::unique_ptr<PluginService> pluginService_ = nullptr; 57 std::unique_ptr<PluginClientTest> pluginClient_ = nullptr; 58 uint32_t pluginId_; 59 }; 60 61 /** 62 * @tc.name: Service 63 * @tc.desc: Set plugin registration information. 64 * @tc.type: FUNC 65 */ 66 HWTEST_F(UnitTestPluginService, AddPluginInfo, TestSize.Level1) 67 { 68 RegisterPluginRequest request; 69 RegisterPluginResponse response; 70 PluginInfo plugin; 71 72 request.set_request_id(1); 73 request.set_path("abc.so"); 74 request.set_sha256("asdfasdfasdfasfd"); 75 request.set_name("abc.so"); 76 ASSERT_TRUE(response.status() != ResponseStatus::OK); 77 pluginId_ = response.plugin_id(); 78 79 plugin.name = "abc.so"; 80 plugin.bufferSizeHint = 0; 81 plugin.sha256 = ""; 82 ASSERT_TRUE(pluginService_->AddPluginInfo(plugin)); 83 } 84 85 /** 86 * @tc.name: Service 87 * @tc.desc: Set plugin configuration information. 88 * @tc.type: FUNC 89 */ 90 HWTEST_F(UnitTestPluginService, CreatePluginSession1, TestSize.Level1) 91 { 92 ProfilerPluginConfig ppc; 93 ppc.set_name("abc.so"); 94 ppc.set_plugin_sha256("ASDFAADSF"); 95 ppc.set_sample_interval(20); 96 97 ASSERT_FALSE(pluginService_->CreatePluginSession(ppc, std::make_shared<ProfilerDataRepeater>(4096))); 98 } 99 100 /** 101 * @tc.name: Service 102 * @tc.desc: Set session configuration. 103 * @tc.type: FUNC 104 */ 105 HWTEST_F(UnitTestPluginService, CreatePluginSession2, TestSize.Level1) 106 { 107 ProfilerPluginConfig ppc; 108 ppc.set_name("abc.so"); 109 ppc.set_plugin_sha256("ASDFAADSF"); 110 ppc.set_sample_interval(20); 111 112 ProfilerSessionConfig::BufferConfig bc; 113 bc.set_pages(1); 114 bc.set_policy(ProfilerSessionConfig_BufferConfig_Policy_RECYCLE); 115 116 ASSERT_FALSE(pluginService_->CreatePluginSession(ppc, bc, std::make_shared<ProfilerDataRepeater>(4096))); 117 } 118 119 /** 120 * @tc.name: Service 121 * @tc.desc: Start plugin session. 122 * @tc.type: FUNC 123 */ 124 HWTEST_F(UnitTestPluginService, StartPluginSession, TestSize.Level1) 125 { 126 ProfilerPluginConfig ppc; 127 ppc.set_name("abc.so"); 128 ppc.set_plugin_sha256("ASDFAADSF"); 129 ppc.set_sample_interval(20); 130 131 ASSERT_FALSE(pluginService_->StartPluginSession(ppc)); 132 } 133 134 /** 135 * @tc.name: Service 136 * @tc.desc: Stop plugin session. 137 * @tc.type: FUNC 138 */ 139 HWTEST_F(UnitTestPluginService, StopPluginSession, TestSize.Level1) 140 { 141 ASSERT_FALSE(pluginService_->StopPluginSession("abc.so")); 142 } 143 144 /** 145 * @tc.name: Service 146 * @tc.desc: Destroy receiving test. 147 * @tc.type: FUNC 148 */ 149 HWTEST_F(UnitTestPluginService, DestroyPluginSession, TestSize.Level1) 150 { 151 ASSERT_FALSE(pluginService_->DestroyPluginSession("abc.so")); 152 } 153 154 /** 155 * @tc.name: Service 156 * @tc.desc: Remove the specified plugin. 157 * @tc.type: FUNC 158 */ 159 HWTEST_F(UnitTestPluginService, RemovePluginInfo, TestSize.Level1) 160 { 161 UnregisterPluginRequest request; 162 PluginInfo pi; 163 pi.id = 0; 164 pi.name = "abc.so"; 165 pi.path = "abc.so"; 166 pi.sha256 = "asdfasdf"; 167 ASSERT_FALSE(pluginService_->RemovePluginInfo(pi)); 168 } 169 170 /** 171 * @tc.name: Service 172 * @tc.desc: Setting report results. 173 * @tc.type: FUNC 174 */ 175 HWTEST_F(UnitTestPluginService, AppendResult, TestSize.Level1) 176 { 177 NotifyResultRequest nrr; 178 nrr.set_request_id(1); 179 nrr.set_command_id(1); 180 ASSERT_TRUE(pluginService_->AppendResult(nrr)); 181 } 182 183 /** 184 * @tc.name: Service 185 * @tc.desc: Get plugin status. 186 * @tc.type: FUNC 187 */ 188 HWTEST_F(UnitTestPluginService, GetPluginStatus, TestSize.Level1) 189 { 190 auto status = pluginService_->GetPluginStatus(); 191 ASSERT_TRUE(status.size() == 0); 192 } 193 194 /** 195 * @tc.name: Service 196 * @tc.desc: Gets the plugin with the specified name. 197 * @tc.type: FUNC 198 */ 199 HWTEST_F(UnitTestPluginService, GetPluginIdByName, TestSize.Level1) 200 { 201 ASSERT_TRUE(pluginService_->GetPluginIdByName("abc.so") == 0); 202 } 203 204 /** 205 * @tc.name: Service 206 * @tc.desc: Set plugin registration information. 207 * @tc.type: FUNC 208 */ 209 HWTEST_F(UnitTestPluginService, AddPluginInfo2, TestSize.Level1) 210 { 211 RegisterPluginRequest request; 212 RegisterPluginResponse response; 213 PluginInfo plugin; 214 215 request.set_request_id(2); 216 request.set_path("mem.so"); 217 request.set_sha256("asdfasdfasdfasfd"); 218 request.set_name("mem.so"); 219 ASSERT_TRUE(response.status() != ResponseStatus::OK); 220 pluginId_ = response.plugin_id(); 221 222 plugin.name = "mem.so"; 223 plugin.bufferSizeHint = 0; 224 plugin.sha256 = ""; 225 EXPECT_TRUE(pluginService_->AddPluginInfo(plugin)); 226 } 227 228 /** 229 * @tc.name: Service 230 * @tc.desc: Set plugin configuration information. 231 * @tc.type: FUNC 232 */ 233 HWTEST_F(UnitTestPluginService, CreatePluginSession12, TestSize.Level1) 234 { 235 ProfilerPluginConfig ppc; 236 ppc.set_name("mem.so"); 237 ppc.set_plugin_sha256("ASDFAADSF"); 238 ppc.set_sample_interval(20); 239 240 ASSERT_FALSE(pluginService_->CreatePluginSession(ppc, std::make_shared<ProfilerDataRepeater>(4096))); 241 } 242 243 /** 244 * @tc.name: Service 245 * @tc.desc: Set session configuration. 246 * @tc.type: FUNC 247 */ 248 HWTEST_F(UnitTestPluginService, CreatePluginSession22, TestSize.Level1) 249 { 250 ProfilerPluginConfig ppc; 251 ppc.set_name("mem.so"); 252 ppc.set_plugin_sha256("ASDFAADSF"); 253 ppc.set_sample_interval(20); 254 255 ProfilerSessionConfig::BufferConfig bc; 256 bc.set_pages(1); 257 bc.set_policy(ProfilerSessionConfig_BufferConfig_Policy_RECYCLE); 258 259 ASSERT_FALSE(pluginService_->CreatePluginSession(ppc, bc, std::make_shared<ProfilerDataRepeater>(4096))); 260 } 261 262 /** 263 * @tc.name: Service 264 * @tc.desc: Start plugin session. 265 * @tc.type: FUNC 266 */ 267 HWTEST_F(UnitTestPluginService, StartPluginSession2, TestSize.Level1) 268 { 269 ProfilerPluginConfig ppc; 270 ppc.set_name("mem.so"); 271 ppc.set_plugin_sha256("ASDFAADSF"); 272 ppc.set_sample_interval(20); 273 274 ASSERT_FALSE(pluginService_->StartPluginSession(ppc)); 275 } 276 277 /** 278 * @tc.name: Service 279 * @tc.desc: Stop plugin session. 280 * @tc.type: FUNC 281 */ 282 HWTEST_F(UnitTestPluginService, StopPluginSession2, TestSize.Level1) 283 { 284 ASSERT_FALSE(pluginService_->StopPluginSession("mem.so")); 285 } 286 287 /** 288 * @tc.name: Service 289 * @tc.desc: Destroy receiving test. 290 * @tc.type: FUNC 291 */ 292 HWTEST_F(UnitTestPluginService, DestroyPluginSession2, TestSize.Level1) 293 { 294 ASSERT_FALSE(pluginService_->DestroyPluginSession("mem.so")); 295 } 296 297 /** 298 * @tc.name: Service 299 * @tc.desc: Remove the specified plugin. 300 * @tc.type: FUNC 301 */ 302 HWTEST_F(UnitTestPluginService, RemovePluginInfo2, TestSize.Level1) 303 { 304 UnregisterPluginRequest request; 305 PluginInfo pi; 306 pi.id = 0; 307 pi.name = "mem.so"; 308 pi.path = "mem.so"; 309 pi.sha256 = "asdfasdf"; 310 ASSERT_FALSE(pluginService_->RemovePluginInfo(pi)); 311 } 312 313 /** 314 * @tc.name: Service 315 * @tc.desc: Setting report results. 316 * @tc.type: FUNC 317 */ 318 HWTEST_F(UnitTestPluginService, AppendResult2, TestSize.Level1) 319 { 320 NotifyResultRequest nrr; 321 nrr.set_request_id(2); 322 nrr.set_command_id(2); 323 ASSERT_TRUE(pluginService_->AppendResult(nrr)); 324 } 325 326 /** 327 * @tc.name: Service 328 * @tc.desc: Get plugin status. 329 * @tc.type: FUNC 330 */ 331 HWTEST_F(UnitTestPluginService, GetPluginStatus2, TestSize.Level1) 332 { 333 auto status = pluginService_->GetPluginStatus(); 334 ASSERT_TRUE(status.size() == 0); 335 } 336 337 /** 338 * @tc.name: Service 339 * @tc.desc: Gets the plugin with the specified name. 340 * @tc.type: FUNC 341 */ 342 HWTEST_F(UnitTestPluginService, GetPluginIdByName2, TestSize.Level1) 343 { 344 ASSERT_TRUE(pluginService_->GetPluginIdByName("mem.so") == 0); 345 } 346 347 /** 348 * @tc.name: Service 349 * @tc.desc: Set plugin registration information. 350 * @tc.type: FUNC 351 */ 352 HWTEST_F(UnitTestPluginService, AddPluginInfo3, TestSize.Level1) 353 { 354 RegisterPluginRequest request; 355 RegisterPluginResponse response; 356 PluginInfo plugin; 357 358 request.set_request_id(3); 359 request.set_path("cpu.so"); 360 request.set_sha256("asdfasdfasdfasfd"); 361 request.set_name("cpu.so"); 362 ASSERT_TRUE(response.status() != ResponseStatus::OK); 363 pluginId_ = response.plugin_id(); 364 365 plugin.name = "cpu.so"; 366 plugin.bufferSizeHint = 0; 367 plugin.sha256 = ""; 368 EXPECT_TRUE(pluginService_->AddPluginInfo(plugin)); 369 } 370 371 /** 372 * @tc.name: Service 373 * @tc.desc: Set plugin configuration information. 374 * @tc.type: FUNC 375 */ 376 HWTEST_F(UnitTestPluginService, CreatePluginSession13, TestSize.Level1) 377 { 378 ProfilerPluginConfig ppc; 379 ppc.set_name("cpu.so"); 380 ppc.set_plugin_sha256("ASDFAADSF"); 381 ppc.set_sample_interval(20); 382 383 ASSERT_FALSE(pluginService_->CreatePluginSession(ppc, std::make_shared<ProfilerDataRepeater>(4096))); 384 } 385 386 /** 387 * @tc.name: Service 388 * @tc.desc: Set session configuration. 389 * @tc.type: FUNC 390 */ 391 HWTEST_F(UnitTestPluginService, CreatePluginSession23, TestSize.Level1) 392 { 393 ProfilerPluginConfig ppc; 394 ppc.set_name("cpu.so"); 395 ppc.set_plugin_sha256("ASDFAADSF"); 396 ppc.set_sample_interval(20); 397 398 ProfilerSessionConfig::BufferConfig bc; 399 bc.set_pages(1); 400 bc.set_policy(ProfilerSessionConfig_BufferConfig_Policy_RECYCLE); 401 402 ASSERT_FALSE(pluginService_->CreatePluginSession(ppc, bc, std::make_shared<ProfilerDataRepeater>(4096))); 403 } 404 405 /** 406 * @tc.name: Service 407 * @tc.desc: Start plugin session. 408 * @tc.type: FUNC 409 */ 410 HWTEST_F(UnitTestPluginService, StartPluginSession3, TestSize.Level1) 411 { 412 ProfilerPluginConfig ppc; 413 ppc.set_name("cpu.so"); 414 ppc.set_plugin_sha256("ASDFAADSF"); 415 ppc.set_sample_interval(20); 416 417 ASSERT_FALSE(pluginService_->StartPluginSession(ppc)); 418 } 419 420 /** 421 * @tc.name: Service 422 * @tc.desc: Stop plugin session. 423 * @tc.type: FUNC 424 */ 425 HWTEST_F(UnitTestPluginService, StopPluginSession3, TestSize.Level1) 426 { 427 ASSERT_FALSE(pluginService_->StopPluginSession("cpu.so")); 428 } 429 430 /** 431 * @tc.name: Service 432 * @tc.desc: Destroy receiving test. 433 * @tc.type: FUNC 434 */ 435 HWTEST_F(UnitTestPluginService, DestroyPluginSession3, TestSize.Level1) 436 { 437 ASSERT_FALSE(pluginService_->DestroyPluginSession("cpu.so")); 438 } 439 440 /** 441 * @tc.name: Service 442 * @tc.desc: Remove the specified plugin. 443 * @tc.type: FUNC 444 */ 445 HWTEST_F(UnitTestPluginService, RemovePluginInfo3, TestSize.Level1) 446 { 447 UnregisterPluginRequest request; 448 PluginInfo pi; 449 pi.id = 0; 450 pi.name = "cpu.so"; 451 pi.path = "cpu.so"; 452 pi.sha256 = "asdfasdf"; 453 ASSERT_FALSE(pluginService_->RemovePluginInfo(pi)); 454 } 455 456 /** 457 * @tc.name: Service 458 * @tc.desc: Setting report results. 459 * @tc.type: FUNC 460 */ 461 HWTEST_F(UnitTestPluginService, AppendResult3, TestSize.Level1) 462 { 463 NotifyResultRequest nrr; 464 nrr.set_request_id(3); 465 nrr.set_command_id(3); 466 ASSERT_TRUE(pluginService_->AppendResult(nrr)); 467 } 468 469 /** 470 * @tc.name: Service 471 * @tc.desc: Get plugin status. 472 * @tc.type: FUNC 473 */ 474 HWTEST_F(UnitTestPluginService, GetPluginStatus3, TestSize.Level1) 475 { 476 auto status = pluginService_->GetPluginStatus(); 477 ASSERT_TRUE(status.size() == 0); 478 } 479 480 /** 481 * @tc.name: Service 482 * @tc.desc: Gets the plugin with the specified name. 483 * @tc.type: FUNC 484 */ 485 HWTEST_F(UnitTestPluginService, GetPluginIdByName3, TestSize.Level1) 486 { 487 ASSERT_TRUE(pluginService_->GetPluginIdByName("cpu.so") == 0); 488 } 489 490 /** 491 * @tc.name: Service 492 * @tc.desc: Set plugin registration information. 493 * @tc.type: FUNC 494 */ 495 HWTEST_F(UnitTestPluginService, AddPluginInfo4, TestSize.Level1) 496 { 497 RegisterPluginRequest request; 498 RegisterPluginResponse response; 499 PluginInfo plugin; 500 501 request.set_request_id(4); 502 request.set_path("stream.so"); 503 request.set_sha256("asdfasdfasdfasfd"); 504 request.set_name("stream.so"); 505 ASSERT_TRUE(response.status() != ResponseStatus::OK); 506 pluginId_ = response.plugin_id(); 507 508 plugin.name = "stream.so"; 509 plugin.bufferSizeHint = 0; 510 plugin.sha256 = ""; 511 EXPECT_TRUE(pluginService_->AddPluginInfo(plugin)); 512 } 513 514 /** 515 * @tc.name: Service 516 * @tc.desc: Set plugin configuration information. 517 * @tc.type: FUNC 518 */ 519 HWTEST_F(UnitTestPluginService, CreatePluginSession14, TestSize.Level1) 520 { 521 ProfilerPluginConfig ppc; 522 ppc.set_name("stream.so"); 523 ppc.set_plugin_sha256("ASDFAADSF"); 524 ppc.set_sample_interval(20); 525 526 ASSERT_FALSE(pluginService_->CreatePluginSession(ppc, std::make_shared<ProfilerDataRepeater>(4096))); 527 } 528 529 /** 530 * @tc.name: Service 531 * @tc.desc: Set session configuration. 532 * @tc.type: FUNC 533 */ 534 HWTEST_F(UnitTestPluginService, CreatePluginSession24, TestSize.Level1) 535 { 536 ProfilerPluginConfig ppc; 537 ppc.set_name("stream.so"); 538 ppc.set_plugin_sha256("ASDFAADSF"); 539 ppc.set_sample_interval(20); 540 541 ProfilerSessionConfig::BufferConfig bc; 542 bc.set_pages(1); 543 bc.set_policy(ProfilerSessionConfig_BufferConfig_Policy_RECYCLE); 544 545 ASSERT_FALSE(pluginService_->CreatePluginSession(ppc, bc, std::make_shared<ProfilerDataRepeater>(4096))); 546 } 547 548 /** 549 * @tc.name: Service 550 * @tc.desc: Start plugin session. 551 * @tc.type: FUNC 552 */ 553 HWTEST_F(UnitTestPluginService, StartPluginSession4, TestSize.Level1) 554 { 555 ProfilerPluginConfig ppc; 556 ppc.set_name("stream.so"); 557 ppc.set_plugin_sha256("ASDFAADSF"); 558 ppc.set_sample_interval(20); 559 560 ASSERT_FALSE(pluginService_->StartPluginSession(ppc)); 561 } 562 563 /** 564 * @tc.name: Service 565 * @tc.desc: Stop plugin session. 566 * @tc.type: FUNC 567 */ 568 HWTEST_F(UnitTestPluginService, StopPluginSession4, TestSize.Level1) 569 { 570 ASSERT_FALSE(pluginService_->StopPluginSession("stream.so")); 571 } 572 573 /** 574 * @tc.name: Service 575 * @tc.desc: Destroy receiving test. 576 * @tc.type: FUNC 577 */ 578 HWTEST_F(UnitTestPluginService, DestroyPluginSession4, TestSize.Level1) 579 { 580 ASSERT_FALSE(pluginService_->DestroyPluginSession("stream.so")); 581 } 582 583 /** 584 * @tc.name: Service 585 * @tc.desc: Remove the specified plugin. 586 * @tc.type: FUNC 587 */ 588 HWTEST_F(UnitTestPluginService, RemovePluginInfo4, TestSize.Level1) 589 { 590 UnregisterPluginRequest request; 591 PluginInfo pi; 592 pi.id = 0; 593 pi.name = "stream.so"; 594 pi.path = "stream.so"; 595 pi.sha256 = "asdfasdf"; 596 ASSERT_FALSE(pluginService_->RemovePluginInfo(pi)); 597 } 598 599 /** 600 * @tc.name: Service 601 * @tc.desc: Setting report results. 602 * @tc.type: FUNC 603 */ 604 HWTEST_F(UnitTestPluginService, AppendResult4, TestSize.Level1) 605 { 606 NotifyResultRequest nrr; 607 nrr.set_request_id(4); 608 nrr.set_command_id(4); 609 ASSERT_TRUE(pluginService_->AppendResult(nrr)); 610 } 611 612 /** 613 * @tc.name: Service 614 * @tc.desc: Get plugin status. 615 * @tc.type: FUNC 616 */ 617 HWTEST_F(UnitTestPluginService, GetPluginStatus4, TestSize.Level1) 618 { 619 auto status = pluginService_->GetPluginStatus(); 620 ASSERT_TRUE(status.size() == 0); 621 } 622 623 /** 624 * @tc.name: Service 625 * @tc.desc: Gets the plugin with the specified name. 626 * @tc.type: FUNC 627 */ 628 HWTEST_F(UnitTestPluginService, GetPluginIdByName4, TestSize.Level1) 629 { 630 ASSERT_TRUE(pluginService_->GetPluginIdByName("stream.so") == 0); 631 } 632 633 /** 634 * @tc.name: Service 635 * @tc.desc: Set plugin registration information. 636 * @tc.type: FUNC 637 */ 638 HWTEST_F(UnitTestPluginService, AddPluginInfo5, TestSize.Level1) 639 { 640 RegisterPluginRequest request; 641 RegisterPluginResponse response; 642 PluginInfo plugin; 643 644 request.set_request_id(5); 645 request.set_path("sample.so"); 646 request.set_sha256("asdfasdfasdfasfd"); 647 request.set_name("sample.so"); 648 ASSERT_TRUE(response.status() != ResponseStatus::OK); 649 pluginId_ = response.plugin_id(); 650 651 plugin.name = "sample.so"; 652 plugin.bufferSizeHint = 0; 653 plugin.sha256 = ""; 654 EXPECT_TRUE(pluginService_->AddPluginInfo(plugin)); 655 } 656 657 /** 658 * @tc.name: Service 659 * @tc.desc: Set plugin configuration information. 660 * @tc.type: FUNC 661 */ 662 HWTEST_F(UnitTestPluginService, CreatePluginSession15, TestSize.Level1) 663 { 664 ProfilerPluginConfig ppc; 665 ppc.set_name("sample.so"); 666 ppc.set_plugin_sha256("ASDFAADSF"); 667 ppc.set_sample_interval(20); 668 669 ASSERT_FALSE(pluginService_->CreatePluginSession(ppc, std::make_shared<ProfilerDataRepeater>(4096))); 670 } 671 672 /** 673 * @tc.name: Service 674 * @tc.desc: Set session configuration. 675 * @tc.type: FUNC 676 */ 677 HWTEST_F(UnitTestPluginService, CreatePluginSession25, TestSize.Level1) 678 { 679 ProfilerPluginConfig ppc; 680 ppc.set_name("sample.so"); 681 ppc.set_plugin_sha256("ASDFAADSF"); 682 ppc.set_sample_interval(20); 683 684 ProfilerSessionConfig::BufferConfig bc; 685 bc.set_pages(1); 686 bc.set_policy(ProfilerSessionConfig_BufferConfig_Policy_RECYCLE); 687 688 ASSERT_FALSE(pluginService_->CreatePluginSession(ppc, bc, std::make_shared<ProfilerDataRepeater>(4096))); 689 } 690 691 /** 692 * @tc.name: Service 693 * @tc.desc: Start plugin session. 694 * @tc.type: FUNC 695 */ 696 HWTEST_F(UnitTestPluginService, StartPluginSession5, TestSize.Level1) 697 { 698 ProfilerPluginConfig ppc; 699 ppc.set_name("sample.so"); 700 ppc.set_plugin_sha256("ASDFAADSF"); 701 ppc.set_sample_interval(20); 702 703 ASSERT_FALSE(pluginService_->StartPluginSession(ppc)); 704 } 705 706 /** 707 * @tc.name: Service 708 * @tc.desc: Stop plugin session. 709 * @tc.type: FUNC 710 */ 711 HWTEST_F(UnitTestPluginService, StopPluginSession5, TestSize.Level1) 712 { 713 ASSERT_FALSE(pluginService_->StopPluginSession("sample.so")); 714 } 715 716 /** 717 * @tc.name: Service 718 * @tc.desc: Destroy receiving test. 719 * @tc.type: FUNC 720 */ 721 HWTEST_F(UnitTestPluginService, DestroyPluginSession5, TestSize.Level1) 722 { 723 ASSERT_FALSE(pluginService_->DestroyPluginSession("sample.so")); 724 } 725 726 /** 727 * @tc.name: Service 728 * @tc.desc: Remove the specified plugin. 729 * @tc.type: FUNC 730 */ 731 HWTEST_F(UnitTestPluginService, RemovePluginInfo5, TestSize.Level1) 732 { 733 UnregisterPluginRequest request; 734 PluginInfo pi; 735 pi.id = 0; 736 pi.name = "sample.so"; 737 pi.path = "sample.so"; 738 pi.sha256 = "asdfasdf"; 739 ASSERT_FALSE(pluginService_->RemovePluginInfo(pi)); 740 } 741 742 /** 743 * @tc.name: Service 744 * @tc.desc: Setting report results. 745 * @tc.type: FUNC 746 */ 747 HWTEST_F(UnitTestPluginService, AppendResult5, TestSize.Level1) 748 { 749 NotifyResultRequest nrr; 750 nrr.set_request_id(5); 751 nrr.set_command_id(5); 752 ASSERT_TRUE(pluginService_->AppendResult(nrr)); 753 } 754 755 /** 756 * @tc.name: Service 757 * @tc.desc: Get plugin status. 758 * @tc.type: FUNC 759 */ 760 HWTEST_F(UnitTestPluginService, GetPluginStatus5, TestSize.Level1) 761 { 762 auto status = pluginService_->GetPluginStatus(); 763 ASSERT_TRUE(status.size() == 0); 764 } 765 766 /** 767 * @tc.name: Service 768 * @tc.desc: Gets the plugin with the specified name. 769 * @tc.type: FUNC 770 */ 771 HWTEST_F(UnitTestPluginService, GetPluginIdByName5, TestSize.Level1) 772 { 773 ASSERT_TRUE(pluginService_->GetPluginIdByName("sample.so") == 0); 774 } 775 } // namespace