summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2016-11-27 17:51:53 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-23 12:05:19 +0000
commitc9fe59d7c5e815fb6453f50d0f15699ea6799129 (patch)
tree4e7715c04b705eb78f49e55d421b25483c594f9c
parent51be1880631435627e8ff490d71b024c2683244a (diff)
downloadpoky-c9fe59d7c5e815fb6453f50d0f15699ea6799129.tar.gz
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>
-rw-r--r--meta/lib/oeqa/sdk/cases/__init__.py3
-rw-r--r--meta/lib/oeqa/sdk/cases/buildcvs.py15
-rw-r--r--meta/lib/oeqa/sdk/cases/buildgalculator.py28
-rw-r--r--meta/lib/oeqa/sdk/cases/buildiptables.py16
-rw-r--r--meta/lib/oeqa/sdk/cases/gcc.py41
-rw-r--r--meta/lib/oeqa/sdk/cases/perl.py25
-rw-r--r--meta/lib/oeqa/sdk/cases/python.py25
7 files changed, 84 insertions, 69 deletions
diff --git a/meta/lib/oeqa/sdk/cases/__init__.py b/meta/lib/oeqa/sdk/cases/__init__.py
deleted file mode 100644
index 4cf3fa76b6..0000000000
--- a/meta/lib/oeqa/sdk/cases/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
1# Enable other layers to have tests in the same named directory
2from pkgutil import extend_path
3__path__ = extend_path(__path__, __name__)
diff --git a/meta/lib/oeqa/sdk/cases/buildcvs.py b/meta/lib/oeqa/sdk/cases/buildcvs.py
index c7146fa4af..ee7fb73803 100644
--- a/meta/lib/oeqa/sdk/cases/buildcvs.py
+++ b/meta/lib/oeqa/sdk/cases/buildcvs.py
@@ -1,13 +1,16 @@
1from oeqa.oetest import oeSDKTest, skipModule 1from oeqa.sdk.case import OESDKTestCase
2from oeqa.utils.decorators import * 2from oeqa.sdk.utils.sdkbuildproject import SDKBuildProject
3from oeqa.utils.targetbuild import SDKBuildProject
4 3
5class BuildCvsTest(oeSDKTest): 4class BuildCvsTest(OESDKTestCase):
5 td_vars = ['TEST_LOG_DIR', 'DATETIME']
6 6
7 @classmethod 7 @classmethod
8 def setUpClass(self): 8 def setUpClass(self):
9 self.project = SDKBuildProject(oeSDKTest.tc.sdktestdir + "/cvs/", oeSDKTest.tc.sdkenv, oeSDKTest.tc.d, 9 dl_dir = self.td.get('DL_DIR', None)
10 "http://ftp.gnu.org/non-gnu/cvs/source/feature/1.12.13/cvs-1.12.13.tar.bz2") 10
11 self.project = SDKBuildProject(self.tc.sdk_dir + "/cvs/", self.tc.sdk_env,
12 "http://ftp.gnu.org/non-gnu/cvs/source/feature/1.12.13/cvs-1.12.13.tar.bz2",
13 self.td['TEST_LOG_DIR'], self.td['DATETIME'], dl_dir=dl_dir)
11 self.project.download_archive() 14 self.project.download_archive()
12 15
13 def test_cvs(self): 16 def test_cvs(self):
diff --git a/meta/lib/oeqa/sdk/cases/buildgalculator.py b/meta/lib/oeqa/sdk/cases/buildgalculator.py
index dc2fa9ce19..d2c1189ce6 100644
--- a/meta/lib/oeqa/sdk/cases/buildgalculator.py
+++ b/meta/lib/oeqa/sdk/cases/buildgalculator.py
@@ -1,17 +1,25 @@
1from oeqa.oetest import oeSDKTest, skipModule 1import unittest
2from oeqa.utils.decorators import *
3from oeqa.utils.targetbuild import SDKBuildProject
4 2
5def setUpModule(): 3from oeqa.sdk.case import OESDKTestCase
6 if not (oeSDKTest.hasPackage("gtk+3") or oeSDKTest.hasPackage("libgtk-3.0")): 4from oeqa.sdk.utils.sdkbuildproject import SDKBuildProject
7 skipModule("Image doesn't have gtk+3 in manifest") 5
6class GalculatorTest(OESDKTestCase):
7 td_vars = ['TEST_LOG_DIR', 'DATETIME']
8
9 @classmethod
10 def setUpClass(self):
11 if not (self.tc.hasTargetPackage("gtk+3") or\
12 self.tc.hasTargetPackage("libgtk-3.0")):
13 raise unittest.SkipTest("%s class: SDK don't support gtk+3" % self.__name__)
8 14
9class GalculatorTest(oeSDKTest):
10 def test_galculator(self): 15 def test_galculator(self):
16 dl_dir = self.td.get('DL_DIR', None)
17 project = None
11 try: 18 try:
12 project = SDKBuildProject(oeSDKTest.tc.sdktestdir + "/galculator/", 19 project = SDKBuildProject(self.tc.sdk_dir + "/galculator/",
13 oeSDKTest.tc.sdkenv, oeSDKTest.tc.d, 20 self.tc.sdk_env,
14 "http://galculator.mnim.org/downloads/galculator-2.1.4.tar.bz2") 21 "http://galculator.mnim.org/downloads/galculator-2.1.4.tar.bz2",
22 self.td['TEST_LOG_DIR'], self.td['DATETIME'], dl_dir=dl_dir)
15 23
16 project.download_archive() 24 project.download_archive()
17 25
diff --git a/meta/lib/oeqa/sdk/cases/buildiptables.py b/meta/lib/oeqa/sdk/cases/buildiptables.py
index f0cb8a4287..a50fb5dcf5 100644
--- a/meta/lib/oeqa/sdk/cases/buildiptables.py
+++ b/meta/lib/oeqa/sdk/cases/buildiptables.py
@@ -1,14 +1,16 @@
1from oeqa.oetest import oeSDKTest 1from oeqa.sdk.case import OESDKTestCase
2from oeqa.utils.decorators import * 2from oeqa.sdk.utils.sdkbuildproject import SDKBuildProject
3from oeqa.utils.targetbuild import SDKBuildProject
4 3
5 4class BuildIptablesTest(OESDKTestCase):
6class BuildIptablesTest(oeSDKTest): 5 td_vars = ['TEST_LOG_DIR', 'DATETIME']
7 6
8 @classmethod 7 @classmethod
9 def setUpClass(self): 8 def setUpClass(self):
10 self.project = SDKBuildProject(oeSDKTest.tc.sdktestdir + "/iptables/", oeSDKTest.tc.sdkenv, oeSDKTest.tc.d, 9 dl_dir = self.td.get('DL_DIR', None)
11 "http://downloads.yoctoproject.org/mirror/sources/iptables-1.4.13.tar.bz2") 10
11 self.project = SDKBuildProject(self.tc.sdk_dir + "/iptables/", self.tc.sdk_env,
12 "http://downloads.yoctoproject.org/mirror/sources/iptables-1.4.13.tar.bz2",
13 self.td['TEST_LOG_DIR'], self.td['DATETIME'], dl_dir=dl_dir)
12 self.project.download_archive() 14 self.project.download_archive()
13 15
14 def test_iptables(self): 16 def test_iptables(self):
diff --git a/meta/lib/oeqa/sdk/cases/gcc.py b/meta/lib/oeqa/sdk/cases/gcc.py
index f3f4341a20..e06af4c247 100644
--- a/meta/lib/oeqa/sdk/cases/gcc.py
+++ b/meta/lib/oeqa/sdk/cases/gcc.py
@@ -1,36 +1,43 @@
1import unittest
2import os 1import os
3import shutil 2import shutil
4from oeqa.oetest import oeSDKTest, skipModule 3import unittest
5from oeqa.utils.decorators import *
6
7def setUpModule():
8 machine = oeSDKTest.tc.d.getVar("MACHINE")
9 if not oeSDKTest.hasHostPackage("packagegroup-cross-canadian-" + machine):
10 skipModule("SDK doesn't contain a cross-canadian toolchain")
11 4
5from oeqa.core.utils.path import remove_safe
6from oeqa.sdk.case import OESDKTestCase
12 7
13class GccCompileTest(oeSDKTest): 8class GccCompileTest(OESDKTestCase):
9 td_vars = ['MACHINE']
14 10
15 @classmethod 11 @classmethod
16 def setUpClass(self): 12 def setUpClass(self):
17 for f in ['test.c', 'test.cpp', 'testsdkmakefile']: 13 files = {'test.c' : self.tc.files_dir, 'test.cpp' : self.tc.files_dir,
18 shutil.copyfile(os.path.join(self.tc.filesdir, f), self.tc.sdktestdir + f) 14 'testsdkmakefile' : self.tc.sdk_files_dir}
15 for f in files:
16 shutil.copyfile(os.path.join(files[f], f),
17 os.path.join(self.tc.sdk_dir, f))
18
19 def setUp(self):
20 machine = self.td.get("MACHINE")
21 if not self.tc.hasHostPackage("packagegroup-cross-canadian-%s" % machine):
22 raise unittest.SkipTest("%s class: SDK doesn't contain a cross-canadian toolchain",
23 self.__name__)
19 24
20 def test_gcc_compile(self): 25 def test_gcc_compile(self):
21 self._run('$CC %s/test.c -o %s/test -lm' % (self.tc.sdktestdir, self.tc.sdktestdir)) 26 self._run('$CC %s/test.c -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir))
22 27
23 def test_gpp_compile(self): 28 def test_gpp_compile(self):
24 self._run('$CXX %s/test.c -o %s/test -lm' % (self.tc.sdktestdir, self.tc.sdktestdir)) 29 self._run('$CXX %s/test.c -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir))
25 30
26 def test_gpp2_compile(self): 31 def test_gpp2_compile(self):
27 self._run('$CXX %s/test.cpp -o %s/test -lm' % (self.tc.sdktestdir, self.tc.sdktestdir)) 32 self._run('$CXX %s/test.cpp -o %s/test -lm' % (self.tc.sdk_dir, self.tc.sdk_dir))
28 33
29 def test_make(self): 34 def test_make(self):
30 self._run('cd %s; make -f testsdkmakefile' % self.tc.sdktestdir) 35 self._run('cd %s; make -f testsdkmakefile' % self.tc.sdk_dir)
31 36
32 @classmethod 37 @classmethod
33 def tearDownClass(self): 38 def tearDownClass(self):
34 files = [self.tc.sdktestdir + f for f in ['test.c', 'test.cpp', 'test.o', 'test', 'testsdkmakefile']] 39 files = [os.path.join(self.tc.sdk_dir, f) \
40 for f in ['test.c', 'test.cpp', 'test.o', 'test',
41 'testsdkmakefile']]
35 for f in files: 42 for f in files:
36 bb.utils.remove(f) 43 remove_safe(f)
diff --git a/meta/lib/oeqa/sdk/cases/perl.py b/meta/lib/oeqa/sdk/cases/perl.py
index 45f422ef0b..e1bded2ff2 100644
--- a/meta/lib/oeqa/sdk/cases/perl.py
+++ b/meta/lib/oeqa/sdk/cases/perl.py
@@ -1,28 +1,27 @@
1import unittest
2import os 1import os
3import shutil 2import shutil
4from oeqa.oetest import oeSDKTest, skipModule 3import unittest
5from oeqa.utils.decorators import *
6
7def setUpModule():
8 if not oeSDKTest.hasHostPackage("nativesdk-perl"):
9 skipModule("No perl package in the SDK")
10
11 4
12class PerlTest(oeSDKTest): 5from oeqa.core.utils.path import remove_safe
6from oeqa.sdk.case import OESDKTestCase
13 7
8class PerlTest(OESDKTestCase):
14 @classmethod 9 @classmethod
15 def setUpClass(self): 10 def setUpClass(self):
11 if not self.tc.hasHostPackage("nativesdk-perl"):
12 raise unittest.SkipTest("No perl package in the SDK")
13
16 for f in ['test.pl']: 14 for f in ['test.pl']:
17 shutil.copyfile(os.path.join(self.tc.filesdir, f), self.tc.sdktestdir + f) 15 shutil.copyfile(os.path.join(self.tc.files_dir, f),
18 self.testfile = self.tc.sdktestdir + "test.pl" 16 os.path.join(self.tc.sdk_dir, f))
17 self.testfile = os.path.join(self.tc.sdk_dir, "test.pl")
19 18
20 def test_perl_exists(self): 19 def test_perl_exists(self):
21 self._run('which perl') 20 self._run('which perl')
22 21
23 def test_perl_works(self): 22 def test_perl_works(self):
24 self._run('perl %s/test.pl' % self.tc.sdktestdir) 23 self._run('perl %s' % self.testfile)
25 24
26 @classmethod 25 @classmethod
27 def tearDownClass(self): 26 def tearDownClass(self):
28 bb.utils.remove("%s/test.pl" % self.tc.sdktestdir) 27 remove_safe(self.testfile)
diff --git a/meta/lib/oeqa/sdk/cases/python.py b/meta/lib/oeqa/sdk/cases/python.py
index 896fab4dfb..94a296f0ec 100644
--- a/meta/lib/oeqa/sdk/cases/python.py
+++ b/meta/lib/oeqa/sdk/cases/python.py
@@ -1,26 +1,25 @@
1import unittest
2import os 1import os
3import shutil 2import shutil
4from oeqa.oetest import oeSDKTest, skipModule 3import unittest
5from oeqa.utils.decorators import *
6
7def setUpModule():
8 if not oeSDKTest.hasHostPackage("nativesdk-python"):
9 skipModule("No python package in the SDK")
10
11 4
12class PythonTest(oeSDKTest): 5from oeqa.core.utils.path import remove_safe
6from oeqa.sdk.case import OESDKTestCase
13 7
8class PythonTest(OESDKTestCase):
14 @classmethod 9 @classmethod
15 def setUpClass(self): 10 def setUpClass(self):
11 if not self.tc.hasHostPackage("nativesdk-python"):
12 raise unittest.SkipTest("No python package in the SDK")
13
16 for f in ['test.py']: 14 for f in ['test.py']:
17 shutil.copyfile(os.path.join(self.tc.filesdir, f), self.tc.sdktestdir + f) 15 shutil.copyfile(os.path.join(self.tc.files_dir, f),
16 os.path.join(self.tc.sdk_dir, f))
18 17
19 def test_python_exists(self): 18 def test_python_exists(self):
20 self._run('which python') 19 self._run('which python')
21 20
22 def test_python_stdout(self): 21 def test_python_stdout(self):
23 output = self._run('python %s/test.py' % self.tc.sdktestdir) 22 output = self._run('python %s/test.py' % self.tc.sdk_dir)
24 self.assertEqual(output.strip(), "the value of a is 0.01", msg="Incorrect output: %s" % output) 23 self.assertEqual(output.strip(), "the value of a is 0.01", msg="Incorrect output: %s" % output)
25 24
26 def test_python_testfile(self): 25 def test_python_testfile(self):
@@ -28,5 +27,5 @@ class PythonTest(oeSDKTest):
28 27
29 @classmethod 28 @classmethod
30 def tearDownClass(self): 29 def tearDownClass(self):
31 bb.utils.remove("%s/test.py" % self.tc.sdktestdir) 30 remove_safe("%s/test.py" % self.tc.sdk_dir)
32 bb.utils.remove("/tmp/testfile.python") 31 remove_safe("/tmp/testfile.python")