File: task.yaml

package info (click to toggle)
snapd 2.74.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 81,428 kB
  • sloc: sh: 16,966; ansic: 16,788; python: 11,332; makefile: 1,897; exp: 190; awk: 58; xml: 22
file content (61 lines) | stat: -rw-r--r-- 2,413 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
summary: Check that a kernel can be reverted after it has booted

details: |
  This test checks that a kernel snap that has not finished installation but
  that already booted can be reverted properly if something else fails, like a
  post-refresh hook.

systems: [ubuntu-*]

execute: |
  echo "Build kernel with failing post-refresh hook"
  VERSION="$(tests.nested show version)"

  unsquashfs -d pc-kernel "$(tests.nested get extra-snaps-path)"/pc-kernel.snap
  HOOKS_D=pc-kernel/meta/hooks/
  POST_REFRESH_P=$HOOKS_D/post-refresh
  mkdir -p "$HOOKS_D"
  cat > "$POST_REFRESH_P" << EOF
  \#!/bin/bash -ex
  exit 1
  EOF
  chmod +x "$POST_REFRESH_P"
  snap pack pc-kernel/ --filename=pc-kernel_badhook.snap

  echo "Wait for the system to be seeded first"
  remote.exec "sudo snap wait system seed.loaded"

  boot_id="$(tests.nested boot-id)"

  echo "Install kernel with failing post-refresh hook"
  remote.push pc-kernel_badhook.snap
  chg_id=$(remote.exec 'sudo snap install --dangerous --no-wait ./pc-kernel_badhook.snap')

  echo "Wait for reboot"
  remote.wait-for reboot "$boot_id"

  boot_id="$(tests.nested boot-id)"
  echo "Wait for second reboot after post-refresh hook failure"
  remote.wait-for reboot "$boot_id"

  boot_id="$(tests.nested boot-id)"
  # wait for change to finish with error
  not remote.exec sudo snap watch "$chg_id"
  # make sure that no additional reboots have happened while the change finished
  test "$boot_id" = "$(tests.nested boot-id)"

  echo "Check that change finished with failure and that the old snap is being used"
  remote.exec "snap info pc-kernel | MATCH 'installed:.*\(x1\)'"
  remote.exec "snap changes | MATCH \"^$chg_id.*Error\""
  if [ "$VERSION" -ge 20 ]; then
      # shellcheck disable=SC2016
      remote.exec 'test $(readlink /run/mnt/ubuntu-boot/EFI/ubuntu/kernel.efi) = pc-kernel_x1.snap/kernel.efi'
      remote.exec 'cat /run/mnt/ubuntu-boot/EFI/ubuntu/grubenv | MATCH "^kernel_status=$"'
      echo "Check that modeenv has only the old kernel"
      remote.exec 'cat /var/lib/snapd/modeenv | MATCH "^current_kernels=pc-kernel_x1.snap$"'
  else
      remote.exec 'cat /boot/grub/grubenv | MATCH "^snap_kernel=pc-kernel_x1.snap$"'
      remote.exec 'cat /boot/grub/grubenv | MATCH "^snap_mode=$"'
      remote.exec 'cat /boot/grub/grubenv | MATCH "^snap_try_kernel=$"'
      remote.exec 'cat /proc/cmdline | MATCH snap_kernel=pc-kernel_x1.snap'
  fi