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 #include <gtest/gtest.h>
16
17 #include "init_param.h"
18 #include "param_message.h"
19 #include "param_stub.h"
20 #include "trigger_manager.h"
21 #include "le_timer.h"
22
23 using namespace testing::ext;
24 using namespace std;
25
TestTriggerExecute(TriggerNode * trigger,const char * content,uint32_t size)26 static int TestTriggerExecute(TriggerNode *trigger, const char *content, uint32_t size)
27 {
28 return 0;
29 }
30
31 extern "C" {
32 void OnClose(ParamTaskPtr client);
33 }
CheckServerParamValue(const char * name,const char * expectValue)34 static int CheckServerParamValue(const char *name, const char *expectValue)
35 {
36 char tmp[PARAM_BUFFER_SIZE] = {0};
37 u_int32_t len = sizeof(tmp);
38 SystemReadParam(name, tmp, &len);
39 printf("CheckParamValue name %s value: \'%s\' expectValue:\'%s\' \n", name, tmp, expectValue);
40 EXPECT_NE((int)strlen(tmp), 0);
41 if (expectValue != nullptr) {
42 EXPECT_EQ(strcmp(tmp, expectValue), 0);
43 }
44 return 0;
45 }
46
47 namespace init_ut {
48 static ParamTaskPtr g_worker = nullptr;
49 class ParamServiceUnitTest : public ::testing::Test {
50 public:
ParamServiceUnitTest()51 ParamServiceUnitTest() {}
~ParamServiceUnitTest()52 virtual ~ParamServiceUnitTest() {}
53
SetUpTestCase(void)54 static void SetUpTestCase(void)
55 {
56 PrepareInitUnitTestEnv();
57 }
SetUp()58 void SetUp()
59 {
60 if (GetParamSecurityLabel() != nullptr) {
61 GetParamSecurityLabel()->cred.uid = 1000; // 1000 test uid
62 GetParamSecurityLabel()->cred.gid = 1000; // 1000 test gid
63 }
64 }
TearDown()65 void TearDown() {}
TestBody()66 void TestBody() {}
67
TestSetParams(const char * params[][1+1],int num)68 int TestSetParams(const char *params[][1 + 1], int num)
69 {
70 for (int i = 0; i < num; i++) {
71 SystemWriteParam(params[i][0], params[i][1]);
72 }
73
74 // check
75 for (int i = 0; i < num; i++) {
76 CheckServerParamValue(params[i][0], params[i][1]);
77 }
78
79 for (int i = num - 1; i >= 0; i--) {
80 CheckServerParamValue(params[i][0], params[i][1]);
81 }
82 return 0;
83 }
84
TestAddSecurityLabel1()85 int TestAddSecurityLabel1()
86 {
87 GetParamSecurityLabel()->cred.gid = 9999; // 9999 test gid
88 const char *name = "label1.test.aaa.bbb.ccc.dddd.eee";
89 const char *value = "2001";
90 uint32_t labelIndex = 0;
91 SystemWriteParam(name, value);
92 // 获取到跟属性
93 WorkSpace *workspace = GetWorkSpace(WORKSPACE_NAME_DAC);
94 (void)FindTrieNode(workspace, name, strlen(name), &labelIndex);
95 ParamSecurityNode *node = (ParamSecurityNode *)GetTrieNode(workspace, labelIndex);
96 if (node == nullptr) {
97 EXPECT_EQ(1, 0);
98 return 0;
99 }
100 EXPECT_EQ(node->gid, 0);
101 return 0;
102 }
103
104 // 添加一个label,最长匹配到这个节点
TestAddSecurityLabel2()105 int TestAddSecurityLabel2()
106 {
107 GetParamSecurityLabel()->cred.gid = 9999; // 9999 test gid
108 const char *name = "label2.test.aaa.bbb.ccc.dddd.eee";
109 const char *value = "2001";
110 ParamAuditData auditData = {};
111 auditData.name = "label2.test.aaa";
112 auditData.dacData.gid = 202; // 202 test dac gid
113 auditData.dacData.uid = geteuid();
114 auditData.dacData.mode = 0666; // 0666 test mode
115 SystemWriteParam(name, value);
116 uint32_t labelIndex = 0;
117 AddSecurityLabel(&auditData);
118 WorkSpace *workspace = GetWorkSpace(WORKSPACE_NAME_DAC);
119 (void)FindTrieNode(workspace, name, strlen(name), &labelIndex);
120 ParamSecurityNode *node = (ParamSecurityNode *)GetTrieNode(workspace, labelIndex);
121 if (node == nullptr) {
122 EXPECT_EQ(1, 0);
123 return 0;
124 }
125 EXPECT_EQ(node->gid, auditData.dacData.gid);
126 return 0;
127 }
128
129 // 添加一个label,最长匹配到最后一个相同节点
TestAddSecurityLabel3()130 int TestAddSecurityLabel3()
131 {
132 GetParamSecurityLabel()->cred.gid = 9999; // 9999 test gid
133 const char *name = "label3.test.aaa.bbb.ccc.dddd.eee";
134 const char *value = "2001";
135 ParamAuditData auditData = {};
136 auditData.name = "label3.test.aaa";
137 auditData.dacData.gid = 203; // 203 test gid
138 auditData.dacData.uid = geteuid();
139 auditData.dacData.mode = 0666; // 0666 test mode
140 SystemWriteParam(name, value);
141 AddSecurityLabel(&auditData);
142
143 auditData.name = "label3.test.aaa.bbb.ccc.dddd.eee.dddd";
144 auditData.dacData.gid = 202; // 202 test dac gid
145 auditData.dacData.uid = geteuid();
146 auditData.dacData.mode = 0666; // 0666 test mode
147 SystemWriteParam(name, value);
148 AddSecurityLabel(&auditData);
149
150 uint32_t labelIndex = 0;
151 WorkSpace *workspace = GetWorkSpace(WORKSPACE_NAME_DAC);
152 ParamTrieNode *paramNode = FindTrieNode(workspace, name, strlen(name), &labelIndex);
153 ParamSecurityNode *node = (ParamSecurityNode *)GetTrieNode(workspace, labelIndex);
154 if (paramNode == nullptr || node == nullptr) {
155 EXPECT_EQ(1, 0);
156 return 0;
157 }
158 EXPECT_EQ((int)node->gid, 203); // 203 test gid
159 return 0;
160 }
161
162 // 添加一个label,完全匹配
TestAddSecurityLabel4()163 int TestAddSecurityLabel4()
164 {
165 GetParamSecurityLabel()->cred.gid = 9999; // 9999 test gid
166 const char *name = "label4.test.aaa.bbb.ccc.dddd.eee";
167 const char *value = "2001";
168 ParamAuditData auditData = {};
169 auditData.name = "label4.test.aaa.bbb.ccc.dddd.eee";
170 auditData.dacData.gid = 203; // 203 test gid
171 auditData.dacData.uid = geteuid();
172 auditData.dacData.mode = 0666; // 0666 test mode
173 SystemWriteParam(name, value);
174 uint32_t labelIndex = 0;
175 AddSecurityLabel(&auditData);
176 WorkSpace *workspace = GetWorkSpace(WORKSPACE_NAME_DAC);
177 ParamTrieNode *paramNode = FindTrieNode(workspace, name, strlen(name), &labelIndex);
178 ParamSecurityNode *node = (ParamSecurityNode *)GetTrieNode(workspace, labelIndex);
179 if (paramNode == nullptr || node == nullptr) {
180 EXPECT_EQ(1, 0);
181 return 0;
182 }
183 EXPECT_EQ(node->gid, auditData.dacData.gid);
184 return 0;
185 }
186
TestBufferValue(char * buffer,uint32_t len)187 void TestBufferValue(char *buffer, uint32_t len)
188 {
189 const int printBase = 10;
190 for (uint32_t index = 0; index <= len; index++) {
191 buffer[index] = '0' + index % printBase;
192 if (index != 0 && index % printBase == 0) {
193 buffer[index] = '.';
194 }
195 }
196 buffer[len] = '\0';
197 }
198
TestNameIsValid()199 int TestNameIsValid()
200 {
201 char buffer[PARAM_BUFFER_SIZE];
202 // set name length = 127
203 TestBufferValue(buffer, PARAM_NAME_LEN_MAX - 1);
204 int ret = SystemWriteParam(buffer, "1111");
205 EXPECT_EQ(ret, 0);
206 TestBufferValue(buffer, PARAM_NAME_LEN_MAX);
207 ret = SystemWriteParam(buffer, "1111");
208 EXPECT_NE(ret, 0);
209 TestBufferValue(buffer, PARAM_NAME_LEN_MAX + 1);
210 ret = SystemWriteParam(buffer, "1111");
211 EXPECT_NE(ret, 0);
212
213 // 保存一个只读的属性,大于最大值
214 TestBufferValue(buffer, PARAM_VALUE_LEN_MAX - 1);
215 ret = SystemWriteParam("const.test_readonly.dddddddddddddddddd.fffffffffffffffffff", buffer);
216 EXPECT_EQ(ret, 0);
217
218 TestBufferValue(buffer, PARAM_VALUE_LEN_MAX + 1);
219 ret = SystemWriteParam("const.test_readonly.aaaaaaaaaaaaaaaaaa.fffffffffffffffffff", buffer);
220 EXPECT_EQ(ret, 0);
221
222 // 更新只读项目
223 TestBufferValue(buffer, PARAM_VALUE_LEN_MAX - 1);
224 ret = SystemWriteParam("const.test_readonly.dddddddddddddddddd.fffffffffffffffffff", buffer);
225 EXPECT_NE(ret, 0);
226
227 // 写普通属性
228 TestBufferValue(buffer, PARAM_VALUE_LEN_MAX - 1);
229 ret = SystemWriteParam("test.bigvalue.dddddddddddddddddd.fffffffffffffffffff", buffer);
230 EXPECT_EQ(ret, 0);
231 TestBufferValue(buffer, PARAM_VALUE_LEN_MAX + 1);
232 ret = SystemWriteParam("test.bigvalue.dddddddddddddddddd.fffffffffffffffffff", buffer);
233 EXPECT_NE(ret, 0);
234
235 // invalid name
236 TestBufferValue(buffer, PARAM_VALUE_LEN_MAX - 1);
237 ret = SystemWriteParam("test.invalidname..fffffffffffffffffff", buffer);
238 EXPECT_NE(ret, 0);
239 ret = SystemWriteParam("test.invalidname.%fffffffffffffffffff", buffer);
240 EXPECT_NE(ret, 0);
241 ret = SystemWriteParam("test.invalidname.$fffffffffffffffffff", buffer);
242 EXPECT_NE(ret, 0);
243 return 0;
244 }
245
TestParamTraversal()246 int TestParamTraversal()
247 {
248 char value[PARAM_BUFFER_SIZE + PARAM_BUFFER_SIZE] = {0};
249 SystemTraversalParameter(
250 "",
251 [](ParamHandle handle, void *cookie) {
252 SystemGetParameterName(handle, (char *)cookie, PARAM_BUFFER_SIZE);
253 u_int32_t len = PARAM_BUFFER_SIZE;
254 SystemGetParameterValue(handle, ((char *)cookie) + PARAM_BUFFER_SIZE, &len);
255 printf("$$$$$$$$Param %s=%s \n", (char *)cookie, ((char *)cookie) + PARAM_BUFFER_SIZE);
256 },
257 (void *)value);
258 return 0;
259 }
260
TestUpdateParam(const char * name,const char * value)261 int TestUpdateParam(const char *name, const char *value)
262 {
263 SystemWriteParam(name, value);
264 SystemWriteParam(name, value);
265 SystemWriteParam(name, value);
266 SystemWriteParam(name, value);
267 CheckServerParamValue(name, value);
268 return 0;
269 }
270
TestPersistParam()271 int TestPersistParam()
272 {
273 ParamAuditData auditData = {};
274 auditData.name = "persist.";
275 auditData.dacData.gid = 0;
276 auditData.dacData.uid = 0;
277 auditData.dacData.mode = 0777; // 0777 test mode
278 AddSecurityLabel(&auditData);
279
280 LoadPersistParams();
281 SystemWriteParam("persist.111.ffff.bbbb.cccc.dddd.eeee", "1101");
282 SystemWriteParam("persist.111.aaaa.bbbb.cccc.dddd.eeee", "1102");
283 SystemWriteParam("persist.111.bbbb.cccc.dddd.eeee", "1103");
284 CheckServerParamValue("persist.111.bbbb.cccc.dddd.eeee", "1103");
285 SystemWriteParam("persist.111.cccc.bbbb.cccc.dddd.eeee", "1104");
286 SystemWriteParam("persist.111.eeee.bbbb.cccc.dddd.eeee", "1105");
287 CheckServerParamValue("persist.111.ffff.bbbb.cccc.dddd.eeee", "1101");
288 SystemWriteParam("persist.111.ffff.bbbb.cccc.dddd.eeee", "1106");
289 CheckServerParamValue("persist.111.ffff.bbbb.cccc.dddd.eeee", "1106");
290 sleep(1);
291 SystemWriteParam("persist.111.bbbb.cccc.dddd.1107", "1107");
292 SystemWriteParam("persist.111.bbbb.cccc.dddd.1108", "1108");
293 SystemWriteParam("persist.111.bbbb.cccc.dddd.1109", "1108");
294 sleep(1);
295 SystemWriteParam("persist.111.bbbb.cccc.dddd.1110", "1108");
296 SystemWriteParam("persist.111.bbbb.cccc.dddd.1111", "1108");
297 TimerCallbackForSave(nullptr, nullptr);
298 LoadPersistParams();
299 return 0;
300 }
301
CreateAndGetStreamTask()302 ParamTaskPtr CreateAndGetStreamTask()
303 {
304 ParamStreamInfo info = {};
305 info.flags = PARAM_TEST_FLAGS;
306 info.server = NULL;
307 info.close = OnClose;
308 info.recvMessage = ProcessMessage;
309 info.incomingConnect = NULL;
310 ParamTaskPtr client = NULL;
311 int ret = ParamStreamCreate(&client, GetParamService()->serverTask, &info, sizeof(ParamWatcher));
312 PARAM_CHECK(ret == 0, return NULL, "Failed to create client");
313
314 ParamWatcher *watcher = (ParamWatcher *)ParamGetTaskUserData(client);
315 PARAM_CHECK(watcher != NULL, return NULL, "Failed to get watcher");
316 OH_ListInit(&watcher->triggerHead);
317 watcher->stream = client;
318 GetParamService()->watcherTask = client;
319 return GetParamService()->watcherTask;
320 }
321
TestServiceProcessMessage(const char * name,const char * value,int userLabel)322 int TestServiceProcessMessage(const char *name, const char *value, int userLabel)
323 {
324 if (g_worker == nullptr) {
325 g_worker = CreateAndGetStreamTask();
326 }
327 if (g_worker == nullptr) {
328 return 0;
329 }
330 ParamSecurityOps *paramSecurityOps = GetParamSecurityOps(0);
331 if (userLabel && paramSecurityOps != NULL) {
332 paramSecurityOps->securityFreeLabel = TestFreeLocalSecurityLabel;
333 paramSecurityOps->securityCheckParamPermission = TestCheckParamPermission;
334 }
335 uint32_t msgSize = sizeof(ParamMessage) + sizeof(ParamMsgContent) + PARAM_ALIGN(strlen(value) + 1);
336 ParamMessage *request = (ParamMessage *)CreateParamMessage(MSG_SET_PARAM, name, msgSize);
337 PARAM_CHECK(request != nullptr, return -1, "Failed to malloc for connect");
338 do {
339 request->type = MSG_SET_PARAM;
340 uint32_t offset = 0;
341 int ret = FillParamMsgContent(request, &offset, PARAM_VALUE, value, strlen(value));
342 PARAM_CHECK(ret == 0, break, "Failed to fill value");
343 ProcessMessage((const ParamTaskPtr)g_worker, (const ParamMessage *)request);
344 } while (0);
345 free(request);
346 RegisterSecurityOps(1);
347 return 0;
348 }
349
AddWatch(int type,const char * name,const char * value)350 int AddWatch(int type, const char *name, const char *value)
351 {
352 if (g_worker == nullptr) {
353 g_worker = CreateAndGetStreamTask();
354 }
355 if (g_worker == nullptr) {
356 return 0;
357 }
358 uint32_t msgSize = sizeof(ParamMessage) + sizeof(ParamMsgContent) + PARAM_ALIGN(strlen(value) + 1);
359 ParamMessage *request = (ParamMessage *)(ParamMessage *)CreateParamMessage(type, name, msgSize);
360 PARAM_CHECK(request != nullptr, return -1, "Failed to malloc for connect");
361 do {
362 uint32_t offset = 0;
363 int ret = FillParamMsgContent(request, &offset, PARAM_VALUE, value, strlen(value));
364 PARAM_CHECK(ret == 0, break, "Failed to fill value");
365 ProcessMessage((const ParamTaskPtr)g_worker, (const ParamMessage *)request);
366 } while (0);
367 free(request);
368 return 0;
369 }
370
371 // 无匹配
TestAddParamWait1()372 int TestAddParamWait1()
373 {
374 const char *name = "wait.aaa.bbb.ccc.111";
375 const char *value = "wait1";
376 AddWatch(MSG_WAIT_PARAM, name, value);
377 SystemWriteParam(name, value);
378 return 0;
379 }
380
381 // 模糊匹配
TestAddParamWait2()382 int TestAddParamWait2()
383 {
384 const char *name = "wait.aaa.bbb.ccc.222";
385 const char *value = "wait2";
386 AddWatch(MSG_WAIT_PARAM, name, "*");
387 SystemWriteParam(name, value);
388 return 0;
389 }
390
391 // 属性存在
TestAddParamWait3()392 int TestAddParamWait3()
393 {
394 const char *name = "wait.aaa.bbb.ccc.333";
395 const char *value = "wait3";
396 SystemWriteParam(name, value);
397 AddWatch(MSG_WAIT_PARAM, name, value);
398 return 0;
399 }
400
TestAddParamWatch1()401 int TestAddParamWatch1()
402 {
403 const char *name = "watch.aaa.bbb.ccc.111";
404 const char *value = "watch1";
405 AddWatch(MSG_ADD_WATCHER, name, value);
406 std::string newName = name;
407 newName += ".test.test.test";
408 SystemWriteParam(newName.c_str(), value);
409 return 0;
410 }
411
TestAddParamWatch2()412 int TestAddParamWatch2()
413 {
414 const char *name = "watch.aaa.bbb.ccc.222";
415 const char *value = "watch2";
416 AddWatch(MSG_ADD_WATCHER, name, "*");
417 SystemWriteParam(name, value);
418 return 0;
419 }
420
TestAddParamWatch3()421 int TestAddParamWatch3()
422 {
423 const char *name = "watch.aaa.bbb.ccc.333";
424 const char *value = "watch3";
425 std::string newName = name;
426 newName += ".test.test.test";
427 SystemWriteParam(newName.c_str(), value);
428 AddWatch(MSG_ADD_WATCHER, name, value);
429 char buffer[] = "testbuff";
430 CheckTrigger(GetTriggerWorkSpace(), TRIGGER_PARAM_WATCH, buffer, strlen(buffer), TestTriggerExecute);
431 #ifdef PARAM_SUPPORT_TRIGGER
432 SystemDumpTriggers(1, NULL);
433 #endif
434 AddWatch(MSG_DEL_WATCHER, name, value);
435 return 0;
436 }
437
TestCloseTriggerWatch()438 int TestCloseTriggerWatch()
439 {
440 ParamWatcher *watcher = (ParamWatcher *)ParamGetTaskUserData(g_worker);
441 ClearWatchTrigger(watcher, TRIGGER_PARAM_WAIT);
442 ParamTaskClose(g_worker);
443 g_worker = nullptr;
444 SystemWriteParam("init.svc.param_watcher", "stopped");
445 return 0;
446 }
447
TestServiceCtrl(const char * serviceName,uint16_t mode)448 int TestServiceCtrl(const char *serviceName, uint16_t mode)
449 {
450 // service forbid
451 TestSetParamCheckResult("ohos.servicectrl.", mode, 1);
452 return SystemWriteParam("ohos.ctl.start", serviceName);
453 }
454
TestPowerCtrl(const char * reboot,uint16_t mode)455 int TestPowerCtrl(const char *reboot, uint16_t mode)
456 {
457 // service forbid
458 TestSetParamCheckResult("ohos.servicectrl.reboot", mode, 1);
459 return SystemWriteParam("ohos.startup.powerctrl", reboot);
460 }
461 };
462
463 HWTEST_F(ParamServiceUnitTest, TestServiceProcessMessage, TestSize.Level0)
464 {
465 ParamServiceUnitTest test;
466 test.TestServiceProcessMessage("wertt.qqqq.wwww.rrrr", "wwww.eeeee", 1);
467 test.TestServiceProcessMessage("wertt.2222.wwww.3333", "wwww.eeeee", 0);
468 }
469
470 HWTEST_F(ParamServiceUnitTest, TestAddParamWait1, TestSize.Level0)
471 {
472 ParamServiceUnitTest test;
473 test.TestAddParamWait1();
474 }
475
476 HWTEST_F(ParamServiceUnitTest, TestAddParamWait2, TestSize.Level0)
477 {
478 ParamServiceUnitTest test;
479 test.TestAddParamWait2();
480 }
481
482 HWTEST_F(ParamServiceUnitTest, TestAddParamWait3, TestSize.Level0)
483 {
484 ParamServiceUnitTest test;
485 test.TestAddParamWait3();
486 }
487
488 HWTEST_F(ParamServiceUnitTest, TestAddParamWatch1, TestSize.Level0)
489 {
490 ParamServiceUnitTest test;
491 test.TestAddParamWatch1();
492 }
493
494 HWTEST_F(ParamServiceUnitTest, TestAddParamWatch2, TestSize.Level0)
495 {
496 ParamServiceUnitTest test;
497 test.TestAddParamWatch2();
498 }
499
500 HWTEST_F(ParamServiceUnitTest, TestAddParamWatch3, TestSize.Level0)
501 {
502 ParamServiceUnitTest test;
503 test.TestAddParamWatch3();
504 if (GetParamService()->timer != nullptr) {
505 ((TimerTask *)GetParamService()->timer)->processTimer(nullptr, nullptr);
506 }
507 int hashCode = CheckWatchTriggerTimeout();
508 EXPECT_EQ(hashCode, 0);
509 }
510
511 HWTEST_F(ParamServiceUnitTest, TestCloseTriggerWatch, TestSize.Level0)
512 {
513 ParamServiceUnitTest test;
514 test.TestCloseTriggerWatch();
515 }
516
517 HWTEST_F(ParamServiceUnitTest, TestServiceCtrl, TestSize.Level0)
518 {
519 ParamServiceUnitTest test;
520 int ret = test.TestServiceCtrl("server1", 0770);
521 EXPECT_NE(ret, 0);
522 #ifdef PARAM_SUPPORT_SELINUX
523 // selinux forbid
524 ret = test.TestServiceCtrl("server2", 0772);
525 EXPECT_NE(ret, 0);
526 #endif
527 ret = 0;
528 }
529
530 HWTEST_F(ParamServiceUnitTest, TestPowerCtrl, TestSize.Level0)
531 {
532 ParamServiceUnitTest test;
533 int ret = test.TestPowerCtrl("reboot,shutdown", 0770);
534 EXPECT_NE(ret, 0);
535
536 #ifdef PARAM_SUPPORT_SELINUX
537 ret = test.TestPowerCtrl("reboot,shutdown", 0772);
538 // selinux forbid
539 EXPECT_NE(ret, 0);
540 #endif
541 ret = test.TestPowerCtrl("reboot,updater", 0770);
542 EXPECT_NE(ret, 0);
543 #ifdef PARAM_SUPPORT_SELINUX
544 ret = test.TestPowerCtrl("reboot,updater", 0772);
545 // selinux forbid
546 EXPECT_NE(ret, 0);
547 #endif
548 ret = test.TestPowerCtrl("reboot,flashd", 0770);
549 EXPECT_NE(ret, 0);
550 #ifdef PARAM_SUPPORT_SELINUX
551 ret = test.TestPowerCtrl("reboot,flashd", 0772);
552 // selinux forbid
553 EXPECT_NE(ret, 0);
554 #endif
555 ret = test.TestPowerCtrl("reboot", 0770);
556 EXPECT_NE(ret, 0);
557 #ifdef PARAM_SUPPORT_SELINUX
558 ret = test.TestPowerCtrl("reboot", 0772);
559 // selinux forbid
560 EXPECT_NE(ret, 0);
561 #endif
562 }
563 } // namespace init_ut
564