1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#!/usr/bin/python
#
# Copyright (C) 2010, Canonical Ltd (http://www.canonical.com/)
#
# This file is part of ubuntu-server-iso-testing.
#
# ubuntu-server-iso-testing is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# ubuntu-server-iso-testing is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ubuntu-server-iso-testing. If not, see
# <http://www.gnu.org/licenses/>.
#
import logging
import os.path
import subprocess
import unittest
import platform
logging.basicConfig(level=logging.INFO)
class MinimalVirtualTest(unittest.TestCase):
def testLinuxVirtual(self):
cmd = ["dpkg-query", "-W", "-f=${Package}", "linux-virtual"]
logging.debug("Cmd: %s" % (cmd))
output = subprocess.Popen(cmd,
stdout=subprocess.PIPE).communicate()[0]
logging.debug("Cmd output: %s" % (output))
self.assertEquals("linux-virtual", output)
def testReadWrite(self):
t_fh = open(os.path.join('/tmp', 'a'), 'w')
self.assertNotEqual(t_fh, None)
self.assertEqual(t_fh.write('a'), None)
self.assertEqual(t_fh.close(), None)
def testNoUbuntuStandard(self):
cmd = ["dpkg-query", "-W", "-f=${Package}", "ubuntu-standard"]
logging.debug("Cmd: %s" % (cmd))
output = subprocess.Popen(cmd,
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0]
logging.debug("Cmd output: %s" % (output))
self.assertNotEquals("ubuntu-standard", output)
def testKernelModuleSize(self):
cmd = ["du", "-s", "/lib/modules"]
logging.debug("Cmd: %s" % (cmd))
output = subprocess.Popen(cmd,
stdout=subprocess.PIPE).communicate()[0]
logging.debug("Cmd output: %s" % (output))
lines = output.split()
self.assertNotEqual(len(lines), 0)
self.assertTrue(int(lines[0]) < 40000, lines[0])
def testInstallSize(self):
cmd = ["df", "/"]
logging.debug("Cmd: %s" % (cmd))
output = subprocess.Popen(cmd,
stdout=subprocess.PIPE).communicate()[0]
logging.debug("Cmd output: %s" % (output))
lines = output.split("\n")
self.assertEqual(len(lines), 3)
used = int(lines[1].split()[2])
# Increased +25MB to accomodate test overlay
max_install_size = 668000
# Add overhead for multiarch package lists on amd64
if platform.machine() == "x86_64":
max_install_size += 93250
self.assertTrue( used < max_install_size, "Used: %s" % (used))
if __name__ == '__main__':
unittest.main()
|