summaryrefslogtreecommitdiff
path: root/meta/lib
diff options
context:
space:
mode:
authorAlexander Kanavin <alexander.kanavin@linux.intel.com>2017-01-30 20:03:53 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-13 09:43:21 +0000
commit749a496d273f9fd378588e309cf976294584ca5f (patch)
tree934850affbf6869c8069033b92e60e8c591a8614 /meta/lib
parent8f331db8136c8bf28ceea7f8ae410eb9d83225ad (diff)
downloadopenembedded-core-749a496d273f9fd378588e309cf976294584ca5f.tar.gz
openembedded-core-749a496d273f9fd378588e309cf976294584ca5f.tar.bz2
openembedded-core-749a496d273f9fd378588e309cf976294584ca5f.zip
testimage.bbclass: fix runtime test for rpm, port smart tests to dnf
Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/oetest.py7
-rw-r--r--meta/lib/oeqa/runtime/cases/dnf.py111
-rw-r--r--meta/lib/oeqa/runtime/cases/parselogs.py1
-rw-r--r--meta/lib/oeqa/runtime/cases/rpm.py21
-rw-r--r--meta/lib/oeqa/runtime/cases/smart.py196
5 files changed, 123 insertions, 213 deletions
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index 1dad763ff1..f7171260e7 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -128,13 +128,6 @@ class oeRuntimeTest(oeTest):
def tearDownLocal(self):
pass
- #TODO: use package_manager.py to install packages on any type of image
- def install_packages(self, packagelist):
- for package in packagelist:
- (status, result) = self.target.run("smart install -y "+package)
- if status != 0:
- return status
-
def getmodule(pos=2):
# stack returns a list of tuples containg frame information
# First element of the list the is current frame, caller is 1
diff --git a/meta/lib/oeqa/runtime/cases/dnf.py b/meta/lib/oeqa/runtime/cases/dnf.py
new file mode 100644
index 0000000000..77e7eb9450
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/dnf.py
@@ -0,0 +1,111 @@
+import os
+import re
+import subprocess
+from oeqa.utils.httpserver import HTTPService
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.oeid import OETestID
+from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class DnfTest(OERuntimeTestCase):
+
+ def dnf(self, command, expected = 0):
+ command = 'dnf-2 %s' % command
+ status, output = self.target.run(command, 1500)
+ message = os.linesep.join([command, output])
+ self.assertEqual(status, expected, message)
+ return output
+
+class DnfBasicTest(DnfTest):
+
+ @skipIfNotFeature('package-management',
+ 'Test requires package-management to be in IMAGE_FEATURES')
+ @skipIfNotDataVar('IMAGE_PKGTYPE', 'rpm',
+ 'RPM is not the primary package manager')
+ @OEHasPackage(['dnf'])
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_dnf_help(self):
+ self.dnf('--help')
+
+ @OETestDepends(['dnf.DnfBasicTest.test_dnf_help'])
+ def test_dnf_version(self):
+ self.dnf('--version')
+
+ @OETestDepends(['dnf.DnfBasicTest.test_dnf_help'])
+ def test_dnf_info(self):
+ self.dnf('info dnf')
+
+ @OETestDepends(['dnf.DnfBasicTest.test_dnf_help'])
+ def test_dnf_search(self):
+ self.dnf('search dnf')
+
+ @OETestDepends(['dnf.DnfBasicTest.test_dnf_help'])
+ def test_dnf_history(self):
+ self.dnf('history')
+
+class DnfRepoTest(DnfTest):
+
+ @classmethod
+ def setUpClass(cls):
+ cls.repo_server = HTTPService(os.path.join(cls.tc.td['WORKDIR'], 'oe-testimage-repo'),
+ cls.tc.target.server_ip)
+ cls.repo_server.start()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.repo_server.stop()
+
+ def dnf_with_repo(self, command):
+ pkgarchs = os.listdir(os.path.join(self.tc.td['WORKDIR'], 'oe-testimage-repo'))
+ deploy_url = 'http://%s:%s/' %(self.target.server_ip, self.repo_server.port)
+ cmdlinerepoopts = ["--repofrompath=oe-testimage-repo-%s,%s%s" %(arch, deploy_url, arch) for arch in pkgarchs]
+
+ self.dnf(" ".join(cmdlinerepoopts) + " --nogpgcheck " + command)
+
+ @OETestDepends(['dnf.DnfBasicTest.test_dnf_help'])
+ def test_dnf_makecache(self):
+ self.dnf_with_repo('makecache')
+
+
+# Does not work when repo is specified on the command line
+# @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache'])
+# def test_dnf_repolist(self):
+# self.dnf_with_repo('repolist')
+
+ @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache'])
+ def test_dnf_repoinfo(self):
+ self.dnf_with_repo('repoinfo')
+
+ @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache'])
+ def test_dnf_install(self):
+ self.dnf_with_repo('install -y run-postinsts-dev')
+
+ @OETestDepends(['dnf.DnfRepoTest.test_dnf_install'])
+ def test_dnf_install_dependency(self):
+ self.dnf_with_repo('remove -y run-postinsts')
+ self.dnf_with_repo('install -y run-postinsts-dev')
+
+ @OETestDepends(['dnf.DnfRepoTest.test_dnf_install_dependency'])
+ def test_dnf_install_from_disk(self):
+ self.dnf_with_repo('remove -y run-postinsts-dev')
+ self.dnf_with_repo('install -y --downloadonly run-postinsts-dev')
+ status, output = self.target.run('find /var/cache/dnf -name run-postinsts-dev*rpm', 1500)
+ self.assertEqual(status, 0, output)
+ self.dnf_with_repo('install -y %s' % output)
+
+ @OETestDepends(['dnf.DnfRepoTest.test_dnf_install_from_disk'])
+ def test_dnf_install_from_http(self):
+ output = subprocess.check_output('%s %s -name run-postinsts-dev*' % (bb.utils.which(os.getenv('PATH'), "find"),
+ self.tc.td['DEPLOY_DIR_RPM']), shell=True).decode("utf-8")
+ rpm_path = output.split("/")[-2] + "/" + output.split("/")[-1]
+ url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, rpm_path)
+ self.dnf_with_repo('remove -y run-postinsts-dev')
+ self.dnf_with_repo('install -y %s' % url)
+
+ @OETestDepends(['dnf.DnfRepoTest.test_dnf_install'])
+ def test_dnf_reinstall(self):
+ self.dnf_with_repo('reinstall -y run-postinsts-dev')
+
+
diff --git a/meta/lib/oeqa/runtime/cases/parselogs.py b/meta/lib/oeqa/runtime/cases/parselogs.py
index a53a3608bd..6e929469c4 100644
--- a/meta/lib/oeqa/runtime/cases/parselogs.py
+++ b/meta/lib/oeqa/runtime/cases/parselogs.py
@@ -48,6 +48,7 @@ common_errors = [
"stmmac_dvr_probe: warning: cannot get CSR clock",
"error: couldn\'t mount because of unsupported optional features",
"GPT: Use GNU Parted to correct GPT errors",
+ "Cannot set xattr user.Librepo.DownloadInProgress",
]
video_related = [
diff --git a/meta/lib/oeqa/runtime/cases/rpm.py b/meta/lib/oeqa/runtime/cases/rpm.py
index 532fbf82eb..05b94c7b40 100644
--- a/meta/lib/oeqa/runtime/cases/rpm.py
+++ b/meta/lib/oeqa/runtime/cases/rpm.py
@@ -102,14 +102,15 @@ class RpmInstallRemoveTest(OERuntimeTestCase):
@OETestDepends(['rpm.RpmInstallRemoveTest.test_rpm_remove'])
def test_check_rpm_install_removal_log_file_size(self):
"""
- Summary: Check rpm install/removal log file size
- Expected: There should be some method to keep rpm log in a small size .
+ Summary: Check that rpm writes into /var/log/messages
+ Expected: There should be some RPM prefixed entries in the above file.
Product: BSPs
Author: Alexandru Georgescu <alexandru.c.georgescu@intel.com>
+ Author: Alexander Kanavin <alexander.kanavin@intel.com>
AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
"""
db_files_cmd = 'ls /var/lib/rpm/__db.*'
- get_log_size_cmd = "du /var/lib/rpm/log/log.* | awk '{print $1}'"
+ check_log_cmd = "grep RPM /var/log/messages | wc -l"
# Make sure that some database files are under /var/lib/rpm as '__db.xxx'
status, output = self.target.run(db_files_cmd)
@@ -129,13 +130,13 @@ class RpmInstallRemoveTest(OERuntimeTestCase):
msg = 'Failed to remove rpm-doc package. Reason: {}'.format(output)
self.assertEqual(0, status, msg=msg)
- # Get the size of log file
- status, output = self.target.run(get_log_size_cmd)
+ # if using systemd this should ensure all entries are flushed to /var
+ status, output = self.target.run("journalctl --sync")
+ # Get the amount of entries in the log file
+ status, output = self.target.run(check_log_cmd)
msg = 'Failed to get the final size of the log file.'
self.assertEqual(0, status, msg=msg)
- # Compare each log size
- for log_file_size in output:
- msg = ('Log file size is greater that expected (~10MB), '
- 'found {} bytes'.format(log_file_size))
- self.assertLessEqual(int(log_file_size), 11264, msg=msg)
+ # Check that there's enough of them
+ self.assertGreaterEqual(int(output), 80,
+ 'Cound not find sufficient amount of rpm entries in /var/log/messages, found {} entries'.format(output))
diff --git a/meta/lib/oeqa/runtime/cases/smart.py b/meta/lib/oeqa/runtime/cases/smart.py
deleted file mode 100644
index 79bd9c8af7..0000000000
--- a/meta/lib/oeqa/runtime/cases/smart.py
+++ /dev/null
@@ -1,196 +0,0 @@
-import os
-import re
-import subprocess
-from oeqa.utils.httpserver import HTTPService
-
-from oeqa.runtime.case import OERuntimeTestCase
-from oeqa.core.decorator.depends import OETestDepends
-from oeqa.core.decorator.oeid import OETestID
-from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature
-from oeqa.runtime.decorator.package import OEHasPackage
-
-class SmartTest(OERuntimeTestCase):
-
- def smart(self, command, expected = 0):
- command = 'smart %s' % command
- status, output = self.target.run(command, 1500)
- message = os.linesep.join([command, output])
- self.assertEqual(status, expected, message)
- self.assertFalse('Cannot allocate memory' in output, message)
- return output
-
-class SmartBasicTest(SmartTest):
-
- @skipIfNotFeature('package-management',
- 'Test requires package-management to be in IMAGE_FEATURES')
- @skipIfNotDataVar('IMAGE_PKGTYPE', 'rpm',
- 'RPM is not the primary package manager')
- @OEHasPackage(['smartpm'])
- @OETestID(716)
- @OETestDepends(['ssh.SSHTest.test_ssh'])
- def test_smart_help(self):
- self.smart('--help')
-
- @OETestID(968)
- @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
- def test_smart_version(self):
- self.smart('--version')
-
- @OETestID(721)
- @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
- def test_smart_info(self):
- self.smart('info python-smartpm')
-
- @OETestID(421)
- @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
- def test_smart_query(self):
- self.smart('query python-smartpm')
-
- @OETestID(720)
- @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
- def test_smart_search(self):
- self.smart('search python-smartpm')
-
- @OETestID(722)
- @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
- def test_smart_stats(self):
- self.smart('stats')
-
-class SmartRepoTest(SmartTest):
-
- @classmethod
- def setUpClass(cls):
- cls.repolist = []
- cls.repo_server = HTTPService(cls.tc.td['WORKDIR'],
- cls.tc.target.server_ip)
- cls.repo_server.start()
-
- @classmethod
- def tearDownClass(cls):
- cls.repo_server.stop()
- for repo in cls.repolist:
- cls.tc.target.run('smart channel -y --remove %s' % repo)
-
- @OETestID(1143)
- @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
- def test_smart_channel(self):
- self.smart('channel', 1)
-
- @OETestID(719)
- @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
- def test_smart_channel_add(self):
- image_pkgtype = self.tc.td['IMAGE_PKGTYPE']
- deploy_url = 'http://%s:%s/%s' % (self.target.server_ip,
- self.repo_server.port,
- image_pkgtype)
- pkgarchs = self.tc.td['PACKAGE_ARCHS'].replace("-","_").split()
- archs = os.listdir(os.path.join(self.repo_server.root_dir,
- image_pkgtype))
- for arch in archs:
- if arch in pkgarchs:
- cmd = ('channel -y --add {a} type=rpm-md '
- 'baseurl={u}/{a}'.format(a=arch, u=deploy_url))
- self.smart(cmd)
- self.repolist.append(arch)
- self.smart('update')
-
- @OETestID(969)
- @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
- def test_smart_channel_help(self):
- self.smart('channel --help')
-
- @OETestID(970)
- @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
- def test_smart_channel_list(self):
- self.smart('channel --list')
-
- @OETestID(971)
- @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
- def test_smart_channel_show(self):
- self.smart('channel --show')
-
- @OETestID(717)
- @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
- def test_smart_channel_rpmsys(self):
- self.smart('channel --show rpmsys')
- self.smart('channel --disable rpmsys')
- self.smart('channel --enable rpmsys')
-
- @OETestID(1144)
- @OETestDepends(['smart.SmartRepoTest.test_smart_channel_add'])
- def test_smart_install(self):
- self.smart('remove -y psplash-default')
- self.smart('install -y psplash-default')
-
- @OETestID(728)
- @OETestDepends(['smart.SmartRepoTest.test_smart_install'])
- def test_smart_install_dependency(self):
- self.smart('remove -y psplash')
- self.smart('install -y psplash-default')
-
- @OETestID(723)
- @OETestDepends(['smart.SmartRepoTest.test_smart_channel_add'])
- def test_smart_install_from_disk(self):
- self.smart('remove -y psplash-default')
- self.smart('download psplash-default')
- self.smart('install -y ./psplash-default*')
-
- @OETestID(725)
- @OETestDepends(['smart.SmartRepoTest.test_smart_channel_add'])
- def test_smart_install_from_http(self):
- output = self.smart('download --urls psplash-default')
- url = re.search('(http://.*/psplash-default.*\.rpm)', output)
- self.assertTrue(url, msg="Couln't find download url in %s" % output)
- self.smart('remove -y psplash-default')
- self.smart('install -y %s' % url.group(0))
-
- @OETestID(729)
- @OETestDepends(['smart.SmartRepoTest.test_smart_install'])
- def test_smart_reinstall(self):
- self.smart('reinstall -y psplash-default')
-
- @OETestID(727)
- @OETestDepends(['smart.SmartRepoTest.test_smart_channel_add'])
- def test_smart_remote_repo(self):
- self.smart('update')
- self.smart('install -y psplash')
- self.smart('remove -y psplash')
-
- @OETestID(726)
- @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
- def test_smart_local_dir(self):
- self.target.run('mkdir /tmp/myrpmdir')
- self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y')
- self.target.run('cd /tmp/myrpmdir')
- self.smart('download psplash')
- output = self.smart('channel --list')
- for i in output.split("\n"):
- if ("rpmsys" != str(i)) and ("myrpmdir" != str(i)):
- self.smart('channel --disable '+str(i))
- self.target.run('cd $HOME')
- self.smart('install psplash')
- for i in output.split("\n"):
- if ("rpmsys" != str(i)) and ("myrpmdir" != str(i)):
- self.smart('channel --enable '+str(i))
- self.smart('channel --remove myrpmdir -y')
- self.target.run("rm -rf /tmp/myrpmdir")
-
- @OETestID(718)
- @OETestDepends(['smart.SmartBasicTest.test_smart_help'])
- def test_smart_add_rpmdir(self):
- self.target.run('mkdir /tmp/myrpmdir')
- self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y')
- self.smart('channel --disable myrpmdir -y')
- output = self.smart('channel --show myrpmdir')
- self.assertTrue("disabled = yes" in output, msg="Failed to disable rpm dir")
- self.smart('channel --enable myrpmdir -y')
- output = self.smart('channel --show myrpmdir')
- self.assertFalse("disabled = yes" in output, msg="Failed to enable rpm dir")
- self.smart('channel --remove myrpmdir -y')
- self.target.run("rm -rf /tmp/myrpmdir")
-
- @OETestID(731)
- @OETestDepends(['smart.SmartRepoTest.test_smart_channel_add'])
- def test_smart_remove_package(self):
- self.smart('install -y psplash')
- self.smart('remove -y psplash')