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 pytest 16from utils import GP, check_cmd_time, check_hdc_cmd, check_rate, get_local_path, get_remote_path, load_gp 17 18 19def clear_env(): 20 check_hdc_cmd("shell rm -rf data/local/tmp/it_*") 21 check_hdc_cmd("shell mkdir data/local/tmp/it_send_dir") 22 23 24class TestShellPerformance: 25 @pytest.mark.L0 26 def test_shell_cmd_timecost_param_p(self): 27 check_hdc_cmd("shell \"ps -ef | grep hdcd\"") 28 assert check_cmd_time( 29 cmd="-p shell \"ps -ef | grep hdcd\"", 30 pattern="hdcd", 31 duration=None, 32 times=50) 33 34 @pytest.mark.L0 35 def test_shell_cmd_timecost_param_none(self): 36 check_hdc_cmd("shell \"ps -ef | grep hdcd\"") 37 assert check_cmd_time( 38 cmd="shell \"ps -ef | grep hdcd\"", 39 pattern="hdcd", 40 duration=None, 41 times=20) 42 43 @pytest.mark.L0 44 def test_shell_huge_cat(self): 45 assert check_hdc_cmd(f"file send {get_local_path('word_100M.txt')} {get_remote_path('it_word_100M.txt')}") 46 assert check_cmd_time( 47 cmd=f"shell cat {get_remote_path('it_word_100M.txt')}", 48 pattern=None, 49 duration=10000, # 10 seconds 50 times=10) 51 52 53class TestFilePerformance: 54 @pytest.mark.L0 55 @pytest.mark.repeat(1) 56 def test_rate(self): 57 clear_env() 58 assert check_rate(f"file send {get_local_path('large')} {get_remote_path('it_large')}", 18000) 59 assert check_rate(f"file recv {get_remote_path('it_large')} {get_local_path('large_recv')}", 18000)