2013-11-27 17:08:52 +00:00
import os
import re
2015-07-22 07:04:08 +00:00
import glob as g
2016-03-04 10:55:33 +00:00
import shutil
import tempfile
2013-11-27 17:08:52 +00:00
from oeqa . selftest . base import oeSelfTest
2013-12-17 11:32:29 +00:00
from oeqa . selftest . buildhistory import BuildhistoryBase
2013-11-27 17:08:52 +00:00
from oeqa . utils . commands import runCmd , bitbake , get_bb_var
import oeqa . utils . ftools as ftools
2014-09-22 10:45:05 +00:00
from oeqa . utils . decorators import testcase
2013-11-27 17:08:52 +00:00
class ImageOptionsTests ( oeSelfTest ) :
2014-09-22 10:45:05 +00:00
@testcase ( 761 )
2013-11-27 17:08:52 +00:00
def test_incremental_image_generation ( self ) :
2014-12-23 15:17:48 +00:00
image_pkgtype = get_bb_var ( " IMAGE_PKGTYPE " )
if image_pkgtype != ' rpm ' :
self . skipTest ( ' Not using RPM as main package format ' )
2013-11-27 17:08:52 +00:00
bitbake ( " -c cleanall core-image-minimal " )
self . write_config ( ' INC_RPM_IMAGE_GEN = " 1 " ' )
self . append_config ( ' IMAGE_FEATURES += " ssh-server-openssh " ' )
bitbake ( " core-image-minimal " )
2014-12-31 02:59:42 +00:00
log_data_file = os . path . join ( get_bb_var ( " WORKDIR " , " core-image-minimal " ) , " temp/log.do_rootfs " )
log_data_created = ftools . read_file ( log_data_file )
incremental_created = re . search ( " NOTE: load old install solution for incremental install \n NOTE: old install solution not exist \n NOTE: creating new install solution for incremental install( \n .*)*NOTE: Installing the following packages:.*packagegroup-core-ssh-openssh " , log_data_created )
2013-11-27 17:08:52 +00:00
self . remove_config ( ' IMAGE_FEATURES += " ssh-server-openssh " ' )
2014-12-31 02:59:42 +00:00
self . assertTrue ( incremental_created , msg = " Match failed in: \n %s " % log_data_created )
2013-11-27 17:08:52 +00:00
bitbake ( " core-image-minimal " )
2014-12-31 02:59:42 +00:00
log_data_removed = ftools . read_file ( log_data_file )
incremental_removed = re . search ( " NOTE: load old install solution for incremental install \n NOTE: creating new install solution for incremental install( \n .*)*NOTE: incremental removed:.*openssh-sshd-.* " , log_data_removed )
self . assertTrue ( incremental_removed , msg = " Match failed in: \n %s " % log_data_removed )
2013-11-27 17:08:52 +00:00
2014-09-22 10:45:05 +00:00
@testcase ( 286 )
2013-11-27 17:08:52 +00:00
def test_ccache_tool ( self ) :
bitbake ( " ccache-native " )
2015-07-14 11:31:11 +00:00
self . assertTrue ( os . path . isfile ( os . path . join ( get_bb_var ( ' STAGING_BINDIR_NATIVE ' , ' ccache-native ' ) , " ccache " ) ) , msg = " No ccache found under %s " % str ( get_bb_var ( ' STAGING_BINDIR_NATIVE ' , ' ccache-native ' ) ) )
2013-11-27 17:08:52 +00:00
self . write_config ( ' INHERIT += " ccache " ' )
bitbake ( " m4 -c cleansstate " )
bitbake ( " m4 -c compile " )
2015-07-14 11:31:11 +00:00
self . addCleanup ( bitbake , ' ccache-native -ccleansstate ' )
2013-11-27 17:08:52 +00:00
res = runCmd ( " grep ccache %s " % ( os . path . join ( get_bb_var ( " WORKDIR " , " m4 " ) , " temp/log.do_compile " ) ) , ignore_status = True )
2015-07-14 11:31:11 +00:00
self . assertEqual ( 0 , res . status , msg = " No match for ccache in m4 log.do_compile. For further details: %s " % os . path . join ( get_bb_var ( " WORKDIR " , " m4 " ) , " temp/log.do_compile " ) )
2013-11-27 17:08:52 +00:00
2016-03-30 15:07:32 +00:00
@testcase ( 1435 )
2016-03-17 22:09:25 +00:00
def test_read_only_image ( self ) :
self . write_config ( ' IMAGE_FEATURES += " read-only-rootfs " ' )
bitbake ( " core-image-sato " )
# do_image will fail if there are any pending postinsts
2013-11-27 17:08:52 +00:00
class DiskMonTest ( oeSelfTest ) :
2014-09-22 10:45:05 +00:00
@testcase ( 277 )
2013-11-27 17:08:52 +00:00
def test_stoptask_behavior ( self ) :
2014-04-11 11:04:49 +00:00
self . write_config ( ' BB_DISKMON_DIRS = " STOPTASKS,$ {TMPDIR} ,100000G,100K " ' )
2013-12-04 13:13:52 +00:00
res = bitbake ( " m4 " , ignore_status = True )
2015-07-14 11:31:11 +00:00
self . assertTrue ( ' ERROR: No new tasks can be executed since the disk space monitor action is " STOPTASKS " ! ' in res . output , msg = " Tasks should have stopped. Disk monitor is set to STOPTASK: %s " % res . output )
self . assertEqual ( res . status , 1 , msg = " bitbake reported exit code %s . It should have been 1. Bitbake output: %s " % ( str ( res . status ) , res . output ) )
2014-04-11 11:04:49 +00:00
self . write_config ( ' BB_DISKMON_DIRS = " ABORT,$ {TMPDIR} ,100000G,100K " ' )
2013-12-04 13:13:52 +00:00
res = bitbake ( " m4 " , ignore_status = True )
2015-07-14 11:31:11 +00:00
self . assertTrue ( ' ERROR: Immediately abort since the disk space monitor action is " ABORT " ! ' in res . output , " Tasks should have been aborted immediatelly. Disk monitor is set to ABORT: %s " % res . output )
self . assertEqual ( res . status , 1 , msg = " bitbake reported exit code %s . It should have been 1. Bitbake output: %s " % ( str ( res . status ) , res . output ) )
2014-04-11 11:04:49 +00:00
self . write_config ( ' BB_DISKMON_DIRS = " WARN,$ {TMPDIR} ,100000G,100K " ' )
2013-12-04 13:13:52 +00:00
res = bitbake ( " m4 " )
2015-07-14 11:31:11 +00:00
self . assertTrue ( ' WARNING: The free space ' in res . output , msg = " A warning should have been displayed for disk monitor is set to WARN: %s " % res . output )
2013-11-27 17:08:52 +00:00
class SanityOptionsTest ( oeSelfTest ) :
2016-02-15 15:46:46 +00:00
def getline ( self , res , line ) :
for l in res . output . split ( ' \n ' ) :
if line in l :
return l
2013-11-27 17:08:52 +00:00
2014-09-22 10:45:05 +00:00
@testcase ( 927 )
2013-11-27 17:08:52 +00:00
def test_options_warnqa_errorqa_switch ( self ) :
bitbake ( " xcursor-transparent-theme -ccleansstate " )
2016-08-04 16:04:51 +00:00
self . write_config ( " INHERIT_remove = \" report-error \" " )
2013-11-27 17:08:52 +00:00
if " packages-list " not in get_bb_var ( " ERROR_QA " ) :
2016-08-04 16:04:51 +00:00
self . append_config ( " ERROR_QA_append = \" packages-list \" " )
2013-11-27 17:08:52 +00:00
self . write_recipeinc ( ' xcursor-transparent-theme ' , ' PACKAGES += \" $ {PN} -dbg \" ' )
res = bitbake ( " xcursor-transparent-theme " , ignore_status = True )
self . delete_recipeinc ( ' xcursor-transparent-theme ' )
2016-02-15 15:46:46 +00:00
line = self . getline ( res , " QA Issue: xcursor-transparent-theme-dbg is listed in PACKAGES multiple times, this leads to packaging errors. " )
self . assertTrue ( line and line . startswith ( " ERROR: " ) , msg = res . output )
2015-07-14 11:31:11 +00:00
self . assertEqual ( res . status , 1 , msg = " bitbake reported exit code %s . It should have been 1. Bitbake output: %s " % ( str ( res . status ) , res . output ) )
2013-11-27 17:08:52 +00:00
self . write_recipeinc ( ' xcursor-transparent-theme ' , ' PACKAGES += \" $ {PN} -dbg \" ' )
self . append_config ( ' ERROR_QA_remove = " packages-list " ' )
self . append_config ( ' WARN_QA_append = " packages-list " ' )
bitbake ( " xcursor-transparent-theme -ccleansstate " )
2014-07-28 15:59:19 +00:00
res = bitbake ( " xcursor-transparent-theme " )
2013-11-27 17:08:52 +00:00
self . delete_recipeinc ( ' xcursor-transparent-theme ' )
2016-02-15 15:46:46 +00:00
line = self . getline ( res , " QA Issue: xcursor-transparent-theme-dbg is listed in PACKAGES multiple times, this leads to packaging errors. " )
self . assertTrue ( line and line . startswith ( " WARNING: " ) , msg = res . output )
2013-11-27 17:08:52 +00:00
2014-09-22 10:45:05 +00:00
@testcase ( 278 )
2016-02-29 15:36:48 +00:00
def test_sanity_unsafe_script_references ( self ) :
self . write_config ( ' WARN_QA_append = " unsafe-references-in-scripts " ' )
bitbake ( " -ccleansstate gzip " )
res = bitbake ( " gzip " )
line = self . getline ( res , " QA Issue: gzip " )
self . assertFalse ( line , " WARNING: QA Issue: gzip message is present in bitbake ' s output and shouldn ' t be: %s " % res . output )
self . append_config ( """
do_install_append_pn - gzip ( ) {
echo " \n $ {bindir} /test " >> $ { D } $ { bindir } / zcat
}
""" )
res = bitbake ( " gzip " )
2016-02-15 15:46:46 +00:00
line = self . getline ( res , " QA Issue: gzip " )
self . assertTrue ( line and line . startswith ( " WARNING: " ) , " WARNING: QA Issue: gzip message is not present in bitbake ' s output: %s " % res . output )
2016-02-29 15:36:48 +00:00
2016-03-30 15:07:32 +00:00
@testcase ( 1434 )
2016-02-29 15:36:48 +00:00
def test_sanity_unsafe_binary_references ( self ) :
self . write_config ( ' WARN_QA_append = " unsafe-references-in-binaries " ' )
bitbake ( " -ccleansstate nfs-utils " )
#res = bitbake("nfs-utils")
# FIXME when nfs-utils passes this test
#line = self.getline(res, "QA Issue: nfs-utils")
#self.assertFalse(line, "WARNING: QA Issue: nfs-utils message is present in bitbake's output and shouldn't be: %s" % res.output)
# self.append_config("""
#do_install_append_pn-nfs-utils () {
# echo "\n${bindir}/test" >> ${D}${base_sbindir}/osd_login
#}
#""")
res = bitbake ( " nfs-utils " )
2016-02-15 15:46:46 +00:00
line = self . getline ( res , " QA Issue: nfs-utils " )
self . assertTrue ( line and line . startswith ( " WARNING: " ) , " WARNING: QA Issue: nfs-utils message is not present in bitbake ' s output: %s " % res . output )
2013-12-17 11:32:29 +00:00
2016-03-04 10:55:33 +00:00
@testcase ( 1421 )
2016-03-17 10:37:29 +00:00
def test_layer_without_git_dir ( self ) :
2016-03-04 10:55:33 +00:00
"""
Summary : Test that layer git revisions are displayed and do not fail without git repository
Expected : The build to be successful and without " fatal " errors
Product : oe - core
Author : Daniel Istrate < daniel . alexandrux . istrate @intel.com >
AutomatedBy : Daniel Istrate < daniel . alexandrux . istrate @intel.com >
"""
dirpath = tempfile . mkdtemp ( )
dummy_layer_name = ' meta-dummy '
dummy_layer_path = os . path . join ( dirpath , dummy_layer_name )
dummy_layer_conf_dir = os . path . join ( dummy_layer_path , ' conf ' )
os . makedirs ( dummy_layer_conf_dir )
dummy_layer_conf_path = os . path . join ( dummy_layer_conf_dir , ' layer.conf ' )
dummy_layer_content = ' BBPATH .= " :$ {LAYERDIR} " \n ' \
' BBFILES += " $ {LAYERDIR} /recipes-*/*/*.bb $ {LAYERDIR} /recipes-*/*/*.bbappend " \n ' \
' BBFILE_COLLECTIONS += " %s " \n ' \
' BBFILE_PATTERN_ %s = " ^$ {LAYERDIR} / " \n ' \
' BBFILE_PRIORITY_ %s = " 6 " \n ' % ( dummy_layer_name , dummy_layer_name , dummy_layer_name )
ftools . write_file ( dummy_layer_conf_path , dummy_layer_content )
bblayers_conf = ' BBLAYERS += " %s " \n ' % dummy_layer_path
self . write_bblayers_config ( bblayers_conf )
test_recipe = ' ed '
ret = bitbake ( ' -n %s ' % test_recipe )
err = ' fatal: Not a git repository '
shutil . rmtree ( dirpath )
self . assertNotIn ( err , ret . output )
2013-12-17 11:32:29 +00:00
class BuildhistoryTests ( BuildhistoryBase ) :
2014-09-22 10:45:05 +00:00
@testcase ( 293 )
2013-12-17 11:32:29 +00:00
def test_buildhistory_basic ( self ) :
self . run_buildhistory_operation ( ' xcursor-transparent-theme ' )
2015-07-14 11:31:11 +00:00
self . assertTrue ( os . path . isdir ( get_bb_var ( ' BUILDHISTORY_DIR ' ) ) , " buildhistory dir was not created. " )
2013-12-17 11:32:29 +00:00
2014-09-22 10:45:05 +00:00
@testcase ( 294 )
2013-12-17 11:32:29 +00:00
def test_buildhistory_buildtime_pr_backwards ( self ) :
self . add_command_to_tearDown ( ' cleanup-workdir ' )
target = ' xcursor-transparent-theme '
2016-02-15 15:46:46 +00:00
error = " ERROR:.*QA Issue: Package version for package %s went backwards which would break package feeds from (.*-r1.* to .*-r0.*) " % target
2013-12-17 11:32:29 +00:00
self . run_buildhistory_operation ( target , target_config = " PR = \" r1 \" " , change_bh_location = True )
self . run_buildhistory_operation ( target , target_config = " PR = \" r0 \" " , change_bh_location = False , expect_error = True , error_regex = error )
2015-07-22 07:04:08 +00:00
class ArchiverTest ( oeSelfTest ) :
@testcase ( 926 )
def test_arch_work_dir_and_export_source ( self ) :
"""
Test for archiving the work directory and exporting the source files .
"""
2015-10-14 05:37:55 +00:00
self . add_command_to_tearDown ( ' cleanup-workdir ' )
2016-03-30 07:30:07 +00:00
self . write_config ( " INHERIT += \" archiver \" \n ARCHIVER_MODE[src] = \" original \" \n ARCHIVER_MODE[srpm] = \" 1 \" " )
2015-07-22 07:04:08 +00:00
res = bitbake ( " xcursor-transparent-theme " , ignore_status = True )
self . assertEqual ( res . status , 0 , " \n Couldn ' t build xcursortransparenttheme. \n bitbake output %s " % res . output )
pkgs_path = g . glob ( str ( self . builddir ) + " /tmp/deploy/sources/allarch*/xcurs* " )
src_file_glob = str ( pkgs_path [ 0 ] ) + " /xcursor*.src.rpm "
tar_file_glob = str ( pkgs_path [ 0 ] ) + " /xcursor*.tar.gz "
self . assertTrue ( ( g . glob ( src_file_glob ) and g . glob ( tar_file_glob ) ) , " Couldn ' t find .src.rpm and .tar.gz files under tmp/deploy/sources/allarch*/xcursor* " )