1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3#
4# Copyright (c) 2024 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
18from sysCapUtils import sysCapUtils
19import json
20
21# @tc.number: M-SOFTWARE-0102
22# @tc.name: testMinimumComponentSet
23# @tc.desc: 【M-SOFTWARE-0102】禁止删减 productdefine/common/base/mini_system.json 定义的最小系统部件集配置。
24class testMinimumComponentSet(TestCase):
25
26    def __init__(self, controllers):
27        self.TAG = self.__class__.__name__
28        super().__init__(self.TAG, controllers)
29
30    def setup(self):
31        Step("Setup")
32
33    def process(self):
34        Step("Process")
35        deviceSysCapsStr = self.device1.execute_shell_command("cat /system/etc/param/syscap.para")
36        deviceSysCapsList = sysCapUtils.getAllSysCaps(deviceSysCapsStr)
37        with open('./resource/pcs/standard_system.json', 'r') as f:
38            minimumComponentDatas = json.load(f)['components']
39        minimumComponentSysCaps = []
40        for minimumComponentData in minimumComponentDatas:
41            componentSysCaps = minimumComponentData['syscap']
42            for componentSysCap in componentSysCaps:
43                minimumComponentSysCaps.append(componentSysCap)
44
45        missingList = []
46        for minimumComponentSysCap in minimumComponentSysCaps:
47            if minimumComponentSysCap not in deviceSysCapsList:
48                missingList.append(minimumComponentSysCap)
49        if len(missingList) != 0:
50            self.log.info('missingList: [' + ', '.join(missingList) + ']')
51            assert False
52
53    def teardown(self):
54        Step("Teardown")