Beispiel #1
0
func main() {
	flag.Parse()

	config := common.DefaultConfig()

	if *runtimePath != "" {
		config.Runner.PreserveFiles = true
	} else {
		var err error
		if *runtimePath, err = ioutil.TempDir("", "runner"); err != nil {
			panic(err)
		}
		defer os.RemoveAll(*runtimePath)
	}
	config.Logging.File = "stderr"
	if *verbose {
		config.Logging.Level = "debug"
	}
	config.Runner.RuntimePath = *runtimePath
	config.Tracing.Enabled = false

	ctx, err := common.NewContext(&config)
	if err != nil {
		panic(err)
	}
	inputManager := common.NewInputManager(ctx)
	results, err := runner.RunHostBenchmark(
		ctx,
		inputManager,
		&minijail,
		&ioLock,
	)
	if err != nil {
		panic(err)
	}
	encoded, err := json.MarshalIndent(results, "", "  ")
	if err != nil {
		panic(err)
	}

	os.Stdout.Write(encoded)
}
Beispiel #2
0
func newRunnerContext() (*common.Context, error) {
	dirname, err := ioutil.TempDir("/tmp", "runnertest")
	if err != nil {
		return nil, err
	}
	config := common.DefaultConfig()
	config.Logging.File = "stderr"
	if testing.Verbose() {
		config.Logging.Level = "debug"
	}
	config.Tracing.Enabled = false
	config.InputManager.CacheSize = 1024
	config.Runner.RuntimePath = dirname
	ctx, err := common.NewContext(&config)
	if err != nil {
		return nil, err
	}
	ctx.Config.Runner.PreserveFiles = os.Getenv("PRESERVE") != ""

	return ctx, nil
}