当前位置: 首页>>代码示例>>Golang>>正文


Golang TestResult.Marshal方法代码示例

本文整理汇总了Golang中github.com/huawei-openlab/oct/tools/runtimeValidator/manager.TestResult.Marshal方法的典型用法代码示例。如果您正苦于以下问题:Golang TestResult.Marshal方法的具体用法?Golang TestResult.Marshal怎么用?Golang TestResult.Marshal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/huawei-openlab/oct/tools/runtimeValidator/manager.TestResult的用法示例。


在下文中一共展示了TestResult.Marshal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestSuiteLinuxSeccompGetcwd

func TestSuiteLinuxSeccompGetcwd() string {
	// copy the testbin into container
	var se specs.Seccomp = specs.Seccomp{
		DefaultAction: "SCMP_ACT_ALLOW",
		Syscalls: []*specs.Syscall{
			{
				Name:   "getcwd",
				Action: "SCMP_ACT_ERRNO",
			},
		},
	}
	linuxSpec = setSeccomp(se)

	result := os.Getenv("GOPATH")
	if result == "" {
		log.Fatalf("utils.setBind error GOPATH == nil")
	}
	resource := result + "/src/github.com/huawei-openlab/oct/tools/runtimeValidator/containerend"
	utils.SetRight(resource, linuxSpec.Process.User.UID, linuxSpec.Process.User.GID)
	linuxSpec.Spec.Process.Args = []string{"/testtool/linuxseccomp"}
	testtoolfolder := specs.Mount{"bind", resource, "/testtool", "bind"}
	linuxSpec.Spec.Mounts = append(linuxSpec.Spec.Mounts, testtoolfolder)
	info := ",Name=" + se.Syscalls[0].Name + ", Action=" + string(se.Syscalls[0].Action)
	result, errout := testSeccomp(&linuxSpec, info)
	var testResult manager.TestResult
	testResult.Set("TestSuiteLinuxSeccompGetcwd", se, errout, result)
	return testResult.Marshal()
}
开发者ID:WeiZhang555,项目名称:oct,代码行数:28,代码来源:test_linuxseccomp.go

示例2: TestCpuQuota

func TestCpuQuota() string {
	var testResourceCPU specs.Resources = specs.Resources{
		CPU: specs.CPU{
			Shares:          0,
			Quota:           20000,
			Period:          0,
			RealtimeRuntime: 0,
			RealtimePeriod:  0,
			Cpus:            "",
			Mems:            "",
		},
	}
	linuxspec, linuxruntimespec := setResources(testResourceCPU)
	failinfo := "CPU Quota"
	c := make(chan bool)
	go func() {
		testResources(&linuxspec, &linuxruntimespec)
		close(c)
	}()
	result, err := checkConfigurationFromHost("cpu", "cpu.cfs_quota_us", "20000", failinfo)
	<-c
	var testResult manager.TestResult
	testResult.Set("TestMemoryLimit", testResourceCPU.CPU, err, result)
	adaptor.DeleteRun()
	return testResult.Marshal()
}
开发者ID:WeiZhang555,项目名称:oct,代码行数:26,代码来源:test_linuxresources_v0.1.1.go

示例3: TestBlockIOWeight

func TestBlockIOWeight() string {
	var testResourceBlockIO specs.Resources = specs.Resources{
		BlockIO: specs.BlockIO{
			Weight:                  300,
			WeightDevice:            nil,
			ThrottleReadBpsDevice:   nil,
			ThrottleWriteBpsDevice:  nil,
			ThrottleReadIOPSDevice:  nil,
			ThrottleWriteIOPSDevice: nil,
		},
	}
	linuxspec, linuxruntimespec := setResources(testResourceBlockIO)
	failinfo := "BlockIO Weight"
	c := make(chan bool)
	go func() {
		testResources(&linuxspec, &linuxruntimespec)
		close(c)
	}()
	result, err := checkConfigurationFromHost("blkio", "blkio.weight", "300", failinfo)
	<-c
	var testResult manager.TestResult
	testResult.Set("TestBlockIOWeight", testResourceBlockIO.BlockIO, err, result)
	adaptor.DeleteRun()
	return testResult.Marshal()
}
开发者ID:WeiZhang555,项目名称:oct,代码行数:25,代码来源:test_linuxresources_v0.1.1.go

示例4: TestSuiteLinuxGidMappings

