1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3# Copyright (C) 2025 Huawei Device Co., Ltd. 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15import time 16import pytest 17from utils import GP, check_hdc_cmd, check_shell, get_local_path, run_command_with_timeout, load_gp 18 19 20class TestSmode: 21 @pytest.mark.L0 22 def test_smode_permission(self): 23 check_shell(f"shell rm -rf data/deep_test_dir") 24 assert check_hdc_cmd(f'smode -r') 25 time.sleep(3) 26 run_command_with_timeout(f"{GP.hdc_head} wait", 15) # wait 15s for the device to connect channel 27 assert check_shell(f"file send {get_local_path('deep_test_dir')} data/", 28 "permission denied") 29 assert check_shell(f"file send {get_local_path('deep_test_dir')} data/", 30 "[E005005]") 31 32 @pytest.mark.L0 33 def test_smode_r(self): 34 assert check_hdc_cmd(f'smode -r') 35 time.sleep(3) # sleep 3s to wait for the device to connect channel 36 run_command_with_timeout(f"{GP.hdc_head} wait", 15) # wait 15s for the device to connect channel 37 time.sleep(3) # sleep 3s to wait for the device to connect channel 38 run_command_with_timeout(f"{GP.hdc_head} wait", 15) # wait 15s for the device to connect channel 39 assert check_shell(f"shell id", "context=u:r:sh:s0") 40 41 @pytest.mark.L0 42 def test_smode(self): 43 assert check_hdc_cmd(f'smode') 44 time.sleep(3) # sleep 3s to wait for the device to connect channel 45 run_command_with_timeout(f"{GP.hdc_head} wait", 15) # wait 15s for the device to connect channel 46 time.sleep(3) # sleep 3s to wait for the device to connect channel 47 run_command_with_timeout(f"{GP.hdc_head} wait", 15) # wait 15s for the device to connect channel 48 assert check_shell(f"shell id", "context=u:r:su:s0")