Exemplo n.º 1
0
// ShowTestDescription shows the description for the selected set of
// tests.
func ShowTestDescription(conf *jsonParser.Config, testPaths []string) {
	for _, testDir := range testPaths {
		testDescription, err := jsonParser.Parse(filepath.Join(testDir, "test_description.json"),
			conf.IncludeDir)
		if err != nil {
			log.Printf("Error parsing test description in %s: %v", testDir, err)
			continue
		}
		fmt.Println("test name: ", path.Base(testDir))
		fmt.Println("--------------------------------------------------------------")
		fmt.Println(testDescription.Description)
		fmt.Println()
	}
}
Exemplo n.º 2
0
// extractCategories extracts the available test categories from the provided
// test selection (x, x:y, 'all', etc.)
func extractCategories(conf *jsonParser.Config, testNames []string) map[string][]string {
	tests := extractAllTestCases(conf.TestDir, testNames)
	categoryMap := make(map[string][]string)
	for _, t := range tests {
		p, err := jsonParser.Parse(filepath.Join(t, "test_description.json"), conf.IncludeDir)
		if err != nil {
			continue
		}
		for _, k := range p.KeyWords {
			if _, ok := categoryMap[k]; !ok {
				categoryMap[k] = []string{t}
			} else {
				categoryMap[k] = append(categoryMap[k], t)
			}
		}
	}
	return categoryMap
}
Exemplo n.º 3
0
// createSimJobs is responsible for filling a worker queue with
// jobs to be run via the simulation tool. It parses the test
// description, assembles a TestDescription struct and adds it
// to the simulation job queue.
func createSimJobs(includePath string, testPaths []string,
	simJobs chan *jsonParser.TestDescription) {
	runID := 0
	for _, testDir := range testPaths {
		testFile := filepath.Join(testDir, "test_description.json")
		testDescription, err := jsonParser.Parse(testFile, includePath)
		if err != nil {
			log.Printf("Error parsing test description in %s: %v", testDir, err)
			continue
		}

		// create output directory
		outputDir := file.GetOutputDir(testDir)
		if err := os.Mkdir(outputDir, 0744); err != nil {
			log.Print(err)
			continue
		}

		// set path and pick a Seed value for run
		testDescription.Path = testDir
		testDescription.Run.RunID = runID

		// schedule requested number of Seeds; if there is just a single
		// Seed requested we pick one randomly
		switch testDescription.Run.NumSeeds {
		case 0: // user didn't set number of Seeds -- assume single Seed
			testDescription.Run.NumSeeds = 1
			testDescription.Run.Seed = rng.Intn(10000)
		case 1:
			testDescription.Run.Seed = rng.Intn(10000)
		default:
			for i := 1; i < testDescription.Run.NumSeeds; i++ {
				newTest := testDescription.Copy()
				newTest.Run.Seed = i
				testDescription.Run.Seed = i + 1
				simJobs <- newTest
			}
		}
		simJobs <- testDescription
		runID++
	}
	close(simJobs)
}