def ubimg_without_uboot_env(request, latest_ubimg, prepared_test_build, bitbake_image): """The ubireader_utils_info tool and friends don't support our UBI volumes that contain the U-Boot environment and hence not valid UBIFS structures. Therefore, make a new temporary image that doesn't contain U-Boot.""" # The tests are marked with "only_with_image('ubimg')", but that is checked # using a function fixture, and this is a session fixture, which cannot # depend on that. So we need this check here to bail out if we don't find a # ubimg. if not latest_ubimg: pytest.skip("No ubimg found") reset_build_conf(prepared_test_build["build_dir"]) build_image( prepared_test_build["build_dir"], prepared_test_build["bitbake_corebase"], bitbake_image, ['MENDER_FEATURES_DISABLE_append = " mender-uboot"'], ) ubimg = latest_build_artifact(request, prepared_test_build["build_dir"], "core-image*.ubimg") imgdir = tempfile.mkdtemp() tmpimg = os.path.join(imgdir, os.path.basename(ubimg)) shutil.copyfile(ubimg, tmpimg) def remove_ubimg(): os.unlink(tmpimg) request.addfinalizer(remove_ubimg) return tmpimg
def test_mender_inventory_network_scripts(self, request, prepared_test_build, bitbake_image): """ Test the 'inventory-network-scripts' build feature configuration through 'PACKAGECONFIG' is working as expected. This verifies that the 'inventory-network-scripts' option is a part build, and also that the inventory scripts are not included when removed. The test only runs for sdimg, as the build image should not really matter here. """ # # Feature enabled # reset_build_conf(prepared_test_build["build_dir"]) build_image( prepared_test_build["build_dir"], prepared_test_build["bitbake_corebase"], bitbake_image, [ 'PACKAGECONFIG_append_pn-mender-client = " inventory-network-scripts"' ], ) rootfs = latest_build_artifact(request, prepared_test_build["build_dir"], "core-image*.ext4") assert len(rootfs) > 0, "rootfs not generated" output = subprocess.check_output( ["debugfs", "-R", "ls /usr/share/mender/inventory", rootfs]) assert ( b"mender-inventory-geo" in output ), "mender-inventory-network-scripts seems not to be a part of the image, like they should" # # Feature disabled # reset_build_conf(prepared_test_build["build_dir"]) build_image( prepared_test_build["build_dir"], prepared_test_build["bitbake_corebase"], bitbake_image, [ 'PACKAGECONFIG_remove_pn-mender-client = " inventory-network-scripts"' ], ) rootfs = latest_build_artifact(request, prepared_test_build["build_dir"], "core-image*.ext4") assert len(rootfs) > 0, "ext4 not generated" output = subprocess.check_output( ["debugfs", "-R", "ls /usr/share/mender/inventory", rootfs]) assert ( b"mender-inventory-geo" not in output ), "mender-inventory-network-scripts unexpectedly a part of the image"
def test_older_uboot_build(self, request, prepared_test_build, bitbake_image): """Test that we can provide our own custom U-Boot provider.""" # Get rid of build outputs in deploy directory that may get in the way. build_image( prepared_test_build["build_dir"], prepared_test_build["bitbake_corebase"], bitbake_image, target="-c clean u-boot", ) try: build_image( prepared_test_build["build_dir"], prepared_test_build["bitbake_corebase"], bitbake_image, [ 'PREFERRED_PROVIDER_u-boot = "u-boot-testing"', 'PREFERRED_RPROVIDER_u-boot = "u-boot-testing"', ], ) finally: # Get rid of build outputs in deploy directory that may get in the # way. build_image( prepared_test_build["build_dir"], prepared_test_build["bitbake_corebase"], bitbake_image, target="-c clean u-boot-testing", ) # Reset local.conf. reset_build_conf(prepared_test_build["build_dir"]) bitbake_vars = get_bitbake_variables( request, "u-boot", prepared_test_build=prepared_test_build) if bitbake_vars["MENDER_UBOOT_AUTO_CONFIGURE"] == "0": # The rest of the test is irrelevant if MENDER_UBOOT_AUTO_CONFIGURE # is already off. return try: # Capture and discard output, it looks very ugly in the log. build_image( prepared_test_build["build_dir"], prepared_test_build["bitbake_corebase"], bitbake_image, ['MENDER_UBOOT_AUTO_CONFIGURE_pn-u-boot = "0"'], capture=True, ) pytest.fail( "Build should not succeed when MENDER_UBOOT_AUTO_CONFIGURE is turned off" ) except subprocess.CalledProcessError: pass