PageRenderTime 36ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/scripts/lib/checklayer/cases/common.py

https://github.com/OSSystems/oe-core
Python | 58 lines | 49 code | 3 blank | 6 comment | 0 complexity | b9a8fd5052aac5f8587f0db8e4f2fde2 MD5 | raw file
  1. # Copyright (C) 2017 Intel Corporation
  2. # Released under the MIT license (see COPYING.MIT)
  3. import glob
  4. import os
  5. import unittest
  6. from checklayer import get_signatures, LayerType, check_command, get_depgraph, compare_signatures
  7. from checklayer.case import OECheckLayerTestCase
  8. class CommonCheckLayer(OECheckLayerTestCase):
  9. def test_readme(self):
  10. # The top-level README file may have a suffix (like README.rst or README.txt).
  11. readme_files = glob.glob(os.path.join(self.tc.layer['path'], 'README*'))
  12. self.assertTrue(len(readme_files) > 0,
  13. msg="Layer doesn't contains README file.")
  14. # There might be more than one file matching the file pattern above
  15. # (for example, README.rst and README-COPYING.rst). The one with the shortest
  16. # name is considered the "main" one.
  17. readme_file = sorted(readme_files)[0]
  18. data = ''
  19. with open(readme_file, 'r') as f:
  20. data = f.read()
  21. self.assertTrue(data,
  22. msg="Layer contains a README file but it is empty.")
  23. def test_parse(self):
  24. check_command('Layer %s failed to parse.' % self.tc.layer['name'],
  25. 'bitbake -p')
  26. def test_show_environment(self):
  27. check_command('Layer %s failed to show environment.' % self.tc.layer['name'],
  28. 'bitbake -e')
  29. def test_world(self):
  30. '''
  31. "bitbake world" is expected to work. test_signatures does not cover that
  32. because it is more lenient and ignores recipes in a world build that
  33. are not actually buildable, so here we fail when "bitbake -S none world"
  34. fails.
  35. '''
  36. get_signatures(self.td['builddir'], failsafe=False)
  37. def test_signatures(self):
  38. if self.tc.layer['type'] == LayerType.SOFTWARE and \
  39. not self.tc.test_software_layer_signatures:
  40. raise unittest.SkipTest("Not testing for signature changes in a software layer %s." \
  41. % self.tc.layer['name'])
  42. curr_sigs, _ = get_signatures(self.td['builddir'], failsafe=True)
  43. msg = compare_signatures(self.td['sigs'], curr_sigs)
  44. if msg is not None:
  45. self.fail('Adding layer %s changed signatures.\n%s' % (self.tc.layer['name'], msg))
  46. def test_layerseries_compat(self):
  47. for collection_name, collection_data in self.tc.layer['collections'].items():
  48. self.assertTrue(collection_data['compat'], "Collection %s from layer %s does not set compatible oe-core versions via LAYERSERIES_COMPAT_collection." \
  49. % (collection_name, self.tc.layer['name']))