summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-12-22 17:03:18 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-28 09:25:14 +0000
commitc2435b11812b32d967253794a7fff59bab2f49df (patch)
treedf8b306d744d61eaf090ad3b6de69ae458c77ccb /meta/lib/oeqa/selftest
parent891673101ed1e01e9acce852bd74f2763cc72c61 (diff)
downloadpoky-c2435b11812b32d967253794a7fff59bab2f49df.tar.gz
oe-selftest: add tests for simple devtool add / recipetool create URL case
Add an oe-selftest test case for the newly supported syntax with only the remote URL specified (auto-detecting name and version). (From OE-Core rev: 7c7df9f62fe15578af0420c63e320c317e058708) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest')
-rw-r--r--meta/lib/oeqa/selftest/devtool.py63
-rw-r--r--meta/lib/oeqa/selftest/recipetool.py19
2 files changed, 76 insertions, 6 deletions
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py
index 7af82df632..41e1b4bf51 100644
--- a/meta/lib/oeqa/selftest/devtool.py
+++ b/meta/lib/oeqa/selftest/devtool.py
@@ -15,18 +15,43 @@ class DevtoolBase(oeSelfTest):
15 15
16 def _test_recipe_contents(self, recipefile, checkvars, checkinherits): 16 def _test_recipe_contents(self, recipefile, checkvars, checkinherits):
17 with open(recipefile, 'r') as f: 17 with open(recipefile, 'r') as f:
18 invar = None
19 invalue = None
18 for line in f: 20 for line in f:
19 if '=' in line: 21 var = None
22 if invar:
23 value = line.strip().strip('"')
24 if value.endswith('\\'):
25 invalue += ' ' + value[:-1].strip()
26 continue
27 else:
28 invalue += ' ' + value.strip()
29 var = invar
30 value = invalue
31 invar = None
32 elif '=' in line:
20 splitline = line.split('=', 1) 33 splitline = line.split('=', 1)
21 var = splitline[0].rstrip() 34 var = splitline[0].rstrip()
22 value = splitline[1].strip().strip('"') 35 value = splitline[1].strip().strip('"')
23 if var in checkvars: 36 if value.endswith('\\'):
24 needvalue = checkvars.pop(var) 37 invalue = value[:-1].strip()
25 self.assertEqual(value, needvalue, 'values for %s do not match' % var) 38 invar = var
26 if line.startswith('inherit '): 39 continue
40 elif line.startswith('inherit '):
27 inherits = line.split()[1:] 41 inherits = line.split()[1:]
28 42
29 self.assertEqual(checkvars, {}, 'Some variables not found: %s' % checkvars) 43 if var and var in checkvars:
44 needvalue = checkvars.pop(var)
45 if needvalue is None:
46 self.fail('Variable %s should not appear in recipe')
47 self.assertEqual(value, needvalue, 'values for %s do not match' % var)
48
49
50 missingvars = {}
51 for var, value in checkvars.iteritems():
52 if value is not None:
53 missingvars[var] = value
54 self.assertEqual(missingvars, {}, 'Some expected variables not found in recipe: %s' % checkvars)
30 55
31 for inherit in checkinherits: 56 for inherit in checkinherits:
32 self.assertIn(inherit, inherits, 'Missing inherit of %s' % inherit) 57 self.assertIn(inherit, inherits, 'Missing inherit of %s' % inherit)
@@ -304,6 +329,32 @@ class DevtoolTests(DevtoolBase):
304 checkvars['SRCREV'] = checkrev 329 checkvars['SRCREV'] = checkrev
305 self._test_recipe_contents(recipefile, checkvars, []) 330 self._test_recipe_contents(recipefile, checkvars, [])
306 331
332 def test_devtool_add_fetch_simple(self):
333 # Fetch source from a remote URL, auto-detecting name
334 tempdir = tempfile.mkdtemp(prefix='devtoolqa')
335 self.track_for_cleanup(tempdir)
336 testver = '1.6.0'
337 url = 'http://www.ivarch.com/programs/sources/pv-%s.tar.bz2' % testver
338 testrecipe = 'pv'
339 srcdir = os.path.join(self.workspacedir, 'sources', testrecipe)
340 # Test devtool add
341 self.track_for_cleanup(self.workspacedir)
342 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
343 result = runCmd('devtool add %s' % url)
344 self.assertTrue(os.path.exists(os.path.join(self.workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created. %s' % result.output)
345 self.assertTrue(os.path.isfile(os.path.join(srcdir, 'configure')), 'Unable to find configure script in source directory')
346 # Test devtool status
347 result = runCmd('devtool status')
348 self.assertIn(testrecipe, result.output)
349 self.assertIn(srcdir, result.output)
350 # Check recipe
351 recipefile = get_bb_var('FILE', testrecipe)
352 self.assertIn('%s_%s.bb' % (testrecipe, testver), recipefile, 'Recipe file incorrectly named')
353 checkvars = {}
354 checkvars['S'] = None
355 checkvars['SRC_URI'] = url.replace(testver, '${PV}')
356 self._test_recipe_contents(recipefile, checkvars, [])
357
307 @testcase(1164) 358 @testcase(1164)
308 def test_devtool_modify(self): 359 def test_devtool_modify(self):
309 # Clean up anything in the workdir/sysroot/sstate cache 360 # Clean up anything in the workdir/sysroot/sstate cache
diff --git a/meta/lib/oeqa/selftest/recipetool.py b/meta/lib/oeqa/selftest/recipetool.py
index bbfce7c394..34e383f772 100644
--- a/meta/lib/oeqa/selftest/recipetool.py
+++ b/meta/lib/oeqa/selftest/recipetool.py
@@ -401,6 +401,25 @@ class RecipetoolTests(RecipetoolBase):
401 inherits = ['autotools', 'pkgconfig'] 401 inherits = ['autotools', 'pkgconfig']
402 self._test_recipe_contents(recipefile, checkvars, inherits) 402 self._test_recipe_contents(recipefile, checkvars, inherits)
403 403
404 def test_recipetool_create_simple(self):
405 # Try adding a recipe
406 temprecipe = os.path.join(self.tempdir, 'recipe')
407 os.makedirs(temprecipe)
408 pv = '1.7.3.0'
409 srcuri = 'http://www.dest-unreach.org/socat/download/socat-%s.tar.bz2' % pv
410 result = runCmd('recipetool create %s -o %s' % (srcuri, temprecipe))
411 dirlist = os.listdir(temprecipe)
412 if len(dirlist) < 1 or not os.path.isfile(os.path.join(temprecipe, dirlist[0])):
413 self.fail('recipetool did not create recipe file; output:\n%s' % result.output)
414 self.assertEqual(dirlist[0], 'socat_%s.bb' % pv, 'Recipe file incorrectly named')
415 checkvars = {}
416 checkvars['LICENSE'] = 'Unknown GPLv2'
417 checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING.OpenSSL;md5=5c9bccc77f67a8328ef4ebaf468116f4 file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263'
418 # We don't check DEPENDS since they are variable for this recipe depending on what's in the sysroot
419 checkvars['S'] = None
420 checkvars['SRC_URI'] = srcuri.replace(pv, '${PV}')
421 inherits = ['autotools']
422 self._test_recipe_contents(os.path.join(temprecipe, dirlist[0]), checkvars, inherits)
404 423
405class RecipetoolAppendsrcBase(RecipetoolBase): 424class RecipetoolAppendsrcBase(RecipetoolBase):
406 def _try_recipetool_appendsrcfile(self, testrecipe, newfile, destfile, options, expectedlines, expectedfiles): 425 def _try_recipetool_appendsrcfile(self, testrecipe, newfile, destfile, options, expectedlines, expectedfiles):