• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
17from devicetest.core.test_case import TestCase, Step
18import json
19import re
20
21
22# @tc.number: XTS_SYSCAPMinSet_0100
23# @tc.name: testSyscapMinSetTest
24# @tc.level: Level0
25# @tc.desc: 验证设备被测设备包含该类设备syscap最小集
26class testSyscapMinSetTest(TestCase):
27
28    def __init__(self, controllers):
29        self.TAG = self.__class__.__name__
30        super().__init__(self.TAG, controllers)
31
32    def setup(self):
33        Step("Setup")
34
35    def process(self):
36        Step("Process")
37
38        # 获取设备 SystemCapability
39        SystemCapability_json_data = self.device1.execute_shell_command("cat /system/etc/SystemCapability.json")
40        data = json.loads(SystemCapability_json_data)
41        device_SystemCapability_list = data['syscap']['os']
42        self.log.info(f"设备端syscap: {device_SystemCapability_list}")
43
44        # 获取设备类型
45        device_type = self.device1.execute_shell_command("param get const.product.devicetype").strip()
46        if device_type == "phone":
47            device_type = "default"
48        self.log.info(f"设备类型: {device_type}")
49
50        # 获取该类设备syscap最小集
51        syscap_json_data = self.device1.execute_shell_command(f"cat /data/local/tmp/syscap/{device_type}.json")
52        try:
53            syscap_data = json.loads(syscap_json_data)
54            syscap_list = syscap_data['SysCaps']
55            self.log.info(f"该类设备syscap最小集: {syscap_list}")
56
57            is_subset = set(syscap_list) <= set(device_SystemCapability_list)
58            if not is_subset:
59                sys = [item for item in syscap_list if item not in device_SystemCapability_list]
60                self.log.info(f"缺少的最小集syscap: {sys}")
61            assert is_subset
62        except ValueError:
63            if "No such file or directory" in syscap_json_data:
64                self.log.info(f"设备类型:{device_type}无最小集要求")
65                assert True
66            else:
67                self.log.info(f"最小集syscap读取失败")
68                assert False
69        return True
70
71    def teardown(self):
72        Step("Teardown")