• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang manager.TestResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了TestResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: TestMountSysfs

func TestMountSysfs() string {
	opts := []string{}
	linuxspec, linuxruntimespec := setMount("sysfs", "sysfs", "sysfs", "/mountTest", opts)
	mount := linuxspec.Spec.Mounts
	failinfo := "Sysfs failed"
	result, err := testMount(&linuxspec, &linuxruntimespec, failinfo)
	var testResult manager.TestResult
	testResult.Set("TestMountSysfs", mount, err, result)
	return testResult.Marshal()
}
开发者ID:WeiZhang555,项目名称:oct,代码行数:10,代码来源:test_mount_v0.1.1.go


示例17: TestMountCgroup

func TestMountCgroup() string {
	opts := []string{"nosuid", "noexec", "nodev", "relatime", "ro"}
	linuxspec, linuxruntimespec := setMount("cgroup", "cgroup", "cgroup", "/mountTest", opts)
	mount := linuxspec.Spec.Mounts
	failinfo := "Cgroup failed"
	result, err := testMount(&linuxspec, &linuxruntimespec, failinfo)
	var testResult manager.TestResult
	testResult.Set("TestMountCgroup", mount, err, result)
	return testResult.Marshal()
}
开发者ID:WeiZhang555,项目名称:oct,代码行数:10,代码来源:test_mount_v0.1.1.go


示例18: TestSysctlNetCoreSomaxconn

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


示例19: TestRootfsPropagationShare

func TestRootfsPropagationShare() string {
	mkdir()
	mode := "share"
	linuxspec := setRootfsPropagation(mode)
	result, err := testRootfsPropagationHost(&linuxspec, "linuxrootfspropagation")
	var testResult manager.TestResult
	testResult.Set("TestRootfsPropagationShare", linuxspec.Linux.RootfsPropagation, err, result)
	rmdir()
	return testResult.Marshal()
}
开发者ID:WeiZhang555,项目名称:oct,代码行数:10,代码来源:test_linuxrootpropagation.go


示例20: TestRlimitNOFILESoft

func TestRlimitNOFILESoft() string {
	var rlimitstest specs.Rlimit = specs.Rlimit{
		Type: syscall.RLIMIT_NOFILE,
		Soft: uint64(2048),
		Hard: uint64(4096),
	}
	var testResult manager.TestResult
	linuxspec := setRlimits(rlimitstest)
	result, err := testRlimits(&linuxspec, "-n", strconv.FormatUint(rlimitstest.Soft, 10), true)
	testResult.Set("TestRlimitNOFILESoft", rlimitstest.Soft, err, result)
	return testResult.Marshal()
}
开发者ID:WeiZhang555,项目名称:oct,代码行数:12,代码来源:test_linuxrlimits_RLIMIT_NPROC.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang configconvert.LinuxSpecToConfig函数代码示例发布时间:2022-05-28
下一篇:
Golang adaptor.StartRunc函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap