File: test_vminstall.bats

package info (click to toggle)
grml-debootstrap 0.124
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 460 kB
  • sloc: sh: 2,525; python: 165; makefile: 70; ansic: 49
file content (39 lines) | stat: -rw-r--r-- 890 bytes parent folder | download
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
#!/usr/bin/env bats

mountpath="/mnt"
image="/srv/debian.img"

setup() {
  if ! mountpoint "${mountpath}" &>/dev/null ; then
    partition="$(kpartx -asv ${image} | awk '/add/ {print $3}')"
    mount "/dev/mapper/${partition}" "${mountpath}"
  fi
}

teardown() {
  if mountpoint "${mountpath}" &>/dev/null ; then
    umount "${mountpath}"
    kpartx -vd "${image}"
  fi
}

@test "ensure grub configuration is present" {
  run ls "${mountpath}"/boot/grub/grub.cfg
  [ "$status" -eq 0 ]
}

@test "ensure eatmydata package is present" {
  run chroot "${mountpath}" dpkg --list eatmydata
  [ "$status" -eq 0 ]
}

@test "kernel is present" {
  run ls "${mountpath}"/boot/vmlinuz-*
  [ "$status" -eq 0 ]
}

@test "debian_version exists and is valid version" {
  run cat "${mountpath}/etc/debian_version"
  [ "$status" -eq 0 ]
  [[ "$output" == [0-9].[0-9]* ]] || [[ "$output" == 'trixe/sid' ]]
}