예제 #1
0
파일: efh_replay.go 프로젝트: ikravets/ev
func (c *cmdEfhReplay) ParsingFinished() (err error) {
	if !c.shouldExecute {
		return
	}
	cc := channels.NewConfig()
	for _, s := range c.EfhChannel {
		errs.CheckE(cc.LoadFromStr(s))
	}

	if c.Inspect != "" {
		buf, err := ioutil.ReadFile(c.Inspect)
		errs.CheckE(err)
		dev, err := device.NewEfh_toolDevice()
		errs.CheckE(err)
		c.regConfig = inspect.NewConfig(dev)
		errs.CheckE(c.regConfig.Parse(string(buf)))
	}

	conf := efh.ReplayConfig{
		InputFileName:   c.InputFileName,
		OutputInterface: c.OutputInterface,
		Pps:             c.Pps,
		Limit:           c.Limit,
		Loop:            c.Loop,
		EfhLoglevel:     c.EfhLoglevel,
		EfhIgnoreGap:    c.EfhIgnoreGap,
		EfhDump:         c.EfhDump,
		EfhSubscribe:    c.EfhSubscribe,
		EfhChannel:      cc,
		EfhProf:         c.EfhProf,
		RegConfig:       c.regConfig,
		TestEfh:         c.TestEfh,
		Local:           c.Local,
	}
	er := efh.NewEfhReplay(conf)
	err = er.Run()
	if err != nil {
		log.Printf("ERROR %s", err)
	}
	return
}
예제 #2
0
파일: inspect.go 프로젝트: ikravets/ev
func (c *cmdInspect) ParsingFinished() (err error) {
	if !c.shouldExecute {
		return
	}
	buf, err := ioutil.ReadFile(c.ConfigFileName)
	errs.CheckE(err)
	dev, err := device.NewEfh_toolDevice()
	errs.CheckE(err)
	conf := inspect.NewConfig(dev)
	errs.CheckE(conf.Parse(string(buf)))
	errs.CheckE(conf.Probe())
	errs.CheckE(ioutil.WriteFile(c.OutputFileName, []byte(conf.Report()), 0666))

	if c.OutputConfigFileName != "" {
		dump, err := conf.Dump()
		errs.CheckE(err)
		errs.CheckE(ioutil.WriteFile(c.OutputConfigFileName, []byte(dump), 0666))
	}

	return
}
예제 #3
0
파일: efh_suite.go 프로젝트: ikravets/ev
func (c *cmdEfhSuite) ParsingFinished() (err error) {
	defer errs.Catch(func(ce errs.CheckerError) {
		log.Printf("caught %s\n", ce)
	})
	if !c.shouldExecute {
		return
	}
	c.topOutDirName = time.Now().Format("efh_regression.2006-01-02-15:04:05")
	suitesDirName := fmt.Sprintf("/local/dumps/%s/regression", c.Exchange)

	if len(c.Suites) == 0 || c.Suites[0] == "?" {
		suites, err2 := listDirs(suitesDirName)
		errs.CheckE(err2)
		if len(c.Suites) > 0 {
			fmt.Printf("suites: %s\n", suites)
			return
		}
		if len(suites) == 0 {
			log.Println("Warning: no suites found")
			return
		}
		c.Suites = suites
	}

	if c.Inspect != "" {
		buf, err := ioutil.ReadFile(c.Inspect)
		errs.CheckE(err)
		dev, err := device.NewEfh_toolDevice()
		errs.CheckE(err)
		c.regConfig = inspect.NewConfig(dev)
		errs.CheckE(c.regConfig.Parse(string(buf)))
	}

	for _, suite := range c.Suites {
		var suiteDirName string
		if strings.HasPrefix(suite, "/") {
			suiteDirName = suite
		} else if strings.HasPrefix(suite, "./") {
			cwd, err := os.Getwd()
			errs.CheckE(err)
			suiteDirName = filepath.Join(cwd, suite)
		} else {
			suiteDirName = filepath.Join(suitesDirName, suite)
		}
		var tests []string
		if len(c.Tests) == 0 || c.Tests[0] == "?" {
			tests, err = listDirs(suiteDirName)
			errs.CheckE(err)
			if len(c.Tests) > 0 {
				fmt.Printf("suite %s tests: %v\n", suiteDirName, tests)
				continue
			}
		} else {
			tests = c.Tests
		}
		if len(tests) == 0 {
			log.Printf("Warning: no tests found in suite %s\n", suite)
			continue
		}

		for _, testName := range tests {
			testDirName := filepath.Join(suiteDirName, testName)
			subscriptionFileNames, err := filepath.Glob(filepath.Join(testDirName, "subscription*"))
			errs.CheckE(err)
			if len(subscriptionFileNames) == 0 {
				c.RunTest(testDirName, nil)
			} else {
				for _, sfn := range subscriptionFileNames {
					a := strings.SplitAfter(sfn, "/subscription")
					suf := ""
					if len(a) > 0 {
						suf = a[len(a)-1]
					}
					c.RunTest(testDirName, &suf)
				}
			}
		}
	}
	log.Printf("Tests OK/Total: %d/%d\n", c.testRunsOk, c.testRunsTotal)
	fmt.Printf("Tests OK/Total: %d/%d\n", c.testRunsOk, c.testRunsTotal)
	return
}