Exemplo n.º 1
0
def test_list_image_types():
    expected_image_types = (
        "aisimage",
        "atmelimage",
        "filesystem",
        "firmware",
        "flat_dt",
        "gpimage",
        "imximage",
        "kernel",
        "kernel_noload",
        "kwbimage",
        "lpc32xximage",
        "multi",
        "omapimage",
        "pblimage",
        "ramdisk",
        "rkimage",
        "rksd",
        "rkspi",
        "script",
        "socfpgaimage",
        "standalone",
        "ublimage",
        "zynqimage",
    )
    m = mkimage.MkImage()
    itl = m.list_image_types()
    assert isinstance(itl, tuple)
    assert len(itl) == len(expected_image_types)
    assert all(expected in itl for expected in expected_image_types)
Exemplo n.º 2
0
def test_fit_image_creation_with_its(test_fitimage_blobs, valid_its_path,
                                     tmp_path):
    output_path = tmp_path / "fitvalid.itb"
    m = mkimage.MkImage()
    mkimage_output = m.create_fit_img(valid_its_path, output_path)

    assert all(expect in mkimage_output.stdout for expect in STDOUT_SUCCESS)
    assert mkimage_output.returncode == 0
    assert not mkimage_output.stderr
    assert output_path.is_file()
Exemplo n.º 3
0
def test_rejects_invalid_its(tmp_path, invalid_its_path):
    output_path = tmp_path / "fitinvalid"
    output_path.touch(exist_ok=True)
    m = mkimage.MkImage()
    with pytest.raises(subprocess.CalledProcessError) as exc_info:
        m.create_fit_img(invalid_its_path, output_path)

    expected_stderr = "mkimage Can't add hashes to FIT blob\n"
    assert (expected_stderr.format(out_path=output_path)
            in exc_info.value.stderr)
    assert exc_info.value.returncode == 255
Exemplo n.º 4
0
def test_make_boot_cmd(tmp_path, valid_boot_cmd_path):
    m = mkimage.MkImage()
    result = m.create_legacy_image(
        tmp_path / "boot.scr",
        arch="arm",
        img_type="script",
        compression="none",
        data_file_path=valid_boot_cmd_path,
        name="Boot script",
    )

    assert all(expect in result.stdout for expect in STDOUT_SUCCESS_BOOT_CMD)
    assert not result.stderr
Exemplo n.º 5
0
def test_modify_fit_image(tmp_path, test_fitimage_blobs, valid_its_path):
    mock_fit_path = tmp_path / "fit.itb"
    mock_key_path = tmp_path / "rotkey.pem"
    mock_key_path.touch()
    m = mkimage.MkImage()
    m.create_fit_img(valid_its_path, mock_fit_path)

    result = m.modify_fit_img(
        img_path=mock_fit_path, key_dir=mock_key_path, key_required=True
    )

    assert all(expect in result.stdout for expect in STDOUT_SUCCESS)
    assert not result.stderr
    assert result.returncode == 0
Exemplo n.º 6
0
def test_fit_image_creation_with_dtc_opts(test_fitimage_blobs, opt,
                                          valid_its_path, tmp_path):
    with mock.patch("signing.fitimage.mkimage.subprocess") as mock_sp:
        m = mkimage.MkImage()
        m.create_fit_img(valid_its_path, tmp_path / "fit.itb", dtc_opts=opt)

        mock_sp.run.assert_called_with(
            [
                "mkimage",
                "-D",
                "--space 1",
                "-f",
                str(valid_its_path),
                str(tmp_path / "fit.itb"),
            ],
            capture_output=True,
            text=True,
            check=True,
        )
Exemplo n.º 7
0
def test_rejects_invalid_dtc_opts(opt, valid_its_path, tmp_path):
    m = mkimage.MkImage()
    with pytest.raises(subprocess.CalledProcessError) as err:
        m.create_fit_img(valid_its_path, tmp_path / "img.itb", dtc_opts=opt)

    assert r"Usage: dtc [options]" in err.value.stderr
Exemplo n.º 8
0
def test_list_image_header_info(valid_its_path):
    m = mkimage.MkImage()
    expected = ["GP Header: Size 2f647473 LoadAddr 2d76312f"]
    output = m.list_img_header_info(valid_its_path)
    assert output == expected