• 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 os
16import time
17import pytest
18from utils import GP, check_cmd_block, check_hdc_cmd, load_gp
19
20
21class TestHdcServer:
22    @pytest.mark.L0
23    def test_hdc_server_foreground(self):
24        port = os.getenv('OHOS_HDC_SERVER_PORT')
25        if port is None:
26            port = 8710
27        assert check_hdc_cmd("kill", "Kill server finish")
28        assert check_cmd_block(f"{GP.hdc_exe} -m", f"port: {port}", timeout=5)
29        assert check_hdc_cmd("start")
30        time.sleep(3) # sleep 3s to wait for the device to connect channel
31
32    @pytest.mark.L0
33    def test_server_kill(self):
34        assert check_hdc_cmd("kill", "Kill server finish")
35        assert check_hdc_cmd("start server")
36        time.sleep(3) # sleep 3s to wait for the device to connect channel
37        assert check_hdc_cmd("kill -r", "Start server finish")
38        assert check_hdc_cmd("start -r", "hdc start server")
39        assert check_hdc_cmd("checkserver", "Ver")
40        time.sleep(3) # sleep 3s to wait for the device to connect channel