Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
runtime: Add testcases for ppc64le and arm64
Browse files Browse the repository at this point in the history
Fixes #302

Signed-off-by: Nitesh Konkar niteshkonkar@in.ibm.com
  • Loading branch information
nitkon committed May 31, 2018
1 parent 12e4dbe commit e14eab0
Show file tree
Hide file tree
Showing 3 changed files with 218 additions and 0 deletions.
114 changes: 114 additions & 0 deletions cli/kata-check_data_ppc64le_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// Copyright (c) 2018 IBM
//
// SPDX-License-Identifier: Apache-2.0
//

package main

const testCPUInfoTemplate = `
processor : 0
cpu : POWER8E (raw), altivec supported
clock : 3690.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 8
cpu : POWER8E (raw), altivec supported
clock : 3690.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 16
cpu : POWER8E (raw), altivec supported
clock : 2360.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 24
cpu : POWER8E (raw), altivec supported
clock : 2061.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 32
cpu : POWER8E (raw), altivec supported
clock : 3690.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 40
cpu : POWER8E (raw), altivec supported
clock : 3690.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 48
cpu : POWER8E (raw), altivec supported
clock : 3690.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 56
cpu : POWER8E (raw), altivec supported
clock : 3690.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 64
cpu : POWER8E (raw), altivec supported
clock : 3690.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 72
cpu : POWER8E (raw), altivec supported
clock : 3059.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 80
cpu : POWER8E (raw), altivec supported
clock : 2693.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 88
cpu : POWER8E (raw), altivec supported
clock : 2061.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 96
cpu : POWER8E (raw), altivec supported
clock : 3690.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 104
cpu : POWER8E (raw), altivec supported
clock : 2061.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 112
cpu : POWER8E (raw), altivec supported
clock : 2061.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 120
cpu : POWER8E (raw), altivec supported
clock : 2061.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 128
cpu : POWER8E (raw), altivec supported
clock : 3690.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 136
cpu : POWER8E (raw), altivec supported
clock : 2061.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 144
cpu : POWER8E (raw), altivec supported
clock : 2294.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 152
cpu : POWER8E (raw), altivec supported
clock : 2560.000000MHz
revision : 2.1 (pvr 004b 0201)
timebase : 512000000
platform : PowerNV
model : 8247-22L
machine : PowerNV 8247-22L
firmware : OPAL v3
`
52 changes: 52 additions & 0 deletions virtcontainers/qemu_arm64_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) 2018 IBM
//
// SPDX-License-Identifier: Apache-2.0
//

package virtcontainers

import (
"fmt"
"testing"

govmmQemu "github.com/intel/govmm/qemu"
"github.com/stretchr/testify/assert"
)

func newTestQemu(machineType string) qemuArch {
config := HypervisorConfig{
HypervisorMachineType: machineType,
}
return newQemuArch(config)
}

func TestQemuArm64CPUModel(t *testing.T) {
assert := assert.New(t)
arm64 := newTestQemu(virt)

expectedOut := defaultCPUModel
model := arm64.cpuModel()
assert.Equal(expectedOut, model)

arm64.enableNestingChecks()
expectedOut = defaultCPUModel + ",pmu=off"
model = arm64.cpuModel()
assert.Equal(expectedOut, model)
}

func TestQemuArm64MemoryTopology(t *testing.T) {
assert := assert.New(t)
arm64 := newTestQemu(virt)
memoryOffset := 1024

hostMem := uint64(1024)
mem := uint64(120)
expectedMemory := govmmQemu.Memory{
Size: fmt.Sprintf("%dM", mem),
Slots: defaultMemSlots,
MaxMem: fmt.Sprintf("%dM", hostMem+uint64(memoryOffset)),
}

m := arm64.memoryTopology(mem, hostMem)
assert.Equal(expectedMemory, m)
}
52 changes: 52 additions & 0 deletions virtcontainers/qemu_ppc64le_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) 2018 IBM
//
// SPDX-License-Identifier: Apache-2.0
//

package virtcontainers

import (
"fmt"
"testing"

govmmQemu "github.com/intel/govmm/qemu"
"github.com/stretchr/testify/assert"
)

func newTestQemu(machineType string) qemuArch {
config := HypervisorConfig{
HypervisorMachineType: machineType,
}
return newQemuArch(config)
}

func TestQemuPPC64leCPUModel(t *testing.T) {
assert := assert.New(t)
ppc64le := newTestQemu(QemuPseries)

expectedOut := defaultCPUModel
model := ppc64le.cpuModel()
assert.Equal(expectedOut, model)

ppc64le.enableNestingChecks()
expectedOut = defaultCPUModel + ",pmu=off"
model = ppc64le.cpuModel()
assert.Equal(expectedOut, model)
}

func TestQemuPPC64leMemoryTopology(t *testing.T) {
assert := assert.New(t)
ppc64le := newTestQemu(QemuPseries)
memoryOffset := 1024

hostMem := uint64(1024)
mem := uint64(120)
expectedMemory := govmmQemu.Memory{
Size: fmt.Sprintf("%dM", mem),
Slots: defaultMemSlots,
MaxMem: fmt.Sprintf("%dM", hostMem+uint64(memoryOffset)),
}

m := ppc64le.memoryTopology(mem, hostMem)
assert.Equal(expectedMemory, m)
}

0 comments on commit e14eab0

Please sign in to comment.