Merge lp:~sergiusens/goget-ubuntu-touch/reducedSize into lp:goget-ubuntu-touch

Proposed by Sergio Schvezov
Status: Merged
Approved by: Sergio Schvezov
Approved revision: 141
Merged at revision: 141
Proposed branch: lp:~sergiusens/goget-ubuntu-touch/reducedSize
Merge into: lp:goget-ubuntu-touch
Diff against target: 69 lines (+53/-1)
2 files modified
sysutils/utils.go (+3/-1)
sysutils/utils_test.go (+50/-0)
To merge this branch: bzr merge lp:~sergiusens/goget-ubuntu-touch/reducedSize
Reviewer Review Type Date Requested Status
Michael Vogt (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+253308@code.launchpad.net

Commit message

For core images, take into account that the real size for drives can be lees that declared.

Description of the change

I personally tested with size 4 and 16, dd'ing to the respective cards and booting from them.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Vogt (mvo) wrote :

This looks fine, the only thing I wonder if maybe a 1 MB file is enough - unless you use a sparse file in which case it does not matter.

review: Approve
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

> This looks fine, the only thing I wonder if maybe a 1 MB file is enough -
> unless you use a sparse file in which case it does not matter.

It is sparse, the 1 and 2 are actually 1GB and 2GB

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sysutils/utils.go'
2--- sysutils/utils.go 2015-01-21 23:22:53 +0000
3+++ sysutils/utils.go 2015-03-18 03:34:33 +0000
4@@ -50,7 +50,9 @@
5 case GiB:
6 size = size * 1024 * 1024 * 1024
7 case GB:
8- size = size * 1000 * 1000 * 1000
9+ // The image size will be reduced to fit commercial drives that are
10+ // smaller than what they claim, 975 comes from 97.5% of the total size
11+ size = size * 1000 * 1000 * 975
12 default:
13 panic("improper sizing unit used")
14 }
15
16=== added file 'sysutils/utils_test.go'
17--- sysutils/utils_test.go 1970-01-01 00:00:00 +0000
18+++ sysutils/utils_test.go 2015-03-18 03:34:33 +0000
19@@ -0,0 +1,50 @@
20+package sysutils
21+
22+import (
23+ "os"
24+ "path/filepath"
25+ "testing"
26+
27+ . "launchpad.net/gocheck"
28+)
29+
30+// Hook up gocheck into the "go test" runner.
31+func Test(t *testing.T) { TestingT(t) }
32+
33+type UtilsTestSuite struct {
34+ tmpdir string
35+}
36+
37+var _ = Suite(&UtilsTestSuite{})
38+
39+func (s *UtilsTestSuite) SetUpTest(c *C) {
40+ s.tmpdir = c.MkDir()
41+}
42+
43+func (s *UtilsTestSuite) TestCreateEmptyFileGiB(c *C) {
44+ f := filepath.Join(s.tmpdir, "gib")
45+ c.Assert(CreateEmptyFile(f, 1, GiB), IsNil)
46+
47+ fStat, err := os.Stat(f)
48+ c.Assert(err, IsNil)
49+
50+ c.Assert(fStat.Size(), Equals, int64(1024*1024*1024))
51+}
52+
53+func (s *UtilsTestSuite) TestCreateEmptyFileGB(c *C) {
54+ f1 := filepath.Join(s.tmpdir, "gb")
55+ c.Assert(CreateEmptyFile(f1, 1, GB), IsNil)
56+
57+ fStat1, err := os.Stat(f1)
58+ c.Assert(err, IsNil)
59+
60+ c.Assert(fStat1.Size(), Equals, int64(1000*1000*975))
61+
62+ f2 := filepath.Join(s.tmpdir, "gb")
63+ c.Assert(CreateEmptyFile(f2, 2, GB), IsNil)
64+
65+ fStat2, err := os.Stat(f2)
66+ c.Assert(err, IsNil)
67+
68+ c.Assert(fStat2.Size(), Equals, int64(2*1000*1000*975))
69+}

Subscribers

People subscribed via source and target branches