1#!/usr/bin/env python3 2#-*- coding: utf-8 -*- 3 4# Copyright (c) 2024 Huawei Device Co., Ltd. 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17import os.path 18from devicetest.core.test_case import TestCase, CheckPoint 19from hypium import UiDriver 20from hypium.action.host import host 21import tools.disk_drop_log 22 23 24class case25_selinux001(TestCase): 25 26 def __init__(self, configs): 27 self.TAG = self.__class__.__name__ 28 TestCase.__init__(self, self.TAG, configs) 29 self.tests = [ 30 "test_step" 31 ] 32 self.driver = UiDriver(self.device1) 33 self.sn = self.device1.device_sn 34 35 def setup(self): 36 self.log.info("case25_selinux001 start") 37 host.shell("hdc -t {} shell rm -r /data/log/hilog".format(self.sn)) 38 host.shell("hdc -t {} shell hilog -d /system/bin/samgr".format(self.sn)) 39 self.driver.System.reboot() 40 41 def test_step(self): 42 log_revice_path = os.path.join(self.get_case_report_path(), "disk_drop") 43 tools.disk_drop_log.pulling_disk_dropping_logs(log_revice_path, self.sn) 44 tools.disk_drop_log.parse_disk_dropping_logs(log_revice_path) 45 result = tools.disk_drop_log.check_disk_dropping_logs(log_revice_path, "scontext=u:r:samgr:s0") 46 CheckPoint("The log does not contain 'scontext=u:r:samgr:s0'") 47 assert result is False 48 49 def teardown(self): 50 self.log.info("case25_selinux001 done") 51