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 <iostream>
17 #include <cstdio>
18 #include <cstring>
19 #include <ctime>
20 #include <chrono>
21 #include <cinttypes>
22 #include <string>
23 #include <unistd.h>
24 #include <gtest/gtest.h>
25 #include <sys/types.h>
26 #include <securec.h>
27
28 #include "dbinder_service.h"
29 #include "dbinder_service_test_helper.h"
30 #include "dbinder_test_service_skeleton.h"
31 #include "ipc_skeleton.h"
32 #include "ipc_object_proxy.h"
33 #include "ipc_types.h"
34 #include "if_system_ability_manager.h"
35 #include "string_ex.h"
36 #include "iservice_registry.h"
37 #include "system_ability_definition.h"
38 #include "distributed_major.h"
39 #include "log_tags.h"
40 #include "dbinder_test_service.h"
41 #include "dbinder_log.h"
42
43 using namespace OHOS;
44 using namespace testing::ext;
45 using namespace OHOS::DistributeSystemTest;
46 using namespace OHOS::HiviewDFX;
47
48 static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, LOG_ID_TEST, "DbinderTest" };
49
50 class DbinderTest : public DistributeTest {
51 public:
52 static const int UNIT = 1024;
53 /* The threshold of packet size is 64 * 1024, including header.
54 * The following definitions are used to test legal and illegal packets.
55 */
56 static const int LEGAL_SIZE_S = 3 * 1024;
57 static const int LEGAL_SIZE_M = 16 * 1024;
58 static const int LEGAL_SIZE_L = 63 * 1024;
59 static const int ILLEGAL_SIZE = 2 * 1024 * 1024;
60 static const int REPEAT_TIMES = 1000;
61 static const int REPEAT_RAW_DATA_TIMES = 100;
62 static const int MULTIPLEX_TIMES = 10;
63 static sptr<ISystemAbilityManager> manager_;
64 static char serverId_[DEVICEID_LENGTH + 1];
65 // Test transferring big data with different sizes
66 const int rawData10K = 10 * 1024;
67 const int rawData100K = 100 * 1024;
68 const int rawData1M = 1024 * 1024;
69 const int rawData10M = 10 * 1024 * 1024;
70 const int rawData100M = 100 * 1024 * 1024;
71
72 DbinderTest() = default;
73 ~DbinderTest() = default;
74 static void SetUpTestCase();
75 static void TearDownTestCase();
76 virtual void SetUp();
TearDown()77 virtual void TearDown() {}
78 std::string IpToDeviceId(const std::string &localIp);
79 bool GetRemoteDeviceId();
80 };
81
82 sptr<ISystemAbilityManager> DbinderTest::manager_ = nullptr;
83 char DbinderTest::serverId_[DEVICEID_LENGTH + 1];
84
SetUpTestCase()85 void DbinderTest::SetUpTestCase()
86 {
87 DBINDER_LOGI(LOG_LABEL, "enter SetUpTestCase");
88 StartDBinderServiceTestService();
89 }
90
TearDownTestCase()91 void DbinderTest::TearDownTestCase()
92 {
93 DBINDER_LOGI(LOG_LABEL, "enter TearDownTestCase");
94 StopDBinderServiceTestService();
95 }
96
SetUp()97 void DbinderTest::SetUp()
98 {
99 bool ret = GetRemoteDeviceId();
100 ASSERT_TRUE(ret);
101
102 sptr<DBinderService> dBinderService = DBinderService::GetInstance();
103 ASSERT_TRUE(dBinderService != nullptr);
104
105 manager_ = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
106 ASSERT_TRUE(manager_ != nullptr);
107 }
108
GetRemoteDeviceId()109 bool DbinderTest::GetRemoteDeviceId()
110 {
111 std::string msg = "Ask Device ID";
112 int ret = SendMessage(AGENT_NO::ONE, msg,
113 strlen(msg.c_str()), [serverId_](const std::string &retId, int retLen) -> bool {
114 if (memcpy_s(serverId_, DEVICEID_LENGTH, retId.c_str(), DEVICEID_LENGTH) != 0 || retLen != DEVICEID_LENGTH) {
115 DBINDER_LOGE(LOG_LABEL, "fail to copy string");
116 return false;
117 }
118 serverId_[DEVICEID_LENGTH] = '\0';
119 return true;
120 });
121
122 return ret > 0;
123 }
124
125 /*
126 * @tc.name: DbinderRemoteCall001
127 * @tc.desc: Verify local client can acquire registered system ability
128 * and invoke remote function on remote server.
129 * @tc.type: FUNC
130 * @tc.require: SR000CS1C1 SR000CS1CA SR000CUFFU I5GORX
131 */
132 HWTEST_F(DbinderTest, DbinderRemoteCall001, TestSize.Level3)
133 {
134 SetCurrentTestCase(DBINDER_TEST_REMOTE_CALL_001);
135 DBINDER_LOGI(LOG_LABEL, "");
136
137 /*
138 * @tc.steps: step1.Get a proxy (called testService) from remote server.
139 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
140 */
141 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
142 ASSERT_TRUE(object != nullptr);
143
144 sptr<IDBinderTestService> testService = iface_cast<IDBinderTestService>(object);
145 ASSERT_TRUE(testService != nullptr);
146
147 /*
148 * @tc.steps: step2.Use the proxy object to invoke remote function.
149 * @tc.expected: step2.Remote call succeeds and returns 0.
150 */
151 int reply = 0;
152 int result = testService->ReverseInt(2019, reply);
153 EXPECT_EQ(result, 0);
154 EXPECT_EQ(reply, 9102);
155
156 SetCurrentTestCase(DBINDER_TEST_INIT);
157 }
158 /*
159 * @tc.name: DbinderRemoteCall002
160 * @tc.desc: Verify local client cannot acquire unregistered system ability
161 * @tc.type: FUNC
162 * @tc.require: SR000CS1C1 SR000CS1CA SR000CUFFU I5GORX
163 */
164 HWTEST_F(DbinderTest, DbinderRemoteCall002, TestSize.Level3)
165 {
166 SetCurrentTestCase(DBINDER_TEST_REMOTE_CALL_002);
167 DBINDER_LOGI(LOG_LABEL, "");
168
169 /*
170 * @tc.steps: step1.Get an unregistered System Ability from remote server.
171 * @tc.expected: step1.Failed to get the SA and return nullptr.
172 */
173 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_UNREGISTERED_TEST_SERVICE, serverId_);
174 ASSERT_TRUE(object == nullptr);
175
176 SetCurrentTestCase(DBINDER_TEST_INIT);
177 }
178
179 /*
180 * @tc.name: DbinderRemoteCall003
181 * @tc.desc: Verify the limit to the size of data sent to remote server
182 * @tc.type: FUNC
183 * @tc.require: SR000CS1C1/SR000CS1CA/SR000CUFFU
184 */
185 HWTEST_F(DbinderTest, DbinderRemoteCall003, TestSize.Level3)
186 {
187 SetCurrentTestCase(DBINDER_TEST_REMOTE_CALL_003);
188 DBINDER_LOGI(LOG_LABEL, "");
189
190 /*
191 * @tc.steps: step1.Get a proxy (called testService) from remote server.
192 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
193 */
194 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
195 ASSERT_TRUE(object != nullptr);
196
197 sptr<IDBinderTestService> testService = iface_cast<IDBinderTestService>(object);
198 ASSERT_TRUE(testService != nullptr);
199
200 /*
201 * @tc.steps: step2.Use the proxy object to invoke remote function with legal and illegal data respectively.
202 * @tc.expected: step2.Succeed in transferring legal data but fail to transfer illegal data.
203 */
204 std::string reply;
205 std::string emptyData;
206 testService->TransOversizedPkt(emptyData, reply);
207 ASSERT_TRUE(emptyData == reply);
208
209 std::string legalDataS(LEGAL_SIZE_S, 'a');
210 int64_t startTime = GetCurrentTime();
211 for (int i = 0; i < MULTIPLEX_TIMES; i++) {
212 testService->TransOversizedPkt(legalDataS, reply);
213 ASSERT_TRUE(legalDataS == reply);
214 }
215 int64_t finishTime = GetCurrentTime();
216 float speed = GetSpeed(finishTime - startTime, LEGAL_SIZE_S, MULTIPLEX_TIMES);
217 printf("Transfer 3k data with speed of %.2fk/s.\n", speed);
218
219 std::string legalDataM(LEGAL_SIZE_M, 'a');
220 startTime = GetCurrentTime();
221 for (int i = 0; i < MULTIPLEX_TIMES; i++) {
222 testService->TransOversizedPkt(legalDataM, reply);
223 ASSERT_TRUE(legalDataM == reply);
224 }
225 finishTime = GetCurrentTime();
226 speed = GetSpeed(finishTime - startTime, LEGAL_SIZE_M, MULTIPLEX_TIMES);
227 printf("Transfer 16k data with speed of %.2fk/s.\n", speed);
228
229 std::string legalDataL(LEGAL_SIZE_L, 'a');
230 startTime = GetCurrentTime();
231 for (int i = 0; i < MULTIPLEX_TIMES; i++) {
232 testService->TransOversizedPkt(legalDataL, reply);
233 ASSERT_TRUE(legalDataL == reply);
234 }
235 finishTime = GetCurrentTime();
236 speed = GetSpeed(finishTime - startTime, LEGAL_SIZE_L, MULTIPLEX_TIMES);
237 printf("Transfer 63k data with speed of %.2fk/s.\n", speed);
238
239 std::string illegalData(ILLEGAL_SIZE, 'a');
240 testService->TransOversizedPkt(illegalData, reply);
241 ASSERT_TRUE(illegalData != reply);
242
243 SetCurrentTestCase(DBINDER_TEST_INIT);
244 }
245
246 /*
247 * @tc.name: DbinderRemoteCall004
248 * @tc.desc: Verify the communication with remote server is stable
249 * @tc.type: PERF
250 * @tc.require: SR000CS1C1/SR000CS1CA/SR000CUFFU
251 */
252 HWTEST_F(DbinderTest, DbinderRemoteCall004, TestSize.Level3)
253 {
254 SetCurrentTestCase(DBINDER_TEST_REMOTE_CALL_004);
255 DBINDER_LOGI(LOG_LABEL, "");
256
257 /*
258 * @tc.steps: step1.Get a proxy (called testService) from remote server.
259 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
260 */
261 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
262 ASSERT_TRUE(object != nullptr);
263
264 sptr<IDBinderTestService> testService = iface_cast<IDBinderTestService>(object);
265 ASSERT_TRUE(testService != nullptr);
266
267 /*
268 * @tc.steps: step2.Use the proxy object to call remote function repeatedly.
269 * @tc.expected: step2.All remote calls succeed and return 0.
270 */
271 for (int i = 0; i < REPEAT_TIMES; i++) {
272 int reply = 0;
273 int result = testService->ReverseInt(2019, reply);
274 EXPECT_EQ(result, 0);
275 EXPECT_EQ(reply, 9102);
276 }
277
278 SetCurrentTestCase(DBINDER_TEST_INIT);
279 }
280
281 /*
282 * @tc.name: DbinderRemoteCall005
283 * @tc.desc: Test the delay of remote call with remote server
284 * @tc.type: PERF
285 * @tc.require: SR000CS1C1/SR000CS1CA/SR000CUFFU
286 */
287 HWTEST_F(DbinderTest, DbinderRemoteCall005, TestSize.Level3)
288 {
289 SetCurrentTestCase(DBINDER_TEST_REMOTE_CALL_005);
290 DBINDER_LOGI(LOG_LABEL, "");
291
292 /*
293 * @tc.steps: step1.Get a proxy (called testService) from remote server.
294 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
295 */
296 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
297 ASSERT_TRUE(object != nullptr);
298
299 sptr<IDBinderTestService> testService = iface_cast<IDBinderTestService>(object);
300 ASSERT_TRUE(testService != nullptr);
301
302 /*
303 * @tc.steps: step2.Use the proxy object to call remote function, and calculate the time consumption.
304 * @tc.expected: step2.Remote call succeeds and the time delay is close to 15ms.
305 */
306 int64_t startTime = GetCurrentTime();
307 int reply = 0;
308 int result = testService->ReverseInt(2019, reply);
309 int64_t finishTime = GetCurrentTime();
310 EXPECT_GE(finishTime - startTime, 0L);
311 printf("Remote call costs %" PRId64"ms\n", (finishTime - startTime));
312 EXPECT_EQ(result, 0);
313 EXPECT_EQ(reply, 9102);
314
315 SetCurrentTestCase(DBINDER_TEST_INIT);
316 }
317
318 /*
319 * @tc.name: DbinderRemoteCall006
320 * @tc.desc: Verify the communications with remote device can be multiplexed
321 * @tc.type: FUNC
322 * @tc.require: SR000CS1C1/SR000CS1CA/SR000CUFFU
323 */
324 HWTEST_F(DbinderTest, DbinderRemoteCall006, TestSize.Level3)
325 {
326 SetCurrentTestCase(DBINDER_TEST_REMOTE_CALL_006);
327 DBINDER_LOGI(LOG_LABEL, "");
328
329 vector<sptr<IRemoteObject>> objects;
330 vector<sptr<IDBinderTestService>> testServices;
331 for (int i = 0; i < MULTIPLEX_TIMES; i++) {
332 /*
333 * @tc.steps: step1.Get a proxy from remote server and stores it.
334 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
335 */
336 objects.push_back(manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_));
337 testServices.push_back(iface_cast<IDBinderTestService>(objects[i]));
338
339 /*
340 * @tc.steps: step2.Use the proxy object to invoke remote function.
341 * @tc.expected: step2.Remote call succeeds and returns 0.
342 */
343 int reply = 0;
344 int result = testServices[i]->ReverseInt(2019, reply);
345 EXPECT_EQ(result, 0);
346 EXPECT_EQ(reply, 9102);
347 }
348
349 SetCurrentTestCase(DBINDER_TEST_INIT);
350 }
351
352 /*
353 * @tc.name: DbinderRemoteCall007
354 * @tc.desc: Verify local client can transfer a local object to remote device.
355 * @tc.type: FUNC
356 * @tc.require: SR000CS1C8/SR000CS1CA/SR000CUFFU
357 */
358 HWTEST_F(DbinderTest, DbinderRemoteCall007, TestSize.Level3)
359 {
360 SetCurrentTestCase(DBINDER_TEST_REMOTE_CALL_007);
361 DBINDER_LOGI(LOG_LABEL, "");
362
363 /*
364 * @tc.steps: step1.Get a local binder object and a proxy pointing to remote stub.
365 * @tc.expected: step1.Get both objects successfully.
366 */
367 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE);
368 ASSERT_TRUE(object != nullptr);
369 sptr<IRemoteObject> remoteObject = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
370 ASSERT_TRUE(remoteObject != nullptr);
371
372 sptr<IDBinderTestService> remoteTestService = iface_cast<IDBinderTestService>(remoteObject);
373 ASSERT_TRUE(remoteTestService != nullptr);
374
375 /*
376 * @tc.steps: step2.Transfer the binder object to remote device.
377 * @tc.expected: step2.Remote device receives the object and use it to communicate with server.
378 */
379 int reply = 0;
380 int withdrawRes = 0;
381 int result =
382 remoteTestService->TransProxyObject(2019, object, OHOS::DBinderTestServiceProxy::NOT_SAVE, reply, withdrawRes);
383 EXPECT_EQ(result, 0);
384 EXPECT_EQ(reply, 9102);
385 EXPECT_EQ(withdrawRes, 0);
386
387 SetCurrentTestCase(DBINDER_TEST_INIT);
388 }
389
390 /*
391 * @tc.name: DbinderRemoteCall008
392 * @tc.desc: Verify local client can transfer two different local objects to remote device.
393 * @tc.type: FUNC
394 * @tc.require: SR000CS1C8/SR000CS1CA/SR000CUFFU
395 */
396 HWTEST_F(DbinderTest, DbinderRemoteCall008, TestSize.Level3)
397 {
398 SetCurrentTestCase(DBINDER_TEST_REMOTE_CALL_008);
399 DBINDER_LOGI(LOG_LABEL, "");
400
401 /*
402 * @tc.steps: step1.Get a local binder object and a proxy pointing to remote stub.
403 * @tc.expected: step1.Get both objects successfully.
404 */
405 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE);
406 ASSERT_TRUE(object != nullptr);
407 sptr<IRemoteObject> object2 = manager_->GetSystemAbility(RPC_TEST_SERVICE);
408 ASSERT_TRUE(object2 != nullptr);
409 sptr<IRemoteObject> remoteObject = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
410 ASSERT_TRUE(remoteObject != nullptr);
411
412 sptr<IDBinderTestService> remoteTestService = iface_cast<IDBinderTestService>(remoteObject);
413 ASSERT_TRUE(remoteTestService != nullptr);
414
415 /*
416 * @tc.steps: step2.Transfer two binder objects to remote device.
417 * @tc.expected: step2.Remote device receives the objects and use them to communicate with server.
418 */
419 int reply = 0;
420 int withdrawRes = 0;
421 int result =
422 remoteTestService->TransProxyObject(2019, object, OHOS::DBinderTestServiceProxy::NOT_SAVE, reply, withdrawRes);
423 EXPECT_EQ(result, 0);
424 EXPECT_EQ(reply, 9102);
425 EXPECT_EQ(withdrawRes, 0);
426
427 result =
428 remoteTestService->TransProxyObject(2019, object2, OHOS::DBinderTestServiceProxy::NOT_SAVE, reply, withdrawRes);
429 EXPECT_EQ(result, 0);
430 EXPECT_EQ(reply, 9102);
431 EXPECT_EQ(withdrawRes, 0);
432
433 SetCurrentTestCase(DBINDER_TEST_INIT);
434 }
435
436 /*
437 * @tc.name: DbinderRemoteCall009
438 * @tc.desc: Verify local client is transmitting the same proxy every time to server.
439 * @tc.type: FUNC
440 * @tc.require: SR000CS1C8/SR000CS1CA/SR000CUFFU
441 */
442 HWTEST_F(DbinderTest, DbinderRemoteCall009, TestSize.Level3)
443 {
444 SetCurrentTestCase(DBINDER_TEST_REMOTE_CALL_009);
445 DBINDER_LOGI(LOG_LABEL, "");
446
447 /*
448 * @tc.steps: step1.Get a local binder object and a proxy pointing to remote stub.
449 * @tc.expected: step1.Get both objects successfully.
450 */
451 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE);
452 ASSERT_TRUE(object != nullptr);
453 sptr<IRemoteObject> remoteObject = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
454 ASSERT_TRUE(remoteObject != nullptr);
455
456 sptr<IDBinderTestService> remoteTestService = iface_cast<IDBinderTestService>(remoteObject);
457 ASSERT_TRUE(remoteTestService != nullptr);
458
459 /*
460 * @tc.steps: step2.Transfer the binder object to remote device twice.
461 * @tc.expected: step2.Remote device receives same object in two transmissions.
462 */
463 int reply = 0;
464 int withdrawRes = 0;
465 int result = remoteTestService->TransProxyObject(2019, object, DBinderTestServiceProxy::SAVE, reply, withdrawRes);
466 EXPECT_EQ(result, 0);
467 EXPECT_EQ(reply, 9102);
468 EXPECT_EQ(withdrawRes, 0);
469
470 result = remoteTestService->TransProxyObject(2019, object, DBinderTestServiceProxy::WITHDRAW, reply, withdrawRes);
471 EXPECT_EQ(result, 0);
472 EXPECT_EQ(reply, 9102);
473 EXPECT_EQ(withdrawRes, 0);
474
475 SetCurrentTestCase(DBINDER_TEST_INIT);
476 }
477
478 /*
479 * @tc.name: DbinderRemoteCall011
480 * @tc.desc: Verify transferring objects between remote devices is stable
481 * @tc.type: FUNC
482 * @tc.require: SR000CS1C8/SR000CS1CA/SR000CUFFU
483 */
484 HWTEST_F(DbinderTest, DbinderRemoteCall011, TestSize.Level3)
485 {
486 SetCurrentTestCase(DBINDER_TEST_REMOTE_CALL_011);
487 DBINDER_LOGI(LOG_LABEL, "");
488
489 /*
490 * @tc.steps: step1.Get a local binder object and a proxy pointing to remote stub.
491 * @tc.expected: step1.Get both objects successfully.
492 */
493 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE);
494 ASSERT_TRUE(object != nullptr);
495 sptr<IRemoteObject> remoteObject = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
496 ASSERT_TRUE(remoteObject != nullptr);
497
498 sptr<IDBinderTestService> remoteTestService = iface_cast<IDBinderTestService>(remoteObject);
499 ASSERT_TRUE(remoteTestService != nullptr);
500
501 /*
502 * @tc.steps: step2.Transfer the binder object to remote device repeatedly.
503 * @tc.expected: step2.Remote device receives the object and use it to communicate with server.
504 */
505 for (int i = 0; i < REPEAT_TIMES; i++) {
506 int reply = 0;
507 int withdrawRes = 0;
508 int result =
509 remoteTestService->TransProxyObject(2019, object, DBinderTestServiceProxy::NOT_SAVE, reply, withdrawRes);
510 EXPECT_EQ(result, 0);
511 EXPECT_EQ(reply, 9102);
512 }
513
514 SetCurrentTestCase(DBINDER_TEST_INIT);
515 }
516
517 /*
518 * @tc.name: DbinderRemoteCall012
519 * @tc.desc: Test the delay of transferring an object between remote devices
520 * @tc.type: PERF
521 * @tc.require: SR000CS1C8/SR000CS1CA/SR000CUFFU
522 */
523 HWTEST_F(DbinderTest, DbinderRemoteCall012, TestSize.Level3)
524 {
525 SetCurrentTestCase(DBINDER_TEST_REMOTE_CALL_012);
526 DBINDER_LOGI(LOG_LABEL, "");
527
528 /*
529 * @tc.steps: step1.Get a local binder object and a proxy pointing to remote stub.
530 * @tc.expected: step1.Get both objects successfully.
531 */
532 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE);
533 ASSERT_TRUE(object != nullptr);
534 sptr<IRemoteObject> remoteObject = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
535 ASSERT_TRUE(remoteObject != nullptr);
536
537 sptr<IDBinderTestService> remoteTestService = iface_cast<IDBinderTestService>(remoteObject);
538 ASSERT_TRUE(remoteTestService != nullptr);
539
540 /*
541 * @tc.steps: step2.Use the proxy object to transfer object, and calculate the time consumption.
542 * @tc.expected: step2.Remote call succeeds and the time delay is close to 50ms.
543 */
544 int64_t startTime = GetCurrentTime();
545 int reply = 0;
546 int withdrawRes = 0;
547 int result =
548 remoteTestService->TransProxyObject(2019, object, DBinderTestServiceProxy::NOT_SAVE, reply, withdrawRes);
549 int64_t finishTime = GetCurrentTime();
550 EXPECT_GE(finishTime - startTime, 0L);
551 printf("Transferring an object costs %" PRId64 "ms\n", (finishTime - startTime));
552 EXPECT_EQ(result, 0);
553 EXPECT_EQ(reply, 9102);
554
555 SetCurrentTestCase(DBINDER_TEST_INIT);
556 }
557
558 /*
559 * @tc.name: DbinderRemoteCall014
560 * @tc.desc: Verify adding and removing death recipient successfully
561 * @tc.type: FUNC
562 * @tc.require: SR000CS1C8/SR000CS1CA
563 */
564 HWTEST_F(DbinderTest, DbinderRemoteCall014, TestSize.Level3)
565 {
566 SetCurrentTestCase(DBINDER_TEST_DEATH_RECIPIENT_001);
567 DBINDER_LOGI(LOG_LABEL, "");
568
569 /*
570 * @tc.steps: step1.Get a proxy (called testService) from remote server.
571 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
572 */
573 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
574 ASSERT_TRUE(object != nullptr);
575
576 sptr<IDBinderTestService> testService = iface_cast<IDBinderTestService>(object);
577 ASSERT_TRUE(testService != nullptr);
578
579 /*
580 * @tc.steps: step2.Add death recipient.
581 * @tc.expected: step2.Register death notification successfully.
582 */
583 sptr<IRemoteObject::DeathRecipient> deathRecipient(new DBinderTestDeathRecipient());
584 bool result = object->AddDeathRecipient(deathRecipient);
585 EXPECT_EQ(result, true);
586
587 /*
588 * @tc.steps: step3.Remove death recipient
589 * @tc.expected: step3.Unregister death notification successfully.
590 */
591 result = object->RemoveDeathRecipient(deathRecipient);
592 EXPECT_EQ(result, true);
593
594 /*
595 * @tc.steps: step4.Use the proxy object to invoke remote function.
596 * @tc.expected: step4.Remote call succeeds and returns 0.
597 */
598 int reply = 0;
599 int res = testService->ReverseInt(2019, reply);
600 EXPECT_EQ(res, 0);
601 EXPECT_EQ(reply, 9102);
602
603 SetCurrentTestCase(DBINDER_TEST_INIT);
604 }
605
606 /*
607 * @tc.name: DbinderRemoteCall015
608 * @tc.desc: Verify adding and removing death recipient successfully
609 * @tc.type: FUNC
610 * @tc.require: SR000CS1C8/SR000CS1CA
611 */
612 HWTEST_F(DbinderTest, DbinderRemoteCall015, TestSize.Level3)
613 {
614 SetCurrentTestCase(DBINDER_TEST_DEATH_RECIPIENT_002);
615 DBINDER_LOGI(LOG_LABEL, "");
616
617 /*
618 * @tc.steps: step1.Get a proxy (called testService) from remote server.
619 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
620 */
621 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
622 ASSERT_TRUE(object != nullptr);
623
624 sptr<IDBinderTestService> testService = iface_cast<IDBinderTestService>(object);
625 ASSERT_TRUE(testService != nullptr);
626
627 sptr<IRemoteObject::DeathRecipient> deathRecipient;
628 bool result = true;
629 int reply = 0, res = 0;
630 for (int i = 0; i < MULTIPLEX_TIMES; i++) {
631 /*
632 * @tc.steps: step2.Add death recipient.
633 * @tc.expected: step2.Register death notification successfully.
634 */
635 deathRecipient = new DBinderTestDeathRecipient();
636 result = object->AddDeathRecipient(deathRecipient);
637 EXPECT_EQ(result, true);
638
639 /*
640 * @tc.steps: step3.Remove death recipient
641 * @tc.expected: step3.Unregister death notification successfully.
642 */
643 result = object->RemoveDeathRecipient(deathRecipient);
644 EXPECT_EQ(result, true);
645
646 /*
647 * @tc.steps: step4.Use the proxy object to invoke remote function.
648 * @tc.expected: step4.Remote call succeeds and returns 0.
649 */
650 res = testService->ReverseInt(2019, reply);
651 EXPECT_EQ(res, 0);
652 EXPECT_EQ(reply, 9102);
653 }
654
655 SetCurrentTestCase(DBINDER_TEST_INIT);
656 }
657
658 /*
659 * @tc.name: DbinderRemoteCall016
660 * @tc.desc: Verify adding and removing death recipient successfully
661 * @tc.type: FUNC
662 * @tc.require: SR000CS1C8/SR000CS1CA
663 */
664 HWTEST_F(DbinderTest, DbinderRemoteCall016, TestSize.Level3)
665 {
666 SetCurrentTestCase(DBINDER_TEST_DEATH_RECIPIENT_003);
667 DBINDER_LOGI(LOG_LABEL, "");
668
669 /*
670 * @tc.steps: step1.Get a proxy (called testService) from remote server.
671 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
672 */
673 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
674 ASSERT_TRUE(object != nullptr);
675
676 sptr<IDBinderTestService> testService = iface_cast<IDBinderTestService>(object);
677 ASSERT_TRUE(testService != nullptr);
678
679 /*
680 * @tc.steps: step2.Add two death recipients.
681 * @tc.expected: step2.Register two death notifications successfully.
682 */
683 sptr<IRemoteObject::DeathRecipient> deathRecipient(new DBinderTestDeathRecipient());
684 bool result = object->AddDeathRecipient(deathRecipient);
685 EXPECT_EQ(result, true);
686
687 sptr<IRemoteObject::DeathRecipient> deathRecipientRepeat(new DBinderTestDeathRecipient());
688 result = object->AddDeathRecipient(deathRecipientRepeat);
689 EXPECT_EQ(result, true);
690
691 /*
692 * @tc.steps: step3.Remove two death recipients.
693 * @tc.expected: step3.Return false when unregisterring 1st death notification because there is another one left.
694 * Return true when unregisterring 2nd death notification because all clean.
695 */
696 result = object->RemoveDeathRecipient(deathRecipient);
697 EXPECT_EQ(result, false);
698
699 result = object->RemoveDeathRecipient(deathRecipientRepeat);
700 EXPECT_EQ(result, true);
701
702 /*
703 * @tc.steps: step4.Use the proxy object to invoke remote function.
704 * @tc.expected: step4.Remote call succeeds and returns 0.
705 */
706 int reply = 0;
707 int res = testService->ReverseInt(2019, reply);
708 EXPECT_EQ(res, 0);
709 EXPECT_EQ(reply, 9102);
710
711 SetCurrentTestCase(DBINDER_TEST_INIT);
712 }
713
714 /*
715 * @tc.name: DbinderRemoteCall017
716 * @tc.desc: Verify receiving death notification when remote device dies
717 * @tc.type: FUNC
718 * @tc.require: SR000CS1C8/SR000CS1CA
719 */
720 HWTEST_F(DbinderTest, DbinderRemoteCall017, TestSize.Level3)
721 {
722 SetCurrentTestCase(DBINDER_TEST_DEATH_RECIPIENT_004);
723 DBINDER_LOGI(LOG_LABEL, "");
724
725 /*
726 * @tc.steps: step1.Get a proxy (called testService) from remote server.
727 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
728 */
729 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
730 ASSERT_TRUE(object != nullptr);
731
732 sptr<IDBinderTestService> testService = iface_cast<IDBinderTestService>(object);
733 ASSERT_TRUE(testService != nullptr);
734
735 /*
736 * @tc.steps: step2.Add death recipient.
737 * @tc.expected: step2.Register death notification successfully.
738 */
739 sptr<IRemoteObject::DeathRecipient> deathRecipient(new DBinderTestDeathRecipient());
740 bool result = object->AddDeathRecipient(deathRecipient);
741 ASSERT_TRUE(result == true);
742
743 /*
744 * @tc.steps: step3.Stop remote service. Wait 10s, then check death notification.
745 * @tc.expected: step3.Stop it successfully, and receive death notification.
746 */
747 std::string command = "KILL";
748 std::string cmdArgs = "server";
749 std::string expectValue = "0";
750 bool ret = RunCmdOnAgent(AGENT_NO::ONE, command, cmdArgs, expectValue);
751 EXPECT_EQ(ret, true);
752 EXPECT_EQ(GetReturnVal(), 0);
753
754 // wait for killing remote service
755 sleep(10);
756 result = DBinderTestDeathRecipient::GotDeathRecipient();
757 EXPECT_EQ(result, true);
758 DBinderTestDeathRecipient::ClearDeathRecipient();
759 printf("Succ! Recv death notification!\n");
760
761 /*
762 * @tc.steps: step4.Remove death recipient
763 * @tc.expected: step4.Fail to remove death recipient
764 * because when receiving death notification, it remove death recipient automatically.
765 */
766 result = object->RemoveDeathRecipient(deathRecipient);
767 EXPECT_EQ(result, false);
768
769 /*
770 * @tc.steps: step5.Restart remote service and wait 10s.
771 * @tc.expected: step5.Restart it successfully.
772 */
773 std::string restartCommand = "RESTART";
774 ret = RunCmdOnAgent(AGENT_NO::ONE, restartCommand, cmdArgs, expectValue);
775 EXPECT_EQ(ret, true);
776 EXPECT_EQ(GetReturnVal(), 0);
777
778 // wait for restarting server
779 sleep(10);
780
781 /*
782 * @tc.steps: step6.Get a proxy (called testService2) from remote server.
783 * @tc.expected: step6.Get the proxy successfully, and the proxy points to remote stub.
784 */
785 sptr<IRemoteObject> object2 = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
786 ASSERT_TRUE(object2 != nullptr);
787
788 sptr<IDBinderTestService> testService2 = iface_cast<IDBinderTestService>(object2);
789 ASSERT_TRUE(testService2 != nullptr);
790
791 /*
792 * @tc.steps: step7.Use the proxy object to invoke remote function.
793 * @tc.expected: step7.Remote call succeeds and returns 0.
794 */
795 int reply = 0;
796 int res = testService2->ReverseInt(2019, reply);
797 EXPECT_EQ(res, 0);
798 EXPECT_EQ(reply, 9102);
799
800 object = nullptr;
801 testService = nullptr;
802 object2 = nullptr;
803 testService2 = nullptr;
804
805 SetCurrentTestCase(DBINDER_TEST_INIT);
806 }
807
808 /*
809 * @tc.name: DbinderRemoteCall018
810 * @tc.desc: Verify transferring raw data
811 * @tc.type: FUNC
812 * @tc.require: AR000ER7PF
813 */
814 HWTEST_F(DbinderTest, DbinderRemoteCall018, TestSize.Level3)
815 {
816 SetCurrentTestCase(DBINDER_TEST_RAW_DATA_001);
817 DBINDER_LOGI(LOG_LABEL, "");
818
819 /*
820 * @tc.steps: step1.Get a proxy (called testService) from remote server.
821 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
822 */
823 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
824 ASSERT_TRUE(object != nullptr);
825
826 sptr<IDBinderTestService> testService = iface_cast<IDBinderTestService>(object);
827 ASSERT_TRUE(testService != nullptr);
828
829 /*
830 * @tc.steps: step2.Use the proxy object to transfer raw data.
831 * @tc.expected: step2.Remote call succeed and return the size of raw data.
832 */
833 // ProxyTransRawData cannot transfer data less than 2.
834 int result = testService->ProxyTransRawData(rawData100M);
835 EXPECT_EQ(result, 0);
836 result = testService->ProxyTransRawData(rawData100M);
837 EXPECT_EQ(result, 0);
838
839 SetCurrentTestCase(DBINDER_TEST_INIT);
840 }
841
842 /*
843 * @tc.name: DbinderRemoteCall019
844 * @tc.desc: Test the speed of transferring raw data by proxy
845 * @tc.type: PERF
846 * @tc.require: SR000D48A5
847 */
848 HWTEST_F(DbinderTest, DbinderRemoteCall019, TestSize.Level3)
849 {
850 SetCurrentTestCase(DBINDER_TEST_RAW_DATA_002);
851 DBINDER_LOGI(LOG_LABEL, "");
852
853 /*
854 * @tc.steps: step1.Get a proxy (called testService) from remote server.
855 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
856 */
857 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
858 ASSERT_TRUE(object != nullptr);
859
860 sptr<IDBinderTestService> testService = iface_cast<IDBinderTestService>(object);
861 ASSERT_TRUE(testService != nullptr);
862
863 /*
864 * @tc.steps: step2.Use the proxy object to transfer raw data with different size.
865 * @tc.expected: step2.Remote calls succeed and return the size of raw data.
866 */
867 int result;
868 int64_t startTime = GetCurrentTime();
869 for (int i = 0; i < MULTIPLEX_TIMES; i++) {
870 result = testService->ProxyTransRawData(rawData10K);
871 EXPECT_EQ(result, 0);
872 }
873 int64_t finishTime = GetCurrentTime();
874 float speed = GetSpeed(finishTime - startTime, rawData10K, MULTIPLEX_TIMES);
875 printf("Transfer 10K raw data with speed of %.2fk/s.\n", speed);
876
877 startTime = GetCurrentTime();
878 for (int i = 0; i < MULTIPLEX_TIMES; i++) {
879 result = testService->ProxyTransRawData(rawData100K);
880 EXPECT_EQ(result, 0);
881 }
882 finishTime = GetCurrentTime();
883 speed = GetSpeed(finishTime - startTime, rawData100K, MULTIPLEX_TIMES);
884 printf("Transfer 100K raw data with speed of %.2fk/s.\n", speed);
885
886 startTime = GetCurrentTime();
887 for (int i = 0; i < MULTIPLEX_TIMES; i++) {
888 result = testService->ProxyTransRawData(rawData1M);
889 EXPECT_EQ(result, 0);
890 }
891 finishTime = GetCurrentTime();
892 speed = GetSpeed(finishTime - startTime, rawData1M, MULTIPLEX_TIMES);
893 printf("Transfer 1M raw data with speed of %.2fk/s.\n", speed);
894
895 startTime = GetCurrentTime();
896 for (int i = 0; i < MULTIPLEX_TIMES; i++) {
897 result = testService->ProxyTransRawData(rawData10M);
898 EXPECT_EQ(result, 0);
899 }
900 finishTime = GetCurrentTime();
901 speed = GetSpeed(finishTime - startTime, rawData10M, MULTIPLEX_TIMES);
902 printf("Transfer 10M raw data with speed of %.2fk/s.\n", speed);
903
904 SetCurrentTestCase(DBINDER_TEST_INIT);
905 }
906
907 /*
908 * @tc.name: DbinderRemoteCall020
909 * @tc.desc: Verify it is stable to transfer raw data
910 * @tc.type: FUNC
911 * @tc.require: SR000D48A5
912 */
913 HWTEST_F(DbinderTest, DbinderRemoteCall020, TestSize.Level3)
914 {
915 SetCurrentTestCase(DBINDER_TEST_RAW_DATA_003);
916 DBINDER_LOGI(LOG_LABEL, "");
917
918 /*
919 * @tc.steps: step1.Get a proxy (called testService) from remote server.
920 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
921 */
922 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
923 ASSERT_TRUE(object != nullptr);
924
925 sptr<IDBinderTestService> testService = iface_cast<IDBinderTestService>(object);
926 ASSERT_TRUE(testService != nullptr);
927
928 /*
929 * @tc.steps: step2.Use the proxy object to transfer raw data with different size.
930 * @tc.expected: step2.Remote calls succeed and return the size of raw data.
931 */
932 int result;
933 for (int i = 0; i < REPEAT_RAW_DATA_TIMES; i++) {
934 result = testService->ProxyTransRawData(rawData10M);
935 EXPECT_EQ(result, 0);
936 }
937
938 SetCurrentTestCase(DBINDER_TEST_INIT);
939 }
940
941 /*
942 * @tc.name: DbinderRemoteCall021
943 * @tc.desc: Verify reply can carry big raw data
944 * @tc.type: FUNC
945 * @tc.require: AR000DAPPO
946 */
947 HWTEST_F(DbinderTest, DbinderRemoteCall021, TestSize.Level3)
948 {
949 SetCurrentTestCase(DBINDER_TEST_RAW_DATA_004);
950 DBINDER_LOGI(LOG_LABEL, "");
951 /*
952 * @tc.steps: step1.Get a proxy (called testService) from remote server.
953 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
954 */
955 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
956 ASSERT_TRUE(object != nullptr);
957
958 sptr<IDBinderTestService> testService = iface_cast<IDBinderTestService>(object);
959 ASSERT_TRUE(testService != nullptr);
960
961 /*
962 * @tc.steps: step2.Use the proxy object to ask stub to transfer raw data.
963 * @tc.expected: step2.Remote call succeed and return 0.
964 */
965 // StubTransRawData cannot ask data less than 2.
966 int result = testService->StubTransRawData(rawData10M);
967 EXPECT_EQ(result, 0);
968 result = testService->StubTransRawData(rawData100M);
969 EXPECT_EQ(result, 0);
970
971 SetCurrentTestCase(DBINDER_TEST_INIT);
972 }
973
974
975 /*
976 * @tc.name: DbinderRemoteCall022
977 * @tc.desc: Test the speed of transferring raw data by stub
978 * @tc.type: PERF
979 * @tc.require: AR000DAPPO
980 */
981 HWTEST_F(DbinderTest, DbinderRemoteCall022, TestSize.Level3)
982 {
983 SetCurrentTestCase(DBINDER_TEST_RAW_DATA_005);
984 DBINDER_LOGI(LOG_LABEL, "");
985
986 /*
987 * @tc.steps: step1.Get a proxy (called testService) from remote server.
988 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
989 */
990 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
991 ASSERT_TRUE(object != nullptr);
992
993 sptr<IDBinderTestService> testService = iface_cast<IDBinderTestService>(object);
994 ASSERT_TRUE(testService != nullptr);
995
996 /*
997 * @tc.steps: step2.Use the proxy object to transfer raw data with different size.
998 * @tc.expected: step2.Remote calls succeed and return the size of raw data.
999 */
1000 int result;
1001 int64_t startTime = GetCurrentTime();
1002 for (int i = 0; i < MULTIPLEX_TIMES; i++) {
1003 result = testService->StubTransRawData(rawData10K);
1004 EXPECT_EQ(result, 0);
1005 }
1006 int64_t finishTime = GetCurrentTime();
1007 float speed = GetSpeed(finishTime - startTime, rawData10K, MULTIPLEX_TIMES);
1008 printf("Receive 10K raw data with speed of %.2fk/s.\n", speed);
1009
1010 startTime = GetCurrentTime();
1011 for (int i = 0; i < MULTIPLEX_TIMES; i++) {
1012 result = testService->StubTransRawData(rawData100K);
1013 EXPECT_EQ(result, 0);
1014 }
1015 finishTime = GetCurrentTime();
1016 speed = GetSpeed(finishTime - startTime, rawData100K, MULTIPLEX_TIMES);
1017 printf("Receive 100K raw data with speed of %.2fk/s.\n", speed);
1018
1019 startTime = GetCurrentTime();
1020 for (int i = 0; i < MULTIPLEX_TIMES; i++) {
1021 result = testService->StubTransRawData(rawData1M);
1022 EXPECT_EQ(result, 0);
1023 }
1024 finishTime = GetCurrentTime();
1025 speed = GetSpeed(finishTime - startTime, rawData1M, MULTIPLEX_TIMES);
1026 printf("Receive 1M raw data with speed of %.2fk/s.\n", speed);
1027
1028 startTime = GetCurrentTime();
1029 for (int i = 0; i < MULTIPLEX_TIMES; i++) {
1030 result = testService->StubTransRawData(rawData10M);
1031 EXPECT_EQ(result, 0);
1032 }
1033 finishTime = GetCurrentTime();
1034 speed = GetSpeed(finishTime - startTime, rawData10M, MULTIPLEX_TIMES);
1035 printf("Receive 10M raw data with speed of %.2fk/s.\n", speed);
1036
1037 SetCurrentTestCase(DBINDER_TEST_INIT);
1038 }
1039
1040 /*
1041 * @tc.name: DbinderRemoteCall023
1042 * @tc.desc: Verify it is stable to transfer raw data by stub
1043 * @tc.type: FUNC
1044 * @tc.require: AR000DAPPO
1045 */
1046 HWTEST_F(DbinderTest, DbinderRemoteCall023, TestSize.Level3)
1047 {
1048 SetCurrentTestCase(DBINDER_TEST_RAW_DATA_006);
1049 DBINDER_LOGI(LOG_LABEL, "");
1050
1051 /*
1052 * @tc.steps: step1.Get a proxy (called testService) from remote server.
1053 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
1054 */
1055 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
1056 ASSERT_TRUE(object != nullptr);
1057
1058 sptr<IDBinderTestService> testService = iface_cast<IDBinderTestService>(object);
1059 ASSERT_TRUE(testService != nullptr);
1060
1061 /*
1062 * @tc.steps: step2.Use the proxy object to transfer raw data with different size.
1063 * @tc.expected: step2.Remote calls succeed and return the size of raw data.
1064 */
1065 int result;
1066 for (int i = 0; i < REPEAT_RAW_DATA_TIMES; i++) {
1067 result = testService->StubTransRawData(rawData10M);
1068 EXPECT_EQ(result, 0);
1069 }
1070
1071 SetCurrentTestCase(DBINDER_TEST_INIT);
1072 }
1073
1074 /*
1075 * @tc.name: DbinderRemoteCall024
1076 * @tc.desc: trace test
1077 * @tc.type: FUNC
1078 * @tc.require: SR000CPN5H AR000CPN5I AR000CPN5J
1079 */
1080 HWTEST_F(DbinderTest, DbinderRemoteCall024, TestSize.Level3)
1081 {
1082 DBINDER_LOGI(LOG_LABEL, "");
1083 SetCurrentTestCase(DBINDER_TEST_TRACE_001);
1084 HiTraceId traceId = HiTraceChain::Begin("rpc hitrace", 0);
1085
1086 /*
1087 * @tc.steps: step1.Get a proxy (called testService) from remote server.
1088 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
1089 */
1090 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
1091 ASSERT_TRUE(object != nullptr);
1092
1093 sptr<IDBinderTestService> testService = iface_cast<IDBinderTestService>(object);
1094 ASSERT_TRUE(testService != nullptr);
1095
1096 /*
1097 * @tc.steps: step2.Use the proxy object to transfer trace id.
1098 * @tc.expected: step2.Remote calls succeed and trace id equal local trace id.
1099 */
1100 uint64_t childId = 0;
1101 int result = testService->GetChildId(childId);
1102 EXPECT_EQ(result, 0);
1103 EXPECT_EQ(childId, traceId.GetChainId());
1104
1105 SetCurrentTestCase(DBINDER_TEST_INIT);
1106 }
1107
1108 /*
1109 * @tc.name: DbinderRemoteCall025
1110 * @tc.desc: Test trans stub object
1111 * @tc.type: PERF
1112 * @tc.require: SR000CQSAB AR000DAPPM
1113 */
1114 HWTEST_F(DbinderTest, DbinderRemoteCall025, TestSize.Level3)
1115 {
1116 SetCurrentTestCase(DBINDER_TEST_TRANS_STUB_001);
1117 DBINDER_LOGI(LOG_LABEL, "");
1118
1119 /*
1120 * @tc.steps: step1.Get a local binder object and a proxy pointing to remote stub.
1121 * @tc.expected: step1.Get both objects successfully.
1122 */
1123 sptr<IRemoteObject> object = new DBinderTestService();
1124 ASSERT_TRUE(object != nullptr);
1125 sptr<IRemoteObject> remoteObject = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
1126 ASSERT_TRUE(remoteObject != nullptr);
1127
1128 sptr<IDBinderTestService> remoteTestService = iface_cast<IDBinderTestService>(remoteObject);
1129 ASSERT_TRUE(remoteTestService != nullptr);
1130
1131 /*
1132 * @tc.steps: step2.Use the proxy object to transfer stub object
1133 * @tc.expected: step2.Remote call succeeds.
1134 */
1135 int reply = 0;
1136 int stubReply = 0;
1137 int result = remoteTestService->TransStubObject(2019, object, reply, stubReply);
1138 EXPECT_EQ(result, 0);
1139 EXPECT_EQ(reply, 9102);
1140 EXPECT_EQ(stubReply, 2019);
1141
1142 SetCurrentTestCase(DBINDER_TEST_INIT);
1143 }
1144
1145 /*
1146 * @tc.name: DbinderRemoteCall026
1147 * @tc.desc: Verify it is stable to transfer raw data by stub
1148 * @tc.type: FUNC
1149 * @tc.require: AR000DHOVU SR000DHOVT
1150 */
1151 HWTEST_F(DbinderTest, DbinderRemoteCall026, TestSize.Level3)
1152 {
1153 SetCurrentTestCase(DBINDER_TEST_FLUSH_COMMAND_001);
1154 DBINDER_LOGI(LOG_LABEL, "");
1155
1156 /*
1157 * @tc.steps: step1.Get a local binder object and a proxy pointing to remote stub.
1158 * @tc.expected: step1.Get both objects successfully.
1159 */
1160 sptr<IRemoteObject> object = new DBinderTestService();
1161 ASSERT_TRUE(object != nullptr);
1162 sptr<IRemoteObject> remoteObject = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
1163 ASSERT_TRUE(remoteObject != nullptr);
1164
1165 sptr<IDBinderTestService> remoteTestService = iface_cast<IDBinderTestService>(remoteObject);
1166 ASSERT_TRUE(remoteTestService != nullptr);
1167
1168 /*
1169 * @tc.steps: step2.Use the proxy object to flush commands
1170 * @tc.expected: step2.Remote call succeeds.
1171 */
1172 int result = remoteTestService->FlushAsyncCommands(MULTIPLEX_TIMES, rawData10K);
1173 EXPECT_EQ(result, 0);
1174
1175 SetCurrentTestCase(DBINDER_TEST_INIT);
1176 }
1177
GetRemoteObjectAndCheck(sptr<IRemoteObject> & object,sptr<IDBinderTestService> & testService,int serverId)1178 static void GetRemoteObjectAndCheck(sptr<IRemoteObject>& object, sptr<IDBinderTestService>& testService, int serverId)
1179 {
1180 object = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId);
1181 ASSERT_TRUE(object != nullptr);
1182 testService = iface_cast<IDBinderTestService>(object);
1183 ASSERT_TRUE(testService != nullptr);
1184 }
1185
ExecuteReverseIntAndCheck(sptr<IDBinderTestService> & testService,int input,int expectedOutput)1186 static void ExecuteReverseIntAndCheck(sptr<IDBinderTestService>& testService, int input, int expectedOutput)
1187 {
1188 int reply;
1189 int result = testService->ReverseInt(input, reply);
1190 EXPECT_EQ(result, 0);
1191 EXPECT_EQ(reply, expectedOutput);
1192 }
1193
AddDeathRecipientAndCheck(sptr<IRemoteObject> & proxy,sptr<IRemoteObject::DeathRecipient> & deathRecipient)1194 static void AddDeathRecipientAndCheck(sptr<IRemoteObject>& proxy, sptr<IRemoteObject::DeathRecipient>& deathRecipient)
1195 {
1196 bool ret = proxy->AddDeathRecipient(deathRecipient);
1197 ASSERT_TRUE(ret);
1198 }
1199
RunCommandAndCheck(const std::string & command,const std::string & cmdArgs,const std::string & expectValue)1200 static void RunCommandAndCheck(const std::string& command, const std::string& cmdArgs, const std::string& expectValue)
1201 {
1202 bool ret = RunCmdOnAgent(AGENT_NO::ONE, command, cmdArgs, expectValue);
1203 EXPECT_EQ(ret, true);
1204 EXPECT_EQ(GetReturnVal(), 0);
1205 }
1206
1207 /*
1208 * @tc.name: DbinderRemoteCall027
1209 * @tc.desc: Death notice for anonymous objects
1210 * @tc.type: FUNC
1211 * @tc.require: SR000DP5BC
1212 */
1213 HWTEST_F(DbinderTest, DbinderRemoteCall027, TestSize.Level3)
1214 {
1215 SetCurrentTestCase(DBINDER_TEST_DEATH_RECIPIENT_007);
1216 DBINDER_LOGI(LOG_LABEL, "");
1217
1218 /*
1219 * @tc.steps: step1.Get a proxy (called testService) from remote server.
1220 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
1221 */
1222 sptr<IRemoteObject> object;
1223 sptr<IDBinderTestService> testService;
1224 GetRemoteObjectAndCheck(object, testService, serverId_);
1225
1226 /*
1227 * @tc.steps: step2.Get two anonymous objects.
1228 * @tc.expected: step2.Get the proxy successfully, and the proxy points to remote stub.
1229 */
1230 sptr<IRemoteObject> proxy1 = testService->GetRemoteObject(IDBinderTestService::FIRST_OBJECT);
1231 ASSERT_TRUE(proxy1 != nullptr);
1232
1233 sptr<IRemoteObject> proxy2 = testService->GetRemoteObject(IDBinderTestService::SECOND_OBJECT);
1234 ASSERT_TRUE(proxy2 != nullptr);
1235
1236 sptr<IDBinderTestService> remoteTestService1 = iface_cast<IDBinderTestService>(proxy1);
1237 ASSERT_TRUE(remoteTestService1 != nullptr);
1238
1239 sptr<IDBinderTestService> remoteTestService2 = iface_cast<IDBinderTestService>(proxy2);
1240 ASSERT_TRUE(remoteTestService2 != nullptr);
1241
1242 /*
1243 * @tc.steps: step3.Use the proxy object to invoke remote function.
1244 * @tc.expected: step3.Remote call succeeds and returns 0.
1245 */
1246 ExecuteReverseIntAndCheck(remoteTestService1, 2019, 9102);
1247 ExecuteReverseIntAndCheck(remoteTestService2, 2019, 9102);
1248
1249 /*
1250 * @tc.steps: step4.Add death recipient.
1251 * @tc.expected: step4.Register death notification successfully.
1252 */
1253 sptr<IRemoteObject::DeathRecipient> deathRecipient1(new DBinderTestDeathRecipient());
1254 AddDeathRecipientAndCheck(proxy1, deathRecipient1);
1255
1256 sptr<IRemoteObject::DeathRecipient> deathRecipient2(new DBinderTestDeathRecipient());
1257 AddDeathRecipientAndCheck(proxy2, deathRecipient2);
1258
1259 /*
1260 * @tc.steps: step5.Stop remote service. Wait 10s, then check death notification.
1261 * @tc.expected: step5.Stop it successfully, and receive death notification.
1262 */
1263 RunCommandAndCheck("KILL", "server", "0");
1264
1265 // wait for killing remote service
1266 sleep(10);
1267 EXPECT_EQ(DBinderTestDeathRecipient::GotDeathRecipient(), true);
1268 EXPECT_EQ(DBinderTestDeathRecipient::GotDeathRecipient(), true);
1269 DBinderTestDeathRecipient::ClearDeathRecipient();
1270 printf("Succ! Recv death notification!\n");
1271
1272 /*
1273 * @tc.steps: step6.Remove death recipient
1274 * @tc.expected: step6.Fail to remove death recipient
1275 * because when receiving death notification, it remove death recipient automatically.
1276 */
1277 bool ret = proxy1->RemoveDeathRecipient(deathRecipient1);
1278 EXPECT_EQ(ret, false);
1279
1280 ret = proxy2->RemoveDeathRecipient(deathRecipient2);
1281 EXPECT_EQ(ret, false);
1282
1283 /*
1284 * @tc.steps: step7.Restart remote service and wait 10s.
1285 * @tc.expected: step7.Restart it successfully.
1286 */
1287 RunCommandAndCheck("RESTART", "server", "0");
1288
1289 // wait for restarting server
1290 sleep(10);
1291
1292 /*
1293 * @tc.steps: step8.Get a proxy (called testService2) from remote server.
1294 * @tc.expected: step8.Get the proxy successfully, and the proxy points to remote stub.
1295 */
1296 sptr<IRemoteObject> object2;
1297 sptr<IDBinderTestService> testService2;
1298 GetRemoteObjectAndCheck(object2, testService2, serverId_);
1299
1300 /*
1301 * @tc.steps: step9.Use the proxy object to invoke remote function.
1302 * @tc.expected: step9.Remote call succeeds and returns 0.
1303 */
1304 ExecuteReverseIntAndCheck(testService2, 2019, 9102);
1305
1306 object = nullptr;
1307 testService = nullptr;
1308 object2 = nullptr;
1309 testService2 = nullptr;
1310
1311 SetCurrentTestCase(DBINDER_TEST_INIT);
1312 }
1313
1314 /*
1315 * @tc.name: DbinderRemoteCall028
1316 * @tc.desc: Death notice for anonymous objects
1317 * @tc.type: FUNC
1318 * @tc.require: SR000CS1C8/SR000CS1CA
1319 */
1320 HWTEST_F(DbinderTest, DbinderRemoteCall028, TestSize.Level3)
1321 {
1322 SetCurrentTestCase(DBINDER_TEST_REMOTE_CALL_015);
1323 DBINDER_LOGI(LOG_LABEL, "");
1324
1325 /*
1326 * @tc.steps: step1.Get a proxy (called testService) from remote server.
1327 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
1328 */
1329 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
1330 ASSERT_TRUE(object != nullptr);
1331
1332 sptr<IDBinderTestService> testService = iface_cast<IDBinderTestService>(object);
1333 ASSERT_TRUE(testService != nullptr);
1334
1335 /*
1336 * @tc.steps: step2.Get two anonymous objects.
1337 * @tc.expected: step2.Get the proxy successfully, and the proxy points to remote stub.
1338 */
1339 sptr<IRemoteObject> proxy1 = testService->GetRemoteObject(IDBinderTestService::FIRST_OBJECT);
1340 ASSERT_TRUE(proxy1 != nullptr);
1341
1342 sptr<IRemoteObject> proxy2 = testService->GetRemoteObject(IDBinderTestService::FIRST_OBJECT);
1343 ASSERT_TRUE(proxy2 != nullptr);
1344
1345 sptr<IDBinderTestService> remoteTestService1 = iface_cast<IDBinderTestService>(proxy1);
1346 ASSERT_TRUE(remoteTestService1 != nullptr);
1347
1348 sptr<IDBinderTestService> remoteTestService2 = iface_cast<IDBinderTestService>(proxy2);
1349 ASSERT_TRUE(remoteTestService2 != nullptr);
1350
1351 /*
1352 * @tc.steps: step3.Use the proxy object to invoke remote function.
1353 * @tc.expected: step3.Remote call succeeds and returns 0.
1354 */
1355 int reply;
1356 int result = remoteTestService1->ReverseInt(2019, reply);
1357 EXPECT_EQ(result, 0);
1358 EXPECT_EQ(reply, 9102);
1359
1360 result = remoteTestService2->ReverseInt(2019, reply);
1361 EXPECT_EQ(result, 0);
1362 EXPECT_EQ(reply, 9102);
1363
1364 testService->ClearRemoteDecTimes();
1365
1366 proxy1 = nullptr;
1367 remoteTestService1 = nullptr;
1368 EXPECT_EQ(testService->GetRemoteDecTimes(), 1);
1369
1370 proxy2 = nullptr;
1371 remoteTestService2 = nullptr;
1372 EXPECT_EQ(testService->GetRemoteDecTimes(), 2);
1373
1374 object = nullptr;
1375 testService = nullptr;
1376
1377 SetCurrentTestCase(DBINDER_TEST_INIT);
1378 }
1379
1380 /*
1381 * @tc.name: DbinderRemoteCall029
1382 * @tc.desc: Death notice for anonymous objects
1383 * @tc.type: FUNC
1384 * @tc.require: SR000CS1C8/SR000CS1CA
1385 */
1386 HWTEST_F(DbinderTest, DbinderRemoteCall029, TestSize.Level3)
1387 {
1388 SetCurrentTestCase(DBINDER_TEST_REMOTE_CALL_016);
1389 DBINDER_LOGI(LOG_LABEL, "");
1390
1391 /*
1392 * @tc.steps: step1.Get a proxy (called testService) from remote server.
1393 * @tc.expected: step1.Get the proxy successfully, and the proxy points to remote stub.
1394 */
1395 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
1396 ASSERT_TRUE(object != NULL);
1397
1398 sptr<IDBinderTestService> testService = iface_cast<IDBinderTestService>(object);
1399 ASSERT_TRUE(testService != NULL);
1400
1401 /*
1402 * @tc.steps: step2.Get two anonymous objects.
1403 * @tc.expected: step2.Get the proxy successfully, and the proxy points to remote stub.
1404 */
1405 sptr<IRemoteObject> proxy1 = testService->GetRemoteObject(IDBinderTestService::SECOND_OBJECT);
1406 ASSERT_TRUE(proxy1 != nullptr);
1407
1408 sptr<IRemoteObject> proxy2 = testService->GetRemoteObject(IDBinderTestService::SECOND_OBJECT);
1409 ASSERT_TRUE(proxy2 != nullptr);
1410 ASSERT_TRUE(proxy2 == proxy1);
1411
1412 sptr<IDBinderTestService> remoteTestService1 = iface_cast<IDBinderTestService>(proxy1);
1413 ASSERT_TRUE(remoteTestService1 != nullptr);
1414
1415 sptr<IDBinderTestService> remoteTestService2 = iface_cast<IDBinderTestService>(proxy2);
1416 ASSERT_TRUE(remoteTestService2 != nullptr);
1417
1418 /*
1419 * @tc.steps: step3.Use the proxy object to invoke remote function.
1420 * @tc.expected: step3.Remote call succeeds and returns 0.
1421 */
1422 int reply;
1423 int result = remoteTestService1->ReverseInt(2019, reply);
1424 EXPECT_EQ(result, 0);
1425 EXPECT_EQ(reply, 9102);
1426
1427 result = remoteTestService2->ReverseInt(2019, reply);
1428 EXPECT_EQ(result, 0);
1429 EXPECT_EQ(reply, 9102);
1430
1431 testService->ClearRemoteDecTimes();
1432
1433 proxy1 = nullptr;
1434 proxy2 = nullptr;
1435 remoteTestService1 = nullptr;
1436 remoteTestService2 = nullptr;
1437 sleep(1);
1438 EXPECT_EQ(testService->GetRemoteDecTimes(), 1);
1439
1440 object = nullptr;
1441 testService = nullptr;
1442
1443 SetCurrentTestCase(DBINDER_TEST_INIT);
1444 }
1445
1446 /*
1447 * @tc.name: DbinderRemoteCall030
1448 * @tc.desc: Verify transferring objects between remote devices and tranfer to anthor process again
1449 * @tc.type: FUNC
1450 * @tc.require: SR000FL75G
1451 */
1452 HWTEST_F(DbinderTest, DbinderRemoteCall030, TestSize.Level3)
1453 {
1454 SetCurrentTestCase(DBINDER_TEST_REMOTE_CALL_011);
1455 DBINDER_LOGI(LOG_LABEL, "");
1456
1457 /*
1458 * @tc.steps: step1.Get a local binder object and a proxy pointing to remote stub.
1459 * @tc.expected: step1.Get both objects successfully.
1460 */
1461 sptr<IRemoteObject> object = manager_->GetSystemAbility(RPC_TEST_SERVICE);
1462 ASSERT_TRUE(object != nullptr);
1463 sptr<IRemoteObject> remoteObject = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
1464 ASSERT_TRUE(remoteObject != nullptr);
1465
1466 sptr<IDBinderTestService> remoteTestService = iface_cast<IDBinderTestService>(remoteObject);
1467 ASSERT_TRUE(remoteTestService != nullptr);
1468
1469 /*
1470 * @tc.steps: step2.Transfer the binder object to remote device repeatedly.
1471 * @tc.expected: step2.Remote device receives the object and use it to communicate with server.
1472 */
1473 for (int i = 0; i < MULTIPLEX_TIMES; i++) {
1474 int reply = 0;
1475 int withdrawRes = 0;
1476 int result = remoteTestService->TransProxyObjectAgain(2021, object, DBinderTestServiceProxy::NOT_SAVE,
1477 reply, withdrawRes);
1478 EXPECT_EQ(result, 0);
1479 EXPECT_EQ(reply, 1202);
1480 }
1481
1482 SetCurrentTestCase(DBINDER_TEST_INIT);
1483 }
1484
1485 /*
1486 * @tc.name: DbinderRemoteCall031
1487 * @tc.desc: Test two ways of sending stub object, GetSystemAbility and through message parcel,
1488 * and its reference count
1489 * @tc.type: FUNC
1490 * @tc.require: SR000CQSAB AR000DAPPM
1491 */
1492 HWTEST_F(DbinderTest, DbinderRemoteCall031, TestSize.Level3)
1493 {
1494 SetCurrentTestCase(DBINDER_TEST_TRANS_STUB_001);
1495
1496 /*
1497 * @tc.steps: step1.Get a local stub object and a proxy pointing to remote a remote stub.
1498 * @tc.expected: step1.Get both objects successfully.
1499 */
1500 sptr<IRemoteObject> object = new DBinderTestService();
1501 ASSERT_TRUE(object != nullptr);
1502 EXPECT_EQ(object->GetSptrRefCount(), 1);
1503 sptr<IRemoteObject> remoteObject = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
1504 ASSERT_TRUE(remoteObject != nullptr);
1505 // refered by one proxy here, another in samgr process of remote device
1506 EXPECT_EQ(remoteObject->GetObjectRefCount(), 2);
1507 sptr<IDBinderTestService> proxy = iface_cast<IDBinderTestService>(remoteObject);
1508 ASSERT_TRUE(proxy != nullptr);
1509 sptr<IRemoteObject> remoteObject2 = manager_->GetSystemAbility(RPC_TEST_SERVICE2, serverId_);
1510 ASSERT_TRUE(remoteObject2 != nullptr);
1511 EXPECT_EQ(remoteObject2->GetObjectRefCount(), 2);
1512 sptr<IDBinderTestService> proxy2 = iface_cast<IDBinderTestService>(remoteObject2);
1513 ASSERT_TRUE(proxy2 != nullptr);
1514
1515 /*
1516 * @tc.steps: step2.Use the proxy object to transfer stub object
1517 * @tc.expected: step2.Remote call succeeds.
1518 */
1519 int result = proxy->TransStubObjectRefCount(object, IDBinderTestService::SAVE);
1520 EXPECT_EQ(result, 0);
1521 EXPECT_EQ(object->GetSptrRefCount(), 2);
1522
1523 result = proxy2->TransStubObjectRefCount(object, IDBinderTestService::SAVE);
1524 EXPECT_EQ(result, 0);
1525 EXPECT_EQ(object->GetSptrRefCount(), 3);
1526
1527 result = proxy->TransStubObjectRefCount(object, IDBinderTestService::WITHDRAW);
1528 EXPECT_EQ(result, 0);
1529 EXPECT_EQ(object->GetSptrRefCount(), 2);
1530
1531 result = proxy2->TransStubObjectRefCount(object, IDBinderTestService::WITHDRAW);
1532 EXPECT_EQ(result, 0);
1533 EXPECT_EQ(object->GetSptrRefCount(), 1);
1534
1535 SetCurrentTestCase(DBINDER_TEST_INIT);
1536 }
1537
1538 /*
1539 * @tc.name: DbinderRemoteCall032
1540 * @tc.desc: Test sending rpc proxy acquired from GetSystemAbility to another process
1541 * in this device, sending ipc proxy acquired from GetSystemAbility to another device,
1542 * and their reference count respectively.
1543 * @tc.type: FUNC
1544 * @tc.require: SR000CQSAB AR000DAPPM
1545 */
1546 HWTEST_F(DbinderTest, DbinderRemoteCall032, TestSize.Level3)
1547 {
1548 SetCurrentTestCase(DBINDER_TEST_TRANS_STUB_001);
1549
1550 /*
1551 * @tc.steps: step1.Get a local proxy and a remote proxy.
1552 * @tc.expected: step1.Get both proxy successfully.
1553 */
1554 sptr<IRemoteObject> remoteObject = manager_->GetSystemAbility(RPC_TEST_SERVICE, serverId_);
1555 ASSERT_TRUE(remoteObject != nullptr);
1556 // refered by one sptr here, another in samgr process of remote device
1557 EXPECT_EQ(remoteObject->GetObjectRefCount(), 2);
1558 sptr<IDBinderTestService> proxy = iface_cast<IDBinderTestService>(remoteObject);
1559 ASSERT_TRUE(proxy != nullptr);
1560 EXPECT_EQ(remoteObject->GetSptrRefCount(), 2);
1561 EXPECT_EQ(remoteObject->GetObjectRefCount(), 2);
1562
1563 sptr<IRemoteObject> remoteObject2 = manager_->GetSystemAbility(RPC_TEST_SERVICE);
1564 ASSERT_TRUE(remoteObject2 != nullptr);
1565 EXPECT_EQ(remoteObject2->GetObjectRefCount(), 1);
1566 sptr<IDBinderTestService> proxy2 = iface_cast<IDBinderTestService>(remoteObject2);
1567 ASSERT_TRUE(proxy2 != nullptr);
1568 EXPECT_EQ(remoteObject2->GetSptrRefCount(), 2);
1569 EXPECT_EQ(remoteObject2->GetObjectRefCount(), 1);
1570
1571 /*
1572 * @tc.steps: step2.Use the local proxy object to transfer remote proxy object
1573 * @tc.expected: step2.Remote call succeeds.
1574 */
1575 int result = proxy2->TransProxyObjectRefCount(remoteObject, IDBinderTestService::SAVE);
1576 EXPECT_EQ(result, 0);
1577 EXPECT_EQ(remoteObject->GetObjectRefCount(), 3);
1578
1579 result = proxy->TransProxyObjectRefCount(remoteObject2, IDBinderTestService::SAVE);
1580 EXPECT_EQ(result, 0);
1581 EXPECT_EQ(remoteObject2->GetObjectRefCount(), 2);
1582
1583 result = proxy2->TransProxyObjectRefCount(remoteObject, IDBinderTestService::WITHDRAW);
1584 EXPECT_EQ(result, 0);
1585 EXPECT_EQ(remoteObject->GetObjectRefCount(), 2);
1586
1587 result = proxy->TransProxyObjectRefCount(remoteObject2, IDBinderTestService::WITHDRAW);
1588 EXPECT_EQ(result, 0);
1589 EXPECT_EQ(remoteObject2->GetObjectRefCount(), 1);
1590
1591 SetCurrentTestCase(DBINDER_TEST_INIT);
1592 }
1593
main(int argc,char * argv[])1594 int main(int argc, char *argv[])
1595 {
1596 g_pDistributetestEnv = new DistributeTestEnvironment("major.desc");
1597 testing::AddGlobalTestEnvironment(g_pDistributetestEnv);
1598 testing::GTEST_FLAG(output) = "xml:./";
1599 testing::InitGoogleTest(&argc, argv);
1600 return RUN_ALL_TESTS();
1601 }
1602