Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 1 | inherit qemu |
| 2 | |
| 3 | TOOLCHAIN_TEST_TARGET ??= "user" |
| 4 | TOOLCHAIN_TEST_HOST ??= "localhost" |
| 5 | TOOLCHAIN_TEST_HOST_USER ??= "root" |
| 6 | TOOLCHAIN_TEST_HOST_PORT ??= "2222" |
| 7 | |
| 8 | MAKE_CHECK_BOARDFLAGS ??= "" |
| 9 | MAKE_CHECK_BOARDARGS ??= "--target_board=${TOOLCHAIN_TEST_TARGET}${MAKE_CHECK_BOARDFLAGS}" |
| 10 | |
| 11 | python () { |
| 12 | # Provide the targets compiler args via targets options. This allows dejagnu to |
| 13 | # correctly mark incompatible tests as UNSUPPORTED (e.g. needs soft-float |
| 14 | # but running on hard-float target). |
| 15 | # |
| 16 | # These options are called "multilib_flags" within the gcc test suite. Most |
| 17 | # architectures handle these options in a sensible way such that tests that |
| 18 | # are incompatible with the provided multilib are marked as UNSUPPORTED. |
| 19 | # |
| 20 | # Note: multilib flags are added to the compile command after the args |
| 21 | # provided by any test (through dg-options), CFLAGS_FOR_TARGET is always |
| 22 | # added to the compile command before any other args but is not interpted |
| 23 | # as options like multilib flags. |
| 24 | # |
| 25 | # i686, x86-64 and aarch64 are special, since most toolchains built for |
| 26 | # these targets don't do multilib the tests do not get correctly marked as |
| 27 | # UNSUPPORTED. More importantly the test suite itself does not handle |
| 28 | # overriding the multilib flags where it could (like other archs do). As |
| 29 | # such do not pass the target compiler args for these targets. |
| 30 | args = d.getVar("TUNE_CCARGS").split() |
| 31 | if d.getVar("TUNE_ARCH") in ["i686", "x86_64", "aarch64"]: |
| 32 | args = [] |
| 33 | d.setVar("MAKE_CHECK_BOARDFLAGS", ("/" + "/".join(args)) if len(args) != 0 else "") |
| 34 | } |
| 35 | |
| 36 | python check_prepare() { |
| 37 | def generate_qemu_linux_user_config(d): |
| 38 | content = [] |
| 39 | content.append('load_generic_config "sim"') |
| 40 | content.append('load_base_board_description "basic-sim"') |
| 41 | content.append('process_multilib_options ""') |
| 42 | |
| 43 | # qemu args |
| 44 | qemu_binary = qemu_target_binary(d) |
| 45 | if not qemu_binary: |
| 46 | bb.fatal("Missing target qemu linux-user binary") |
| 47 | |
| 48 | args = [] |
| 49 | # QEMU_OPTIONS is not always valid due to -cross recipe |
| 50 | args += ["-r", d.getVar("OLDEST_KERNEL")] |
| 51 | # enable all valid instructions, since the test suite itself does not |
| 52 | # limit itself to the target cpu options. |
| 53 | # - valid for x86*, powerpc, arm, arm64 |
| 54 | if qemu_binary.lstrip("qemu-") in ["x86_64", "i386", "ppc", "arm", "aarch64"]: |
| 55 | args += ["-cpu", "max"] |
| 56 | |
| 57 | sysroot = d.getVar("RECIPE_SYSROOT") |
| 58 | args += ["-L", sysroot] |
| 59 | # lib paths are static here instead of using $libdir since this is used by a -cross recipe |
| 60 | libpaths = [sysroot + "/usr/lib", sysroot + "/lib"] |
| 61 | args += ["-E", "LD_LIBRARY_PATH={0}".format(":".join(libpaths))] |
| 62 | |
| 63 | content.append('set_board_info is_simulator 1') |
| 64 | content.append('set_board_info sim "{0}"'.format(qemu_binary)) |
| 65 | content.append('set_board_info sim,options "{0}"'.format(" ".join(args))) |
| 66 | |
| 67 | # target build/test config |
| 68 | content.append('set_board_info target_install {%s}' % d.getVar("TARGET_SYS")) |
| 69 | content.append('set_board_info ldscript ""') |
| 70 | #content.append('set_board_info needs_status_wrapper 1') # qemu-linux-user return codes work, and abort works fine |
| 71 | content.append('set_board_info gcc,stack_size 16834') |
| 72 | content.append('set_board_info gdb,nosignals 1') |
| 73 | content.append('set_board_info gcc,timeout 60') |
| 74 | |
| 75 | return "\n".join(content) |
| 76 | |
| 77 | def generate_remote_ssh_linux_config(d): |
| 78 | content = [] |
| 79 | content.append('load_generic_config "unix"') |
| 80 | content.append('process_multilib_options ""') |
| 81 | content.append("set_board_info hostname {0}".format(d.getVar("TOOLCHAIN_TEST_HOST"))) |
| 82 | content.append("set_board_info username {0}".format(d.getVar("TOOLCHAIN_TEST_HOST_USER"))) |
| 83 | |
| 84 | port = d.getVar("TOOLCHAIN_TEST_HOST_PORT") |
| 85 | content.append("set_board_info rsh_prog \"/usr/bin/ssh -p {0} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no\"".format(port)) |
| 86 | content.append("set_board_info rcp_prog \"/usr/bin/scp -P {0} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no\"".format(port)) |
| 87 | |
| 88 | return "\n".join(content) |
| 89 | |
| 90 | dejagnudir = d.expand("${WORKDIR}/dejagnu") |
| 91 | if not os.path.isdir(dejagnudir): |
| 92 | os.makedirs(dejagnudir) |
| 93 | |
| 94 | # write out target qemu board config |
| 95 | with open(os.path.join(dejagnudir, "user.exp"), "w") as f: |
| 96 | f.write(generate_qemu_linux_user_config(d)) |
| 97 | |
| 98 | # write out target ssh board config |
| 99 | with open(os.path.join(dejagnudir, "ssh.exp"), "w") as f: |
| 100 | f.write(generate_remote_ssh_linux_config(d)) |
| 101 | |
| 102 | # generate site.exp to provide boards |
| 103 | with open(os.path.join(dejagnudir, "site.exp"), "w") as f: |
| 104 | f.write("lappend boards_dir {0}\n".format(dejagnudir)) |
| 105 | f.write("set CFLAGS_FOR_TARGET \"{0}\"\n".format(d.getVar("TOOLCHAIN_OPTIONS"))) |
| 106 | } |
| 107 | |