test_architecture

tests/test_architecture.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from debputy.architecture_support import DpkgArchitectureBuildProcessValuesTable


# Ensure our mocks seem to be working reasonably
def test_mock_arch_table():
    amd64_native_table = DpkgArchitectureBuildProcessValuesTable(fake_host="amd64")
    amd64_cross_table = DpkgArchitectureBuildProcessValuesTable(
        fake_host="amd64",
        fake_build="i386",
    )
    amd64_cross_target_table = DpkgArchitectureBuildProcessValuesTable(
        fake_host="amd64",
        fake_target="arm64",
    )
    all_differ_table = DpkgArchitectureBuildProcessValuesTable(
        fake_host="amd64",
        fake_build="i386",
        fake_target="arm64",
    )

    for var_stem in ["ARCH", "MULTIARCH"]:
        host_var = f"DEB_HOST_{var_stem}"
        build_var = f"DEB_BUILD_{var_stem}"
        target_var = f"DEB_TARGET_{var_stem}"

        assert (
            amd64_cross_table.current_host_arch == amd64_native_table.current_host_arch
        )
        assert amd64_native_table[host_var] == amd64_native_table[build_var]
        assert amd64_native_table[host_var] == amd64_native_table[target_var]

        # HOST_ARCH differ in a cross build, but the rest remain the same
        assert amd64_cross_table[host_var] == amd64_native_table[host_var]
        assert amd64_cross_table[target_var] == amd64_native_table[target_var]
        assert amd64_cross_table[build_var] != amd64_native_table[build_var]
        assert amd64_cross_table[target_var] == amd64_native_table[target_var]
        assert (
            amd64_cross_table.current_host_multiarch
            == amd64_native_table.current_host_multiarch
        )

        # TARGET_ARCH differ in a cross-compiler build, but the rest remain the same
        assert amd64_cross_target_table[host_var] == amd64_native_table[host_var]
        assert amd64_cross_target_table[target_var] != amd64_native_table[target_var]
        assert amd64_cross_target_table[build_var] == amd64_native_table[build_var]
        assert (
            amd64_cross_target_table.current_host_multiarch
            == amd64_native_table.current_host_multiarch
        )

        # TARGET_ARCH differ in a cross-compiler build, but the rest remain the same
        assert all_differ_table[host_var] == amd64_native_table[host_var]
        assert all_differ_table[target_var] != amd64_native_table[target_var]
        assert all_differ_table[build_var] != amd64_native_table[build_var]
        assert all_differ_table[build_var] == amd64_cross_table[build_var]
        assert all_differ_table[target_var] == amd64_cross_target_table[target_var]
        assert (
            all_differ_table.current_host_arch == amd64_native_table.current_host_arch
        )
        assert (
            all_differ_table.current_host_multiarch
            == amd64_native_table.current_host_multiarch
        )

    # Finally, check is_cross_compiling
    assert not amd64_native_table.is_cross_compiling
    assert amd64_cross_table.is_cross_compiling
    assert not amd64_cross_target_table.is_cross_compiling
    assert all_differ_table.is_cross_compiling