Example #1
0
func (s *serviceSuite) TearDownTest(c *check.C) {
	if !common.IsInRebootProcess() {
		common.RemoveSnap(c, data.BasicServiceSnapName)
	}
	// run cleanup last
	s.SnappySuite.TearDownTest(c)
}
func (s *initRAMFSSuite) TearDownTest(c *check.C) {
	s.SnappySuite.TearDownTest(c)
	if !common.IsInRebootProcess() {
		bootDir := getCurrentBootDir(c)
		cli.ExecCommand(
			c, "sudo", "mv", path.Join(os.Getenv("ADT_ARTIFACTS"), "initrd.img"), bootDir)
	}
}
Example #3
0
func (fr *SubunitV2ParserReporter) Write(data []byte) (int, error) {
	var err error
	sdata := string(data)

	if matches := announceRegexp.FindStringSubmatch(sdata); len(matches) == 2 {
		testID := matches[1]
		if isTest(testID) && !common.IsInRebootProcess() {
			err = fr.statuser.Status(subunit.Event{TestID: matches[1], Status: "exists"})
		}
	} else if matches := successRegexp.FindStringSubmatch(sdata); len(matches) == 2 {
		testID := matches[1]
		if isTest(testID) && !common.IsInRebootProcess() {
			err = fr.statuser.Status(subunit.Event{TestID: matches[1], Status: "success"})
		}
	} else if matches := failureRegexp.FindStringSubmatch(sdata); len(matches) == 2 {
		err = fr.statuser.Status(subunit.Event{TestID: matches[1], Status: "fail"})
	} else if matches := skipRegexp.FindStringSubmatch(sdata); len(matches) == 3 {
		reason := matches[2]
		// Do not report anything about the set ups skipped because of another test's reboot.
		duringReboot := matchString(
			fmt.Sprintf(regexp.QuoteMeta(common.FormatSkipDuringReboot), ".*", ".*"),
			reason)
		afterReboot := matchString(
			fmt.Sprintf(regexp.QuoteMeta(common.FormatSkipAfterReboot), ".*", ".*"),
			reason)
		if duringReboot || afterReboot {
			return 0, nil
		}
		err = fr.statuser.Status(subunit.Event{
			TestID:    matches[1],
			Status:    "skip",
			FileName:  "reason",
			FileBytes: []byte(reason),
			MIME:      "text/plain;charset=utf8",
		})
	}

	if wr, ok := fr.Next.(*writerRecorder); ok {
		return wr.nbytes, err
	}
	return 0, err
}
Example #4
0
func (fr *SubunitV2ParserReporter) Write(data []byte) (int, error) {
	var err error
	sdata := string(data)

	if matches := announceRegexp.FindStringSubmatch(sdata); len(matches) == 2 {
		testID := matches[1]
		if isTest(testID) && !common.IsInRebootProcess() {
			err = fr.statuser.Status(subunit.Event{TestID: matches[1], Status: "exists"})
		}
	} else if matches := successRegexp.FindStringSubmatch(sdata); len(matches) == 2 {
		testID := matches[1]
		if isTest(testID) && !common.IsInRebootProcess() {
			err = fr.statuser.Status(subunit.Event{TestID: matches[1], Status: "success"})
		}
	} else if matches := failureRegexp.FindStringSubmatch(sdata); len(matches) == 2 {
		err = fr.statuser.Status(subunit.Event{TestID: matches[1], Status: "fail"})
	} else if matches := skipRegexp.FindStringSubmatch(sdata); len(matches) == 3 {
		reason := matches[2]
		// Do not take into account skipped SetUpTest
		if strings.HasSuffix(matches[1], "SetUpTest") {
			return 0, nil
		}
		// Do not report anything about the set ups skipped because of another test's reboot.
		if checkReboot(reason) {
			return 0, nil
		}

		err = fr.statuser.Status(subunit.Event{
			TestID:    matches[1],
			Status:    "skip",
			FileName:  "reason",
			FileBytes: []byte(reason),
			MIME:      "text/plain;charset=utf8",
		})
	}
	if wr, ok := fr.Next.(*writerRecorder); ok {
		return wr.nbytes, err
	}
	return 0, err
}