summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorChristopher Larson <chris_larson@mentor.com>2015-07-16 12:35:58 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-07-27 23:29:13 +0100
commit6e7ee4e9bf9cced4e780617ee9b70d95d965b1bc (patch)
tree7d310814bdeae596a0254d6f85a4b40f9e133a57 /meta
parent51d760e2a7e22f1b07608fc925da343e56a9ae74 (diff)
downloadpoky-6e7ee4e9bf9cced4e780617ee9b70d95d965b1bc.tar.gz
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>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/selftest/recipetool.py52
1 files changed, 34 insertions, 18 deletions
diff --git a/meta/lib/oeqa/selftest/recipetool.py b/meta/lib/oeqa/selftest/recipetool.py
index 12c6b255ea..854ebfa7b6 100644
--- a/meta/lib/oeqa/selftest/recipetool.py
+++ b/meta/lib/oeqa/selftest/recipetool.py
@@ -1,37 +1,29 @@
1import unittest
2import os 1import os
3import logging 2import logging
4import re
5import tempfile 3import tempfile
4import urlparse
6 5
7import oeqa.utils.ftools as ftools
8from oeqa.selftest.base import oeSelfTest
9from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer 6from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer
10from oeqa.utils.decorators import testcase 7from oeqa.utils.decorators import testcase
11from oeqa.selftest.devtool import DevtoolBase 8from oeqa.selftest import devtool
12 9
13 10
14templayerdir = '' 11templayerdir = ''
15 12
13
16def setUpModule(): 14def setUpModule():
17 global templayerdir 15 global templayerdir
18 templayerdir = tempfile.mkdtemp(prefix='recipetoolqa') 16 templayerdir = tempfile.mkdtemp(prefix='recipetoolqa')
19 create_temp_layer(templayerdir, 'selftestrecipetool') 17 create_temp_layer(templayerdir, 'selftestrecipetool')
20 result = runCmd('bitbake-layers add-layer %s' % templayerdir) 18 runCmd('bitbake-layers add-layer %s' % templayerdir)
21 # Ensure we have the right data in shlibs/pkgdata 19
22 logger = logging.getLogger("selftest")
23 logger.info('Running bitbake to generate pkgdata')
24 bitbake('base-files coreutils busybox selftest-recipetool-appendfile')
25 20
26def tearDownModule(): 21def tearDownModule():
27 runCmd('bitbake-layers remove-layer %s' % templayerdir, ignore_status=True) 22 runCmd('bitbake-layers remove-layer %s' % templayerdir, ignore_status=True)
28 runCmd('rm -rf %s' % templayerdir) 23 runCmd('rm -rf %s' % templayerdir)
29 # Shouldn't leave any traces of this artificial recipe behind
30 bitbake('-c cleansstate selftest-recipetool-appendfile')
31 24
32 25
33class RecipetoolTests(DevtoolBase): 26class RecipetoolBase(devtool.DevtoolBase):
34
35 def setUpLocal(self): 27 def setUpLocal(self):
36 self.tempdir = tempfile.mkdtemp(prefix='recipetoolqa') 28 self.tempdir = tempfile.mkdtemp(prefix='recipetoolqa')
37 self.track_for_cleanup(self.tempdir) 29 self.track_for_cleanup(self.tempdir)
@@ -42,27 +34,51 @@ class RecipetoolTests(DevtoolBase):
42 def tearDownLocal(self): 34 def tearDownLocal(self):
43 runCmd('rm -rf %s/recipes-*' % templayerdir) 35 runCmd('rm -rf %s/recipes-*' % templayerdir)
44 36
45 def _try_recipetool_appendfile(self, testrecipe, destfile, newfile, options, expectedlines, expectedfiles): 37 def _try_recipetool_appendcmd(self, cmd, testrecipe, expectedfiles, expectedlines=None):
46 result = runCmd('recipetool appendfile %s %s %s %s' % (templayerdir, destfile, newfile, options)) 38 result = runCmd(cmd)
47 self.assertNotIn('Traceback', result.output) 39 self.assertNotIn('Traceback', result.output)
40
48 # Check the bbappend was created and applies properly 41 # Check the bbappend was created and applies properly
49 recipefile = get_bb_var('FILE', testrecipe) 42 recipefile = get_bb_var('FILE', testrecipe)
50 bbappendfile = self._check_bbappend(testrecipe, recipefile, templayerdir) 43 bbappendfile = self._check_bbappend(testrecipe, recipefile, templayerdir)
44
51 # Check the bbappend contents 45 # Check the bbappend contents
52 with open(bbappendfile, 'r') as f: 46 if expectedlines is not None:
53 self.assertEqual(expectedlines, f.readlines(), "Expected lines are not present in %s" % bbappendfile) 47 with open(bbappendfile, 'r') as f:
48 self.assertEqual(expectedlines, f.readlines(), "Expected lines are not present in %s" % bbappendfile)
49
54 # Check file was copied 50 # Check file was copied
55 filesdir = os.path.join(os.path.dirname(bbappendfile), testrecipe) 51 filesdir = os.path.join(os.path.dirname(bbappendfile), testrecipe)
56 for expectedfile in expectedfiles: 52 for expectedfile in expectedfiles:
57 self.assertTrue(os.path.isfile(os.path.join(filesdir, expectedfile)), 'Expected file %s to be copied next to bbappend, but it wasn\'t' % expectedfile) 53 self.assertTrue(os.path.isfile(os.path.join(filesdir, expectedfile)), 'Expected file %s to be copied next to bbappend, but it wasn\'t' % expectedfile)
54
58 # Check no other files created 55 # Check no other files created
59 createdfiles = [] 56 createdfiles = []
60 for root, _, files in os.walk(filesdir): 57 for root, _, files in os.walk(filesdir):
61 for f in files: 58 for f in files:
62 createdfiles.append(os.path.relpath(os.path.join(root, f), filesdir)) 59 createdfiles.append(os.path.relpath(os.path.join(root, f), filesdir))
63 self.assertTrue(sorted(createdfiles), sorted(expectedfiles)) 60 self.assertTrue(sorted(createdfiles), sorted(expectedfiles))
61
64 return bbappendfile, result.output 62 return bbappendfile, result.output
65 63
64
65class RecipetoolTests(RecipetoolBase):
66 @classmethod
67 def setUpClass(cls):
68 # Ensure we have the right data in shlibs/pkgdata
69 logger = logging.getLogger("selftest")
70 logger.info('Running bitbake to generate pkgdata')
71 bitbake('-c packagedata base-files coreutils busybox selftest-recipetool-appendfile')
72
73 @classmethod
74 def tearDownClass(cls):
75 # Shouldn't leave any traces of this artificial recipe behind
76 bitbake('-c cleansstate selftest-recipetool-appendfile')
77
78 def _try_recipetool_appendfile(self, testrecipe, destfile, newfile, options, expectedlines, expectedfiles):
79 cmd = 'recipetool appendfile %s %s %s %s' % (templayerdir, destfile, newfile, options)
80 return self._try_recipetool_appendcmd(cmd, testrecipe, expectedfiles, expectedlines)
81
66 def _try_recipetool_appendfile_fail(self, destfile, newfile, checkerror): 82 def _try_recipetool_appendfile_fail(self, destfile, newfile, checkerror):
67 cmd = 'recipetool appendfile %s %s %s' % (templayerdir, destfile, newfile) 83 cmd = 'recipetool appendfile %s %s %s' % (templayerdir, destfile, newfile)
68 result = runCmd(cmd, ignore_status=True) 84 result = runCmd(cmd, ignore_status=True)