func TestSuiteLinuxGidMappings() string {
	addTestUser()
	linuxSpec.Spec.Process.Args = []string{"/bin/bash", "-c", "cat /proc/1/gid_map"}
	//get uid&gid of test account
	testuser, _ := user.Lookup("uidgidtest")
	testuidInt, _ := strconv.ParseInt(testuser.Uid, 10, 32)
	testgidInt, _ := strconv.ParseInt(testuser.Uid, 10, 32)
	//change owner of rootfs
	gopath := os.Getenv("GOPATH")
	if gopath == "" {
		log.Fatalf("utils.setBind error GOPATH == nil")
	}
	rootfspath := gopath + "/src/github.com/huawei-openlab/oct/tools/runtimeValidator/rootfs"
	utils.SetRight(rootfspath, int32(testuidInt), int32(testgidInt))
	var uid specs.IDMapping = specs.IDMapping{
		HostID:      int32(testuidInt),
		ContainerID: 0,
		Size:        10,
	}
	var gid specs.IDMapping = specs.IDMapping{
		HostID:      int32(testgidInt),
		ContainerID: 0,
		Size:        10,
	}
	failinfo := "mapping from Host GID to Container GID failed"
	linuxSpec = setIDmappings(uid, gid)
	result, err := testIDmappings(&linuxSpec, true, failinfo)
	var testResult manager.TestResult
	testResult.Set("TestSuiteLinuxGidMappings", gid, err, result)
	cleanTestUser()
	return testResult.Marshal()

}
开发者ID:WeiZhang555,项目名称:oct,代码行数:33,代码来源:test_linuxuidgidmappings.go

示例5: TestLinuxCapabilitiesSETFCAP

func TestLinuxCapabilitiesSETFCAP() string {
	linuxspec, linuxruntimespec := setCapability("CAP_SETFCAP")
	linuxspec.Spec.Process.Args = []string{"/sbin/setcap", "CAP_SETFCAP=eip", "/containerend/linuxcapabilities"}
	capability := linuxspec.Linux.Capabilities

	configFile := "./config.json"
	runtimeFile := "./runtime.json"
	err := configconvert.LinuxSpecToConfig(configFile, &linuxspec)
	err = configconvert.LinuxRuntimeToConfig(runtimeFile, &linuxruntimespec)
	out, err := adaptor.StartRunc(configFile, runtimeFile)

	var result string
	var errout error
	if err != nil {
		result = manager.UNSPPORTED
		errout = errors.New(string(out) + err.Error())
	} else if strings.EqualFold(strings.TrimSpace(string(out)), "") {
		result = manager.PASSED
		errout = nil
	} else {
		result = manager.FAILED
		errout = errors.New("test Capabilities CAP_SETFCAP NOT  does''t work")
	}
	var testResult manager.TestResult
	testResult.Set("TestMountTmpfs", capability, errout, result)
	return testResult.Marshal()
}
开发者ID:WeiZhang555,项目名称:oct,代码行数:27,代码来源:test_capabilities_SETFCAP_v0.1.1.go

示例6: TestLinuxApparmorProfile

func TestLinuxApparmorProfile() string {
	apparmorfile := "testapporprofile"
	linuxspec := setApparmorProfile(apparmorfile)
	result, err := testApparmorProfile(&linuxspec)
	var testResult manager.TestResult
	testResult.Set("TestLinuxApparmorProfile", linuxspec.Linux.ApparmorProfile, err, result)
	return testResult.Marshal()
}
开发者ID:WeiZhang555,项目名称:oct,代码行数:8,代码来源:test_linuxapparmorprofile.go

示例7: TestLinuxSelinuxProcessLabel

func TestLinuxSelinuxProcessLabel() string {
	labelin := "system_u:system_r:svirt_lxc_net_t:s0:c124,c675"
	linuxspec := setSElinuxLabel(labelin)
	result, err := testSElinuxLabel(&linuxspec)
	var testResult manager.TestResult
	testResult.Set("TestLinuxSelinuxProcessLabel", linuxspec.Linux.SelinuxProcessLabel, err, result)
	return testResult.Marshal()
}
开发者ID:WeiZhang555,项目名称:oct,代码行数:8,代码来源:test_linuxseliuxlabel.go

示例8: TestCgroupspath

func TestCgroupspath() string {
	cgpath := "/cgroupspathtest/testcontainer"
	linuxspec, linuxruntimespec := setCgroupspath(cgpath)
	result, err := testCgroupspath(&linuxspec, &linuxruntimespec)
	var testResult manager.TestResult
	testResult.Set("TestCgroupspath", cgpath, err, result)
	return testResult.Marshal()
}
开发者ID:WeiZhang555,项目名称:oct,代码行数:8,代码来源:test_linuxcgrouppath_v0.1.1.go

