[PATCH 08/20] oeqa.selftest.imagefeatures: Split configuration from code

Jose Lamego
2016-08-08T16:23:20Z

meta/lib/oeqa/selftest/conf/imagefeatures.conf | 19 +++++++++
meta/lib/oeqa/selftest/imagefeatures.py | 55 +++++++++++++++++---------
2 files changed, 56 insertions(+), 18 deletions(-)
create mode 100644 meta/lib/oeqa/selftest/conf/imagefeatures.conf

diff --git a/meta/lib/oeqa/selftest/conf/imagefeatures.conf b/meta/lib/oeqa/selftest/conf/imagefeatures.conf
new file mode 100644
index 0000000..23e9dd5
--- /dev/null
+++ b/meta/lib/oeqa/selftest/conf/imagefeatures.conf
@@ -0,0 +1,19 @@
+[imagefeatures]
+test_user = tester
+root_user = root
+test_non_root_user_can_connect_via_ssh_without_password_features =
+ 'EXTRA_IMAGE_FEATURES = \
+ "ssh-server-openssh empty-root-password allow-empty-password"\n\
+ INHERIT += "extrausers"\n'
+test_non_root_user_can_connect_via_ssh_without_password_image = core-image-minimal
+test_all_users_can_connect_via_ssh_without_password_features =
+ 'EXTRA_IMAGE_FEATURES = \
+ "ssh-server-openssh allow-empty-password"\n\
+ INHERIT += "extrausers"\n'
+test_all_users_can_connect_via_ssh_without_password_image = core-image-minimal
+test_wayland_support_in_image_features =
+ 'DISTRO_FEATURES_append = " wayland"\n\
+ CORE_IMAGE_EXTRA_INSTALL += "wayland weston"'
+test_wayland_support_in_image_image = core-image-weston
+test_bmap_features = IMAGE_FSTYPES += " ext4 ext4.bmap"
+test_bmap_image = core-image-minimal
diff --git a/meta/lib/oeqa/selftest/imagefeatures.py b/meta/lib/oeqa/selftest/imagefeatures.py
index 08e382f..654a020 100644
--- a/meta/lib/oeqa/selftest/imagefeatures.py
+++ b/meta/lib/oeqa/selftest/imagefeatures.py
@@ -5,11 +5,17 @@ from oeqa.utils.sshcontrol import SSHControl
import os
import sys
import logging
+from oeqa.utils.readconfig import conffile
+

class ImageFeatures(oeSelfTest):

- test_user = 'tester'
- root_user = 'root'
+ @classmethod
+ def setUpClass(cls):
+ # Get test configurations from configuration file
+ cls.config = conffile(__file__)
+ cls.test_user = cls.config.get('imagefeatures', 'test_user')
+ cls.root_user = cls.config.get('imagefeatures', 'root_user')

@testcase(1107)
def test_non_root_user_can_connect_via_ssh_without_password(self):
@@ -22,15 +28,22 @@ class ImageFeatures(oeSelfTest):
AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
"""

- features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh empty-root-password allow-empty-password"\n'
- features += 'INHERIT += "extrausers"\n'
- features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user)
+ features = eval(
+ self.config.get(
+ 'imagefeatures',
+ 'test_non_root_user_can_connect_via_ssh_without_password_\
+features'))
+ image = self.config.get(
+ 'imagefeatures',
+ 'test_non_root_user_can_connect_via_ssh_without_password_image')
+ features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s \
+/bin/sh {};"'.format(self.test_user, self.test_user)
self.write_config(features)

# Build a core-image-minimal
- bitbake('core-image-minimal')
+ bitbake(image)

- with runqemu("core-image-minimal") as qemu:
+ with runqemu(image) as qemu:
# Attempt to ssh with each user into qemu with empty password
for user in [self.root_user, self.test_user]:
ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user=user)
@@ -48,15 +61,19 @@ class ImageFeatures(oeSelfTest):
AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
"""

- features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh allow-empty-password"\n'
- features += 'INHERIT += "extrausers"\n'
- features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user)
+ features = eval(
+ self.config.get('imagefeatures', 'test_all_users_can_connect_\
+via_ssh_without_password_features'))
+ image = self.config.get('imagefeatures', 'test_all_users_can_connect_\
+via_ssh_without_password_image')
+ features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s \
+/bin/sh {};"'.format(self.test_user, self.test_user)
self.write_config(features)

# Build a core-image-minimal
- bitbake('core-image-minimal')
+ bitbake(image)

- with runqemu("core-image-minimal") as qemu:
+ with runqemu(image) as qemu:
# Attempt to ssh with each user into qemu with empty password
for user in [self.root_user, self.test_user]:
ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user=user)
@@ -66,7 +83,6 @@ class ImageFeatures(oeSelfTest):
else:
self.assertEqual(status, 0, 'ssh to user tester failed with %s' % output)

-
@testcase(1116)
def test_clutter_image_can_be_built(self):
"""
@@ -91,12 +107,15 @@ class ImageFeatures(oeSelfTest):
AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
"""

- features = 'DISTRO_FEATURES_append = " wayland"\n'
- features += 'CORE_IMAGE_EXTRA_INSTALL += "wayland weston"'
+ features = eval(self.config.get(
+ 'imagefeatures',
+ 'test_wayland_support_in_image_features'))
+ image = self.config.get(
+ 'imagefeatures', 'test_wayland_support_in_image_image')
self.write_config(features)

# Build a core-image-weston
- bitbake('core-image-weston')
+ bitbake(image)

def test_bmap(self):
"""
@@ -107,10 +126,10 @@ class ImageFeatures(oeSelfTest):
Author: Ed Bartosh <ed.bartosh@linux.intel.com>
"""

- features = 'IMAGE_FSTYPES += " ext4 ext4.bmap"'
+ features = self.config.get('imagefeatures', 'test_bmap_features')
+ image_name = self.config.get('imagefeatures', 'test_bmap_image')
self.write_config(features)

- image_name = 'core-image-minimal'
bitbake(image_name)

deploy_dir = get_bb_var('DEPLOY_DIR_IMAGE')
--
1.8.3.1