mirror of
https://git.yoctoproject.org/poky
synced 2026-05-09 17:39:31 +00:00
oeqa/recipetool: refactor / split out RecipetoolBase
(From OE-Core rev: 2de348bcc5b015c64c4be7f538a7abd434434ed6) Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
51d760e2a7
commit
6e7ee4e9bf
@@ -1,37 +1,29 @@
|
|||||||
import unittest
|
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
import re
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import urlparse
|
||||||
|
|
||||||
import oeqa.utils.ftools as ftools
|
|
||||||
from oeqa.selftest.base import oeSelfTest
|
|
||||||
from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer
|
from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer
|
||||||
from oeqa.utils.decorators import testcase
|
from oeqa.utils.decorators import testcase
|
||||||
from oeqa.selftest.devtool import DevtoolBase
|
from oeqa.selftest import devtool
|
||||||
|
|
||||||
|
|
||||||
templayerdir = ''
|
templayerdir = ''
|
||||||
|
|
||||||
|
|
||||||
def setUpModule():
|
def setUpModule():
|
||||||
global templayerdir
|
global templayerdir
|
||||||
templayerdir = tempfile.mkdtemp(prefix='recipetoolqa')
|
templayerdir = tempfile.mkdtemp(prefix='recipetoolqa')
|
||||||
create_temp_layer(templayerdir, 'selftestrecipetool')
|
create_temp_layer(templayerdir, 'selftestrecipetool')
|
||||||
result = runCmd('bitbake-layers add-layer %s' % templayerdir)
|
runCmd('bitbake-layers add-layer %s' % templayerdir)
|
||||||
# Ensure we have the right data in shlibs/pkgdata
|
|
||||||
logger = logging.getLogger("selftest")
|
|
||||||
logger.info('Running bitbake to generate pkgdata')
|
|
||||||
bitbake('base-files coreutils busybox selftest-recipetool-appendfile')
|
|
||||||
|
|
||||||
def tearDownModule():
|
def tearDownModule():
|
||||||
runCmd('bitbake-layers remove-layer %s' % templayerdir, ignore_status=True)
|
runCmd('bitbake-layers remove-layer %s' % templayerdir, ignore_status=True)
|
||||||
runCmd('rm -rf %s' % templayerdir)
|
runCmd('rm -rf %s' % templayerdir)
|
||||||
# Shouldn't leave any traces of this artificial recipe behind
|
|
||||||
bitbake('-c cleansstate selftest-recipetool-appendfile')
|
|
||||||
|
|
||||||
|
|
||||||
class RecipetoolTests(DevtoolBase):
|
class RecipetoolBase(devtool.DevtoolBase):
|
||||||
|
|
||||||
def setUpLocal(self):
|
def setUpLocal(self):
|
||||||
self.tempdir = tempfile.mkdtemp(prefix='recipetoolqa')
|
self.tempdir = tempfile.mkdtemp(prefix='recipetoolqa')
|
||||||
self.track_for_cleanup(self.tempdir)
|
self.track_for_cleanup(self.tempdir)
|
||||||
@@ -42,27 +34,51 @@ class RecipetoolTests(DevtoolBase):
|
|||||||
def tearDownLocal(self):
|
def tearDownLocal(self):
|
||||||
runCmd('rm -rf %s/recipes-*' % templayerdir)
|
runCmd('rm -rf %s/recipes-*' % templayerdir)
|
||||||
|
|
||||||
def _try_recipetool_appendfile(self, testrecipe, destfile, newfile, options, expectedlines, expectedfiles):
|
def _try_recipetool_appendcmd(self, cmd, testrecipe, expectedfiles, expectedlines=None):
|
||||||
result = runCmd('recipetool appendfile %s %s %s %s' % (templayerdir, destfile, newfile, options))
|
result = runCmd(cmd)
|
||||||
self.assertNotIn('Traceback', result.output)
|
self.assertNotIn('Traceback', result.output)
|
||||||
|
|
||||||
# Check the bbappend was created and applies properly
|
# Check the bbappend was created and applies properly
|
||||||
recipefile = get_bb_var('FILE', testrecipe)
|
recipefile = get_bb_var('FILE', testrecipe)
|
||||||
bbappendfile = self._check_bbappend(testrecipe, recipefile, templayerdir)
|
bbappendfile = self._check_bbappend(testrecipe, recipefile, templayerdir)
|
||||||
|
|
||||||
# Check the bbappend contents
|
# Check the bbappend contents
|
||||||
with open(bbappendfile, 'r') as f:
|
if expectedlines is not None:
|
||||||
self.assertEqual(expectedlines, f.readlines(), "Expected lines are not present in %s" % bbappendfile)
|
with open(bbappendfile, 'r') as f:
|
||||||
|
self.assertEqual(expectedlines, f.readlines(), "Expected lines are not present in %s" % bbappendfile)
|
||||||
|
|
||||||
# Check file was copied
|
# Check file was copied
|
||||||
filesdir = os.path.join(os.path.dirname(bbappendfile), testrecipe)
|
filesdir = os.path.join(os.path.dirname(bbappendfile), testrecipe)
|
||||||
for expectedfile in expectedfiles:
|
for expectedfile in expectedfiles:
|
||||||
self.assertTrue(os.path.isfile(os.path.join(filesdir, expectedfile)), 'Expected file %s to be copied next to bbappend, but it wasn\'t' % expectedfile)
|
self.assertTrue(os.path.isfile(os.path.join(filesdir, expectedfile)), 'Expected file %s to be copied next to bbappend, but it wasn\'t' % expectedfile)
|
||||||
|
|
||||||
# Check no other files created
|
# Check no other files created
|
||||||
createdfiles = []
|
createdfiles = []
|
||||||
for root, _, files in os.walk(filesdir):
|
for root, _, files in os.walk(filesdir):
|
||||||
for f in files:
|
for f in files:
|
||||||
createdfiles.append(os.path.relpath(os.path.join(root, f), filesdir))
|
createdfiles.append(os.path.relpath(os.path.join(root, f), filesdir))
|
||||||
self.assertTrue(sorted(createdfiles), sorted(expectedfiles))
|
self.assertTrue(sorted(createdfiles), sorted(expectedfiles))
|
||||||
|
|
||||||
return bbappendfile, result.output
|
return bbappendfile, result.output
|
||||||
|
|
||||||
|
|
||||||
|
class RecipetoolTests(RecipetoolBase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
# Ensure we have the right data in shlibs/pkgdata
|
||||||
|
logger = logging.getLogger("selftest")
|
||||||
|
logger.info('Running bitbake to generate pkgdata')
|
||||||
|
bitbake('-c packagedata base-files coreutils busybox selftest-recipetool-appendfile')
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
# Shouldn't leave any traces of this artificial recipe behind
|
||||||
|
bitbake('-c cleansstate selftest-recipetool-appendfile')
|
||||||
|
|
||||||
|
def _try_recipetool_appendfile(self, testrecipe, destfile, newfile, options, expectedlines, expectedfiles):
|
||||||
|
cmd = 'recipetool appendfile %s %s %s %s' % (templayerdir, destfile, newfile, options)
|
||||||
|
return self._try_recipetool_appendcmd(cmd, testrecipe, expectedfiles, expectedlines)
|
||||||
|
|
||||||
def _try_recipetool_appendfile_fail(self, destfile, newfile, checkerror):
|
def _try_recipetool_appendfile_fail(self, destfile, newfile, checkerror):
|
||||||
cmd = 'recipetool appendfile %s %s %s' % (templayerdir, destfile, newfile)
|
cmd = 'recipetool appendfile %s %s %s' % (templayerdir, destfile, newfile)
|
||||||
result = runCmd(cmd, ignore_status=True)
|
result = runCmd(cmd, ignore_status=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user