Skip to content

Commit

Permalink
qemu-arm64: add unit test for func appendImage on aarch64
Browse files Browse the repository at this point in the history
Since we overrided the func appendImage for aarch64, we should also
provide related unit test.

Fixes: kata-containers#843

Signed-off-by: Penny Zheng <penny.zheng@arm.com>
  • Loading branch information
Pennyzct committed Mar 5, 2019
1 parent 83cb8e8 commit 6ae1426
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions virtcontainers/qemu_arm64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,33 @@ func TestQemuArm64AppendBridges(t *testing.T) {

assert.Equal(expectedOut, devices)
}

func TestQemuArm64AppendImage(t *testing.T) {
var devices []govmmQemu.Device
assert := assert.New(t)
arm64 := newTestQemu(QemuVirt)

f, err := ioutil.TempFile("", "img")
assert.NoError(err)
defer func() { _ = f.Close() }()
defer func() { _ = os.Remove(f.Name()) }()

imageStat, err := f.Stat()
assert.NoError(err)

expectedOut := []govmmQemu.Device{
govmmQemu.Object{
Driver: govmmQemu.NVDIMM,
Type: govmmQemu.MemoryBackendFile,
DeviceID: "nv0",
ID: "mem0",
MemPath: f.Name(),
Size: (uint64)(imageStat.Size()),
},
}

devices, err = arm64.appendImage(devices, f.Name())
assert.NoError(err)

assert.Equal(expectedOut, devices)
}

0 comments on commit 6ae1426

Please sign in to comment.