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