summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/imagefeatures.py
diff options
context:
space:
mode:
authorLeonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>2017-05-12 14:40:21 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-06 19:02:43 +0100
commit157c3be2ca93f076033f725ec1ee912df91f7488 (patch)
tree8ef896ff7adf78d63b34059cd5b017a4f0a3419a /meta/lib/oeqa/selftest/cases/imagefeatures.py
parent10c512b60d1167122b5fe778b93838dca3def717 (diff)
downloadpoky-157c3be2ca93f076033f725ec1ee912df91f7488.tar.gz
oeqa/selftest/cases: Migrate test cases into the new oe-qa framework
New framework has different classes/decorators so adapt current test cases to support these. Changes include changes on base classes and decorators. Also include paths in selftest/__init__.py isn't needed because the loader is the standard unittest one. (From OE-Core rev: ddbbefdd124604d10bd47dd0266b55a764fcc0ab) Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/imagefeatures.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/imagefeatures.py125
1 files changed, 125 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/imagefeatures.py b/meta/lib/oeqa/selftest/cases/imagefeatures.py
new file mode 100644
index 0000000000..45a06feaf3
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/imagefeatures.py
@@ -0,0 +1,125 @@
1from oeqa.selftest.case import OESelftestTestCase
2from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu
3from oeqa.core.decorator.oeid import OETestID
4from oeqa.utils.sshcontrol import SSHControl
5import os
6
7class ImageFeatures(OESelftestTestCase):
8
9 test_user = 'tester'
10 root_user = 'root'
11
12 @OETestID(1107)
13 def test_non_root_user_can_connect_via_ssh_without_password(self):
14 """
15 Summary: Check if non root user can connect via ssh without password
16 Expected: 1. Connection to the image via ssh using root user without providing a password should be allowed.
17 2. Connection to the image via ssh using tester user without providing a password should be allowed.
18 Product: oe-core
19 Author: Ionut Chisanovici <ionutx.chisanovici@intel.com>
20 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
21 """
22
23 features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh empty-root-password allow-empty-password"\n'
24 features += 'INHERIT += "extrausers"\n'
25 features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user)
26 self.write_config(features)
27
28 # Build a core-image-minimal
29 bitbake('core-image-minimal')
30
31 with runqemu("core-image-minimal") as qemu:
32 # Attempt to ssh with each user into qemu with empty password
33 for user in [self.root_user, self.test_user]:
34 ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user=user)
35 status, output = ssh.run("true")
36 self.assertEqual(status, 0, 'ssh to user %s failed with %s' % (user, output))
37
38 @OETestID(1115)
39 def test_all_users_can_connect_via_ssh_without_password(self):
40 """
41 Summary: Check if all users can connect via ssh without password
42 Expected: 1. Connection to the image via ssh using root user without providing a password should NOT be allowed.
43 2. Connection to the image via ssh using tester user without providing a password should be allowed.
44 Product: oe-core
45 Author: Ionut Chisanovici <ionutx.chisanovici@intel.com>
46 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
47 """
48
49 features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh allow-empty-password"\n'
50 features += 'INHERIT += "extrausers"\n'
51 features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user)
52 self.write_config(features)
53
54 # Build a core-image-minimal
55 bitbake('core-image-minimal')
56
57 with runqemu("core-image-minimal") as qemu:
58 # Attempt to ssh with each user into qemu with empty password
59 for user in [self.root_user, self.test_user]:
60 ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user=user)
61 status, output = ssh.run("true")
62 if user == 'root':
63 self.assertNotEqual(status, 0, 'ssh to user root was allowed when it should not have been')
64 else:
65 self.assertEqual(status, 0, 'ssh to user tester failed with %s' % output)
66
67
68 @OETestID(1116)
69 def test_clutter_image_can_be_built(self):
70 """
71 Summary: Check if clutter image can be built
72 Expected: 1. core-image-clutter can be built
73 Product: oe-core
74 Author: Ionut Chisanovici <ionutx.chisanovici@intel.com>
75 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
76 """
77
78 # Build a core-image-clutter
79 bitbake('core-image-clutter')
80
81 @OETestID(1117)
82 def test_wayland_support_in_image(self):
83 """
84 Summary: Check Wayland support in image
85 Expected: 1. Wayland image can be build
86 2. Wayland feature can be installed
87 Product: oe-core
88 Author: Ionut Chisanovici <ionutx.chisanovici@intel.com>
89 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
90 """
91
92 distro_features = get_bb_var('DISTRO_FEATURES')
93 if not ('opengl' in distro_features and 'wayland' in distro_features):
94 self.skipTest('neither opengl nor wayland present on DISTRO_FEATURES so core-image-weston cannot be built')
95
96 # Build a core-image-weston
97 bitbake('core-image-weston')
98
99 def test_bmap(self):
100 """
101 Summary: Check bmap support
102 Expected: 1. core-image-minimal can be build with bmap support
103 2. core-image-minimal is sparse
104 Product: oe-core
105 Author: Ed Bartosh <ed.bartosh@linux.intel.com>
106 """
107
108 features = 'IMAGE_FSTYPES += " ext4 ext4.bmap"'
109 self.write_config(features)
110
111 image_name = 'core-image-minimal'
112 bitbake(image_name)
113
114 deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE')
115 link_name = get_bb_var('IMAGE_LINK_NAME', image_name)
116 image_path = os.path.join(deploy_dir_image, "%s.ext4" % link_name)
117 bmap_path = "%s.bmap" % image_path
118
119 # check if result image and bmap file are in deploy directory
120 self.assertTrue(os.path.exists(image_path))
121 self.assertTrue(os.path.exists(bmap_path))
122
123 # check if result image is sparse
124 image_stat = os.stat(image_path)
125 self.assertTrue(image_stat.st_size > image_stat.st_blocks * 512)