Exemplo n.º 1
0
func main() {

	flag.Parse()
	fmt.Println("Testing Revision:")
	var checkoutSpecsRev, checkoutRuncRev, runcBuildtags string
	if *specsRev == "predraft" {
		checkoutSpecsRev = "45ae53d4dba8e550942f7384914206103f6d2216"
		fmt.Printf("	Specs revision: %v \n", checkoutSpecsRev)
	} else if *specsRev == "" {
		checkoutSpecsRev = "origin/master"
		fmt.Println("   Specs revision: newest commit")
	} else {
		checkoutSpecsRev = *specsRev
		fmt.Printf("	Specs revision: %v \n", checkoutSpecsRev)
	}

	if *runcRev == "" {
		checkoutRuncRev = "origin/master"
		fmt.Println("   Runc revision: newest commit")
	} else {
		checkoutRuncRev = *runcRev
		fmt.Printf("	Runc revision: %v \n", checkoutRuncRev)
	}

	if *runctags == "" {
		runcBuildtags = "seccomp"
	} else if *runctags != "seccomp" && *runctags != "selinux" && *runctags != "apparmor" {
		log.Fatalf("Parameter runctags=%v is the wrong value", *runctags)
	} else {
		runcBuildtags = *runctags
	}

	fmt.Println("Going to update revision, maybe need several mins, plz be patient!")
	hostenv.UpateSpecsRev(checkoutSpecsRev)
	hostenv.UpateRuncRev(checkoutRuncRev, runcBuildtags)

	fmt.Println("Testing output: ")
	if *output == "" {
		*output = "./report/"
	}
	fmt.Printf("   %v\n", *output+"linuxspec.json")

	if !exists("rootfs") {
		err := hostenv.CreateBoundle()
		if err != nil {
			log.Fatalf("Create boundle error, %v", err)
		}
	}

	/*linuxnamespace.TestSuiteNP.Run()
	result := linuxnamespace.TestSuiteNP.GetResult()

	err = utils.StringOutput("namespace_out.json", result)
	if err != nil {
		log.Fatalf("Write namespace out file error,%v\n", err)
	}
	*/
	// // spec.version test
	/*specversion.TestSuiteVersion.Run()
	result = specversion.TestSuiteVersion.GetResult()

	err = utils.StringOutput("Version_out.json", result)
	if err != nil {
		log.Fatalf("Write version out file error,%v\n", err)
	}*/

	// // spec.mount test
	/*specmount.TestSuiteMount.Run()
	result = specmount.TestSuiteMount.GetResult()
	err = utils.StringOutput("Mount_out.json", result)
	if err != nil {
		log.Fatalf("Write mount out file error,%v\n", err)
	}*/
	// manager * TestManager = new(TestManager)

	for _, ts := range manager.Manager.TestSuite {
		ts.Run()
		result := ts.GetResult()
		outputJson := ts.Name + ".json"
		err := utils.StringOutput(outputJson, result)
		if err != nil {
			log.Fatalf("Write %v out file error,%v\n", ts.Name, err)
		}

	}
	result := manager.Manager.GetTotalResult()
	err := utils.SpecifyOutput(*output, result)
	if err != nil {
		log.Fatalf("Write %v out file error,%v\n", *output, err)
	}
	/*
		specroot.TestSuiteRoot.Run()
		result := specroot.TestSuiteRoot.GetResult()
		err = utils.StringOutput("Root_out.json", result)
		if err != nil {
			log.Fatalf("Write Root out file error,%v\n", err)
		}*/

	/*specplatform.TestSuitePlatform.Run()
	result = specplatform.TestSuitePlatform.GetResult()
	err = utils.StringOutput("Platform_out.json", result)
	if err != nil {
		log.Fatalf("Write Platform out file error,%v\n", err)
	}
	*/
	//linux resources test
	/*linuxresources.TestSuiteLinuxResources.Run()
	result := linuxresources.TestSuiteLinuxResources.GetResult()
	err = ioutil.WriteFile("LinuxResources_out.json", []byte(result), 0777)
	if err != nil {
		log.Fatalf("Write LinuxResources out file error,%v\n", err)
	}*/

}
Exemplo n.º 2
0
func main() {

	flag.Parse()
	fmt.Println("Tested Revision:")
	if *specsRev == "" {
		defaultRev := "45ae53d4dba8e550942f7384914206103f6d2216"
		fmt.Printf("	Default specs revision: pre-draft(commit: %v)\n", defaultRev)
		hostenv.UpateSpecsRev(defaultRev)
	}

	if *runcRev == "" {
		defaultRev := "v0.0.4"
		fmt.Printf("	Default runc revision :  %v\n", defaultRev)
		hostenv.UpateRuncRev(defaultRev)
	}

	if *specsRev != "" && *runcRev != "" {
		hostenv.UpateSpecsRev(*specsRev)
		hostenv.UpateRuncRev(*runcRev)
		fmt.Printf("	Specified specs revision: %v \n", *specsRev)
		fmt.Printf("	Specified runc revision: %v \n", *runcRev)
	}

	if *output == "" {
		*output = "./report/"
		fmt.Println("Using default output: oct/tools/runtimeValidator/report/linuxspec.json")
	} else {
		fmt.Printf("Specified output: %v\n", *output)
	}

	err := hostenv.CreateBoundle()
	if err != nil {
		log.Fatalf("Create boundle error, %v", err)
	}

	/*linuxnamespace.TestSuiteNP.Run()
	result := linuxnamespace.TestSuiteNP.GetResult()

	err = utils.StringOutput("namespace_out.json", result)
	if err != nil {
		log.Fatalf("Write namespace out file error,%v\n", err)
	}
	*/
	// // spec.version test
	/*specversion.TestSuiteVersion.Run()
	result = specversion.TestSuiteVersion.GetResult()

	err = utils.StringOutput("Version_out.json", result)
	if err != nil {
		log.Fatalf("Write version out file error,%v\n", err)
	}*/

	// // spec.mount test
	/*specmount.TestSuiteMount.Run()
	result = specmount.TestSuiteMount.GetResult()
	err = utils.StringOutput("Mount_out.json", result)
	if err != nil {
		log.Fatalf("Write mount out file error,%v\n", err)
	}*/
	// manager * TestManager = new(TestManager)

	for _, ts := range manager.Manager.TestSuite {
		ts.Run()
		result := ts.GetResult()
		outputJson := ts.Name + ".json"
		err := utils.StringOutput(outputJson, result)
		if err != nil {
			log.Fatalf("Write %v out file error,%v\n", ts.Name, err)
		}

	}
	result := manager.Manager.GetTotalResult()
	err = utils.SpecifyOutput(*output, result)
	if err != nil {
		log.Fatalf("Write %v out file error,%v\n", *output, err)
	}
	/*
		specroot.TestSuiteRoot.Run()
		result := specroot.TestSuiteRoot.GetResult()
		err = utils.StringOutput("Root_out.json", result)
		if err != nil {
			log.Fatalf("Write Root out file error,%v\n", err)
		}*/

	/*specplatform.TestSuitePlatform.Run()
	result = specplatform.TestSuitePlatform.GetResult()
	err = utils.StringOutput("Platform_out.json", result)
	if err != nil {
		log.Fatalf("Write Platform out file error,%v\n", err)
	}
	*/
	//linux resources test
	/*linuxresources.TestSuiteLinuxResources.Run()
	result := linuxresources.TestSuiteLinuxResources.GetResult()
	err = ioutil.WriteFile("LinuxResources_out.json", []byte(result), 0777)
	if err != nil {
		log.Fatalf("Write LinuxResources out file error,%v\n", err)
	}*/

}