github.com/u-root/u-root@v7.0.1-0.20200915234505-ad7babab0a8e+incompatible/integration/generic-tests/kexec_test.go (about) 1 // Copyright 2018 the u-root Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build !race 6 7 package integration 8 9 import ( 10 "testing" 11 "time" 12 13 "github.com/u-root/u-root/pkg/qemu" 14 "github.com/u-root/u-root/pkg/vmtest" 15 ) 16 17 // TestMountKexec tests that kexec occurs correctly by checking the kernel cmdline. 18 // This is possible because the generic initramfs ensures that we mount the 19 // testdata directory containing the initramfs and kernel used in the VM. 20 func TestMountKexec(t *testing.T) { 21 // TODO: support arm 22 if vmtest.TestArch() != "amd64" && vmtest.TestArch() != "arm64" { 23 t.Skipf("test not supported on %s", vmtest.TestArch()) 24 } 25 26 q, cleanup := vmtest.QEMUTest(t, &vmtest.Options{ 27 TestCmds: []string{ 28 "CMDLINE = (cat /proc/cmdline)", 29 "SUFFIX = $CMDLINE[-7:]", 30 "echo SAW $SUFFIX", 31 "kexec -i /testdata/initramfs.cpio -c $CMDLINE' KEXEC=Y' /testdata/kernel", 32 }, 33 QEMUOpts: qemu.Options{ 34 Timeout: 20 * time.Second, 35 }, 36 }) 37 defer cleanup() 38 39 if err := q.Expect("SAW KEXEC=Y"); err != nil { 40 t.Fatal(err) 41 } 42 }