diff options
Diffstat (limited to 'meta/lib/oeqa/runtime/smart.py')
-rw-r--r-- | meta/lib/oeqa/runtime/smart.py | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/smart.py b/meta/lib/oeqa/runtime/smart.py new file mode 100644 index 0000000000..3b49314df7 --- /dev/null +++ b/meta/lib/oeqa/runtime/smart.py | |||
@@ -0,0 +1,121 @@ | |||
1 | import unittest | ||
2 | import re | ||
3 | from oeqa.oetest import oeRuntimeTest, skipModule | ||
4 | from oeqa.utils.decorators import * | ||
5 | from oeqa.utils.httpserver import HTTPService | ||
6 | |||
7 | def setUpModule(): | ||
8 | if not oeRuntimeTest.hasFeature("package-management"): | ||
9 | skipModule("Image doesn't have package management feature") | ||
10 | if not oeRuntimeTest.hasPackage("smart"): | ||
11 | skipModule("Image doesn't have smart installed") | ||
12 | if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES", True).split()[0]: | ||
13 | skipModule("Rpm is not the primary package manager") | ||
14 | |||
15 | class SmartTest(oeRuntimeTest): | ||
16 | |||
17 | @skipUnlessPassed('test_smart_help') | ||
18 | def smart(self, command, expected = 0): | ||
19 | command = 'smart %s' % command | ||
20 | status, output = self.target.run(command, 1500) | ||
21 | message = os.linesep.join([command, output]) | ||
22 | self.assertEqual(status, expected, message) | ||
23 | self.assertFalse("Cannot allocate memory" in output, message) | ||
24 | return output | ||
25 | |||
26 | class SmartBasicTest(SmartTest): | ||
27 | |||
28 | @testcase(716) | ||
29 | @skipUnlessPassed('test_ssh') | ||
30 | def test_smart_help(self): | ||
31 | self.smart('--help') | ||
32 | |||
33 | def test_smart_version(self): | ||
34 | self.smart('--version') | ||
35 | |||
36 | @testcase(721) | ||
37 | def test_smart_info(self): | ||
38 | self.smart('info python-smartpm') | ||
39 | |||
40 | @testcase(421) | ||
41 | def test_smart_query(self): | ||
42 | self.smart('query python-smartpm') | ||
43 | |||
44 | @testcase(720) | ||
45 | def test_smart_search(self): | ||
46 | self.smart('search python-smartpm') | ||
47 | |||
48 | @testcase(722) | ||
49 | def test_smart_stats(self): | ||
50 | self.smart('stats') | ||
51 | |||
52 | class SmartRepoTest(SmartTest): | ||
53 | |||
54 | @classmethod | ||
55 | def setUpClass(self): | ||
56 | self.repo_server = HTTPService(oeRuntimeTest.tc.d.getVar('DEPLOY_DIR', True), oeRuntimeTest.tc.target.server_ip) | ||
57 | self.repo_server.start() | ||
58 | |||
59 | @classmethod | ||
60 | def tearDownClass(self): | ||
61 | self.repo_server.stop() | ||
62 | |||
63 | def test_smart_channel(self): | ||
64 | self.smart('channel', 1) | ||
65 | |||
66 | @testcase(719) | ||
67 | def test_smart_channel_add(self): | ||
68 | image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE', True) | ||
69 | deploy_url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, image_pkgtype) | ||
70 | pkgarchs = self.tc.d.getVar('PACKAGE_ARCHS', True).replace("-","_").split() | ||
71 | for arch in os.listdir('%s/%s' % (self.repo_server.root_dir, image_pkgtype)): | ||
72 | if arch in pkgarchs: | ||
73 | self.smart('channel -y --add {a} type=rpm-md baseurl={u}/{a}'.format(a=arch, u=deploy_url)) | ||
74 | self.smart('update') | ||
75 | |||
76 | def test_smart_channel_help(self): | ||
77 | self.smart('channel --help') | ||
78 | |||
79 | def test_smart_channel_list(self): | ||
80 | self.smart('channel --list') | ||
81 | |||
82 | def test_smart_channel_show(self): | ||
83 | self.smart('channel --show') | ||
84 | |||
85 | @testcase(717) | ||
86 | def test_smart_channel_rpmsys(self): | ||
87 | self.smart('channel --show rpmsys') | ||
88 | self.smart('channel --disable rpmsys') | ||
89 | self.smart('channel --enable rpmsys') | ||
90 | |||
91 | @skipUnlessPassed('test_smart_channel_add') | ||
92 | def test_smart_install(self): | ||
93 | self.smart('remove -y psplash-default') | ||
94 | self.smart('install -y psplash-default') | ||
95 | |||
96 | @testcase(728) | ||
97 | @skipUnlessPassed('test_smart_install') | ||
98 | def test_smart_install_dependency(self): | ||
99 | self.smart('remove -y psplash') | ||
100 | self.smart('install -y psplash-default') | ||
101 | |||
102 | @testcase(723) | ||
103 | @skipUnlessPassed('test_smart_channel_add') | ||
104 | def test_smart_install_from_disk(self): | ||
105 | self.smart('remove -y psplash-default') | ||
106 | self.smart('download psplash-default') | ||
107 | self.smart('install -y ./psplash-default*') | ||
108 | |||
109 | @testcase(725) | ||
110 | @skipUnlessPassed('test_smart_channel_add') | ||
111 | def test_smart_install_from_http(self): | ||
112 | output = self.smart('download --urls psplash-default') | ||
113 | url = re.search('(http://.*/psplash-default.*\.rpm)', output) | ||
114 | self.assertTrue(url, msg="Couln't find download url in %s" % output) | ||
115 | self.smart('remove -y psplash-default') | ||
116 | self.smart('install -y %s' % url.group(0)) | ||
117 | |||
118 | @testcase(729) | ||
119 | @skipUnlessPassed('test_smart_install') | ||
120 | def test_smart_reinstall(self): | ||
121 | self.smart('reinstall -y psplash-default') | ||