Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions cmd/runtimetest/main.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strings"
"syscall"

Expand Down Expand Up @@ -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 {
Expand All @@ -211,6 +227,7 @@ func main() {

validations := []validation{
validateProcess,
validatePlatform,
validateCapabilities,
validateHostname,
validateRlimits,
Expand Down