~snappy-dev/snappy/15.04

« back to all changes in this revision

Viewing changes to _integration-tests/tests/failover_zero_size_file_test.go

  • Committer: Snappy Tarmac
  • Author(s): John R. Lenton, Michael Vogt, Leo Arias, Launchpad Translations on behalf of snappy-dev, Federico Gimenez, Ricardo Mendoza
  • Date: 2015-10-13 06:03:57 UTC
  • mfrom: (711.1.54 snappy)
  • Revision ID: snappy_tarmac-20151013060357-rf1cz6y7190uzzlr
Merge trunk fixes. by snappy-dev approved by chipaca

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
        "path/filepath"
26
26
        "strings"
27
27
 
28
 
        . "launchpad.net/snappy/_integration-tests/testutils/common"
 
28
        "launchpad.net/snappy/_integration-tests/testutils/cli"
 
29
        "launchpad.net/snappy/_integration-tests/testutils/common"
29
30
        "launchpad.net/snappy/_integration-tests/testutils/partition"
30
31
 
31
32
        "gopkg.in/check.v1"
45
46
type zeroSizeSystemd struct{}
46
47
 
47
48
func (zeroSizeKernel) set(c *check.C) {
48
 
        commonSet(c, BaseAltPartitionPath, origBootFilenamePattern, kernelFilename)
 
49
        commonSet(c, common.BaseAltPartitionPath, origBootFilenamePattern, kernelFilename)
49
50
}
50
51
 
51
52
func (zeroSizeKernel) unset(c *check.C) {
52
 
        commonUnset(c, BaseAltPartitionPath, origBootFilenamePattern, kernelFilename)
 
53
        commonUnset(c, common.BaseAltPartitionPath, origBootFilenamePattern, kernelFilename)
53
54
}
54
55
 
55
56
func (zeroSizeInitrd) set(c *check.C) {
71
72
}
72
73
 
73
74
func (zeroSizeSystemd) set(c *check.C) {
74
 
        commonSet(c, BaseAltPartitionPath, origSystemdFilenamePattern, systemdFilename)
 
75
        commonSet(c, common.BaseAltPartitionPath, origSystemdFilenamePattern, systemdFilename)
75
76
}
76
77
 
77
78
func (zeroSizeSystemd) unset(c *check.C) {
78
 
        commonUnset(c, BaseAltPartitionPath, origSystemdFilenamePattern, systemdFilename)
 
79
        commonUnset(c, common.BaseAltPartitionPath, origSystemdFilenamePattern, systemdFilename)
79
80
}
80
81
 
81
82
func commonSet(c *check.C, baseOtherPath, origPattern, filename string) {
105
106
func renameFile(c *check.C, basePath, oldFilename, newFilename string, keepOld bool) {
106
107
        // Only need to make writable and revert for BaseAltPartitionPath,
107
108
        // kernel files' boot directory is writable
108
 
        if basePath == BaseAltPartitionPath {
109
 
                MakeWritable(c, basePath)
110
 
                defer MakeReadonly(c, basePath)
 
109
        if basePath == common.BaseAltPartitionPath {
 
110
                partition.MakeWritable(c, basePath)
 
111
                defer partition.MakeReadonly(c, basePath)
111
112
        }
112
113
 
113
 
        ExecCommand(c, "sudo", "mv", oldFilename, newFilename)
 
114
        cli.ExecCommand(c, "sudo", "mv", oldFilename, newFilename)
114
115
 
115
116
        if keepOld {
116
 
                ExecCommand(c, "sudo", "touch", oldFilename)
 
117
                cli.ExecCommand(c, "sudo", "touch", oldFilename)
117
118
                mode := getFileMode(c, newFilename)
118
 
                ExecCommand(c, "sudo", "chmod", fmt.Sprintf("%o", mode), oldFilename)
 
119
                cli.ExecCommand(c, "sudo", "chmod", fmt.Sprintf("%o", mode), oldFilename)
119
120
        }
120
121
}
121
122