gcc-testsuite.inc 4.8 KB

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