blob: f16d471478c38bce36990761a384c67902b32bf8 [file] [log] [blame]
Brad Bishop79641f22019-09-10 07:20:22 -04001inherit qemu
2
3TOOLCHAIN_TEST_TARGET ??= "user"
4TOOLCHAIN_TEST_HOST ??= "localhost"
5TOOLCHAIN_TEST_HOST_USER ??= "root"
6TOOLCHAIN_TEST_HOST_PORT ??= "2222"
7
8MAKE_CHECK_BOARDFLAGS ??= ""
9MAKE_CHECK_BOARDARGS ??= "--target_board=${TOOLCHAIN_TEST_TARGET}${MAKE_CHECK_BOARDFLAGS}"
10
11python () {
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
36python 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
Andrew Geissler5082cc72023-09-11 08:41:39 -040054 if qemu_binary.endswith(("x86_64", "i386", "arm", "aarch64")):
Brad Bishop79641f22019-09-10 07:20:22 -040055 args += ["-cpu", "max"]
Andrew Geissler5082cc72023-09-11 08:41:39 -040056 elif qemu_binary.endswith(("ppc", "mips", "mips64")):
57 extra = d.getVar("QEMU_EXTRAOPTIONS_%s" % d.getVar('PACKAGE_ARCH'))
58 if extra:
59 args += extra.split()
60 # For mips64 we could set a maximal CPU (e.g. Loongson-3A4000) however they either have MSA
61 # or Loongson-MMI vector extensions, not both and qemu lacks complete support for MMI
Brad Bishop79641f22019-09-10 07:20:22 -040062 sysroot = d.getVar("RECIPE_SYSROOT")
63 args += ["-L", sysroot]
64 # lib paths are static here instead of using $libdir since this is used by a -cross recipe
65 libpaths = [sysroot + "/usr/lib", sysroot + "/lib"]
66 args += ["-E", "LD_LIBRARY_PATH={0}".format(":".join(libpaths))]
67
68 content.append('set_board_info is_simulator 1')
69 content.append('set_board_info sim "{0}"'.format(qemu_binary))
70 content.append('set_board_info sim,options "{0}"'.format(" ".join(args)))
71
72 # target build/test config
73 content.append('set_board_info target_install {%s}' % d.getVar("TARGET_SYS"))
74 content.append('set_board_info ldscript ""')
75 #content.append('set_board_info needs_status_wrapper 1') # qemu-linux-user return codes work, and abort works fine
76 content.append('set_board_info gcc,stack_size 16834')
77 content.append('set_board_info gdb,nosignals 1')
78 content.append('set_board_info gcc,timeout 60')
79
80 return "\n".join(content)
81
82 def generate_remote_ssh_linux_config(d):
83 content = []
84 content.append('load_generic_config "unix"')
85 content.append('process_multilib_options ""')
86 content.append("set_board_info hostname {0}".format(d.getVar("TOOLCHAIN_TEST_HOST")))
87 content.append("set_board_info username {0}".format(d.getVar("TOOLCHAIN_TEST_HOST_USER")))
88
89 port = d.getVar("TOOLCHAIN_TEST_HOST_PORT")
90 content.append("set_board_info rsh_prog \"/usr/bin/ssh -p {0} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no\"".format(port))
91 content.append("set_board_info rcp_prog \"/usr/bin/scp -P {0} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no\"".format(port))
92
93 return "\n".join(content)
94
95 dejagnudir = d.expand("${WORKDIR}/dejagnu")
96 if not os.path.isdir(dejagnudir):
97 os.makedirs(dejagnudir)
98
99 # write out target qemu board config
100 with open(os.path.join(dejagnudir, "user.exp"), "w") as f:
101 f.write(generate_qemu_linux_user_config(d))
102
103 # write out target ssh board config
104 with open(os.path.join(dejagnudir, "ssh.exp"), "w") as f:
105 f.write(generate_remote_ssh_linux_config(d))
106
107 # generate site.exp to provide boards
108 with open(os.path.join(dejagnudir, "site.exp"), "w") as f:
109 f.write("lappend boards_dir {0}\n".format(dejagnudir))
110 f.write("set CFLAGS_FOR_TARGET \"{0}\"\n".format(d.getVar("TOOLCHAIN_OPTIONS")))
111}
112