Merge lp:~elopio/snappy/test_free_space into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by Leo Arias on 2015-09-04
Status: Merged
Approved by: Oliver Grawert on 2015-09-04
Approved revision: 652
Merged at revision: 652
Proposed branch: lp:~elopio/snappy/test_free_space
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Diff against target: 64 lines (+55/-0)
2 files modified
_integration-tests/tests/get_unpartitioned_space (+8/-0)
_integration-tests/tests/initramfs_test.go (+47/-0)
To merge this branch: bzr merge lp:~elopio/snappy/test_free_space
Reviewer Review Type Date Requested Status
Oliver Grawert Approve on 2015-09-04
Leo Arias Approve on 2015-09-04
Federico Gimenez (community) 2015-09-04 Approve on 2015-09-04
Review via email: mp+270137@code.launchpad.net

Commit Message

Added a test for the free unpartitioned space.

To post a comment you must log in.
Federico Gimenez (fgimenez) wrote :

LGTM, a couple of ignorable nits about naming imports inline :)

review: Approve
lp:~elopio/snappy/test_free_space updated on 2015-09-04
652. By Leo Arias on 2015-09-04

Import fixes.

Leo Arias (elopio) wrote :

Thanks Federico. I pushed the changes.

review: Approve
Oliver Grawert (ogra) wrote :

looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '_integration-tests/tests/get_unpartitioned_space'
2--- _integration-tests/tests/get_unpartitioned_space 1970-01-01 00:00:00 +0000
3+++ _integration-tests/tests/get_unpartitioned_space 2015-09-04 13:48:54 +0000
4@@ -0,0 +1,8 @@
5+#!/bin/sh
6+
7+set -e
8+
9+writable_part="$(findfs LABEL=writable)"
10+syspath="$(dirname $(realpath /sys/class/block/$(basename $writable_part)))"
11+device="$(realpath /dev/block/$(cat $syspath/dev))"
12+sudo parted $device unit % print free | grep 'Free Space' | tail -n1 | awk '{print $3}'
13
14=== added file '_integration-tests/tests/initramfs_test.go'
15--- _integration-tests/tests/initramfs_test.go 1970-01-01 00:00:00 +0000
16+++ _integration-tests/tests/initramfs_test.go 2015-09-04 13:48:54 +0000
17@@ -0,0 +1,47 @@
18+// -*- Mode: Go; indent-tabs-mode: t -*-
19+
20+/*
21+ * Copyright (C) 2015 Canonical Ltd
22+ *
23+ * This program is free software: you can redistribute it and/or modify
24+ * it under the terms of the GNU General Public License version 3 as
25+ * published by the Free Software Foundation.
26+ *
27+ * This program is distributed in the hope that it will be useful,
28+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
29+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30+ * GNU General Public License for more details.
31+ *
32+ * You should have received a copy of the GNU General Public License
33+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
34+ *
35+ */
36+
37+package tests
38+
39+import (
40+ "os/exec"
41+ "strconv"
42+ "strings"
43+
44+ "launchpad.net/snappy/_integration-tests/testutils/common"
45+
46+ "gopkg.in/check.v1"
47+)
48+
49+var _ = check.Suite(&initRAMFSSuite{})
50+
51+type initRAMFSSuite struct {
52+ common.SnappySuite
53+}
54+
55+func (s *initRAMFSSuite) TestFreeSpace(c *check.C) {
56+ cmd := exec.Command("sh", "_integration-tests/tests/get_unpartitioned_space")
57+ free, err := cmd.Output()
58+ freePercent := strings.TrimRight(strings.TrimSpace(string(free)), "%")
59+ freePercentFloat, err := strconv.ParseFloat(freePercent, 32)
60+ c.Assert(err, check.IsNil,
61+ check.Commentf("Error converting the free space percentage to float: %s", err))
62+ c.Assert(freePercentFloat < 10, check.Equals, true,
63+ check.Commentf("The free space at the end of the disk is greater than 10%"))
64+}

Subscribers

People subscribed via source and target branches