Skip to content
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
10 changes: 1 addition & 9 deletions tcbuilder/cli/dt.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from tcbuilder.backend import kernel as kernel_be
from tcbuilder.backend.common import \
(checkout_dt_git_repo, images_unpack_executed, is_file_type_fit, set_output_ownership,
unpacked_image_type, update_dt_git_repo, get_src_sysroot_dir)
update_dt_git_repo, get_src_sysroot_dir)
from tcbuilder.backend.kernelfit import KernelFit
from tcbuilder.backend.deploy import get_image_bootloader
from tcbuilder.errors import \
Expand All @@ -38,9 +38,6 @@ def do_dt_status(_args):
f"Device Tree and Device Tree Overlay customization is not supported for {img_bootld} "
"bootloader. Aborting.")

if unpacked_image_type() == "raw":
raise InvalidDataError("Command not supported for WIC/raw images. Aborting.")

dtb_basename = dt_be.get_current_dtb_basename()
if not dtb_basename:
log.error("error: cannot identify the enabled device tree in the image "
Expand Down Expand Up @@ -152,11 +149,6 @@ def dt_apply(dts_path, *, include_dirs=None):
f"Device Tree and Device Tree Overlay customization is not supported for {img_bootld} "
"bootloader. Aborting.")

if unpacked_image_type() == "raw":
raise InvalidDataError(
"Device tree customization is not supported for WIC/raw images. "
"Aborting.")

unpacked_kernel_path = kernel_be.find_kernel_in_sysroot()
kernel_is_fit = is_file_type_fit(unpacked_kernel_path)
log.debug(f"dt_apply: kernel_is_fit={kernel_is_fit}")
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ $TESTCASES_DIR/wic/images-unpack.bats \
$TESTCASES_DIR/wic/images-download.bats \
$TESTCASES_DIR/wic/union.bats \
$TESTCASES_DIR/wic/deploy.bats \
$TESTCASES_DIR/wic/dt.bats \
$TESTCASES_DIR/wic/dto.bats \
$TESTCASES_DIR/wic/splash.bats \
$TESTCASES_DIR/wic/splashconfig.bats \
Expand All @@ -57,7 +58,8 @@ export DEVICE_ADDR=$TCB_DEVICE
export DEVICE_USER="torizon"

export WIC_MACHINES="intel-corei7-64 qemux86-64 raspberrypi4-64 \
am62xx-evm am62pxx-evm am62lxx-evm beagley-ai"
am62xx-evm am62pxx-evm am62lxx-evm beagley-ai \
luna-sl1680 sl1680"

# DEVICE_PORT defines the default SSH port used in test cases
if [ ! -z "$TCB_PORT" ]; then
Expand Down
92 changes: 92 additions & 0 deletions tests/integration/testcases/wic/dt.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
bats_load_library 'bats/bats-support/load.bash'
bats_load_library 'bats/bats-assert/load.bash'
bats_load_library 'bats/bats-file/load.bash'
load '../lib/common.bash'

setup_file() {
local UNSUPPORTED_MACHINES="intel-corei7-64 qemux86-64"
local ARCHIVE='/storage/ostree-archive/'
local DEFAULT_REF='base'
torizoncore-builder images --remove-storage unpack "${DEFAULT_WIC_IMAGE}"
IMG_MACHINE=$(torizoncore-builder-shell "ostree --repo=${ARCHIVE} show \
--print-metadata-key='oe.machine' ${DEFAULT_REF}" | tr -d "'")

case "${UNSUPPORTED_MACHINES}" in
*${IMG_MACHINE}* )
UNSUPPORTED_MACHINE="1"
;;
*)
UNSUPPORTED_MACHINE="0"
;;
esac

export UNSUPPORTED_MACHINE
export IMG_MACHINE
}

setup() {
if [ "${UNSUPPORTED_MACHINE}" = "1" ]; then
skip "DT/DTO customization is not supported for ${IMG_MACHINE}"
fi
}

@test "dt: run without parameters" {
run torizoncore-builder dt
assert_failure 2
assert_output --partial "error: the following arguments are required: cmd"
}

@test "dt: check help output" {
run torizoncore-builder dt --help
assert_success
assert_output --partial "{status,checkout,apply}"
}


@test "dt: check currently enabled device tree without images unpack" {
torizoncore-builder-clean-storage

run torizoncore-builder dt status
assert_failure
assert_output --partial "Error: could not find an Easy Installer or WIC image in the storage."
assert_output --partial "Please use the 'images' command to unpack an image before running this command."
}

@test "dt: check currently enabled device tree" {
torizoncore-builder images --remove-storage unpack $DEFAULT_WIC_IMAGE

run torizoncore-builder dt status
assert [ $? = "0" -o $? = "1" ]
assert_output --regexp "Current device tree is|error: cannot identify the enabled device tree"
}

@test "dt: apply device tree in the image without images unpack" {
torizoncore-builder-clean-storage

run torizoncore-builder dt apply some_dto_file
assert_failure
assert_output --partial "Error: could not find an Easy Installer or WIC image in the storage."
assert_output --partial "Please use the 'images' command to unpack an image before running this command."
}

@test "dt: apply device tree in the image" {
torizoncore-builder images --remove-storage unpack $DEFAULT_WIC_IMAGE
torizoncore-builder-shell "rm -rf device-trees"

local exp_dts_path="$SAMPLES_DIR/dts/small-nodev.dts"
local exp_dts_name=${exp_dts_path##*/}
local exp_dtb_name=${exp_dts_name%%.*}.dtb

run torizoncore-builder dt apply "${exp_dts_path}"
assert_success
assert_output --regexp "Device tree.*successfully applied"

run torizoncore-builder dt status
assert_success
assert_output --partial "$DTB"

echo "Checking existence of device-tree file in kernel dtb directory."
run torizoncore-builder-shell \
"DTB=\$(find /storage/dt/ -wholename '*/usr/lib/modules/*/dtb/${exp_dtb_name}'); echo \${DTB}; test -n \"\${DTB}\""
assert_success
}
Loading