// Reads in the platform that we want to use and prepares for the tests func main() { flag.Parse() deployP = platform.NewPlatform(platformDst) if deployP == nil { log.Fatal("Platform not recognized.", platformDst) } log.Lvl1("Deploying to", platformDst) simulations := flag.Args() if len(simulations) == 0 { log.Fatal("Please give a simulation to run") } for _, simulation := range simulations { runconfigs := platform.ReadRunFile(deployP, simulation) if len(runconfigs) == 0 { log.Fatal("No tests found in", simulation) } deployP.Configure(&platform.Config{ MonitorPort: monitorPort, Debug: log.DebugVisible(), }) if clean { err := deployP.Deploy(runconfigs[0]) if err != nil { log.Fatal("Couldn't deploy:", err) } if err := deployP.Cleanup(); err != nil { log.Error("Couldn't cleanup correctly:", err) } } else { logname := strings.Replace(filepath.Base(simulation), ".toml", "", 1) testsDone := make(chan bool) go func() { RunTests(logname, runconfigs) testsDone <- true }() timeout := getExperimentWait(runconfigs) select { case <-testsDone: log.Lvl3("Done with test", simulation) case <-time.After(time.Second * time.Duration(timeout)): log.Fatal("Test failed to finish in", timeout, "seconds") } } } }
func TestReadRunfile(t *testing.T) { log.TestOutput(testing.Verbose(), 2) tplat := &TPlat{} tmpfile := "/tmp/testrun.toml" err := ioutil.WriteFile(tmpfile, []byte(testfile), 0666) if err != nil { log.Fatal("Couldn't create file:", err) } tests := platform.ReadRunFile(tplat, tmpfile) log.Lvl2(tplat) log.Lvlf2("%+v\n", tests[0]) if tplat.App != "sign" { log.Fatal("App should be 'sign'") } if len(tests) != 2 { log.Fatal("There should be 2 tests") } if tests[0].Get("machines") != "8" { log.Fatal("Machines = 8 has not been copied into RunConfig") } }