File: task.yaml

package info (click to toggle)
snapd 2.72-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 80,412 kB
  • sloc: sh: 16,506; ansic: 16,211; python: 11,213; makefile: 1,919; exp: 190; awk: 58; xml: 22
file content (59 lines) | stat: -rw-r--r-- 1,996 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
summary: Enable and use coredump options on UC

details: |
  Use coredump options and ensure that systemd-coredump can generate
  core files when configured to do so.

systems: [-ubuntu-core-1*, -ubuntu-core-20*, -ubuntu-core-22*]

restore: |
  rm -f /var/lib/systemd/coredump/*

execute: |
  # To get VERSION_ID defined
  . /etc/os-release

  cfg_path=/etc/systemd/coredump.conf.d/ubuntu-core.conf

  # coredumps should be initially disabled
  expect=$(printf "[Coredump]\nStorage=none\nProcessSizeMax=0\n")
  test "$expect" = "$(cat $cfg_path)"

  # Install snap with a service that simply waits
  cp -r "$TESTSLIB"/snaps/core-dump-snap .
  core_dump_d=core-dump-snap
  BASE=core"$VERSION_ID"
  sed -i "s/##BASE##/$BASE/" "$core_dump_d"/meta/snap.yaml
  DUMP_SNAP_FILE=core-dump-snap.snap
  snap pack "$core_dump_d" --filename="$DUMP_SNAP_FILE"
  snap install --dangerous "$DUMP_SNAP_FILE"

  # try to generate dump
  CRASH_PID=$(retry --wait 1 -n 5 pgrep crash.sh)
  kill -ABRT "$CRASH_PID"
  retry --wait 1 -n 5 sh -c "coredumpctl | MATCH 'none .*/bin/bash'"
  # This cleans-up the coredumctl list
  journalctl --rotate; journalctl --vacuum-time=1ms

  # enable coredump with a max use size
  max_use=10M
  snap set system system.coredump.enable=true
  snap set system system.coredump.maxuse="$max_use"

  expect=$(printf "[Coredump]\nStorage=external\nMaxUse=%s\n" "$max_use")
  test "$expect" = "$(cat $cfg_path)"

  # Force generation of core dump and check it is present
  CRASH_PID=$(retry --wait 1 -n 5 pgrep crash.sh)
  kill -ABRT "$CRASH_PID"
  retry --wait 1 -n 5 sh -c "coredumpctl | MATCH 'present .*/bin/bash'"
  coredumpctl dump --output=core
  test -s core
  # This cleans-up the coredumctl list and the core dump
  journalctl --rotate; journalctl --vacuum-time=1ms
  rm /var/lib/systemd/coredump/*

  # Finally, disable again
  snap set system system.coredump.enable=false
  expect=$(printf "[Coredump]\nStorage=none\nProcessSizeMax=0\n")
  test "$expect" = "$(cat $cfg_path)"