oeqa/runtime/cases: Migrate underscore cases
There were two missing cases to be migrated to the new framework: _qemutiny and _ptest. qemutiny was straightforward. ptest on the other hand wasn't working even in previous releases; it has been migrated from smart to dnf, and how ptest packages are gathered to be installed, adapted to use unicode, and removed a lot of code that wasn't needed anymore. (From OE-Core rev: ee7c19546b686e852d01df25143504d9798d10d6) Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
34a7654689
commit
739130370f
|
@ -1,30 +1,39 @@
|
||||||
import unittest, os, shutil
|
import os
|
||||||
from oeqa.oetest import oeRuntimeTest, skipModule
|
import shutil
|
||||||
from oeqa.utils.decorators import *
|
|
||||||
from oeqa.utils.logparser import *
|
|
||||||
from oeqa.utils.httpserver import HTTPService
|
|
||||||
import bb
|
|
||||||
import glob
|
|
||||||
from oe.package_manager import RpmPkgsList
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
def setUpModule():
|
from oeqa.runtime.case import OERuntimeTestCase
|
||||||
if not oeRuntimeTest.hasFeature("package-management"):
|
from oeqa.core.decorator.depends import OETestDepends
|
||||||
skipModule("Image doesn't have package management feature")
|
from oeqa.core.decorator.oeid import OETestID
|
||||||
if not oeRuntimeTest.hasPackage("smartpm"):
|
from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature
|
||||||
skipModule("Image doesn't have smart installed")
|
from oeqa.runtime.decorator.package import OEHasPackage
|
||||||
if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES").split()[0]:
|
|
||||||
skipModule("Rpm is not the primary package manager")
|
|
||||||
|
|
||||||
class PtestRunnerTest(oeRuntimeTest):
|
from oeqa.runtime.cases.dnf import DnfTest
|
||||||
|
from oeqa.utils.logparser import *
|
||||||
|
from oeqa.utils.httpserver import HTTPService
|
||||||
|
|
||||||
|
class PtestRunnerTest(DnfTest):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
rpm_deploy = os.path.join(cls.tc.td['DEPLOY_DIR'], 'rpm')
|
||||||
|
cls.repo_server = HTTPService(rpm_deploy, cls.tc.target.server_ip)
|
||||||
|
cls.repo_server.start()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
cls.repo_server.stop()
|
||||||
|
|
||||||
# a ptest log parser
|
# a ptest log parser
|
||||||
def parse_ptest(self, logfile):
|
def parse_ptest(self, logfile):
|
||||||
parser = Lparser(test_0_pass_regex="^PASS:(.+)", test_0_fail_regex="^FAIL:(.+)", section_0_begin_regex="^BEGIN: .*/(.+)/ptest", section_0_end_regex="^END: .*/(.+)/ptest")
|
parser = Lparser(test_0_pass_regex="^PASS:(.+)",
|
||||||
|
test_0_fail_regex="^FAIL:(.+)",
|
||||||
|
section_0_begin_regex="^BEGIN: .*/(.+)/ptest",
|
||||||
|
section_0_end_regex="^END: .*/(.+)/ptest")
|
||||||
parser.init()
|
parser.init()
|
||||||
result = Result()
|
result = Result()
|
||||||
|
|
||||||
with open(logfile) as f:
|
with open(logfile, errors='replace') as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
result_tuple = parser.parse_line(line)
|
result_tuple = parser.parse_line(line)
|
||||||
if not result_tuple:
|
if not result_tuple:
|
||||||
|
@ -50,70 +59,39 @@ class PtestRunnerTest(oeRuntimeTest):
|
||||||
result.sort_tests()
|
result.sort_tests()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@classmethod
|
def _install_ptest_packages(self):
|
||||||
def setUpClass(self):
|
# Get ptest packages that can be installed in the image.
|
||||||
#note the existing channels that are on the board before creating new ones
|
packages_dir = os.path.join(self.tc.td['DEPLOY_DIR'], 'rpm')
|
||||||
# self.existingchannels = set()
|
ptest_pkgs = [pkg[:pkg.find('-ptest')+6]
|
||||||
# (status, result) = oeRuntimeTest.tc.target.run('smart channel --show | grep "\["', 0)
|
for _, _, filenames in os.walk(packages_dir)
|
||||||
# for x in result.split("\n"):
|
for pkg in filenames
|
||||||
# self.existingchannels.add(x)
|
if 'ptest' in pkg
|
||||||
self.repo_server = HTTPService(oeRuntimeTest.tc.d.getVar('DEPLOY_DIR'), oeRuntimeTest.tc.target.server_ip)
|
and pkg[:pkg.find('-ptest')] in self.tc.image_packages]
|
||||||
self.repo_server.start()
|
|
||||||
|
|
||||||
@classmethod
|
repo_url = 'http://%s:%s' % (self.target.server_ip,
|
||||||
def tearDownClass(self):
|
self.repo_server.port)
|
||||||
self.repo_server.stop()
|
dnf_options = ('--repofrompath=oe-ptest-repo,%s '
|
||||||
#remove created channels to be able to repeat the tests on same image
|
'--nogpgcheck '
|
||||||
# (status, result) = oeRuntimeTest.tc.target.run('smart channel --show | grep "\["', 0)
|
'install -y' % repo_url)
|
||||||
# for x in result.split("\n"):
|
self.dnf('%s %s ptest-runner' % (dnf_options, ' '.join(ptest_pkgs)))
|
||||||
# if x not in self.existingchannels:
|
|
||||||
# oeRuntimeTest.tc.target.run('smart channel --remove '+x[1:-1]+' -y', 0)
|
|
||||||
|
|
||||||
def add_smart_channel(self):
|
@skipIfNotFeature('package-management',
|
||||||
image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE')
|
'Test requires package-management to be in DISTRO_FEATURES')
|
||||||
deploy_url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, image_pkgtype)
|
@skipIfNotFeature('ptest',
|
||||||
pkgarchs = self.tc.d.getVar('PACKAGE_ARCHS').replace("-","_").split()
|
'Test requires package-management to be in DISTRO_FEATURES')
|
||||||
for arch in os.listdir('%s/%s' % (self.repo_server.root_dir, image_pkgtype)):
|
@skipIfNotDataVar('IMAGE_PKGTYPE', 'rpm',
|
||||||
if arch in pkgarchs:
|
'RPM is not the primary package manager')
|
||||||
self.target.run('smart channel -y --add {a} type=rpm-md baseurl={u}/{a}'.format(a=arch, u=deploy_url), 0)
|
@OEHasPackage(['dnf'])
|
||||||
self.target.run('smart update', 0)
|
@OETestDepends(['ssh.SSHTest.test_ssh'])
|
||||||
|
|
||||||
def install_complementary(self, globs=None):
|
|
||||||
installed_pkgs_file = os.path.join(oeRuntimeTest.tc.d.getVar('WORKDIR'),
|
|
||||||
"installed_pkgs.txt")
|
|
||||||
self.pkgs_list = RpmPkgsList(oeRuntimeTest.tc.d, oeRuntimeTest.tc.d.getVar('IMAGE_ROOTFS'), oeRuntimeTest.tc.d.getVar('arch_var'), oeRuntimeTest.tc.d.getVar('os_var'))
|
|
||||||
with open(installed_pkgs_file, "w+") as installed_pkgs:
|
|
||||||
installed_pkgs.write(self.pkgs_list.list("arch"))
|
|
||||||
|
|
||||||
cmd = [bb.utils.which(os.getenv('PATH'), "oe-pkgdata-util"),
|
|
||||||
"-p", oeRuntimeTest.tc.d.getVar('PKGDATA_DIR'), "glob", installed_pkgs_file,
|
|
||||||
globs]
|
|
||||||
try:
|
|
||||||
bb.note("Installing complementary packages ...")
|
|
||||||
complementary_pkgs = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
|
|
||||||
except subprocess.CalledProcessError as e:
|
|
||||||
bb.fatal("Could not compute complementary packages list. Command "
|
|
||||||
"'%s' returned %d:\n%s" %
|
|
||||||
(' '.join(cmd), e.returncode, e.output))
|
|
||||||
|
|
||||||
return complementary_pkgs.split()
|
|
||||||
|
|
||||||
def setUpLocal(self):
|
|
||||||
self.ptest_log = os.path.join(oeRuntimeTest.tc.d.getVar("TEST_LOG_DIR"), "ptest-%s.log" % oeRuntimeTest.tc.d.getVar('DATETIME'))
|
|
||||||
|
|
||||||
@skipUnlessPassed('test_ssh')
|
|
||||||
def test_ptestrunner(self):
|
def test_ptestrunner(self):
|
||||||
self.add_smart_channel()
|
self.ptest_log = os.path.join(self.tc.td['TEST_LOG_DIR'],
|
||||||
(runnerstatus, result) = self.target.run('which ptest-runner', 0)
|
'ptest-%s.log' % self.tc.td['DATETIME'])
|
||||||
cond = oeRuntimeTest.hasPackage("ptest-runner") and oeRuntimeTest.hasFeature("ptest") and oeRuntimeTest.hasPackageMatch("-ptest") and (runnerstatus != 0)
|
self._install_ptest_packages()
|
||||||
if cond:
|
|
||||||
self.install_packages(self.install_complementary("*-ptest"))
|
|
||||||
self.install_packages(['ptest-runner'])
|
|
||||||
|
|
||||||
(runnerstatus, result) = self.target.run('/usr/bin/ptest-runner > /tmp/ptest.log 2>&1', 0)
|
(runnerstatus, result) = self.target.run('/usr/bin/ptest-runner > /tmp/ptest.log 2>&1', 0)
|
||||||
#exit code is !=0 even if ptest-runner executes because some ptest tests fail.
|
#exit code is !=0 even if ptest-runner executes because some ptest tests fail.
|
||||||
self.assertTrue(runnerstatus != 127, msg="Cannot execute ptest-runner!")
|
self.assertTrue(runnerstatus != 127, msg="Cannot execute ptest-runner!")
|
||||||
self.target.copy_from('/tmp/ptest.log', self.ptest_log)
|
self.target.copyFrom('/tmp/ptest.log', self.ptest_log)
|
||||||
shutil.copyfile(self.ptest_log, "ptest.log")
|
shutil.copyfile(self.ptest_log, "ptest.log")
|
||||||
|
|
||||||
result = self.parse_ptest("ptest.log")
|
result = self.parse_ptest("ptest.log")
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import unittest
|
from oeqa.runtime.case import OERuntimeTestCase
|
||||||
from oeqa.oetest import oeRuntimeTest
|
|
||||||
from oeqa.utils.qemutinyrunner import *
|
|
||||||
|
|
||||||
class QemuTinyTest(oeRuntimeTest):
|
class QemuTinyTest(OERuntimeTestCase):
|
||||||
|
|
||||||
def test_boot_tiny(self):
|
def test_boot_tiny(self):
|
||||||
(status, output) = self.target.run_serial('uname -a')
|
status, output = self.target.run_serial('uname -a')
|
||||||
self.assertTrue("yocto-tiny" in output, msg="Cannot detect poky tiny boot!")
|
msg = "Cannot detect poky tiny boot!"
|
||||||
|
self.assertTrue("yocto-tiny" in output, msg)
|
||||||
|
|
Loading…
Reference in New Issue