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