示例9: TestLinuxApparmorProfile

func TestLinuxApparmorProfile() string {
	apparmorfile := "testapporprofile"
	linuxspec, linuxruntimespec := setApparmorProfile(apparmorfile)
	result, err := testApparmorProfile(&linuxspec, &linuxruntimespec)
	adaptor.DeleteRun()
	var testResult manager.TestResult
	testResult.Set("TestLinuxApparmorProfile", linuxRuntimeSpec.Linux.ApparmorProfile, err, result)
	return testResult.Marshal()
}
开发者ID:WeiZhang555,项目名称:oct,代码行数:9,代码来源:test_linuxapparmorprofile_v0.1.1.go

示例10: TestVersionCorrect

func TestVersionCorrect() string {

	linuxspec := setVersion(testValueCorrect)
	version := linuxspec.Spec.Version
	result, err := testVersion(&linuxspec)
	var testResult manager.TestResult
	testResult.Set("TestVersionCorrect", version, err, result)
	return testResult.Marshal()
}
开发者ID:WeiZhang555,项目名称:oct,代码行数:9,代码来源:test_version_correct.go

示例11: TestPathError

func TestPathError() string {
	linuxspec := setRoot(true, testPathError)
	root := linuxspec.Spec.Root
	lr := specsinit.SetLinuxruntimeMinimum()
	result, err := testRoot(&linuxspec, &lr, true, testPathError)
	var testResult manager.TestResult
	testResult.Set("TestPathError", root, err, result)
	return testResult.Marshal()
}
开发者ID:WeiZhang555,项目名称:oct,代码行数:9,代码来源:test_root_readonly_v0.1.1.go

示例12: TestReadOnlyFalse

func TestReadOnlyFalse() string {
	linuxspec := setRoot(false, testPathCorrect)
	root := linuxspec.Spec.Root
	lr := specsinit.SetLinuxruntimeMinimum()
	result, err := testRoot(&linuxspec, &lr, false, testPathCorrect)
	var testResult manager.TestResult
	testResult.Set("TestReadOnlyFalse", root, err, result)
	return testResult.Marshal()
}
开发者ID:WeiZhang555,项目名称:oct,代码行数:9,代码来源:test_root_readonly_v0.1.1.go

示例13: TestPlatformCorrect

func TestPlatformCorrect() string {
	linuxspec := setPlatform(runtime.GOOS, runtime.GOARCH)
	platform := linuxspec.Spec.Platform

	lr := specsinit.SetLinuxruntimeMinimum()
	result, err := testPlatform(&linuxspec, &lr, runtime.GOOS, runtime.GOARCH)
	var testResult manager.TestResult
	testResult.Set("TestPlatformCorrect", platform, err, result)
	return testResult.Marshal()
}
开发者ID:WeiZhang555,项目名称:oct,代码行数:10,代码来源:test_platform_v0.1.1.go

示例14: TestVersionError

func TestVersionError() string {

	ls := setVersion(testVauleError)
	lr := specsinit.SetLinuxruntimeMinimum()
	version := ls.Spec.Version
	result, err := testVersion(&ls, &lr, false)
	var testResult manager.TestResult
	testResult.Set("TestVersionError", version, err, result)
	return testResult.Marshal()
}
开发者ID:WeiZhang555,项目名称:oct,代码行数:10,代码来源:test_version_error_v0.1.1.go

示例15: TestSysctlNetIpv4IpForward

func TestSysctlNetIpv4IpForward() string {
	sysctlInput := make(map[string]string)
	sysctlInput["net.ipv4.ip_forward"] = "4"
	failinfo := " set net.ipv4.ip_forward failed"
	var testResult manager.TestResult
	linuxspec, linuxruntimespec := setSysctls(sysctlInput)
	result, err := testSysctls(&linuxspec, &linuxruntimespec, failinfo)
	testResult.Set("TestSysctlNetIpv4IpForward", sysctlInput, err, result)
	return testResult.Marshal()
}
开发者ID:WeiZhang555,项目名称:oct,代码行数:10,代码来源:test_linuxsysctl_v0.1.1.go


注:本文中的github.com/huawei-openlab/oct/tools/runtimeValidator/manager.TestResult.Marshal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。