runtime: add hugepages support

Add hugepages support, port from:
b486387cba

Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
Signed-off-by: bin <bin@hyper.sh>
This commit is contained in:
bin
2021-12-23 14:02:11 +08:00
parent 7df677c01e
commit 81a8baa5e5
9 changed files with 168 additions and 11 deletions

View File

@@ -6,7 +6,10 @@
package utils
import (
"bytes"
"errors"
"os/exec"
"strings"
"testing"
"github.com/stretchr/testify/assert"
@@ -34,20 +37,31 @@ func TestFindContextID(t *testing.T) {
assert.Error(err)
}
func TestGetDevicePathAndFsTypeEmptyMount(t *testing.T) {
func TestGetDevicePathAndFsTypeOptionsEmptyMount(t *testing.T) {
assert := assert.New(t)
_, _, err := GetDevicePathAndFsType("")
_, _, _, err := GetDevicePathAndFsTypeOptions("")
assert.Error(err)
}
func TestGetDevicePathAndFsTypeSuccessful(t *testing.T) {
func TestGetDevicePathAndFsTypeOptionsSuccessful(t *testing.T) {
assert := assert.New(t)
path, fstype, err := GetDevicePathAndFsType("/proc")
cmdStr := "grep ^proc /proc/mounts"
cmd := exec.Command("sh", "-c", cmdStr)
output, err := cmd.Output()
assert.NoError(err)
data := bytes.Split(output, []byte(" "))
fstypeOut := string(data[2])
optsOut := strings.Split(string(data[3]), ",")
path, fstype, fsOptions, err := GetDevicePathAndFsTypeOptions("/proc")
assert.NoError(err)
assert.Equal(path, "proc")
assert.Equal(fstype, "proc")
assert.Equal(fstype, fstypeOut)
assert.Equal(fsOptions, optsOut)
}
func TestIsAPVFIOMediatedDeviceFalse(t *testing.T) {