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