summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2017-03-30 15:18:14 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-04-01 08:14:57 +0100
commit739130370fd75c6cae434a60a2bec59e104e6a2b (patch)
tree4acfda4e90e01d8229fed0ed03dc6df3dd9cd76f /meta/lib
parent34a7654689ca96ceb6fbe0753d650270189710eb (diff)
downloadpoky-739130370fd75c6cae434a60a2bec59e104e6a2b.tar.gz
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>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/runtime/cases/_ptest.py130
-rw-r--r--meta/lib/oeqa/runtime/cases/_qemutiny.py11
2 files changed, 59 insertions, 82 deletions
diff --git a/meta/lib/oeqa/runtime/cases/_ptest.py b/meta/lib/oeqa/runtime/cases/_ptest.py
index a2432517e3..aaed9a5352 100644
--- a/meta/lib/oeqa/runtime/cases/_ptest.py
+++ b/meta/lib/oeqa/runtime/cases/_ptest.py
@@ -1,30 +1,39 @@
1import unittest, os, shutil 1import os
2from oeqa.oetest import oeRuntimeTest, skipModule 2import shutil
3from oeqa.utils.decorators import * 3import subprocess
4
5from oeqa.runtime.case import OERuntimeTestCase
6from oeqa.core.decorator.depends import OETestDepends
7from oeqa.core.decorator.oeid import OETestID
8from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature
9from oeqa.runtime.decorator.package import OEHasPackage
10
11from oeqa.runtime.cases.dnf import DnfTest
4from oeqa.utils.logparser import * 12from oeqa.utils.logparser import *
5from oeqa.utils.httpserver import HTTPService 13from oeqa.utils.httpserver import HTTPService
6import bb
7import glob
8from oe.package_manager import RpmPkgsList
9import subprocess
10 14
11def setUpModule(): 15class PtestRunnerTest(DnfTest):
12 if not oeRuntimeTest.hasFeature("package-management"): 16
13 skipModule("Image doesn't have package management feature") 17 @classmethod
14 if not oeRuntimeTest.hasPackage("smartpm"): 18 def setUpClass(cls):
15 skipModule("Image doesn't have smart installed") 19 rpm_deploy = os.path.join(cls.tc.td['DEPLOY_DIR'], 'rpm')
16 if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES").split()[0]: 20 cls.repo_server = HTTPService(rpm_deploy, cls.tc.target.server_ip)
17 skipModule("Rpm is not the primary package manager") 21 cls.repo_server.start()
18 22
19class PtestRunnerTest(oeRuntimeTest): 23 @classmethod
24 def tearDownClass(cls):
25 cls.repo_server.stop()
20 26
21 # a ptest log parser 27 # a ptest log parser
22 def parse_ptest(self, logfile): 28 def parse_ptest(self, logfile):
23 parser = Lparser(test_0_pass_regex="^PASS:(.+)", test_0_fail_regex="^FAIL:(.+)", section_0_begin_regex="^BEGIN: .*/(.+)/ptest", section_0_end_regex="^END: .*/(.+)/ptest") 29 parser = Lparser(test_0_pass_regex="^PASS:(.+)",
30 test_0_fail_regex="^FAIL:(.+)",
31 section_0_begin_regex="^BEGIN: .*/(.+)/ptest",
32 section_0_end_regex="^END: .*/(.+)/ptest")
24 parser.init() 33 parser.init()
25 result = Result() 34 result = Result()
26 35
27 with open(logfile) as f: 36 with open(logfile, errors='replace') as f:
28 for line in f: 37 for line in f:
29 result_tuple = parser.parse_line(line) 38 result_tuple = parser.parse_line(line)
30 if not result_tuple: 39 if not result_tuple:
@@ -50,70 +59,39 @@ class PtestRunnerTest(oeRuntimeTest):
50 result.sort_tests() 59 result.sort_tests()
51 return result 60 return result
52 61
53 @classmethod 62 def _install_ptest_packages(self):
54 def setUpClass(self): 63 # Get ptest packages that can be installed in the image.
55 #note the existing channels that are on the board before creating new ones 64 packages_dir = os.path.join(self.tc.td['DEPLOY_DIR'], 'rpm')
56# self.existingchannels = set() 65 ptest_pkgs = [pkg[:pkg.find('-ptest')+6]
57# (status, result) = oeRuntimeTest.tc.target.run('smart channel --show | grep "\["', 0) 66 for _, _, filenames in os.walk(packages_dir)
58# for x in result.split("\n"): 67 for pkg in filenames
59# self.existingchannels.add(x) 68 if 'ptest' in pkg
60 self.repo_server = HTTPService(oeRuntimeTest.tc.d.getVar('DEPLOY_DIR'), oeRuntimeTest.tc.target.server_ip) 69 and pkg[:pkg.find('-ptest')] in self.tc.image_packages]
61 self.repo_server.start() 70
62 71 repo_url = 'http://%s:%s' % (self.target.server_ip,
63 @classmethod 72 self.repo_server.port)
64 def tearDownClass(self): 73 dnf_options = ('--repofrompath=oe-ptest-repo,%s '
65 self.repo_server.stop() 74 '--nogpgcheck '
66 #remove created channels to be able to repeat the tests on same image 75 'install -y' % repo_url)
67# (status, result) = oeRuntimeTest.tc.target.run('smart channel --show | grep "\["', 0) 76 self.dnf('%s %s ptest-runner' % (dnf_options, ' '.join(ptest_pkgs)))
68# for x in result.split("\n"): 77
69# if x not in self.existingchannels: 78 @skipIfNotFeature('package-management',
70# oeRuntimeTest.tc.target.run('smart channel --remove '+x[1:-1]+' -y', 0) 79 'Test requires package-management to be in DISTRO_FEATURES')
71 80 @skipIfNotFeature('ptest',
72 def add_smart_channel(self): 81 'Test requires package-management to be in DISTRO_FEATURES')
73 image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE') 82 @skipIfNotDataVar('IMAGE_PKGTYPE', 'rpm',
74 deploy_url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, image_pkgtype) 83 'RPM is not the primary package manager')
75 pkgarchs = self.tc.d.getVar('PACKAGE_ARCHS').replace("-","_").split() 84 @OEHasPackage(['dnf'])
76 for arch in os.listdir('%s/%s' % (self.repo_server.root_dir, image_pkgtype)): 85 @OETestDepends(['ssh.SSHTest.test_ssh'])
77 if arch in pkgarchs:
78 self.target.run('smart channel -y --add {a} type=rpm-md baseurl={u}/{a}'.format(a=arch, u=deploy_url), 0)
79 self.target.run('smart update', 0)
80
81 def install_complementary(self, globs=None):
82 installed_pkgs_file = os.path.join(oeRuntimeTest.tc.d.getVar('WORKDIR'),
83 "installed_pkgs.txt")
84 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'))
85 with open(installed_pkgs_file, "w+") as installed_pkgs:
86 installed_pkgs.write(self.pkgs_list.list("arch"))
87
88 cmd = [bb.utils.which(os.getenv('PATH'), "oe-pkgdata-util"),
89 "-p", oeRuntimeTest.tc.d.getVar('PKGDATA_DIR'), "glob", installed_pkgs_file,
90 globs]
91 try:
92 bb.note("Installing complementary packages ...")
93 complementary_pkgs = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
94 except subprocess.CalledProcessError as e:
95 bb.fatal("Could not compute complementary packages list. Command "
96 "'%s' returned %d:\n%s" %
97 (' '.join(cmd), e.returncode, e.output))
98
99 return complementary_pkgs.split()
100
101 def setUpLocal(self):
102 self.ptest_log = os.path.join(oeRuntimeTest.tc.d.getVar("TEST_LOG_DIR"), "ptest-%s.log" % oeRuntimeTest.tc.d.getVar('DATETIME'))
103
104 @skipUnlessPassed('test_ssh')
105 def test_ptestrunner(self): 86 def test_ptestrunner(self):
106 self.add_smart_channel() 87 self.ptest_log = os.path.join(self.tc.td['TEST_LOG_DIR'],
107 (runnerstatus, result) = self.target.run('which ptest-runner', 0) 88 'ptest-%s.log' % self.tc.td['DATETIME'])
108 cond = oeRuntimeTest.hasPackage("ptest-runner") and oeRuntimeTest.hasFeature("ptest") and oeRuntimeTest.hasPackageMatch("-ptest") and (runnerstatus != 0) 89 self._install_ptest_packages()
109 if cond:
110 self.install_packages(self.install_complementary("*-ptest"))
111 self.install_packages(['ptest-runner'])
112 90
113 (runnerstatus, result) = self.target.run('/usr/bin/ptest-runner > /tmp/ptest.log 2>&1', 0) 91 (runnerstatus, result) = self.target.run('/usr/bin/ptest-runner > /tmp/ptest.log 2>&1', 0)
114 #exit code is !=0 even if ptest-runner executes because some ptest tests fail. 92 #exit code is !=0 even if ptest-runner executes because some ptest tests fail.
115 self.assertTrue(runnerstatus != 127, msg="Cannot execute ptest-runner!") 93 self.assertTrue(runnerstatus != 127, msg="Cannot execute ptest-runner!")
116 self.target.copy_from('/tmp/ptest.log', self.ptest_log) 94 self.target.copyFrom('/tmp/ptest.log', self.ptest_log)
117 shutil.copyfile(self.ptest_log, "ptest.log") 95 shutil.copyfile(self.ptest_log, "ptest.log")
118 96
119 result = self.parse_ptest("ptest.log") 97 result = self.parse_ptest("ptest.log")
diff --git a/meta/lib/oeqa/runtime/cases/_qemutiny.py b/meta/lib/oeqa/runtime/cases/_qemutiny.py
index a3c29f3572..7b5b48141f 100644
--- a/meta/lib/oeqa/runtime/cases/_qemutiny.py
+++ b/meta/lib/oeqa/runtime/cases/_qemutiny.py
@@ -1,9 +1,8 @@
1import unittest 1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.oetest import oeRuntimeTest
3from oeqa.utils.qemutinyrunner import *
4 2
5class QemuTinyTest(oeRuntimeTest): 3class QemuTinyTest(OERuntimeTestCase):
6 4
7 def test_boot_tiny(self): 5 def test_boot_tiny(self):
8 (status, output) = self.target.run_serial('uname -a') 6 status, output = self.target.run_serial('uname -a')
9 self.assertTrue("yocto-tiny" in output, msg="Cannot detect poky tiny boot!") \ No newline at end of file 7 msg = "Cannot detect poky tiny boot!"
8 self.assertTrue("yocto-tiny" in output, msg)