openubmc-bingo 0.6.45__py3-none-any.whl → 0.6.99__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. bmcgo/__init__.py +1 -1
  2. bmcgo/bmcgo.py +9 -3
  3. bmcgo/bmcgo_config.py +16 -0
  4. bmcgo/cli/cli.py +72 -21
  5. bmcgo/codegen/__init__.py +1 -1
  6. bmcgo/codegen/lua/codegen.py +2 -2
  7. bmcgo/codegen/lua/script/check_intfs.py +1 -0
  8. bmcgo/codegen/lua/script/dto/options.py +1 -0
  9. bmcgo/codegen/lua/script/gen_db_json.py +4 -3
  10. bmcgo/codegen/lua/script/gen_rpc_msg_json.py +78 -11
  11. bmcgo/codegen/lua/script/model_consistency_check.py +1 -1
  12. bmcgo/codegen/lua/script/render_utils/db_lua.py +5 -6
  13. bmcgo/codegen/lua/script/render_utils/model_lua.py +5 -1
  14. bmcgo/codegen/lua/script/template.py +5 -0
  15. bmcgo/codegen/lua/script/utils.py +50 -8
  16. bmcgo/codegen/lua/templates/apps/Makefile +2 -2
  17. bmcgo/codegen/lua/templates/apps/client.lua.mako +1 -1
  18. bmcgo/codegen/lua/templates/apps/model.lua.mako +4 -3
  19. bmcgo/codegen/lua/templates/apps/service.lua.mako +1 -1
  20. bmcgo/codegen/lua/templates/apps/utils/mdb_intf.lua.mako +4 -0
  21. bmcgo/codegen/lua/templates/new_app_v2/CMakeLists.txt.mako +26 -0
  22. bmcgo/codegen/lua/templates/new_app_v2/conanfile.py.mako +9 -0
  23. bmcgo/codegen/lua/v1/script/render_utils/db_lua.py +5 -6
  24. bmcgo/codegen/lua/v1/script/render_utils/model_lua.py +13 -1
  25. bmcgo/codegen/lua/v1/templates/apps/client.lua.mako +1 -1
  26. bmcgo/codegen/lua/v1/templates/apps/local_db.lua.mako +0 -4
  27. bmcgo/codegen/lua/v1/templates/apps/message.lua.mako +3 -0
  28. bmcgo/codegen/lua/v1/templates/apps/model.lua.mako +3 -0
  29. bmcgo/codegen/lua/v1/templates/apps/utils/mdb_intf.lua.mako +6 -4
  30. bmcgo/component/analysis/analysis.py +9 -4
  31. bmcgo/component/analysis/dep-rules.json +20 -8
  32. bmcgo/component/analysis/dep_node.py +2 -0
  33. bmcgo/component/analysis/intf_validation.py +8 -7
  34. bmcgo/component/analysis/sr_validation.py +5 -4
  35. bmcgo/component/busctl_log_parse/busctl_log_parser.py +809 -0
  36. bmcgo/component/busctl_log_parse/mock_data_save.py +170 -0
  37. bmcgo/component/busctl_log_parse/test_data_save.py +49 -0
  38. bmcgo/component/component_helper.py +29 -0
  39. bmcgo/component/coverage/incremental_cov.py +5 -0
  40. bmcgo/component/fixture/__init__.py +29 -0
  41. bmcgo/component/fixture/auto_case_generator.py +490 -0
  42. bmcgo/component/fixture/busctl_type_converter.py +1081 -0
  43. bmcgo/component/fixture/common_config.py +15 -0
  44. bmcgo/component/fixture/dbus_gateway.py +669 -0
  45. bmcgo/component/fixture/dbus_library.py +250 -0
  46. bmcgo/component/fixture/dbus_mock_utils.py +514 -0
  47. bmcgo/component/fixture/dbus_response_handler.py +138 -0
  48. bmcgo/component/fixture/dbus_signature.py +110 -0
  49. bmcgo/component/template_v2/conanbase.py.mako +1 -5
  50. bmcgo/component/test.py +69 -10
  51. bmcgo/error_analyzer/__init__.py +0 -0
  52. bmcgo/error_analyzer/case_matcher.py +114 -0
  53. bmcgo/error_analyzer/log_parser.py +128 -0
  54. bmcgo/error_analyzer/unified_error_analyzer.py +359 -0
  55. bmcgo/error_cases/cases.yml +59 -0
  56. bmcgo/error_cases/cases_template_valid.json +71 -0
  57. bmcgo/error_cases/conanfile.py +58 -0
  58. bmcgo/frame.py +0 -4
  59. bmcgo/functional/analysis.py +18 -12
  60. bmcgo/functional/bmc_studio_action.py +21 -10
  61. bmcgo/functional/check.py +86 -42
  62. bmcgo/functional/conan_index_build.py +1 -1
  63. bmcgo/functional/config.py +22 -18
  64. bmcgo/functional/csr_build.py +63 -34
  65. bmcgo/functional/deploy.py +4 -3
  66. bmcgo/functional/diff.py +51 -34
  67. bmcgo/functional/full_component.py +16 -5
  68. bmcgo/functional/hpm_signer.py +484 -0
  69. bmcgo/functional/new.py +8 -2
  70. bmcgo/functional/schema_valid.py +111 -15
  71. bmcgo/functional/upgrade.py +6 -6
  72. bmcgo/misc.py +1 -0
  73. bmcgo/tasks/task_build_conan.py +27 -6
  74. bmcgo/tasks/task_build_rootfs_img.py +120 -83
  75. bmcgo/tasks/task_buildgppbin.py +30 -13
  76. bmcgo/tasks/task_buildhpm_ext4.py +5 -3
  77. bmcgo/tasks/task_download_buildtools.py +20 -11
  78. bmcgo/tasks/task_download_dependency.py +29 -20
  79. bmcgo/tasks/task_hpm_envir_prepare.py +32 -53
  80. bmcgo/tasks/task_packet_to_supporte.py +12 -4
  81. bmcgo/tasks/task_prepare.py +1 -1
  82. bmcgo/tasks/task_sign_and_pack_hpm.py +15 -7
  83. bmcgo/utils/component_version_check.py +4 -4
  84. bmcgo/utils/config.py +3 -0
  85. bmcgo/utils/fetch_component_code.py +148 -17
  86. bmcgo/utils/install_manager.py +2 -2
  87. bmcgo/utils/installations/base_installer.py +10 -27
  88. bmcgo/utils/installations/install_plans/studio.yml +3 -0
  89. bmcgo/utils/mapping_config_patch.py +5 -4
  90. bmcgo/utils/tools.py +49 -7
  91. {openubmc_bingo-0.6.45.dist-info → openubmc_bingo-0.6.99.dist-info}/METADATA +1 -1
  92. {openubmc_bingo-0.6.45.dist-info → openubmc_bingo-0.6.99.dist-info}/RECORD +95 -74
  93. bmcgo/tasks/download_buildtools_hm.py +0 -124
  94. {openubmc_bingo-0.6.45.dist-info → openubmc_bingo-0.6.99.dist-info}/WHEEL +0 -0
  95. {openubmc_bingo-0.6.45.dist-info → openubmc_bingo-0.6.99.dist-info}/entry_points.txt +0 -0
  96. {openubmc_bingo-0.6.45.dist-info → openubmc_bingo-0.6.99.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,170 @@
1
+ #!/usr/bin/python3
2
+ # coding: utf-8
3
+ # Copyright (c) 2024 Huawei Technologies Co., Ltd.
4
+ # openUBMC is licensed under Mulan PSL v2.
5
+ # You can use this software according to the terms and conditions of the Mulan PSL v2.
6
+ # You may obtain a copy of Mulan PSL v2 at:
7
+ # http://license.coscl.org.cn/MulanPSL2
8
+ # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
9
+ # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
10
+ # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11
+ # See the Mulan PSL v2 for more details.
12
+ import logging
13
+ import os
14
+ import json
15
+
16
+ # 配置日志记录
17
+ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
18
+ DBUS_MOCK_DATA_FILE_NAME = 'mock_data.json'
19
+
20
+
21
+ class MockDataSaver:
22
+ """
23
+ 用于保存mock数据和信号数据的类
24
+ """
25
+ def __init__(self, service_prefix):
26
+ # 不再需要name_to_service参数
27
+ self.service_prefix = service_prefix
28
+ # 服务名集合将在处理过程中动态收集
29
+ self.service_names = set()
30
+
31
+ @staticmethod
32
+ def _save_service_data(mock_data, service_name, output_dir_path):
33
+ """
34
+ 保存单个服务的数据
35
+
36
+ :param mock_data: 该服务的mock数据
37
+ :param signals: 该服务的信号数据
38
+ :param service_name: 服务名
39
+ :param output_dir_path: 输出目录路径
40
+ """
41
+ # 创建服务目录
42
+ service_dir = os.path.join(output_dir_path, service_name.replace('.', '_'))
43
+ os.makedirs(service_dir, exist_ok=True)
44
+
45
+ # 分别保存mock数据和信号数据
46
+ MockDataSaver._save_mock_data(mock_data, service_name, service_dir)
47
+
48
+ @staticmethod
49
+ def _save_mock_data(mock_data, service_name, service_dir):
50
+ """
51
+ 保存单个服务的mock数据
52
+
53
+ :param mock_data: 该服务的mock数据
54
+ :param service_name: 服务名
55
+ :param service_dir: 服务目录路径
56
+ """
57
+ # 当mock_data为空时,直接返回不保存文件
58
+ if not mock_data:
59
+ logging.info(f" 服务 {service_name} 没有mock数据,跳过保存")
60
+ return
61
+
62
+ # 保存mock数据
63
+ mock_file_path = os.path.join(service_dir, DBUS_MOCK_DATA_FILE_NAME)
64
+ # 读取现有mock数据(如果存在)
65
+ existing_mock_data = {}
66
+ if os.path.exists(mock_file_path):
67
+ try:
68
+ with open(mock_file_path, 'r', encoding='utf-8') as in_f:
69
+ existing_mock_data = json.load(in_f)
70
+ except (json.JSONDecodeError, IOError) as e:
71
+ logging.warning(f" 警告: 读取现有mock数据文件时出错 {e},将覆盖文件")
72
+
73
+ # 合并新数据与现有数据
74
+ for key, calls in mock_data.items():
75
+ if key in existing_mock_data:
76
+ # 如果键已存在,将新调用追加到现有调用列表
77
+ existing_mock_data[key].extend(calls)
78
+ else:
79
+ # 如果键不存在,直接添加
80
+ existing_mock_data[key] = calls
81
+
82
+ # 保存合并后的mock数据
83
+ with open(mock_file_path, 'w', encoding='utf-8') as out_f:
84
+ json.dump(existing_mock_data, out_f, indent=4, ensure_ascii=False)
85
+ logging.info(f" 已保存 {service_name} 的mock数据到 {mock_file_path}")
86
+
87
+ def save_mock_data(self, mock_data, output_dir_path):
88
+ # 从mock_data的key中收集服务名
89
+ for key in mock_data.keys():
90
+ parts = key.split('|')
91
+ if len(parts) >= 1:
92
+ service_name = parts[0]
93
+ if service_name.startswith(self.service_prefix):
94
+ self.service_names.add(service_name)
95
+
96
+ # 初始化各服务的数据存储
97
+ service_mock_data = {service: {} for service in self.service_names}
98
+
99
+ # 分类数据到各服务
100
+ self._categorize_data_by_service(
101
+ mock_data,
102
+ service_mock_data
103
+ )
104
+
105
+ # 保存各服务的数据
106
+ for service_name in self.service_names:
107
+ MockDataSaver._save_service_data(
108
+ service_mock_data[service_name],
109
+ service_name,
110
+ output_dir_path
111
+ )
112
+
113
+ def _categorize_data_by_service(self, mock_data, service_mock_data):
114
+ """
115
+ 将数据按服务名分类存储
116
+
117
+ :param mock_data: mock数据
118
+ :param signals: 信号数据
119
+ :param service_mock_data: 各服务的mock数据存储
120
+ :param service_signals: 各服务的信号数据存储
121
+ """
122
+ # 分类mock数据 - 直接从key中提取服务名
123
+ for key, calls in mock_data.items():
124
+ # 从key中提取服务名(第一部分)
125
+ parts = key.split('|')
126
+ if len(parts) >= 1:
127
+ service_name = parts[0]
128
+
129
+ # 检查服务名是否以service_prefix开头并且已在service_mock_data中
130
+ if service_name.startswith(self.service_prefix) and service_name in service_mock_data:
131
+ if key not in service_mock_data[service_name]:
132
+ service_mock_data[service_name][key] = []
133
+ service_mock_data[service_name][key].extend(calls)
134
+
135
+ def _save_data_by_service(self, mock_data, output_dir_path):
136
+ """
137
+ 按服务名分别存储数据
138
+
139
+ :param mock_data: mock数据
140
+ :param signals: 信号数据
141
+ :param output_dir_path: 输出目录路径
142
+ """
143
+ # 直接从mock_data的key中收集服务名
144
+ service_names = set()
145
+
146
+ # 从mock数据中收集服务名
147
+ for key in mock_data.keys():
148
+ parts = key.split('|')
149
+ if len(parts) >= 1:
150
+ service_name = parts[0]
151
+ if service_name.startswith(self.service_prefix):
152
+ service_names.add(service_name)
153
+
154
+ # 为每个服务创建数据存储
155
+ service_mock_data = {service: {} for service in service_names}
156
+
157
+ # 分类mock数据
158
+ for key, calls in mock_data.items():
159
+ parts = key.split('|')
160
+ if len(parts) >= 1:
161
+ service_name = parts[0]
162
+ if service_name.startswith(self.service_prefix) and service_name in service_mock_data:
163
+ service_mock_data[service_name][key] = calls
164
+ # 保存各服务的数据
165
+ for service_name in service_names:
166
+ MockDataSaver._save_service_data(
167
+ service_mock_data[service_name],
168
+ service_name,
169
+ output_dir_path
170
+ )
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/python3
2
+ # coding: utf-8
3
+ # Copyright (c) 2024 Huawei Technologies Co., Ltd.
4
+ # openUBMC is licensed under Mulan PSL v2.
5
+ # You can use this software according to the terms and conditions of the Mulan PSL v2.
6
+ # You may obtain a copy of Mulan PSL v2 at:
7
+ # http://license.coscl.org.cn/MulanPSL2
8
+ # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
9
+ # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
10
+ # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11
+ # See the Mulan PSL v2 for more details.
12
+ import logging
13
+ import os
14
+ import json
15
+
16
+ # 配置日志记录
17
+ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
18
+ TEST_DATA_FILE = 'test_data.json'
19
+
20
+
21
+ class TestDataSave:
22
+ def __init__(self, test_data, output_dir_path):
23
+ """
24
+ 初始化测试数据保存器
25
+
26
+ Args:
27
+ test_data: 要保存的测试数据
28
+ output_dir_path: 输出目录路径
29
+ """
30
+ self.test_data = test_data
31
+ self.output_dir_path = output_dir_path
32
+
33
+ def save(self):
34
+ """
35
+ 保存测试数据到JSON文件
36
+ """
37
+ try:
38
+ # 使用传入的输出目录路径,在其下创建 test_data 子目录
39
+ test_data_dir = os.path.join(self.output_dir_path, 'test_data')
40
+ # 确保目录存在
41
+ os.makedirs(test_data_dir, exist_ok=True)
42
+ # 构建文件路径
43
+ file_path = os.path.join(test_data_dir, TEST_DATA_FILE)
44
+ # 写入JSON文件
45
+ with open(file_path, 'w') as f:
46
+ json.dump(self.test_data, f, indent=4)
47
+ logging.info(f"测试数据已成功保存到 {file_path}")
48
+ except Exception as e:
49
+ logging.error(f"保存测试数据到 {TEST_DATA_FILE} 时出错: {e}")
@@ -126,11 +126,30 @@ class ComponentHelper:
126
126
  return default
127
127
  return json_data
128
128
 
129
+ @staticmethod
130
+ def try_download_once(comp, tools: Tools, remote_list):
131
+ # 先尝试一次下载,防止认证失败
132
+ args = "--only-recipe" if misc.conan_v2() else "--recipe"
133
+ for remote in remote_list:
134
+ # 重试3次
135
+ for _ in range(1, 3):
136
+ try:
137
+ tools.run_command(f"conan download {comp} -r {remote} {args}", show_log=True)
138
+ tools.last_succ_remote = remote
139
+ return
140
+ except Exception as e:
141
+ tools.log.info(f"Recipe not fount in {remote}: {comp}")
142
+
129
143
  @staticmethod
130
144
  def download_recipes(depdencies: List[str], tools: Tools, remote_list):
131
145
  pools = []
132
146
  ignore_error = os.getenv("CLOUD_BUILD_IGNORE_ERROR")
147
+ # 先尝试一次下载,防止认证失败
148
+ ComponentHelper.try_download_once(depdencies[0], tools, remote_list)
149
+ del depdencies[0]
133
150
  for dep in depdencies:
151
+ if "@" not in dep:
152
+ continue
134
153
  task = DownloadComponentRecipe(tools, dep, remote_list)
135
154
  task.start()
136
155
  pools.append(task)
@@ -194,3 +213,13 @@ class ComponentHelper:
194
213
  stage = misc.StageEnum.STAGE_RC.value
195
214
  user_channel = f"@{misc.conan_user()}/{stage}"
196
215
  return user_channel
216
+
217
+ @staticmethod
218
+ def get_full_reference(components: List[str], stage: str):
219
+ user_channel = ComponentHelper.get_user_channel(stage)
220
+ full_reference_comps = []
221
+ for comp in components:
222
+ if "@" not in comp:
223
+ comp += user_channel
224
+ full_reference_comps.append(comp)
225
+ return full_reference_comps
@@ -144,12 +144,17 @@ class IncrementalCov(object):
144
144
  cov = []
145
145
  else:
146
146
  cov = cov_lines[file]
147
+ with open(file, "r") as fp:
148
+ change_content = fp.readlines()
147
149
 
148
150
  for change in change_lines:
149
151
  if filters[change - 1] == 0:
150
152
  continue
151
153
  temp_changes.append(change)
152
154
  if not cov or not cov[change - 1]:
155
+ content = change_content[change - 1].strip()
156
+ if content.find("<const>") > 0:
157
+ continue
153
158
  temp_uncovers.append(change)
154
159
  lua_changes[file] = temp_changes
155
160
  uncovers[file] = temp_uncovers
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/python3
2
+ # coding: utf-8
3
+ # Copyright (c) 2024 Huawei Technologies Co., Ltd.
4
+ # openUBMC is licensed under Mulan PSL v2.
5
+ # You can use this software according to the terms and conditions of the Mulan PSL v2.
6
+ # You may obtain a copy of Mulan PSL v2 at:
7
+ # http://license.coscl.org.cn/MulanPSL2
8
+ # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
9
+ # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
10
+ # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11
+ # See the Mulan PSL v2 for more details.
12
+ """
13
+ Fixture package exposing reusable helpers for DBus tests.
14
+
15
+ Having this module allows imports such as `from fixture.busctl_type_converter import BusCtlTypeConverter`
16
+ to resolve correctly when running tests.
17
+ """
18
+
19
+ __all__ = [
20
+ "busctl_type_converter",
21
+ "common_config",
22
+ "dbus_gateway",
23
+ "dbus_mock_utils",
24
+ "dbus_response_handler",
25
+ "dbus_signature",
26
+ "dbus_type_converter",
27
+ "DBusLibrary",
28
+ ]
29
+