Ejemplo n.º 1
0
    def test_older_uboot_build(self, 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"])

        env_setup = "cd %s && . oe-init-build-env %s" % (
            prepared_test_build["bitbake_corebase"],
            prepared_test_build["build_dir"],
        )
        bitbake_vars = get_bitbake_variables("u-boot", env_setup=env_setup)
        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
Ejemplo n.º 2
0
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(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
Ejemplo n.º 3
0
def prepared_test_build(prepared_test_build_base):
    """
    Prepares a separate test build directory where a custom build can be
    made, which reuses the sstate-cache.
    """

    reset_build_conf(prepared_test_build_base["build_dir"])
    return prepared_test_build_base
Ejemplo n.º 4
0
    def test_mender_inventory_network_scripts(self, 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(
            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(
            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"
Ejemplo n.º 5
0
    def img_builder():
        if conversion:
            assert os.environ.get("BUILDDIR", False), "BUILDDIR must be set"
            return os.environ["BUILDDIR"]

        reset_build_conf(prepared_test_build_base["build_dir"])
        build_image(
            prepared_test_build_base["build_dir"],
            prepared_test_build_base["bitbake_corebase"],
            bitbake_image,
            [
                'SYSTEMD_AUTO_ENABLE_pn-mender-client = "disable"',
                'EXTRA_IMAGE_FEATURES_append = " ssh-server-openssh"',
            ],
        )
        return prepared_test_build_base["build_dir"]
Ejemplo n.º 6
0
 def cleanup_test_build():
     if not no_tmp_build_dir:
         run_verbose("rm -rf %s" % build_dir)
     else:
         reset_build_conf(build_dir, full_cleanup=True)