// newKernelFilenamePattern returns the filename pattern to modify files
// in the partition declared in the boot config file.
//
// After the update, the config file is already changed to point to the new partition.
// If we are on a and update, the config file would point to b
// and this function would return "b/%s%s*"
// If we are not in an update process (ie. we are unsetting the failover conditions)
// we want to change the files in the other partition
func newKernelFilenamePattern(c *check.C, bootSystem string) string {
	part, err := partition.CurrentPartition()
	c.Assert(err, check.IsNil,
		check.Commentf("Error getting the current partition: %s", err))
	part = partition.OtherPartition(part)
	return filepath.Join(part, "%s%s*")
}
func getCurrentBootDir(c *check.C) string {
	system, err := partition.BootSystem()
	c.Assert(err, check.IsNil, check.Commentf("Error getting the boot system: %s", err))
	bootDir := partition.BootDir(system)
	current, err := partition.CurrentPartition()
	c.Assert(err, check.IsNil, check.Commentf("Error getting the current partition: %s", err))
	return path.Join(bootDir, current)
}
// newKernelFilenamePattern returns the filename pattern to modify files
// in the partition declared in the boot config file.
//
// After the update, the config file is already changed to point to the new partition.
// If we are on a and update, the config file would point to b
// and this function would return "b/%s%s*"
// If we are not in an update process (ie. we are unsetting the failover conditions)
// we want to change the files in the other partition
func newKernelFilenamePattern(c *check.C, bootSystem string, afterUpdate bool) string {
	var part string
	var err error
	if afterUpdate {
		part, err = partition.NextBootPartition()
		c.Assert(err, check.IsNil,
			check.Commentf("Error getting the next boot partition: %s", err))
	} else {
		part, err = partition.CurrentPartition()
		c.Assert(err, check.IsNil,
			check.Commentf("Error getting the current partition: %s", err))
		part = partition.OtherPartition(part)
	}
	return filepath.Join(part, "%s%s*")
}
Ejemplo n.º 4
0
func (s *updateSuite) assertBootDirContents(c *check.C) {
	system, err := partition.BootSystem()
	c.Assert(err, check.IsNil, check.Commentf("Error getting the boot system: %s", err))
	current, err := partition.CurrentPartition()
	c.Assert(err, check.IsNil, check.Commentf("Error getting the current partition: %s", err))
	files, err := ioutil.ReadDir(
		path.Join(partition.BootDir(system), partition.OtherPartition(current)))
	c.Assert(err, check.IsNil, check.Commentf("Error reading the other partition boot dir: %s", err))

	expectedFileNames := []string{"hardware.yaml", "initrd.img", "vmlinuz"}
	if system == "uboot" {
		expectedFileNames = append([]string{"dtbs"}, expectedFileNames...)
	}

	fileNames := []string{}
	for _, f := range files {
		fileNames = append(fileNames, f.Name())
	}
	c.Assert(fileNames, check.DeepEquals, expectedFileNames,
		check.Commentf("Wrong files in the other partition boot dir"))
}
Ejemplo n.º 5
0
// SetUpTest handles reboots and stores version information. It will run before
// all the integration tests. Before running a test, it will save the
// ubuntu-core version. If a reboot was requested by a previous test, it
// will skip all the following tests. If the suite is being called after the
// test bed was rebooted, it will resume the test that requested the reboot.
func (s *SnappySuite) SetUpTest(c *check.C) {
	if NeedsReboot() {
		contents, err := ioutil.ReadFile(NeedsRebootFile)
		c.Assert(err, check.IsNil, check.Commentf("Error reading needs-reboot file %v", err))
		c.Skip(fmt.Sprintf(FormatSkipDuringReboot, c.TestName(), contents))
	} else {
		if CheckRebootMark("") {
			c.Logf("****** Running %s", c.TestName())
			SetSavedVersion(c, GetCurrentUbuntuCoreVersion(c))
		} else {
			if AfterReboot(c) {
				c.Logf("****** Resuming %s after reboot", c.TestName())
				p, err := partition.CurrentPartition()
				c.Assert(err, check.IsNil, check.Commentf("Error getting the current boot partition: %v", err))
				c.Logf(fmt.Sprintf("Rebooted to partition %s", p))
			} else {
				c.Skip(fmt.Sprintf(FormatSkipAfterReboot, c.TestName(), os.Getenv("ADT_REBOOT_MARK")))
			}
		}
	}
	// clear slice
	s.cleanupHandlers = nil
}