1#!/usr/bin/env python3 2#-*- coding: utf-8 -*- 3 4# Copyright (c) 2025 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 18import sys 19 20current_dir = os.path.abspath(os.path.dirname(__file__)) 21rootPath = os.path.split(current_dir)[0] 22awPath = os.path.split(rootPath)[0] 23sys.path.append(rootPath) 24sys.path.append(os.path.join(awPath, "aw")) 25 26import os.path 27from devicetest.core.test_case import TestCase, CheckPoint 28from hypium import UiDriver 29import disk_drop_log 30 31 32class case25_selinux001(TestCase): 33 34 def __init__(self, configs): 35 self.TAG = self.__class__.__name__ 36 TestCase.__init__(self, self.TAG, configs) 37 self.tests = [ 38 "test_step" 39 ] 40 self.driver = UiDriver(self.device1) 41 42 def setup(self): 43 self.log.info("case25_selinux001 start") 44 self.driver.shell("rm -r /data/log/hilog") 45 self.driver.shell("hilog -d /system/bin/samgr") 46 self.driver.System.reboot() 47 48 def test_step(self): 49 log_revice_path = os.path.join(self.get_case_report_path(), "disk_drop") 50 disk_drop_log.pulling_disk_dropping_logs(log_revice_path, self.driver) 51 disk_drop_log.parse_disk_dropping_logs(log_revice_path) 52 result = disk_drop_log.check_disk_dropping_logs(log_revice_path, "scontext=u:r:samgr:s0") 53 CheckPoint("The log does not contain 'scontext=u:r:samgr:s0'") 54 assert result is False 55 56 def teardown(self): 57 self.log.info("case25_selinux001 done") 58