From 91cd1ed19a3f34c29cd77eb136036975fe465444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=C3=ADbal=20Lim=C3=B3n?= Date: Sun, 27 Nov 2016 17:51:53 -0600 Subject: oeqa/sdk/cases: Migrate tests to the new OEQA framework MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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] Signed-off-by: Aníbal Limón Signed-off-by: Mariano Lopez --- meta/lib/oeqa/sdk/cases/gcc.py | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'meta/lib/oeqa/sdk/cases/gcc.py') 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 @@ -import unittest import os import shutil -from oeqa.oetest import oeSDKTest, skipModule -from oeqa.utils.decorators import * - -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") +import unittest +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) -- cgit v1.2.3