From 7be5036e89c04233c79474f6a43b3b40173a0d37 Mon Sep 17 00:00:00 2001 From: Wang Qilin Date: Mon, 25 Jan 2016 19:22:24 +0800 Subject: [PATCH] runtimetest:add platform validation Signed-off-by: Wang Qilin --- cmd/runtimetest/main.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) mode change 100644 => 100755 cmd/runtimetest/main.go diff --git a/cmd/runtimetest/main.go b/cmd/runtimetest/main.go old mode 100644 new mode 100755 index f1a1c6043..80c3e998a --- a/cmd/runtimetest/main.go +++ b/cmd/runtimetest/main.go @@ -7,6 +7,7 @@ import ( "io/ioutil" "os" "path/filepath" + "runtime" "strings" "syscall" @@ -203,6 +204,21 @@ func validateSysctls(spec *specs.LinuxSpec, rspec *specs.LinuxRuntimeSpec) error return nil } +func validatePlatform(spec *specs.LinuxSpec, rspec *specs.LinuxRuntimeSpec) error { + fmt.Println("validating platform") + os := spec.Platform.OS + arch := spec.Platform.Arch + hos := runtime.GOOS + harch := runtime.GOARCH + if !strings.EqualFold(os, hos) { + return fmt.Errorf("OS expected: %v, actual: %v", os, hos) + } + if !strings.EqualFold(arch, harch) { + return fmt.Errorf("Arch expected: %v, actual: %v", arch, harch) + } + return nil +} + func main() { spec, rspec, err := loadSpecConfig() if err != nil { @@ -211,6 +227,7 @@ func main() { validations := []validation{ validateProcess, + validatePlatform, validateCapabilities, validateHostname, validateRlimits,