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

tests: application_development: Add spdx SBOM test #83359

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions scripts/west_commands/spdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ def do_run_init(self, args):
if query_ready:
self.inf("initialized; run `west build` then run `west spdx`")
else:
self.err("Couldn't create CMake file-based API query directory")
self.err("You can manually create an empty file at $BUILDDIR/.cmake/api/v1/query/codemodel-v2")
self.die("Couldn't create CMake file-based API query directory\n"
"You can manually create an empty file at "
"$BUILDDIR/.cmake/api/v1/query/codemodel-v2")

def do_run_spdx(self, args):
if not args.build_dir:
Expand Down Expand Up @@ -110,4 +111,5 @@ def do_run_spdx(self, args):
# create the directory
os.makedirs(cfg.spdxDir, exist_ok=False)

makeSPDX(cfg)
if not makeSPDX(cfg):
self.die("Failed to create SPDX output")
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2024 Basalte bv
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})

project(sbom_spdx)
target_sources(app PRIVATE ${ZEPHYR_BASE}/misc/empty_file.c)

enable_testing()
include(CTest)

add_test(NAME spdx_gen COMMAND west spdx -d ${CMAKE_BINARY_DIR})
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2024 Basalte bv
# SPDX-License-Identifier: Apache-2.0

# WARNING: the PreLoad.cmake is an undocumented feature
# We need to create the CMake file API query before the configure step

execute_process(
COMMAND west spdx --init -d ${CMAKE_BINARY_DIR}
COMMAND_ERROR_IS_FATAL ANY
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_BUILD_OUTPUT_META=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
common:
tags:
- spdx
integration_platforms:
- native_sim
harness: ctest
tests:
sbom.spdx: {}
Loading