func TestLinuxCapabilitiesSETFCAP() string {
	// copy the testbin into container
	cmd := exec.Command("/bin/sh", "-c", "cp  cases/linuxcapabilities/capabilitytestbin /tmp/testtool")
	_, err := cmd.Output()
	if err != nil {
		log.Fatalf("[Specstest] linux Capabilities test : init the testbin file error, %v", err)
	}

	linuxspec := setCapability("SETFCAP")
	linuxspec.Spec.Process.Args = []string{"/sbin/setcap", "CAP_SETFCAP=eip", "/testtool/capabilitytestbin"}
	capability := linuxspec.Linux.Capabilities
	configFile := "./config.json"
	err = configconvert.LinuxSpecToConfig(configFile, &linuxspec)
	out, err := adaptor.StartRunc(configFile)
	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 = nil
	}
	var testResult manager.TestResult
	testResult.Set("TestMountTmpfs", capability, errout, result)
	return testResult.Marshal()
}
示例#2
0
func TestPlatformCorrect() string {
	linuxspec := setPlatform(runtime.GOOS, runtime.GOARCH)
	platform := linuxspec.Spec.Platform
	result, err := testPlatform(&linuxspec, runtime.GOOS, runtime.GOARCH)
	var testResult manager.TestResult
	testResult.Set("TestPlatformCorrect", platform, err, result)
	return testResult.Marshal()
}
示例#3
0
func TestPathError() string {
	linuxspec := setRoot(true, testPathError)
	root := linuxspec.Spec.Root
	result, err := testRoot(&linuxspec, true, testPathError)
	var testResult manager.TestResult
	testResult.Set("TestPathError", root, err, result)
	return testResult.Marshal()
}
示例#4
0
func TestReadOnlyFalse() string {
	linuxspec := setRoot(false, testPathCorrect)
	root := linuxspec.Spec.Root
	result, err := testRoot(&linuxspec, false, testPathCorrect)
	var testResult manager.TestResult
	testResult.Set("TestReadOnlyFalse", root, err, result)
	return testResult.Marshal()
}
示例#5
0
func TestMountTmpfs() string {
	linuxspec := setMount("tmpfs", "tmpfs", "/mountTest", "")
	mount := linuxspec.Spec.Mounts
	result, err := testMount(&linuxspec)
	var testResult manager.TestResult
	testResult.Set("TestMountTmpfs", mount, err, result)
	return testResult.Marshal()
}
示例#6
0
func TestVersionError() string {

	linuxspec := setVersion(testVauleError)
	version := linuxspec.Spec.Version
	result, err := testVersion(&linuxspec)
	var testResult manager.TestResult
	testResult.Set("TestVersionCorrect", version, err, result)
	return testResult.Marshal()
}
示例#7
0
func TestSysctlNetCoreSomaxconn() string {
	sysctlInput := make(map[string]string)
	sysctlInput["net.core.somaxconn"] = "192"
	var testResult manager.TestResult
	linuxspec := setSysctls(sysctlInput)
	result, err := testSysctls(&linuxspec)
	testResult.Set("TestSysctlNetCoreSomaxconn", sysctlInput, err, result)
	return testResult.Marshal()
}
示例#8
0
func TestSysctlNetIpv4IpForward() string {
	sysctlInput := make(map[string]string)
	sysctlInput["net.ipv4.ip_forward"] = "4"
	var testResult manager.TestResult
	linuxspec := setSysctls(sysctlInput)
	result, err := testSysctls(&linuxspec)
	testResult.Set("TestSysctlNetIpv4IpForward", sysctlInput, err, result)
	return testResult.Marshal()
}
示例#9
0
func TestPlatformErr() string {
	osErr := "osErr"
	archErr := "archErr"
	linuxspec := setPlatform(osErr, archErr)
	platform := linuxspec.Spec.Platform
	result, err := testPlatform(&linuxspec, osErr, archErr)
	var testResult manager.TestResult
	testResult.Set("TestPlatformErr", platform, err, result)
	return testResult.Marshal()
}
func TestRlimitNPROCHard() string {
	var rlimitstest specs.Rlimit = specs.Rlimit{
		Type: 0,
		Soft: uint64(0),
		Hard: uint64(20480),
	}
	var testResult manager.TestResult
	linuxspec := setRlimits(rlimitstest)
	result, err := testRlimits(&linuxspec, "-n", strconv.FormatUint(rlimitstest.Hard, 10), false)
	testResult.Set("TestRlimitNPROCHard", rlimitstest.Hard, err, result)
	return testResult.Marshal()
}
示例#11
0
func TestNetPathEmpty() string {

	ns := specs.Namespace{Type: "network",
		Path: ""}

	ls := setNetSpec(ns)
	result, err := TestPathEmpty(&ls, "/proc/*/ns/net")

	var testResult manager.TestResult
	testResult.Set("TestNetPathEmpty", ns, err, result)
	return testResult.Marshal()
}
示例#12
0
文件: ipc.go 项目: yuchangchun1/oct
func TestIpcPathUnempty() string {

	ns := specs.Namespace{Type: "ipc",
		Path: "/proc/1/ns/ipc"}

	ls := setIpcSpec(ns)
	result, err := TestPathUnEmpty(&ls, ns.Path)

	var testResult manager.TestResult
	testResult.Set("TestIpcPathUnempty", ns, err, result)
	return testResult.Marshal()
}
示例#13
0
文件: mount.go 项目: yuchangchun1/oct
func TestMntPathEmpty() string {

	ns := specs.Namespace{Type: "mount",
		Path: ""}

	ls := linuxSpec
	ls.Process.Args = append(ls.Process.Args, "/bin/readlink", "/proc/self/ns/mnt")
	result, err := TestPathEmpty(&ls, "/proc/*/ns/mnt")

	var testResult manager.TestResult
	testResult.Set("TestMntPathEmpty", ns, err, result)
	return testResult.Marshal()
}
func TestMemoryLimit() string {
	var testResourceseMemory specs.Resources = specs.Resources{
		Memory: specs.Memory{
			Limit:       204800,
			Reservation: 0,
			Swap:        0,
			Kernel:      0,
			Swappiness:  -1,
		},
	}
	linuxspec := setResources(testResourceseMemory)
	go testResources(&linuxspec)
	// if err == nil {
	result, err := checkConfigurationFromHost("memory.limit_in_bytes", "204800")
	// }
	var testResult manager.TestResult
	testResult.Set("TestMemoryLimit", testResourceseMemory.Memory, err, result)
	return testResult.Marshal()
}