File: smoke-amd64.yarn

package info (click to toggle)
vmdb2 0.22-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 612 kB
  • sloc: python: 1,894; sh: 222; makefile: 26
file content (101 lines) | stat: -rw-r--r-- 3,017 bytes parent folder | download | duplicates (2)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Smoke test vmdb2-built images

This yarn file builds a basic image, and runs it under Qemu. The image
is configured to have a serial console enabled, and the scenario below
will log in as root (no password), and command the virtual machine to
power off. If this works, the image is at least minimally functional,
so the "smoke test" passes.

More elaborate testing can be added, but smoke testing is enough for
now.

To run this yarn file, you need to run it as root (since it needs to
build an image as root), and you need to run on a system where
qemu-system-x86_64 is installed. Additionally, you need to add the
following option to yarn:
    EXAMPLE
    --env ROOTFS_TARBALL=/path/to/rootfs/tarball

This means vmdb2 will use the given tarball when creating an image,
and if the tarball doesn't exist yet, it will create it. This makes
testing multiple time much faster.

    SCENARIO smoke test amd64 image
    WHEN user runs vmdb smoke-amd64.vmdb --output smoke-amd64.img
    THEN user can BIOS boot smoke-amd64.img and power it off from root shell

    WHEN user runs vmdb smoke-uefi-amd64.vmdb --output smoke-uefi-amd64.img
    THEN user can UEFI boot smoke-uefi-amd64.img and power it off from root shell

    IMPLEMENTS WHEN user runs vmdb (\S+) --output (\S+)
    "$SRCDIR/vmdb2" "$SRCDIR/$MATCH_1" \
        --output "$DATADIR/$MATCH_2" \
        --log "$DATADIR/vmdb.log" \
        --verbose \
        --rootfs-tarball "$ROOTFS_TARBALL"

    IMPLEMENTS THEN user can BIOS boot (\S+) and power it off from root shell
    cd "$DATADIR"
    img="$MATCH_1"
    cat << EOF > run.sh
    qemu-system-x86_64 -drive file="$img",format=raw -m 1024 -nographic
    EOF
    chmod a+rx run.sh
    cat << EOF > expect.txt
    set timeout 300
    proc abort {} {
        puts "ERROR ERROR\n"
        exit 1
    }
    spawn ./run.sh
    expect "login: "
    send "root\n"
    expect "# "
    send "poweroff\r"
    set timeout 5
    expect {
        "reboot: Power down" {puts poweroffing\n}
        eof abort
        timeout abort
    }
    expect eof
    wait
    EOF
    expect -d expect.txt > expect.out

    IMPLEMENTS THEN user can UEFI boot (\S+) and power it off from root shell
    cd "$DATADIR"
    img="$MATCH_1"
    cat << EOF > run.sh
    cp /usr/share/OVMF/OVMF_VARS_4M.fd .
    qemu-system-x86_64 \
      -machine q35 \
      -cpu max \
      -m 1024 \
      -drive if=pflash,format=raw,unit=0,file=/usr/share/OVMF/OVMF_CODE_4M.fd,readonly=on \
      -drive if=pflash,format=raw,unit=1,file=OVMF_VARS_4M.fd \
      -drive format=raw,file="$img" \
      -nographic
    EOF
    chmod a+rx run.sh
    cat << EOF > expect.txt
    set timeout 600
    proc abort {} {
        puts "ERROR ERROR\n"
        exit 1
    }
    spawn ./run.sh
    expect "login: "
    send "root\n"
    expect "# "
    send "poweroff\r"
    set timeout 5
    expect {
        "reboot: Power down" {puts poweroffing\n}
        eof abort
        timeout abort
    }
    expect eof
    wait
    EOF
    expect -d expect.txt > expect.out