diff --git a/tests/lib/assertions/pc-kernel-snap-decl-extras.json b/tests/lib/assertions/pc-kernel-snap-decl-extras.json new file mode 100644 index 00000000000..775ab3ef230 --- /dev/null +++ b/tests/lib/assertions/pc-kernel-snap-decl-extras.json @@ -0,0 +1,26 @@ +{ + "format": "5", + "slots": { + "cuda-driver-libs": { + "allow-installation": "true" + }, + "egl-driver-libs": { + "allow-installation": "true" + }, + "gbm-driver-libs": { + "allow-installation": "true" + }, + "opengl-driver-libs": { + "allow-installation": "true" + }, + "opengles-driver-libs": { + "allow-installation": "true" + }, + "vulkan-driver-libs": { + "allow-installation": "true" + }, + "nvidia-video-driver-libs": { + "allow-installation": "true" + } + } +} diff --git a/tests/lib/nested.sh b/tests/lib/nested.sh index 8be7bb98c4e..f85a2248b24 100755 --- a/tests/lib/nested.sh +++ b/tests/lib/nested.sh @@ -17,6 +17,7 @@ : "${NESTED_SIGN_SNAPS_FAKESTORE:=false}" : "${NESTED_REPACK_FOR_FAKESTORE:=false}" : "${NESTED_FAKESTORE_SNAP_DECL_PC_GADGET:=}" +: "${NESTED_FAKESTORE_SNAP_DECL_PC_KERNEL:=}" : "${NESTED_UBUNTU_IMAGE_SNAPPY_FORCE_SAS_URL:=}" : "${NESTED_UBUNTU_IMAGE_PRESEED_KEY:=}" : "${NESTED_UBUNTU_SEED_SIZE:=}" @@ -754,7 +755,16 @@ nested_prepare_kernel() { # sign the pc-kernel snap with fakestore if requested if [ "$NESTED_SIGN_SNAPS_FAKESTORE" = "true" ]; then - "$TESTSTOOLS"/store-state make-snap-installable --noack "$NESTED_FAKESTORE_BLOB_DIR" "$(nested_get_extra_snaps_path)/$output_name" "$snap_id" + local extra_decl_args="" + local kernel_decl="$NESTED_FAKESTORE_SNAP_DECL_PC_KERNEL" + if [ -z "$kernel_decl" ] ; then + kernel_decl="$TESTSLIB/assertions/pc-kernel-snap-decl-extras.json" + fi + if [ -n "$kernel_decl" ]; then + extra_decl_args="--extra-decl-json $kernel_decl" + fi + # shellcheck disable=SC2086 + "$TESTSTOOLS"/store-state make-snap-installable --noack $extra_decl_args "$NESTED_FAKESTORE_BLOB_DIR" "$(nested_get_extra_snaps_path)/$output_name" "$snap_id" fi fi } diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh index e7b3121c9de..4e96429cfcc 100755 --- a/tests/lib/prepare.sh +++ b/tests/lib/prepare.sh @@ -854,15 +854,25 @@ repack_core_snap_with_tweaks() { UNPACK_DIR="$(mktemp -d /tmp/core-unpack.XXXXXXXX)" unsquashfs -no-progress -f -d "$UNPACK_DIR" "$CORESNAP" - mkdir -p "$UNPACK_DIR"/etc/systemd/journald.conf.d - cat < "$UNPACK_DIR"/etc/systemd/journald.conf.d/to-console.conf + # determine destination directory for systemd configuration files + # core26+ uses /usr/share/factory/writable/system-data/etc/ + # core24 and earlier use /etc/ + local DEST_ETC + if [ -e "$UNPACK_DIR/usr/share/factory/writable" ]; then + DEST_ETC="$UNPACK_DIR/usr/share/factory/writable/system-data/etc" + else + DEST_ETC="$UNPACK_DIR/etc" + fi + + mkdir -p "$DEST_ETC"/systemd/journald.conf.d + cat < "$DEST_ETC"/systemd/journald.conf.d/to-console.conf [Journal] ForwardToConsole=yes TTYPath=/dev/ttyS0 MaxLevelConsole=debug EOF - mkdir -p "$UNPACK_DIR"/etc/systemd/system/snapd.service.d -cat < "$UNPACK_DIR"/etc/systemd/system/snapd.service.d/logging.conf + mkdir -p "$DEST_ETC"/systemd/system/snapd.service.d +cat < "$DEST_ETC"/systemd/system/snapd.service.d/logging.conf [Service] Environment=SNAPD_DEBUG_HTTP=7 SNAPD_DEBUG=1 SNAPPY_TESTING=1 SNAPD_CONFIGURE_HOOK_TIMEOUT=30s StandardOutput=journal+console @@ -870,7 +880,7 @@ StandardError=journal+console EOF if [ "${NESTED_REPACK_FOR_FAKESTORE-}" = "true" ]; then - cat < "$UNPACK_DIR"/etc/systemd/system/snapd.service.d/store.conf + cat < "$DEST_ETC"/systemd/system/snapd.service.d/store.conf [Service] Environment=SNAPPY_FORCE_API_URL=http://10.0.2.2:11028 EOF diff --git a/tests/lib/tools/build_kernel_with_comps.sh b/tests/lib/tools/build_kernel_with_comps.sh index d952d7bf97e..7eabdf90ea7 100755 --- a/tests/lib/tools/build_kernel_with_comps.sh +++ b/tests/lib/tools/build_kernel_with_comps.sh @@ -39,16 +39,19 @@ description: kernel component for testing purposes EOF # Replace _ or - with [_-], as it can be any of these glob_mod_name=$(printf '%s' "$mod_name" | sed -r 's/[-_]/[-_]/g') - module_path=$(find kernel -name "${glob_mod_name}.ko*") - mapfile -t module_path <<< "$module_path" - cp --update=none "${module_path[@]}" "$comp_ko_dir" + # TODO: search only in kernel/modules to avoid duplicates (pc-kernel in + # 26/edge has both modules/ and lib/modules/). remove this hack once + # the kernel snap is fixed + module_path=$(find kernel/modules -name "${glob_mod_name}.ko*") + cp "$module_path" "$comp_ko_dir" snap pack --filename="${kernel_name}+${comp_name}".comp "$comp_name" # Create kernel without the kernel module - rm "${module_path[@]}" - # depmod wants a lib subdir - mkdir -p kernel/lib - ln -s ../modules kernel/lib/modules + rm "$module_path" + if [ ! -e kernel/lib/modules ]; then + mkdir -p kernel/lib + ln -s ../modules kernel/lib/modules + fi depmod -b kernel/ "$kern_ver" rm "${kernel_snap_file}" # append component meta-information diff --git a/tests/nested/manual/kernel-modules-components/task.yaml b/tests/nested/manual/kernel-modules-components/task.yaml index 5f2d9a51152..a7ffcf79465 100644 --- a/tests/nested/manual/kernel-modules-components/task.yaml +++ b/tests/nested/manual/kernel-modules-components/task.yaml @@ -7,8 +7,6 @@ systems: - -ubuntu-1* - -ubuntu-20* - -ubuntu-22* - # FIXME - - -ubuntu-26* environment: # Test both encrypted and unencrypted cases diff --git a/tests/nested/manual/remodel-with-components-offline/task.yaml b/tests/nested/manual/remodel-with-components-offline/task.yaml index 1e0b6c5dc5b..cd531988983 100644 --- a/tests/nested/manual/remodel-with-components-offline/task.yaml +++ b/tests/nested/manual/remodel-with-components-offline/task.yaml @@ -10,8 +10,6 @@ systems: - -ubuntu-1* - -ubuntu-20* - -ubuntu-22* - # FIXME - - -ubuntu-26* environment: INITIAL_MODEL_JSON: $TESTSLIB/assertions/test-snapd-component-remodel-initial-pc-VERSION.json @@ -86,9 +84,17 @@ execute: | kernel_id='pYVQrBcKmBa0mZ4CCN7ExT6jH8rY1hza' + # include declaration extras for driver slots + extra_decl_args="" + if [ "$(tests.nested show version)" -ge 26 ]; then + extra_decl_args="--extra-decl-json $TESTSLIB/assertions/pc-kernel-snap-decl-extras.json" + fi + # bump the available kernel version in the fake store + #shellcheck disable=SC2086 "${TESTSTOOLS}"/store-state make-snap-installable --noack \ --revision 2 \ + $extra_decl_args \ "${NESTED_FAKESTORE_BLOB_DIR}" \ ./pc-kernel-with-comps.snap \ "${kernel_id}" diff --git a/tests/nested/manual/remodel-with-components/task.yaml b/tests/nested/manual/remodel-with-components/task.yaml index 98354d50d3f..0f8739d6876 100644 --- a/tests/nested/manual/remodel-with-components/task.yaml +++ b/tests/nested/manual/remodel-with-components/task.yaml @@ -8,8 +8,8 @@ details: | validates that the newly created system can be rebooted into. systems: - # FIXME: make it work on 26 - ubuntu-24* + - ubuntu-26* environment: INITIAL_MODEL_JSON: $TESTSLIB/assertions/test-snapd-component-remodel-initial-pc-VERSION.json @@ -84,9 +84,17 @@ execute: | kernel_id='pYVQrBcKmBa0mZ4CCN7ExT6jH8rY1hza' + # include declaration extras for driver slots + extra_decl_args="" + if [ "$(tests.nested show version)" -ge 26 ]; then + extra_decl_args="--extra-decl-json $TESTSLIB/assertions/pc-kernel-snap-decl-extras.json" + fi + # bump the available kernel version in the fake store + #shellcheck disable=SC2086 "${TESTSTOOLS}"/store-state make-snap-installable --noack \ --revision 2 \ + $extra_decl_args \ "${NESTED_FAKESTORE_BLOB_DIR}" \ ./pc-kernel-with-comps.snap \ "${kernel_id}"