2013-11-27 17:08:53 +00:00
import os
import re
import oeqa . utils . ftools as ftools
from oeqa . selftest . base import oeSelfTest
from oeqa . utils . commands import runCmd , bitbake , get_bb_var
2014-07-09 08:36:47 +00:00
from oeqa . utils . decorators import testcase
2013-11-27 17:08:53 +00:00
class BitbakeTests ( oeSelfTest ) :
2014-07-09 08:36:47 +00:00
@testcase ( 789 )
2013-11-27 17:08:53 +00:00
def test_run_bitbake_from_dir_1 ( self ) :
os . chdir ( os . path . join ( self . builddir , ' conf ' ) )
2015-07-14 11:31:09 +00:00
self . assertEqual ( bitbake ( ' -e ' ) . status , 0 , msg = " bitbake couldn ' t run from \" conf \" dir " )
2013-11-27 17:08:53 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 790 )
2013-11-27 17:08:53 +00:00
def test_run_bitbake_from_dir_2 ( self ) :
my_env = os . environ . copy ( )
my_env [ ' BBPATH ' ] = my_env [ ' BUILDDIR ' ]
os . chdir ( os . path . dirname ( os . environ [ ' BUILDDIR ' ] ) )
2015-07-14 11:31:09 +00:00
self . assertEqual ( bitbake ( ' -e ' , env = my_env ) . status , 0 , msg = " bitbake couldn ' t run from builddir " )
2013-11-27 17:08:53 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 806 )
2013-11-27 17:08:53 +00:00
def test_event_handler ( self ) :
self . write_config ( " INHERIT += \" test_events \" " )
result = bitbake ( ' m4-native ' )
2014-12-23 14:39:03 +00:00
find_build_started = re . search ( " NOTE: Test for bb \ .event \ .BuildStarted( \n .*)*NOTE: Preparing RunQueue " , result . output )
2013-11-27 17:08:53 +00:00
find_build_completed = re . search ( " Tasks Summary:.*( \n .*)*NOTE: Test for bb \ .event \ .BuildCompleted " , result . output )
self . assertTrue ( find_build_started , msg = " Match failed in: \n %s " % result . output )
self . assertTrue ( find_build_completed , msg = " Match failed in: \n %s " % result . output )
2015-07-14 11:31:09 +00:00
self . assertFalse ( ' Test for bb.event.InvalidEvent ' in result . output , msg = " \" Test for bb.event.InvalidEvent \" message found during bitbake process. bitbake output: %s " % result . output )
2013-11-27 17:08:53 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 103 )
2013-11-27 17:08:53 +00:00
def test_local_sstate ( self ) :
bitbake ( ' m4-native -ccleansstate ' )
bitbake ( ' m4-native ' )
bitbake ( ' m4-native -cclean ' )
result = bitbake ( ' m4-native ' )
find_setscene = re . search ( " m4-native.*do_.*_setscene " , result . output )
2015-07-14 11:31:09 +00:00
self . assertTrue ( find_setscene , msg = " No \" m4-native.*do_.*_setscene \" message found during bitbake m4-native. bitbake output: %s " % result . output )
2013-11-27 17:08:53 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 105 )
2013-11-27 17:08:53 +00:00
def test_bitbake_invalid_recipe ( self ) :
result = bitbake ( ' -b asdf ' , ignore_status = True )
2015-07-14 11:31:09 +00:00
self . assertTrue ( " ERROR: Unable to find any recipe file matching ' asdf ' " in result . output , msg = " Though asdf recipe doesn ' t exist, bitbake didn ' t output any err. message. bitbake output: %s " % result . output )
2013-11-27 17:08:53 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 107 )
2013-11-27 17:08:53 +00:00
def test_bitbake_invalid_target ( self ) :
result = bitbake ( ' asdf ' , ignore_status = True )
2015-07-14 11:31:09 +00:00
self . assertTrue ( " ERROR: Nothing PROVIDES ' asdf ' " in result . output , msg = " Though no ' asdf ' target exists, bitbake didn ' t output any err. message. bitbake output: %s " % result . output )
2013-11-27 17:08:53 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 106 )
2013-11-27 17:08:53 +00:00
def test_warnings_errors ( self ) :
result = bitbake ( ' -b asdf ' , ignore_status = True )
2014-03-27 10:32:03 +00:00
find_warnings = re . search ( " Summary: There w. { 2,3}? [1-9][0-9]* WARNING messages* shown " , result . output )
find_errors = re . search ( " Summary: There w. { 2,3}? [1-9][0-9]* ERROR messages* shown " , result . output )
self . assertTrue ( find_warnings , msg = " Did not find the mumber of warnings at the end of the build: \n " + result . output )
self . assertTrue ( find_errors , msg = " Did not find the mumber of errors at the end of the build: \n " + result . output )
2013-11-27 17:08:53 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 108 )
2013-11-27 17:08:53 +00:00
def test_invalid_patch ( self ) :
self . write_recipeinc ( ' man ' , ' SRC_URI += " file://man-1.5h1-make.patch " ' )
result = bitbake ( ' man -c patch ' , ignore_status = True )
self . delete_recipeinc ( ' man ' )
bitbake ( ' -cclean man ' )
2015-07-14 11:31:09 +00:00
self . assertTrue ( " ERROR: Function failed: patch_do_patch " in result . output , msg = " Though no man-1.5h1-make.patch file exists, bitbake didn ' t output any err. message. bitbake output: %s " % result . output )
2013-11-27 17:08:53 +00:00
2015-10-13 15:00:40 +00:00
@testcase ( 1354 )
def test_force_task_1 ( self ) :
# test 1 from bug 5875
test_recipe = ' zlib '
test_data = " Microsoft Made No Profit From Anyone ' s Zunes Yo "
image_dir = get_bb_var ( ' D ' , test_recipe )
pkgsplit_dir = get_bb_var ( ' PKGDEST ' , test_recipe )
man_dir = get_bb_var ( ' mandir ' , test_recipe )
bitbake ( ' -c cleansstate %s ' % test_recipe )
bitbake ( test_recipe )
self . add_command_to_tearDown ( ' bitbake -c clean %s ' % test_recipe )
man_file = os . path . join ( image_dir + man_dir , ' man3/zlib.3 ' )
ftools . append_file ( man_file , test_data )
bitbake ( ' -c package -f %s ' % test_recipe )
man_split_file = os . path . join ( pkgsplit_dir , ' zlib-doc ' + man_dir , ' man3/zlib.3 ' )
man_split_content = ftools . read_file ( man_split_file )
self . assertIn ( test_data , man_split_content , ' The man file has not changed in packages-split. ' )
ret = bitbake ( test_recipe )
self . assertIn ( ' task do_package_write_rpm: ' , ret . output , ' Task do_package_write_rpm did not re-executed. ' )
2014-07-09 08:36:47 +00:00
@testcase ( 163 )
2015-10-13 15:00:40 +00:00
def test_force_task_2 ( self ) :
# test 2 from bug 5875
test_recipe = ' zlib '
bitbake ( ' -c cleansstate %s ' % test_recipe )
bitbake ( test_recipe )
self . add_command_to_tearDown ( ' bitbake -c clean %s ' % test_recipe )
result = bitbake ( ' -C compile %s ' % test_recipe )
look_for_tasks = [ ' do_compile: ' , ' do_install: ' , ' do_populate_sysroot: ' , ' do_package: ' ]
2013-11-27 17:08:53 +00:00
for task in look_for_tasks :
2015-10-13 15:00:40 +00:00
self . assertIn ( task , result . output , msg = " Couldn ' t find %s task. " )
2013-11-27 17:08:53 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 167 )
2013-11-27 17:08:53 +00:00
def test_bitbake_g ( self ) :
2014-03-06 16:46:08 +00:00
result = bitbake ( ' -g core-image-full-cmdline ' )
2013-11-27 17:08:53 +00:00
for f in [ ' pn-buildlist ' , ' pn-depends.dot ' , ' package-depends.dot ' , ' task-depends.dot ' ] :
2015-07-14 11:31:09 +00:00
self . addCleanup ( os . remove , f )
self . assertTrue ( ' NOTE: PN build list saved to \' pn-buildlist \' ' in result . output , msg = " No dependency \" pn-buildlist \" file was generated for the given task target. bitbake output: %s " % result . output )
self . assertTrue ( ' openssh ' in ftools . read_file ( os . path . join ( self . builddir , ' pn-buildlist ' ) ) , msg = " No \" openssh \" dependency found in pn-buildlist file. " )
2013-11-27 17:08:53 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 899 )
2014-03-05 08:55:14 +00:00
def test_image_manifest ( self ) :
bitbake ( ' core-image-minimal ' )
deploydir = get_bb_var ( " DEPLOY_DIR_IMAGE " , target = " core-image-minimal " )
imagename = get_bb_var ( " IMAGE_LINK_NAME " , target = " core-image-minimal " )
manifest = os . path . join ( deploydir , imagename + " .manifest " )
2015-07-14 11:31:09 +00:00
self . assertTrue ( os . path . islink ( manifest ) , msg = " No manifest file created for image. It should have been created in %s " % manifest )
2014-03-05 08:55:14 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 168 )
2013-11-27 17:08:53 +00:00
def test_invalid_recipe_src_uri ( self ) :
data = ' SRC_URI = " file://invalid " '
self . write_recipeinc ( ' man ' , data )
2015-07-08 11:55:28 +00:00
self . write_config ( """ DL_DIR = \" $ {TOPDIR} /download-selftest \"
SSTATE_DIR = \" $ {TOPDIR} /download-selftest \"
""" )
2015-10-20 12:49:04 +00:00
self . track_for_cleanup ( os . path . join ( self . builddir , " download-selftest " ) )
2013-11-27 17:08:53 +00:00
bitbake ( ' -ccleanall man ' )
result = bitbake ( ' -c fetch man ' , ignore_status = True )
bitbake ( ' -ccleanall man ' )
self . delete_recipeinc ( ' man ' )
2015-07-14 11:31:09 +00:00
self . assertEqual ( result . status , 1 , msg = " Command succeded when it should have failed. bitbake output: %s " % result . output )
self . assertTrue ( ' Fetcher failure: Unable to find file file://invalid anywhere. The paths that were searched were: ' in result . output , msg = " \" invalid \" file \
doesn ' t exist, yet no error message encountered. bitbake output: %s " % r esult.output)
self . assertTrue ( ' ERROR: Function failed: Fetcher failure for URL: \' file://invalid \' . Unable to fetch URL from any source. ' in result . output , msg = " \" invalid \" file \
doesn ' t exist, yet fetcher didn ' t report any error . bitbake output : % s " % r esult.output)
2013-11-27 17:08:53 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 171 )
2013-11-27 17:08:53 +00:00
def test_rename_downloaded_file ( self ) :
2015-07-08 11:55:28 +00:00
self . write_config ( """ DL_DIR = \" $ {TOPDIR} /download-selftest \"
SSTATE_DIR = \" $ {TOPDIR} /download-selftest \"
""" )
2015-10-20 12:49:04 +00:00
self . track_for_cleanup ( os . path . join ( self . builddir , " download-selftest " ) )
2013-11-27 17:08:53 +00:00
data = ' SRC_URI_append = " ;downloadfilename=test-aspell.tar.gz " '
self . write_recipeinc ( ' aspell ' , data )
bitbake ( ' -ccleanall aspell ' )
result = bitbake ( ' -c fetch aspell ' , ignore_status = True )
self . delete_recipeinc ( ' aspell ' )
2015-07-14 11:31:09 +00:00
self . assertEqual ( result . status , 0 , msg = " Couldn ' t fetch aspell. %s " % result . output )
self . assertTrue ( os . path . isfile ( os . path . join ( get_bb_var ( " DL_DIR " ) , ' test-aspell.tar.gz ' ) ) , msg = " File rename failed. No corresponding test-aspell.tar.gz file found under %s " % str ( get_bb_var ( " DL_DIR " ) ) )
self . assertTrue ( os . path . isfile ( os . path . join ( get_bb_var ( " DL_DIR " ) , ' test-aspell.tar.gz.done ' ) ) , " File rename failed. No corresponding test-aspell.tar.gz.done file found under %s " % str ( get_bb_var ( " DL_DIR " ) ) )
2014-06-04 15:26:30 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 1028 )
2014-06-04 15:26:30 +00:00
def test_environment ( self ) :
2015-10-19 14:58:26 +00:00
self . write_config ( " TEST_ENV= \" localconf \" " )
2015-03-20 12:15:02 +00:00
result = runCmd ( ' bitbake -e | grep TEST_ENV= ' )
2015-07-14 11:31:09 +00:00
self . assertTrue ( ' localconf ' in result . output , msg = " bitbake didn ' t report any value for TEST_ENV variable. To test, run ' bitbake -e | grep TEST_ENV= ' " )
2014-06-04 15:26:30 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 1029 )
2014-06-04 15:26:30 +00:00
def test_dry_run ( self ) :
2015-03-20 12:15:02 +00:00
result = runCmd ( ' bitbake -n m4-native ' )
2015-07-14 11:31:09 +00:00
self . assertEqual ( 0 , result . status , " bitbake dry run didn ' t run as expected. %s " % result . output )
2014-06-04 15:26:30 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 1030 )
2014-06-04 15:26:30 +00:00
def test_just_parse ( self ) :
2015-03-20 12:15:02 +00:00
result = runCmd ( ' bitbake -p ' )
2015-07-14 11:31:09 +00:00
self . assertEqual ( 0 , result . status , " errors encountered when parsing recipes. %s " % result . output )
2014-06-04 15:26:30 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 1031 )
2014-06-04 15:26:30 +00:00
def test_version ( self ) :
2015-03-20 12:15:02 +00:00
result = runCmd ( ' bitbake -s | grep wget ' )
find = re . search ( " wget *:([0-9a-zA-Z \ . \ -]+) " , result . output )
2015-07-14 11:31:09 +00:00
self . assertTrue ( find , " No version returned for searched recipe. bitbake output: %s " % result . output )
2014-06-04 15:26:30 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 1032 )
2014-06-04 15:26:30 +00:00
def test_prefile ( self ) :
2015-03-20 12:15:02 +00:00
preconf = os . path . join ( self . builddir , ' conf/prefile.conf ' )
self . track_for_cleanup ( preconf )
ftools . write_file ( preconf , " TEST_PREFILE= \" prefile \" " )
result = runCmd ( ' bitbake -r conf/prefile.conf -e | grep TEST_PREFILE= ' )
2015-07-14 11:31:09 +00:00
self . assertTrue ( ' prefile ' in result . output , " Preconfigure file \" prefile.conf \" was not taken into consideration. " )
2015-10-19 14:58:26 +00:00
self . write_config ( " TEST_PREFILE= \" localconf \" " )
2015-03-20 12:15:02 +00:00
result = runCmd ( ' bitbake -r conf/prefile.conf -e | grep TEST_PREFILE= ' )
2015-07-14 11:31:09 +00:00
self . assertTrue ( ' localconf ' in result . output , " Preconfigure file \" prefile.conf \" was not taken into consideration. " )
2014-06-04 15:26:30 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 1033 )
2014-06-04 15:26:30 +00:00
def test_postfile ( self ) :
2015-03-20 12:15:02 +00:00
postconf = os . path . join ( self . builddir , ' conf/postfile.conf ' )
self . track_for_cleanup ( postconf )
ftools . write_file ( postconf , " TEST_POSTFILE= \" postfile \" " )
2015-10-19 14:58:26 +00:00
self . write_config ( " TEST_POSTFILE= \" localconf \" " )
2015-03-20 12:15:02 +00:00
result = runCmd ( ' bitbake -R conf/postfile.conf -e | grep TEST_POSTFILE= ' )
2015-07-14 11:31:09 +00:00
self . assertTrue ( ' postfile ' in result . output , " Postconfigure file \" postfile.conf \" was not taken into consideration. " )
2014-06-04 15:26:30 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 1034 )
2014-06-04 15:26:30 +00:00
def test_checkuri ( self ) :
2015-03-20 12:15:02 +00:00
result = runCmd ( ' bitbake -c checkuri m4 ' )
2015-07-14 11:31:09 +00:00
self . assertEqual ( 0 , result . status , msg = " \" checkuri \" task was not executed. bitbake output: %s " % result . output )
2014-06-04 15:26:30 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 1035 )
2014-06-04 15:26:30 +00:00
def test_continue ( self ) :
2015-07-08 11:55:28 +00:00
self . write_config ( """ DL_DIR = \" $ {TOPDIR} /download-selftest \"
SSTATE_DIR = \" $ {TOPDIR} /download-selftest \"
""" )
2015-10-20 12:49:04 +00:00
self . track_for_cleanup ( os . path . join ( self . builddir , " download-selftest " ) )
2015-03-20 12:15:02 +00:00
self . write_recipeinc ( ' man ' , " \n do_fail_task () { \n exit 1 \n } \n \n addtask do_fail_task before do_fetch \n " )
runCmd ( ' bitbake -c cleanall man xcursor-transparent-theme ' )
result = runCmd ( ' bitbake man xcursor-transparent-theme -k ' , ignore_status = True )
errorpos = result . output . find ( ' ERROR: Function failed: do_fail_task ' )
manver = re . search ( " NOTE: recipe xcursor-transparent-theme-(.*?): task do_unpack: Started " , result . output )
continuepos = result . output . find ( ' NOTE: recipe xcursor-transparent-theme- %s : task do_unpack: Started ' % manver . group ( 1 ) )
2015-07-14 11:31:09 +00:00
self . assertLess ( errorpos , continuepos , msg = " bitbake didn ' t pass do_fail_task. bitbake output: %s " % result . output )
2015-03-03 10:31:12 +00:00
@testcase ( 1119 )
def test_non_gplv3 ( self ) :
data = ' INCOMPATIBLE_LICENSE = " GPLv3 " '
conf = os . path . join ( self . builddir , ' conf/local.conf ' )
ftools . append_file ( conf , data )
2015-06-29 08:16:11 +00:00
self . addCleanup ( ftools . remove_from_file , conf , data )
2015-03-03 10:31:12 +00:00
result = bitbake ( ' readline ' , ignore_status = True )
2015-06-29 08:16:43 +00:00
self . assertEqual ( result . status , 0 , " Bitbake failed, exit code %s , output %s " % ( result . status , result . output ) )
2015-03-03 10:31:12 +00:00
self . assertFalse ( os . path . isfile ( os . path . join ( self . builddir , ' tmp/deploy/licenses/readline/generic_GPLv3 ' ) ) )
self . assertTrue ( os . path . isfile ( os . path . join ( self . builddir , ' tmp/deploy/licenses/readline/generic_GPLv2 ' ) ) )