oeqa/sdk/cases: Migrate tests to the new OEQA framework
Summary of the changes: - Remove auto extend_path using pkgutil at __init__, is not needed. - Change base class to OESDKTestCase. - Add td_vars attr to set dependencies of certain variables in test data. - Change skips from module level to class level because Test context (tc) now isn't at module level. - Variable names changes to be consistent (i.e. sdktestdir -> sdk_dir). [YOCTO #10599] - Don't use bb.utils functions use instead remove_safe and shutil for copy files. - SDKBuildProject pass test data variables instead of call getVar inside. [YOCTO #10231] (From OE-Core rev: 91cd1ed19a3f34c29cd77eb136036975fe465444) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> 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
51be188063
commit
c9fe59d7c5
|
@ -1,3 +0,0 @@
|
|||
# Enable other layers to have tests in the same named directory
|
||||
from pkgutil import extend_path
|
||||
__path__ = extend_path(__path__, __name__)
|
|
@ -1,13 +1,16 @@
|
|||
from oeqa.oetest import oeSDKTest, skipModule
|
||||
from oeqa.utils.decorators import *
|
||||
from oeqa.utils.targetbuild import SDKBuildProject
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
from oeqa.sdk.utils.sdkbuildproject import SDKBuildProject
|
||||
|
||||
class BuildCvsTest(oeSDKTest):
|
||||
class BuildCvsTest(OESDKTestCase):
|
||||
td_vars = ['TEST_LOG_DIR', 'DATETIME']
|
||||
|
||||
@classmethod
|
||||
def setUpClass(self):
|
||||
self.project = SDKBuildProject(oeSDKTest.tc.sdktestdir + "/cvs/", oeSDKTest.tc.sdkenv, oeSDKTest.tc.d,
|
||||
"http://ftp.gnu.org/non-gnu/cvs/source/feature/1.12.13/cvs-1.12.13.tar.bz2")
|
||||
dl_dir = self.td.get('DL_DIR', None)
|
||||
|
||||
self.project = SDKBuildProject(self.tc.sdk_dir + "/cvs/", self.tc.sdk_env,
|
||||
"http://ftp.gnu.org/non-gnu/cvs/source/feature/1.12.13/cvs-1.12.13.tar.bz2",
|
||||
self.td['TEST_LOG_DIR'], self.td['DATETIME'], dl_dir=dl_dir)
|
||||
self.project.download_archive()
|
||||
|
||||
def test_cvs(self):
|
||||
|
|
|
@ -1,17 +1,25 @@
|
|||
from oeqa.oetest import oeSDKTest, skipModule
|
||||
from oeqa.utils.decorators import *
|
||||
from oeqa.utils.targetbuild import SDKBuildProject
|
||||
import unittest
|
||||
|
||||
def setUpModule():
|
||||
if not (oeSDKTest.hasPackage("gtk+3") or oeSDKTest.hasPackage("libgtk-3.0")):
|
||||
skipModule("Image doesn't have gtk+3 in manifest")
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
from oeqa.sdk.utils.sdkbuildproject import SDKBuildProject
|
||||
|
||||
class GalculatorTest(OESDKTestCase):
|
||||
td_vars = ['TEST_LOG_DIR', 'DATETIME']
|
||||
|
||||
@classmethod
|
||||
def setUpClass(self):
|
||||
if not (self.tc.hasTargetPackage("gtk+3") or\
|
||||
self.tc.hasTargetPackage("libgtk-3.0")):
|
||||
raise unittest.SkipTest("%s class: SDK don't support gtk+3" % self.__name__)
|
||||
|
||||
class GalculatorTest(oeSDKTest):
|
||||
def test_galculator(self):
|
||||
dl_dir = self.td.get('DL_DIR', None)
|
||||
project = None
|
||||
try:
|
||||
project = SDKBuildProject(oeSDKTest.tc.sdktestdir + "/galculator/",
|
||||
oeSDKTest.tc.sdkenv, oeSDKTest.tc.d,
|
||||
"http://galculator.mnim.org/downloads/galculator-2.1.4.tar.bz2")
|
||||
project = SDKBuildProject(self.tc.sdk_dir + "/galculator/",
|
||||
self.tc.sdk_env,
|
||||
"http://galculator.mnim.org/downloads/galculator-2.1.4.tar.bz2",
|
||||
self.td['TEST_LOG_DIR'], self.td['DATETIME'], dl_dir=dl_dir)
|
||||
|
||||
project.download_archive()
|
||||
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
from oeqa.oetest import oeSDKTest
|
||||
from oeqa.utils.decorators import *
|
||||
from oeqa.utils.targetbuild import SDKBuildProject
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
from oeqa.sdk.utils.sdkbuildproject import SDKBuildProject
|
||||
|
||||
|
||||
class BuildIptablesTest(oeSDKTest):
|
||||
class BuildIptablesTest(OESDKTestCase):
|
||||
td_vars = ['TEST_LOG_DIR', 'DATETIME']
|
||||
|
||||
@classmethod
|
||||
def setUpClass(self):
|
||||
self.project = SDKBuildProject(oeSDKTest.tc.sdktestdir + "/iptables/", oeSDKTest.tc.sdkenv, oeSDKTest.tc.d,
|
||||
"http://downloads.yoctoproject.org/mirror/sources/iptables-1.4.13.tar.bz2")
|
||||
dl_dir = self.td.get('DL_DIR', None)
|
||||
|
||||
self.project = SDKBuildProject(self.tc.sdk_dir + "/iptables/", self.tc.sdk_env,
|
||||
"http://downloads.yoctoproject.org/mirror/sources/iptables-1.4.13.tar.bz2",
|
||||
self.td['TEST_LOG_DIR'], self.td['DATETIME'], dl_dir=dl_dir)
|
||||
self.project.download_archive()
|
||||
|
||||
def test_iptables(self):
|
||||
|
|
|
@ -1,36 +1,43 @@
|
|||
import unittest
|
||||
import os
|
||||
import shutil
|
||||
from oeqa.oetest import oeSDKTest, skipModule
|
||||
from oeqa.utils.decorators import *
|
||||
import unittest
|
||||
|
||||
def setUpModule():
|
||||
machine = oeSDKTest.tc.d.getVar("MACHINE")
|
||||
if not oeSDKTest.hasHostPackage("packagegroup-cross-canadian-" + machine):
|
||||
skipModule("SDK doesn't contain a cross-canadian toolchain")
|
||||
from oeqa.core.utils.path import remove_safe
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
|
||||
|
||||
class GccCompileTest(oeSDKTest):
|
||||
class GccCompileTest(OESDKTestCase):
|
||||
td_vars = ['MACHINE']
|
||||
|
||||
@classmethod
|
||||
def setUpClass(self):
|
||||
for f in ['test.c', 'test.cpp', 'testsdkmakefile']:
|
||||
shutil.copyfile(os.path.join(self.tc.filesdir, f), self.tc.sdktestdir + f)
|
||||
files = {'test.c' : self.tc.files_dir, 'test.cpp' : self.tc.files_dir,
|
||||
'testsdkmakefile' : self.tc.sdk_files_dir}
|
||||
for f in files:
|
||||
shutil.copyfile(os.path.join(files[f], f),
|
||||
os.path.join(self.tc.sdk_dir, f))
|
||||
|
||||
def setUp(self):
|
||||
machine = self.td.get("MACHINE")
|
||||
if not self.tc.hasHostPackage("packagegroup-cross-canadian-%s" % machine):
|
||||
raise unittest.SkipTest("%s class: SDK doesn't contain a cross-canadian toolchain",
|
||||
self.__name__)
|
||||
|
||||
def test_gcc_compile(self):
|
||||
self._run('$CC %s/test.c -o %s/test -lm' % (self.tc.sdktestdir, self.tc.sdktestdir))
|
||||
self._run('$CC %s/test.c -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir))
|
||||
|
||||
def test_gpp_compile(self):
|
||||
self._run('$CXX %s/test.c -o %s/test -lm' % (self.tc.sdktestdir, self.tc.sdktestdir))
|
||||
self._run('$CXX %s/test.c -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir))
|
||||
|
||||
def test_gpp2_compile(self):
|
||||
self._run('$CXX %s/test.cpp -o %s/test -lm' % (self.tc.sdktestdir, self.tc.sdktestdir))
|
||||
self._run('$CXX %s/test.cpp -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir))
|
||||
|
||||
def test_make(self):
|
||||
self._run('cd %s; make -f testsdkmakefile' % self.tc.sdktestdir)
|
||||
self._run('cd %s; make -f testsdkmakefile' % self.tc.sdk_dir)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(self):
|
||||
files = [self.tc.sdktestdir + f for f in ['test.c', 'test.cpp', 'test.o', 'test', 'testsdkmakefile']]
|
||||
files = [os.path.join(self.tc.sdk_dir, f) \
|
||||
for f in ['test.c', 'test.cpp', 'test.o', 'test',
|
||||
'testsdkmakefile']]
|
||||
for f in files:
|
||||
bb.utils.remove(f)
|
||||
remove_safe(f)
|
||||
|
|
|
@ -1,28 +1,27 @@
|
|||
import unittest
|
||||
import os
|
||||
import shutil
|
||||
from oeqa.oetest import oeSDKTest, skipModule
|
||||
from oeqa.utils.decorators import *
|
||||
import unittest
|
||||
|
||||
def setUpModule():
|
||||
if not oeSDKTest.hasHostPackage("nativesdk-perl"):
|
||||
skipModule("No perl package in the SDK")
|
||||
|
||||
|
||||
class PerlTest(oeSDKTest):
|
||||
from oeqa.core.utils.path import remove_safe
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
|
||||
class PerlTest(OESDKTestCase):
|
||||
@classmethod
|
||||
def setUpClass(self):
|
||||
if not self.tc.hasHostPackage("nativesdk-perl"):
|
||||
raise unittest.SkipTest("No perl package in the SDK")
|
||||
|
||||
for f in ['test.pl']:
|
||||
shutil.copyfile(os.path.join(self.tc.filesdir, f), self.tc.sdktestdir + f)
|
||||
self.testfile = self.tc.sdktestdir + "test.pl"
|
||||
shutil.copyfile(os.path.join(self.tc.files_dir, f),
|
||||
os.path.join(self.tc.sdk_dir, f))
|
||||
self.testfile = os.path.join(self.tc.sdk_dir, "test.pl")
|
||||
|
||||
def test_perl_exists(self):
|
||||
self._run('which perl')
|
||||
|
||||
def test_perl_works(self):
|
||||
self._run('perl %s/test.pl' % self.tc.sdktestdir)
|
||||
self._run('perl %s' % self.testfile)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(self):
|
||||
bb.utils.remove("%s/test.pl" % self.tc.sdktestdir)
|
||||
remove_safe(self.testfile)
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
import unittest
|
||||
import os
|
||||
import shutil
|
||||
from oeqa.oetest import oeSDKTest, skipModule
|
||||
from oeqa.utils.decorators import *
|
||||
import unittest
|
||||
|
||||
def setUpModule():
|
||||
if not oeSDKTest.hasHostPackage("nativesdk-python"):
|
||||
skipModule("No python package in the SDK")
|
||||
|
||||
|
||||
class PythonTest(oeSDKTest):
|
||||
from oeqa.core.utils.path import remove_safe
|
||||
from oeqa.sdk.case import OESDKTestCase
|
||||
|
||||
class PythonTest(OESDKTestCase):
|
||||
@classmethod
|
||||
def setUpClass(self):
|
||||
if not self.tc.hasHostPackage("nativesdk-python"):
|
||||
raise unittest.SkipTest("No python package in the SDK")
|
||||
|
||||
for f in ['test.py']:
|
||||
shutil.copyfile(os.path.join(self.tc.filesdir, f), self.tc.sdktestdir + f)
|
||||
shutil.copyfile(os.path.join(self.tc.files_dir, f),
|
||||
os.path.join(self.tc.sdk_dir, f))
|
||||
|
||||
def test_python_exists(self):
|
||||
self._run('which python')
|
||||
|
||||
def test_python_stdout(self):
|
||||
output = self._run('python %s/test.py' % self.tc.sdktestdir)
|
||||
output = self._run('python %s/test.py' % self.tc.sdk_dir)
|
||||
self.assertEqual(output.strip(), "the value of a is 0.01", msg="Incorrect output: %s" % output)
|
||||
|
||||
def test_python_testfile(self):
|
||||
|
@ -28,5 +27,5 @@ class PythonTest(oeSDKTest):
|
|||
|
||||
@classmethod
|
||||
def tearDownClass(self):
|
||||
bb.utils.remove("%s/test.py" % self.tc.sdktestdir)
|
||||
bb.utils.remove("/tmp/testfile.python")
|
||||
remove_safe("%s/test.py" % self.tc.sdk_dir)
|
||||
remove_safe("/tmp/testfile.python")
|
||||
|
|
Loading…
Reference in New Issue