2013-12-19 17:05:32 +00:00
import datetime
import unittest
import os
import re
import shutil
2015-09-16 20:53:01 +00:00
import glob
2016-04-11 17:33:16 +00:00
import subprocess
2013-12-19 17:05:32 +00:00
import oeqa . utils . ftools as ftools
from oeqa . selftest . base import oeSelfTest
from oeqa . utils . commands import runCmd , bitbake , get_bb_var , get_test_layer
2014-01-14 13:21:21 +00:00
from oeqa . selftest . sstate import SStateBase
2014-07-09 08:36:47 +00:00
from oeqa . utils . decorators import testcase
2013-12-19 17:05:32 +00:00
2014-01-14 13:21:19 +00:00
class SStateTests ( SStateBase ) :
2013-12-19 17:05:32 +00:00
# Test sstate files creation and their location
def run_test_sstate_creation ( self , targets , distro_specific = True , distro_nonspecific = True , temp_sstate_location = True , should_pass = True ) :
self . config_sstate ( temp_sstate_location )
if self . temp_sstate_location :
bitbake ( [ ' -cclean ' ] + targets )
else :
bitbake ( [ ' -ccleansstate ' ] + targets )
bitbake ( targets )
2016-02-07 17:10:43 +00:00
file_tracker = [ ]
results = self . search_sstate ( ' | ' . join ( map ( str , targets ) ) , distro_specific , distro_nonspecific )
if distro_nonspecific :
for r in results :
if r . endswith ( ( " _populate_lic.tgz " , " _populate_lic.tgz.siginfo " , " _fetch.tgz.siginfo " , " _unpack.tgz.siginfo " , " _patch.tgz.siginfo " ) ) :
continue
file_tracker . append ( r )
else :
file_tracker = results
2013-12-19 17:05:32 +00:00
if should_pass :
self . assertTrue ( file_tracker , msg = " Could not find sstate files for: %s " % ' , ' . join ( map ( str , targets ) ) )
else :
2016-02-07 17:10:14 +00:00
self . assertTrue ( not file_tracker , msg = " Found sstate files in the wrong place for: %s (found %s ) " % ( ' , ' . join ( map ( str , targets ) ) , str ( file_tracker ) ) )
2013-12-19 17:05:32 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 975 )
2013-12-19 17:05:32 +00:00
def test_sstate_creation_distro_specific_pass ( self ) :
2014-05-04 16:36:10 +00:00
targetarch = get_bb_var ( ' TUNE_ARCH ' )
2014-05-04 08:29:02 +00:00
self . run_test_sstate_creation ( [ ' binutils-cross- ' + targetarch , ' binutils-native ' ] , distro_specific = True , distro_nonspecific = False , temp_sstate_location = True )
2013-12-19 17:05:32 +00:00
2015-10-23 12:07:51 +00:00
@testcase ( 1374 )
2013-12-19 17:05:32 +00:00
def test_sstate_creation_distro_specific_fail ( self ) :
2014-05-04 16:36:10 +00:00
targetarch = get_bb_var ( ' TUNE_ARCH ' )
2014-05-04 08:29:02 +00:00
self . run_test_sstate_creation ( [ ' binutils-cross- ' + targetarch , ' binutils-native ' ] , distro_specific = False , distro_nonspecific = True , temp_sstate_location = True , should_pass = False )
2013-12-19 17:05:32 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 976 )
2013-12-19 17:05:32 +00:00
def test_sstate_creation_distro_nonspecific_pass ( self ) :
2014-08-28 06:12:13 +00:00
self . run_test_sstate_creation ( [ ' glibc-initial ' ] , distro_specific = False , distro_nonspecific = True , temp_sstate_location = True )
2013-12-19 17:05:32 +00:00
2015-10-23 12:07:51 +00:00
@testcase ( 1375 )
2013-12-19 17:05:32 +00:00
def test_sstate_creation_distro_nonspecific_fail ( self ) :
2014-08-28 06:12:13 +00:00
self . run_test_sstate_creation ( [ ' glibc-initial ' ] , distro_specific = True , distro_nonspecific = False , temp_sstate_location = True , should_pass = False )
2013-12-19 17:05:32 +00:00
# Test the sstate files deletion part of the do_cleansstate task
def run_test_cleansstate_task ( self , targets , distro_specific = True , distro_nonspecific = True , temp_sstate_location = True ) :
self . config_sstate ( temp_sstate_location )
bitbake ( [ ' -ccleansstate ' ] + targets )
bitbake ( targets )
2014-01-17 11:23:29 +00:00
tgz_created = self . search_sstate ( ' | ' . join ( map ( str , [ s + ' .*? \ .tgz$ ' for s in targets ] ) ) , distro_specific , distro_nonspecific )
2016-02-07 17:10:14 +00:00
self . assertTrue ( tgz_created , msg = " Could not find sstate .tgz files for: %s ( %s ) " % ( ' , ' . join ( map ( str , targets ) ) , str ( tgz_created ) ) )
2014-01-17 11:23:29 +00:00
siginfo_created = self . search_sstate ( ' | ' . join ( map ( str , [ s + ' .*? \ .siginfo$ ' for s in targets ] ) ) , distro_specific , distro_nonspecific )
2016-02-07 17:10:14 +00:00
self . assertTrue ( siginfo_created , msg = " Could not find sstate .siginfo files for: %s ( %s ) " % ( ' , ' . join ( map ( str , targets ) ) , str ( siginfo_created ) ) )
2013-12-19 17:05:32 +00:00
bitbake ( [ ' -ccleansstate ' ] + targets )
2014-01-17 11:23:29 +00:00
tgz_removed = self . search_sstate ( ' | ' . join ( map ( str , [ s + ' .*? \ .tgz$ ' for s in targets ] ) ) , distro_specific , distro_nonspecific )
2016-02-07 17:10:14 +00:00
self . assertTrue ( not tgz_removed , msg = " do_cleansstate didn ' t remove .tgz sstate files for: %s ( %s ) " % ( ' , ' . join ( map ( str , targets ) ) , str ( tgz_removed ) ) )
2013-12-19 17:05:32 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 977 )
2013-12-19 17:05:32 +00:00
def test_cleansstate_task_distro_specific_nonspecific ( self ) :
2014-05-04 16:36:10 +00:00
targetarch = get_bb_var ( ' TUNE_ARCH ' )
2014-08-28 06:12:13 +00:00
self . run_test_cleansstate_task ( [ ' binutils-cross- ' + targetarch , ' binutils-native ' , ' glibc-initial ' ] , distro_specific = True , distro_nonspecific = True , temp_sstate_location = True )
2013-12-19 17:05:32 +00:00
2015-10-23 12:07:51 +00:00
@testcase ( 1376 )
2013-12-19 17:05:32 +00:00
def test_cleansstate_task_distro_nonspecific ( self ) :
2014-08-28 06:12:13 +00:00
self . run_test_cleansstate_task ( [ ' glibc-initial ' ] , distro_specific = False , distro_nonspecific = True , temp_sstate_location = True )
2013-12-19 17:05:32 +00:00
2015-10-23 12:07:51 +00:00
@testcase ( 1377 )
2013-12-19 17:05:32 +00:00
def test_cleansstate_task_distro_specific ( self ) :
2014-05-04 16:36:10 +00:00
targetarch = get_bb_var ( ' TUNE_ARCH ' )
2014-08-28 06:12:13 +00:00
self . run_test_cleansstate_task ( [ ' binutils-cross- ' + targetarch , ' binutils-native ' , ' glibc-initial ' ] , distro_specific = True , distro_nonspecific = False , temp_sstate_location = True )
2013-12-19 17:05:32 +00:00
# Test rebuilding of distro-specific sstate files
def run_test_rebuild_distro_specific_sstate ( self , targets , temp_sstate_location = True ) :
self . config_sstate ( temp_sstate_location )
bitbake ( [ ' -ccleansstate ' ] + targets )
bitbake ( targets )
2016-02-07 17:10:43 +00:00
results = self . search_sstate ( ' | ' . join ( map ( str , [ s + ' .*? \ .tgz$ ' for s in targets ] ) ) , distro_specific = False , distro_nonspecific = True )
filtered_results = [ ]
for r in results :
if r . endswith ( ( " _populate_lic.tgz " , " _populate_lic.tgz.siginfo " ) ) :
continue
filtered_results . append ( r )
self . assertTrue ( filtered_results == [ ] , msg = " Found distro non-specific sstate for: %s ( %s ) " % ( ' , ' . join ( map ( str , targets ) ) , str ( filtered_results ) ) )
2014-01-17 11:23:29 +00:00
file_tracker_1 = self . search_sstate ( ' | ' . join ( map ( str , [ s + ' .*? \ .tgz$ ' for s in targets ] ) ) , distro_specific = True , distro_nonspecific = False )
self . assertTrue ( len ( file_tracker_1 ) > = len ( targets ) , msg = " Not all sstate files ware created for: %s " % ' , ' . join ( map ( str , targets ) ) )
2013-12-19 17:05:32 +00:00
self . track_for_cleanup ( self . distro_specific_sstate + " _old " )
shutil . copytree ( self . distro_specific_sstate , self . distro_specific_sstate + " _old " )
shutil . rmtree ( self . distro_specific_sstate )
bitbake ( [ ' -cclean ' ] + targets )
bitbake ( targets )
2014-01-17 11:23:29 +00:00
file_tracker_2 = self . search_sstate ( ' | ' . join ( map ( str , [ s + ' .*? \ .tgz$ ' for s in targets ] ) ) , distro_specific = True , distro_nonspecific = False )
self . assertTrue ( len ( file_tracker_2 ) > = len ( targets ) , msg = " Not all sstate files ware created for: %s " % ' , ' . join ( map ( str , targets ) ) )
2013-12-19 17:05:32 +00:00
not_recreated = [ x for x in file_tracker_1 if x not in file_tracker_2 ]
self . assertTrue ( not_recreated == [ ] , msg = " The following sstate files ware not recreated: %s " % ' , ' . join ( map ( str , not_recreated ) ) )
created_once = [ x for x in file_tracker_2 if x not in file_tracker_1 ]
self . assertTrue ( created_once == [ ] , msg = " The following sstate files ware created only in the second run: %s " % ' , ' . join ( map ( str , created_once ) ) )
2014-07-09 08:36:47 +00:00
@testcase ( 175 )
2013-12-19 17:05:32 +00:00
def test_rebuild_distro_specific_sstate_cross_native_targets ( self ) :
2014-05-04 16:36:10 +00:00
targetarch = get_bb_var ( ' TUNE_ARCH ' )
2014-05-04 08:29:02 +00:00
self . run_test_rebuild_distro_specific_sstate ( [ ' binutils-cross- ' + targetarch , ' binutils-native ' ] , temp_sstate_location = True )
2013-12-19 17:05:32 +00:00
2015-10-23 12:07:51 +00:00
@testcase ( 1372 )
2013-12-19 17:05:32 +00:00
def test_rebuild_distro_specific_sstate_cross_target ( self ) :
2014-05-04 16:36:10 +00:00
targetarch = get_bb_var ( ' TUNE_ARCH ' )
2014-05-04 08:29:02 +00:00
self . run_test_rebuild_distro_specific_sstate ( [ ' binutils-cross- ' + targetarch ] , temp_sstate_location = True )
2013-12-19 17:05:32 +00:00
2015-10-23 12:07:51 +00:00
@testcase ( 1373 )
2013-12-19 17:05:32 +00:00
def test_rebuild_distro_specific_sstate_native_target ( self ) :
self . run_test_rebuild_distro_specific_sstate ( [ ' binutils-native ' ] , temp_sstate_location = True )
# Test the sstate-cache-management script. Each element in the global_config list is used with the corresponding element in the target_config list
2014-02-28 16:59:28 +00:00
# global_config elements are expected to not generate any sstate files that would be removed by sstate-cache-management.sh (such as changing the value of MACHINE)
def run_test_sstate_cache_management_script ( self , target , global_config = [ ' ' ] , target_config = [ ' ' ] , ignore_patterns = [ ] ) :
2013-12-19 17:05:32 +00:00
self . assertTrue ( global_config )
self . assertTrue ( target_config )
self . assertTrue ( len ( global_config ) == len ( target_config ) , msg = ' Lists global_config and target_config should have the same number of elements ' )
self . config_sstate ( temp_sstate_location = True , add_local_mirrors = [ self . sstate_path ] )
# If buildhistory is enabled, we need to disable version-going-backwards QA checks for this test. It may report errors otherwise.
if ( ' buildhistory ' in get_bb_var ( ' USER_CLASSES ' ) ) or ( ' buildhistory ' in get_bb_var ( ' INHERIT ' ) ) :
remove_errors_config = ' ERROR_QA_remove = " version-going-backwards " '
self . append_config ( remove_errors_config )
# For not this only checks if random sstate tasks are handled correctly as a group.
# In the future we should add control over what tasks we check for.
2014-02-28 16:59:28 +00:00
sstate_archs_list = [ ]
2013-12-19 17:05:32 +00:00
expected_remaining_sstate = [ ]
for idx in range ( len ( target_config ) ) :
self . append_config ( global_config [ idx ] )
self . append_recipeinc ( target , target_config [ idx ] )
2014-02-28 16:59:28 +00:00
sstate_arch = get_bb_var ( ' SSTATE_PKGARCH ' , target )
if not sstate_arch in sstate_archs_list :
sstate_archs_list . append ( sstate_arch )
2013-12-19 17:05:32 +00:00
if target_config [ idx ] == target_config [ - 1 ] :
2014-01-17 11:23:29 +00:00
target_sstate_before_build = self . search_sstate ( target + ' .*? \ .tgz$ ' )
2013-12-19 17:05:32 +00:00
bitbake ( " -cclean %s " % target )
result = bitbake ( target , ignore_status = True )
if target_config [ idx ] == target_config [ - 1 ] :
2014-01-17 11:23:29 +00:00
target_sstate_after_build = self . search_sstate ( target + ' .*? \ .tgz$ ' )
2014-02-28 16:59:28 +00:00
expected_remaining_sstate + = [ x for x in target_sstate_after_build if x not in target_sstate_before_build if not any ( pattern in x for pattern in ignore_patterns ) ]
2013-12-19 17:05:32 +00:00
self . remove_config ( global_config [ idx ] )
self . remove_recipeinc ( target , target_config [ idx ] )
2015-09-07 19:24:28 +00:00
self . assertEqual ( result . status , 0 , msg = " build of %s failed with %s " % ( target , result . output ) )
2013-12-19 17:05:32 +00:00
2014-02-28 16:59:28 +00:00
runCmd ( " sstate-cache-management.sh -y --cache-dir= %s --remove-duplicated --extra-archs= %s " % ( self . sstate_path , ' , ' . join ( map ( str , sstate_archs_list ) ) ) )
actual_remaining_sstate = [ x for x in self . search_sstate ( target + ' .*? \ .tgz$ ' ) if not any ( pattern in x for pattern in ignore_patterns ) ]
2013-12-19 17:05:32 +00:00
actual_not_expected = [ x for x in actual_remaining_sstate if x not in expected_remaining_sstate ]
self . assertFalse ( actual_not_expected , msg = " Files should have been removed but ware not: %s " % ' , ' . join ( map ( str , actual_not_expected ) ) )
expected_not_actual = [ x for x in expected_remaining_sstate if x not in actual_remaining_sstate ]
self . assertFalse ( expected_not_actual , msg = " Extra files ware removed: %s " ' , ' . join ( map ( str , expected_not_actual ) ) )
2014-07-09 08:36:47 +00:00
@testcase ( 973 )
2013-12-19 17:05:32 +00:00
def test_sstate_cache_management_script_using_pr_1 ( self ) :
global_config = [ ]
target_config = [ ]
global_config . append ( ' ' )
target_config . append ( ' PR = " 0 " ' )
2014-04-03 10:26:07 +00:00
self . run_test_sstate_cache_management_script ( ' m4 ' , global_config , target_config , ignore_patterns = [ ' populate_lic ' ] )
2013-12-19 17:05:32 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 978 )
2013-12-19 17:05:32 +00:00
def test_sstate_cache_management_script_using_pr_2 ( self ) :
global_config = [ ]
target_config = [ ]
global_config . append ( ' ' )
target_config . append ( ' PR = " 0 " ' )
global_config . append ( ' ' )
target_config . append ( ' PR = " 1 " ' )
2014-04-03 10:26:07 +00:00
self . run_test_sstate_cache_management_script ( ' m4 ' , global_config , target_config , ignore_patterns = [ ' populate_lic ' ] )
2013-12-19 17:05:32 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 979 )
2013-12-19 17:05:32 +00:00
def test_sstate_cache_management_script_using_pr_3 ( self ) :
global_config = [ ]
target_config = [ ]
global_config . append ( ' MACHINE = " qemux86-64 " ' )
target_config . append ( ' PR = " 0 " ' )
global_config . append ( global_config [ 0 ] )
target_config . append ( ' PR = " 1 " ' )
global_config . append ( ' MACHINE = " qemux86 " ' )
target_config . append ( ' PR = " 1 " ' )
2014-02-28 16:59:28 +00:00
self . run_test_sstate_cache_management_script ( ' m4 ' , global_config , target_config , ignore_patterns = [ ' populate_lic ' ] )
2013-12-19 17:05:32 +00:00
2014-07-09 08:36:47 +00:00
@testcase ( 974 )
2013-12-19 17:05:32 +00:00
def test_sstate_cache_management_script_using_machine ( self ) :
global_config = [ ]
target_config = [ ]
global_config . append ( ' MACHINE = " qemux86-64 " ' )
target_config . append ( ' ' )
global_config . append ( ' MACHINE = " qemux86 " ' )
target_config . append ( ' ' )
2014-02-28 16:59:28 +00:00
self . run_test_sstate_cache_management_script ( ' m4 ' , global_config , target_config , ignore_patterns = [ ' populate_lic ' ] )
2015-07-08 11:56:13 +00:00
2015-07-30 11:35:43 +00:00
@testcase ( 1270 )
2015-07-08 11:56:13 +00:00
def test_sstate_32_64_same_hash ( self ) :
"""
The sstate checksums for both native and target should not vary whether
2016-02-09 21:49:27 +00:00
they ' re built on a 32 or 64 bit system. Rather than requiring two different
2015-07-08 11:56:13 +00:00
build machines and running a builds , override the variables calling uname ( )
manually and check using bitbake - S .
"""
topdir = get_bb_var ( ' TOPDIR ' )
targetvendor = get_bb_var ( ' TARGET_VENDOR ' )
self . write_config ( """
2016-02-09 21:49:27 +00:00
MACHINE = " qemux86 "
TMPDIR = " $ {TOPDIR} /tmp-sstatesamehash "
BUILD_ARCH = " x86_64 "
BUILD_OS = " linux "
SDKMACHINE = " x86_64 "
2015-07-08 11:56:13 +00:00
""" )
self . track_for_cleanup ( topdir + " /tmp-sstatesamehash " )
2015-08-25 16:56:12 +00:00
bitbake ( " core-image-sato -S none " )
2015-07-08 11:56:13 +00:00
self . write_config ( """
2016-02-09 21:49:27 +00:00
MACHINE = " qemux86 "
TMPDIR = " $ {TOPDIR} /tmp-sstatesamehash2 "
BUILD_ARCH = " i686 "
BUILD_OS = " linux "
SDKMACHINE = " i686 "
2015-07-08 11:56:13 +00:00
""" )
self . track_for_cleanup ( topdir + " /tmp-sstatesamehash2 " )
2015-08-25 16:56:12 +00:00
bitbake ( " core-image-sato -S none " )
2015-07-08 11:56:13 +00:00
def get_files ( d ) :
f = [ ]
for root , dirs , files in os . walk ( d ) :
2015-09-30 13:46:28 +00:00
if " core-image-sato " in root :
2016-02-09 21:49:27 +00:00
# SDKMACHINE changing will change
# do_rootfs/do_testimage/do_build stamps of images which
# is safe to ignore.
continue
2015-07-08 11:56:13 +00:00
f . extend ( os . path . join ( root , name ) for name in files )
return f
files1 = get_files ( topdir + " /tmp-sstatesamehash/stamps/ " )
files2 = get_files ( topdir + " /tmp-sstatesamehash2/stamps/ " )
files2 = [ x . replace ( " tmp-sstatesamehash2 " , " tmp-sstatesamehash " ) . replace ( " i686-linux " , " x86_64-linux " ) . replace ( " i686 " + targetvendor + " -linux " , " x86_64 " + targetvendor + " -linux " , ) for x in files2 ]
2015-09-30 13:46:28 +00:00
self . maxDiff = None
2016-05-20 10:57:44 +00:00
self . assertCountEqual ( files1 , files2 )
2015-07-10 13:07:25 +00:00
2015-07-30 11:54:27 +00:00
@testcase ( 1271 )
2015-07-10 13:07:25 +00:00
def test_sstate_nativelsbstring_same_hash ( self ) :
"""
The sstate checksums should be independent of whichever NATIVELSBSTRING is
2016-04-11 17:33:16 +00:00
detected . Rather than requiring two different build machines and running
2015-07-10 13:07:25 +00:00
builds , override the variables manually and check using bitbake - S .
"""
topdir = get_bb_var ( ' TOPDIR ' )
self . write_config ( """
TMPDIR = \" $ {TOPDIR} /tmp-sstatesamehash \"
NATIVELSBSTRING = \" DistroA \"
""" )
self . track_for_cleanup ( topdir + " /tmp-sstatesamehash " )
2015-08-25 16:56:12 +00:00
bitbake ( " core-image-sato -S none " )
2015-07-10 13:07:25 +00:00
self . write_config ( """
TMPDIR = \" $ {TOPDIR} /tmp-sstatesamehash2 \"
NATIVELSBSTRING = \" DistroB \"
""" )
self . track_for_cleanup ( topdir + " /tmp-sstatesamehash2 " )
2015-08-25 16:56:12 +00:00
bitbake ( " core-image-sato -S none " )
2015-07-10 13:07:25 +00:00
def get_files ( d ) :
f = [ ]
for root , dirs , files in os . walk ( d ) :
f . extend ( os . path . join ( root , name ) for name in files )
return f
files1 = get_files ( topdir + " /tmp-sstatesamehash/stamps/ " )
files2 = get_files ( topdir + " /tmp-sstatesamehash2/stamps/ " )
files2 = [ x . replace ( " tmp-sstatesamehash2 " , " tmp-sstatesamehash " ) for x in files2 ]
2015-09-30 13:46:28 +00:00
self . maxDiff = None
2016-05-20 10:57:44 +00:00
self . assertCountEqual ( files1 , files2 )
2015-07-10 13:07:25 +00:00
2015-10-23 12:07:51 +00:00
@testcase ( 1368 )
2015-08-25 16:56:53 +00:00
def test_sstate_allarch_samesigs ( self ) :
"""
2016-04-11 17:33:16 +00:00
The sstate checksums of allarch packages should be independent of whichever
2015-08-25 16:56:53 +00:00
MACHINE is set . Check this using bitbake - S .
2015-09-16 20:53:01 +00:00
Also , rather than duplicate the test , check nativesdk stamps are the same between
the two MACHINE values .
2015-08-25 16:56:53 +00:00
"""
topdir = get_bb_var ( ' TOPDIR ' )
targetos = get_bb_var ( ' TARGET_OS ' )
targetvendor = get_bb_var ( ' TARGET_VENDOR ' )
self . write_config ( """
TMPDIR = \" $ {TOPDIR} /tmp-sstatesamehash \"
MACHINE = \" qemux86 \"
""" )
self . track_for_cleanup ( topdir + " /tmp-sstatesamehash " )
2015-09-16 20:53:01 +00:00
bitbake ( " world meta-toolchain -S none " )
2015-08-25 16:56:53 +00:00
self . write_config ( """
TMPDIR = \" $ {TOPDIR} /tmp-sstatesamehash2 \"
MACHINE = \" qemuarm \"
""" )
self . track_for_cleanup ( topdir + " /tmp-sstatesamehash2 " )
2015-09-16 20:53:01 +00:00
bitbake ( " world meta-toolchain -S none " )
2015-08-25 16:56:53 +00:00
def get_files ( d ) :
2015-11-09 18:07:25 +00:00
f = { }
2015-08-25 16:56:53 +00:00
for root , dirs , files in os . walk ( d ) :
for name in files :
2015-09-16 20:53:01 +00:00
if " meta-environment " in root or " cross-canadian " in root :
continue
2015-08-25 16:56:53 +00:00
if " do_build " not in name :
2015-11-09 18:07:25 +00:00
# 1.4.1+gitAUTOINC+302fca9f4c-r0.do_package_write_ipk.sigdata.f3a2a38697da743f0dbed8b56aafcf79
( _ , task , _ , shash ) = name . rsplit ( " . " , 3 )
f [ os . path . join ( os . path . basename ( root ) , task ) ] = shash
2015-08-25 16:56:53 +00:00
return f
files1 = get_files ( topdir + " /tmp-sstatesamehash/stamps/all " + targetvendor + " - " + targetos )
files2 = get_files ( topdir + " /tmp-sstatesamehash2/stamps/all " + targetvendor + " - " + targetos )
self . maxDiff = None
2015-11-09 18:07:25 +00:00
self . assertEqual ( files1 , files2 )
2015-09-16 20:53:01 +00:00
nativesdkdir = os . path . basename ( glob . glob ( topdir + " /tmp-sstatesamehash/stamps/*-nativesdk*-linux " ) [ 0 ] )
files1 = get_files ( topdir + " /tmp-sstatesamehash/stamps/ " + nativesdkdir )
files2 = get_files ( topdir + " /tmp-sstatesamehash2/stamps/ " + nativesdkdir )
self . maxDiff = None
2015-11-09 18:07:25 +00:00
self . assertEqual ( files1 , files2 )
2015-09-30 13:49:23 +00:00
2015-10-23 12:07:51 +00:00
@testcase ( 1369 )
2015-09-30 13:49:23 +00:00
def test_sstate_sametune_samesigs ( self ) :
"""
2016-04-11 17:33:16 +00:00
The sstate checksums of two identical machines ( using the same tune ) should be the
2015-09-30 13:49:23 +00:00
same , apart from changes within the machine specific stamps directory . We use the
qemux86copy machine to test this . Also include multilibs in the test .
"""
topdir = get_bb_var ( ' TOPDIR ' )
targetos = get_bb_var ( ' TARGET_OS ' )
targetvendor = get_bb_var ( ' TARGET_VENDOR ' )
self . write_config ( """
TMPDIR = \" $ {TOPDIR} /tmp-sstatesamehash \"
MACHINE = \" qemux86 \"
require conf / multilib . conf
MULTILIBS = " multilib:lib32 "
DEFAULTTUNE_virtclass - multilib - lib32 = " x86 "
""" )
self . track_for_cleanup ( topdir + " /tmp-sstatesamehash " )
bitbake ( " world meta-toolchain -S none " )
self . write_config ( """
TMPDIR = \" $ {TOPDIR} /tmp-sstatesamehash2 \"
MACHINE = \" qemux86copy \"
require conf / multilib . conf
MULTILIBS = " multilib:lib32 "
DEFAULTTUNE_virtclass - multilib - lib32 = " x86 "
""" )
self . track_for_cleanup ( topdir + " /tmp-sstatesamehash2 " )
bitbake ( " world meta-toolchain -S none " )
def get_files ( d ) :
f = [ ]
for root , dirs , files in os . walk ( d ) :
for name in files :
if " meta-environment " in root or " cross-canadian " in root :
continue
if " qemux86copy- " in root or " qemux86- " in root :
continue
if " do_build " not in name and " do_populate_sdk " not in name :
f . append ( os . path . join ( root , name ) )
return f
files1 = get_files ( topdir + " /tmp-sstatesamehash/stamps " )
files2 = get_files ( topdir + " /tmp-sstatesamehash2/stamps " )
files2 = [ x . replace ( " tmp-sstatesamehash2 " , " tmp-sstatesamehash " ) for x in files2 ]
self . maxDiff = None
2016-05-20 10:57:44 +00:00
self . assertCountEqual ( files1 , files2 )
2016-04-11 17:33:16 +00:00
def test_sstate_noop_samesigs ( self ) :
"""
The sstate checksums of two builds with these variables changed or
classes inherits should be the same .
"""
topdir = get_bb_var ( ' TOPDIR ' )
targetvendor = get_bb_var ( ' TARGET_VENDOR ' )
self . write_config ( """
TMPDIR = " $ {TOPDIR} /tmp-sstatesamehash "
BB_NUMBER_THREADS = " 1 "
PARALLEL_MAKE = " -j 1 "
DL_DIR = " $ {TOPDIR} /download1 "
TIME = " 111111 "
DATE = " 20161111 "
2016-04-25 20:16:36 +00:00
INHERIT_remove = " buildstats-summary buildhistory uninative "
http_proxy = " "
2016-04-11 17:33:16 +00:00
""" )
self . track_for_cleanup ( topdir + " /tmp-sstatesamehash " )
2016-04-25 21:14:38 +00:00
self . track_for_cleanup ( topdir + " /download1 " )
2016-04-11 17:33:16 +00:00
bitbake ( " world meta-toolchain -S none " )
self . write_config ( """
TMPDIR = " $ {TOPDIR} /tmp-sstatesamehash2 "
BB_NUMBER_THREADS = " 2 "
PARALLEL_MAKE = " -j 2 "
DL_DIR = " $ {TOPDIR} /download2 "
TIME = " 222222 "
DATE = " 20161212 "
2016-04-25 20:16:36 +00:00
# Always remove uninative as we're changing proxies
INHERIT_remove = " uninative "
2016-04-11 17:33:16 +00:00
INHERIT + = " buildstats-summary buildhistory "
2016-04-25 20:16:36 +00:00
http_proxy = " http://example.com/ "
2016-04-11 17:33:16 +00:00
""" )
self . track_for_cleanup ( topdir + " /tmp-sstatesamehash2 " )
2016-04-25 21:14:38 +00:00
self . track_for_cleanup ( topdir + " /download2 " )
2016-04-11 17:33:16 +00:00
bitbake ( " world meta-toolchain -S none " )
def get_files ( d ) :
f = { }
for root , dirs , files in os . walk ( d ) :
for name in files :
name , shash = name . rsplit ( ' . ' , 1 )
# Extract just the machine and recipe name
base = os . sep . join ( root . rsplit ( os . sep , 2 ) [ - 2 : ] + [ name ] )
f [ base ] = shash
return f
files1 = get_files ( topdir + " /tmp-sstatesamehash/stamps/ " )
files2 = get_files ( topdir + " /tmp-sstatesamehash2/stamps/ " )
# Remove items that are identical in both sets
2016-05-20 10:49:34 +00:00
for k , v in files1 . items ( ) & files2 . items ( ) :
2016-04-11 17:33:16 +00:00
del files1 [ k ]
del files2 [ k ]
if not files1 and not files2 :
# No changes, so we're done
return
2016-05-20 10:49:34 +00:00
for k in files1 . keys ( ) | files2 . keys ( ) :
2016-04-11 17:33:16 +00:00
if k in files1 and k in files2 :
2016-05-15 09:23:25 +00:00
print ( " %s differs: " % k )
print ( subprocess . check_output ( ( " bitbake-diffsigs " ,
2016-04-11 17:33:16 +00:00
topdir + " /tmp-sstatesamehash/stamps/ " + k + " . " + files1 [ k ] ,
2016-05-15 09:23:25 +00:00
topdir + " /tmp-sstatesamehash2/stamps/ " + k + " . " + files2 [ k ] ) ) )
2016-04-11 17:33:16 +00:00
elif k in files1 and k not in files2 :
2016-05-15 09:23:25 +00:00
print ( " %s in files1 " % k )
2016-04-11 17:33:16 +00:00
elif k not in files1 and k in files2 :
2016-05-15 09:23:25 +00:00
print ( " %s in files2 " % k )
2016-04-11 17:33:16 +00:00
else :
assert " shouldn ' t reach here "
self . fail ( " sstate hashes not identical. " )