Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(kbuild): Add kselftest disable option #2702

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 47 additions & 38 deletions kernelci/kbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- cross_compile: cross compile prefix
- cross_compile_compat: cross compile compat prefix
- dtbs_check: run "make dtbs_check" ONLY, it is actually a separate test
- kselftest: false - do not build kselftest
"""

import os
Expand All @@ -38,14 +39,14 @@


CROS_CONFIG_URL = \
"https://chromium.googlesource.com/chromiumos/third_party/kernel/+archive/refs/heads/{branch}/chromeos/config.tar.gz" # noqa

Check warning on line 42 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

Line too long (129/100)
LEGACY_CONFIG = [
'config/core/build-configs.yaml',
'/etc/kernelci/core/build-configs.yaml',
]
FW_GIT = "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git" # noqa

# TODO: find a way to automatically fetch this information

Check warning on line 49 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

TODO: find a way to automatically fetch this information
LATEST_LTS_MAJOR = 6
LATEST_LTS_MINOR = 6

Expand Down Expand Up @@ -151,7 +152,10 @@
self._dtbs_check = params['dtbs_check']
else:
self._dtbs_check = False
self._disable_modules = params.get('disable_modules', False)
if params.get('kselftest') == 'disable':
self._kfselftest = False
else:
self._kfselftest = True
self._apijobname = jobname
self._steps = []
self._artifacts = []
Expand Down Expand Up @@ -205,7 +209,7 @@
)
self._full_artifacts = jsonobj['full_artifacts']
self._dtbs_check = jsonobj['dtbs_check']
self._disable_modules = jsonobj['disable_modules']
self._kfselftest = jsonobj['kfselftest']
return
raise ValueError("No valid arguments provided")

Expand Down Expand Up @@ -303,11 +307,11 @@
if not self._dtbs_check:
self._artifacts.append("build_kimage.log")
self._artifacts.append("build_kimage_stderr.log")
if not self._disable_modules:
self._artifacts.append("build_modules.log")
self._artifacts.append("build_modules_stderr.log")
self._artifacts.append("build_kselftest.log")
self._artifacts.append("build_kselftest_stderr.log")
self._artifacts.append("build_modules.log")
self._artifacts.append("build_modules_stderr.log")
if self._kfselftest:
self._artifacts.append("build_kselftest.log")
self._artifacts.append("build_kselftest_stderr.log")
# disable DTBS for some archs
if self._arch not in DTBS_DISABLED:
self._artifacts.append("build_dtbs.log")
Expand Down Expand Up @@ -448,8 +452,8 @@
sys.exit(1)

print(f"Searching for fragment {fragname} in {cfg_path}")
if 'fragments' in yml:

Check failure on line 455 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

Value 'yml' doesn't support membership test
frag = yml['fragments']

Check failure on line 456 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

Value 'yml' is unsubscriptable
else:
print("No fragments section in config file")
self.submit_failure("No fragments section in config file")
Expand All @@ -475,7 +479,7 @@
elif fragment.startswith("CONFIG_"):
content = fragment + '\n'
else:
# TODO: implement 'path' option properly

Check warning on line 482 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

TODO: implement 'path' option properly
content = self.add_legacy_fragment(fragment)

fragfile = os.path.join(self._fragments_dir, f"{num}.config")
Expand Down Expand Up @@ -524,8 +528,8 @@
for i in range(0, fragnum):
self.addcmd("./scripts/kconfig/merge_config.sh" +
f" -m .config {self._fragments_dir}/{i}.config")
# TODO: olddefconfig should be optional/configurable

Check warning on line 531 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

TODO: olddefconfig should be optional/configurable
# TODO: log all warnings/errors of olddefconfig to separate file

Check warning on line 532 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

TODO: log all warnings/errors of olddefconfig to separate file
self.addcmd("make olddefconfig")
self.addcmd(f"cp .config {self._af_dir}/")
self.addcmd("cd ..")
Expand All @@ -533,24 +537,24 @@

def _generate_script(self):
""" Generate shell script for complete build """
# TODO(nuclearcat): Fetch firmware only if needed

Check warning on line 540 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

TODO(nuclearcat): Fetch firmware only if needed
print("Generating shell script")
fragnum = self._parse_fragments(firmware=True)
self._merge_frags(fragnum)
if not self._dtbs_check:
# TODO: verify if CONFIG_EXTRA_FIRMWARE have any files

Check warning on line 545 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

TODO: verify if CONFIG_EXTRA_FIRMWARE have any files
# We can check that if fragments have CONFIG_EXTRA_FIRMWARE
self._fetch_firmware()
self._build_kernel()
if not self._disable_modules:
self._build_modules()
self._build_kselftest()
self._build_modules()
if self._kfselftest:
self._build_kselftest()
if self._arch not in DTBS_DISABLED:
self._build_dtbs()
self._package_kimage()
if not self._disable_modules:
self._package_modules()
self._package_kselftest()
self._package_modules()
if self._kfselftest:
self._package_kselftest()
if self._arch not in DTBS_DISABLED:
self._package_dtbs()
else:
Expand Down Expand Up @@ -850,7 +854,7 @@
api.node.update(node)
except requests.exceptions.HTTPError as err:
err_msg = json.loads(err.response.content).get("detail", [])
self.log.error(err_msg)

Check failure on line 857 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

Instance of 'KBuild' has no 'log' member
return

def submit(self, retcode, dry_run=False):
Expand Down Expand Up @@ -923,11 +927,12 @@
# TODO(nuclearcat):
# Add child_nodes for each sub-step
# do we have kselftest_tar_gz in artifact keys? then node is ok
kselftest_result = 'fail'
for artifact in af_uri:
if artifact == 'kselftest_tar_gz':
kselftest_result = 'pass'
break
if self._kfselftest:
kselftest_result = 'fail'
for artifact in af_uri:
if artifact == 'kselftest_tar_gz':
kselftest_result = 'pass'
break

results = {
'node': {
Expand All @@ -953,26 +958,30 @@
results['node']['data']['fragments'] = self._fragments
results['node']['data']['config_full'] = self._config_full

kselftest_node = self._node.copy()
# remove id to not have same as parent
kselftest_node.pop('id')
kselftest_node['name'] = kselftest_node['name'] + "-kselftest"
kselftest_node['kind'] = 'test'
existing_path = kselftest_node.get('path')
if existing_path and isinstance(existing_path, list):
kselftest_node['path'] = existing_path.append(kselftest_node['name'])
kselftest_node['parent'] = self._node['id']
kselftest_node['data'] = results['node']['data'].copy()
kselftest_node['artifacts'] = None
kselftest_node['state'] = 'done'
kselftest_node['result'] = kselftest_result

child_nodes = [
{
'node': kselftest_node,
'child_nodes': []
}
]
# if we have kselftest, we need to add child node
if self._kfselftest:
kselftest_node = self._node.copy()
# remove id to not have same as parent
kselftest_node.pop('id')
kselftest_node['name'] = kselftest_node['name'] + "-kselftest"
kselftest_node['kind'] = 'test'
existing_path = kselftest_node.get('path')
if existing_path and isinstance(existing_path, list):
kselftest_node['path'] = existing_path.append(kselftest_node['name'])
kselftest_node['parent'] = self._node['id']
kselftest_node['data'] = results['node']['data'].copy()
kselftest_node['artifacts'] = None
kselftest_node['state'] = 'done'
kselftest_node['result'] = kselftest_result

child_nodes = [
{
'node': kselftest_node,
'child_nodes': []
}
]
else:
child_nodes = []

results['child_nodes'] = child_nodes
api_helper = kernelci.api.helper.APIHelper(api)
Expand Down
Loading