summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-testsuite.inc
blob: f9924f2d86785ffc4cb0434ee591743c202fbc55 (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
inherit qemu

BUILD_TEST_TARGET ??= "user"
BUILD_TEST_HOST ??= "localhost"
BUILD_TEST_HOST_USER ??= "root"
BUILD_TEST_HOST_PORT ??= "2222"

MAKE_CHECK_BOARDFLAGS ??= ""
MAKE_CHECK_BOARDARGS ??= "--target_board=${BUILD_TEST_TARGET}${MAKE_CHECK_BOARDFLAGS}"

python () {
    # Provide the targets compiler args via targets options. This allows dejagnu to
    # correctly mark incompatible tests as UNSUPPORTED (e.g. needs soft-float
    # but running on hard-float target).
    #
    # These options are called "multilib_flags" within the gcc test suite. Most
    # architectures handle these options in a sensible way such that tests that
    # are incompatible with the provided multilib are marked as UNSUPPORTED.
    #
    # Note: multilib flags are added to the compile command after the args
    # provided by any test (through dg-options), CFLAGS_FOR_TARGET is always
    # added to the compile command before any other args but is not interpted
    # as options like multilib flags.
    #
    # i686, x86-64 and aarch64 are special, since most toolchains built for
    # these targets don't do multilib the tests do not get correctly marked as
    # UNSUPPORTED. More importantly the test suite itself does not handle
    # overriding the multilib flags where it could (like other archs do). As
    # such do not pass the target compiler args for these targets.
    args = d.getVar("TUNE_CCARGS").split()
    if d.getVar("TUNE_ARCH") in ["i686", "x86_64", "aarch64"]:
        args = []
    d.setVar("MAKE_CHECK_BOARDFLAGS", ("/" + "/".join(args)) if len(args) != 0 else "")
}

python check_prepare() {
    def generate_qemu_linux_user_config(d):
        content = []
        content.append('load_generic_config "sim"')
        content.append('load_base_board_description "basic-sim"')
        content.append('process_multilib_options ""')

        # qemu args
        qemu_binary = qemu_target_binary(d)
        if not qemu_binary:
            bb.fatal("Missing target qemu linux-user binary")

        args = []
        # QEMU_OPTIONS is not always valid due to -cross recipe
        args += ["-r", d.getVar("OLDEST_KERNEL")]
        # enable all valid instructions, since the test suite itself does not
        # limit itself to the target cpu options.
        #   - valid for x86*, powerpc, arm, arm64
        if qemu_binary.lstrip("qemu-") in ["x86_64", "i386", "ppc", "arm", "aarch64"]:
            args += ["-cpu", "max"]

        sysroot = d.getVar("RECIPE_SYSROOT")
        args += ["-L", sysroot]
        # lib paths are static here instead of using $libdir since this is used by a -cross recipe
        libpaths = [sysroot + "/usr/lib", sysroot + "/lib"]
        args += ["-E", "LD_LIBRARY_PATH={0}".format(":".join(libpaths))]

        content.append('set_board_info is_simulator 1')
        content.append('set_board_info sim "{0}"'.format(qemu_binary))
        content.append('set_board_info sim,options "{0}"'.format(" ".join(args)))

        # target build/test config
        content.append('set_board_info target_install {%s}' % d.getVar("TARGET_SYS"))
        content.append('set_board_info ldscript ""')
        #content.append('set_board_info needs_status_wrapper 1') # qemu-linux-user return codes work, and abort works fine
        content.append('set_board_info gcc,stack_size 16834')
        content.append('set_board_info gdb,nosignals 1')
        content.append('set_board_info gcc,timeout 60')

        return "\n".join(content)

    def generate_remote_ssh_linux_config(d):
        content = []
        content.append('load_generic_config "unix"')
        content.append("set_board_info hostname {0}".format(d.getVar("BUILD_TEST_HOST")))
        content.append("set_board_info username {0}".format(d.getVar("BUILD_TEST_HOST_USER")))

        port = d.getVar("BUILD_TEST_HOST_PORT")
        content.append("set_board_info rsh_prog \"/usr/bin/ssh -p {0} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no\"".format(port))
        content.append("set_board_info rcp_prog \"/usr/bin/scp -P {0} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no\"".format(port))

        return "\n".join(content)

    dejagnudir = d.expand("${WORKDIR}/dejagnu")
    if not os.path.isdir(dejagnudir):
        os.makedirs(dejagnudir)

    # write out target qemu board config
    with open(os.path.join(dejagnudir, "user.exp"), "w") as f:
        f.write(generate_qemu_linux_user_config(d))

    # write out target ssh board config
    with open(os.path.join(dejagnudir, "ssh.exp"), "w") as f:
        f.write(generate_remote_ssh_linux_config(d))

    # generate site.exp to provide boards
    with open(os.path.join(dejagnudir, "site.exp"), "w") as f:
        f.write("lappend boards_dir {0}\n".format(dejagnudir))
        f.write("set CFLAGS_FOR_TARGET \"{0}\"\n".format(d.getVar("TOOLCHAIN_OPTIONS")))
}