Skip to contentSkip to conversation

Rust cross testing integration with oe-selftest.

PATCH In review Vinay Kumar 5 participants 90 messages Apr 9, 2021 – May 29, 2021 3 messages not in the archive Page 1 of 2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Rust cross testing integration with oe-selftest.

---
 meta/classes/rust-common.bbclass              |   5 +-
 meta/conf/bitbake.conf                        |   2 +-
 meta/lib/oeqa/selftest/cases/rust.py          |  41 ++
 meta/lib/oeqa/utils/qemurunner.py             |   8 +-
 meta/recipes-devtools/rust/rust-test.inc      | 504 ++++++++++++++++++
 .../recipes-devtools/rust/rust-test_1.46.0.bb |  12 +
 scripts/runqemu                               |  15 +-
 7 files changed, 583 insertions(+), 4 deletions(-)
 create mode 100644 meta/lib/oeqa/selftest/cases/rust.py
 create mode 100644 meta/recipes-devtools/rust/rust-test.inc
 create mode 100644 meta/recipes-devtools/rust/rust-test_1.46.0.bb
meta/classes/rust-common.bbclass +4 -1
index ff7b9da8f3..fb75b07ba3 100644
@@ -84,7 +84,10 @@ def rust_base_triple(d, thing):
     # This catches ARM targets and appends the necessary hard float bits
     if os == "linux-gnueabi" or os == "linux-musleabi":
         libc = bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', 'hf', '', d)
-    return arch + vendor + '-' + os + libc
+    if d.getVar('TARGET_ARCH') == 'mips64':
+       return arch + vendor + '-' + os + libc + 'abi64'
+    else:
+       return arch + vendor + '-' + os + libc
 
 # Naming explanation
 # Yocto
meta/conf/bitbake.conf +1 -1
index 3438be92b7..83e1b68071 100644
@@ -483,7 +483,7 @@ HOSTTOOLS_DIR = "${TMPDIR}/hosttools"
 HOSTTOOLS += " \
     [ ar as awk basename bash bzip2 cat chgrp chmod chown chrpath cmp comm cp cpio \
     cpp cut date dd diff diffstat dirname du echo egrep env expand expr false \
-    fgrep file find flock g++ gawk gcc getconf getopt git grep gunzip gzip \
+    fgrep file find flock g++ gawk gcc cc getconf getopt git grep gunzip gzip \
     head hostname iconv id install ld ldd ln ls make md5sum mkdir mkfifo mknod \
     mktemp mv nm objcopy objdump od patch perl pr printf pwd \
     python3 ranlib readelf readlink realpath rm rmdir rpcgen sed seq sh \
meta/lib/oeqa/selftest/cases/rust.py new file +41 -0

41 lines not on this page · raw message

meta/lib/oeqa/utils/qemurunner.py +7 -1
index 77ec939ad7..aea7c624ec 100644
@@ -184,7 +184,13 @@ class QemuRunner:
         # and analyze descendents in order to determine it.
         if os.path.exists(self.qemu_pidfile):
             os.remove(self.qemu_pidfile)
-        self.qemuparams = 'bootparams="{0}" qemuparams="-pidfile {1}"'.format(bootparams, self.qemu_pidfile)
+
+        if "slirp" in launch_cmd:
+            self.use_slirp = True
+            self.qemuparams = 'bootparams="{0}" qemuparams="-pidfile {1} -monitor telnet:127.0.0.1:1234,server,nowait -serial mon:stdio -serial null"'.format(bootparams, self.qemu_pidfile)
+        else:
+            self.qemuparams = 'bootparams="{0}" qemuparams="-pidfile {1}"'.format(bootparams, self.qemu_pidfile)
+
         if qemuparams:
             self.qemuparams = self.qemuparams[:-1] + " " + qemuparams + " " + '\"'
 
meta/recipes-devtools/rust/rust-test.inc new file +504 -0

504 lines not on this page · raw message

meta/recipes-devtools/rust/rust-test_1.46.0.bb new file +12 -0
new file mode 100644
index 0000000000..b724ea5eb0
@@ -0,0 +1,12 @@
+require rust-test.inc
+require rust-source-${PV}.inc
+require rust-snapshot-${PV}.inc
+
+DEPENDS += "rust-llvm (=${PV})"
+
+# Otherwise we'll depend on what we provide
+INHIBIT_DEFAULT_RUST_DEPS_class-native = "1"
+# We don't need to depend on gcc-native because yocto assumes it exists
+PROVIDES_class-native = "virtual/${TARGET_PREFIX}rust"
+
+BBCLASSEXTEND = "native"
scripts/runqemu +14 -1
index dd92a64553..1a21a90add 100755
@@ -1055,7 +1055,7 @@ class BaseConfig(object):
         logger.info("Network configuration:%s", netconf)
         self.kernel_cmdline_script += netconf
         # Port mapping
-        hostfwd = ",hostfwd=tcp::2222-:22,hostfwd=tcp::2323-:23"
+        hostfwd = ",hostfwd=tcp::12345-:12345,hostfwd=tcp::2323-:23,hostfwd=tcp::2222-:22"
         qb_slirp_opt_default = "-netdev user,id=net0%s,tftp=%s" % (hostfwd, self.get('DEPLOY_DIR_IMAGE'))
         qb_slirp_opt = self.get('QB_SLIRP_OPT') or qb_slirp_opt_default
         # Figure out the port
@@ -1084,6 +1084,19 @@ class BaseConfig(object):
                         mac += 1
             if p != p_new:
                 ports.append(p_new)
+                temp=__file__.split(os.path.basename(__file__))[0]
+                with open(temp+"../meta/recipes-devtools/rust/rust-test.inc", 'r+') as f:
+                    text = f.readlines()
+                    temp1=[]
+                    for i in text:
+                        temp = re.sub(r'(\S+\s)(-.)(\s\d+)( -o StrictHostKeyChecking=no .*)', r'\1\2 '+str(p_new)+'\\4', i)
+                        temp1.append(temp)
+                    temp2=''
+                    for i in temp1:
+                        temp2=temp2+i
+                    f.seek(0)
+                    f.write(temp2)
+                    f.truncate()
                 qb_slirp_opt = re.sub(':%s-' % p, ':%s-' % p_new, qb_slirp_opt)
                 logger.info("Port forward changed: %s -> %s" % (p, p_new))
         mac = "%s%02x" % (self.mac_slirp, mac)
Signature · 1 line
2.17.1
#1 lore raw

There are a few unrelated changes all bundled together - please split it into several commits and properly describe each. Particularly rust-test.inc is huge, and does need a proper explanation of what is happening and why, in both the commit message and inline comments. Do keep in mind: making the code work is only half the job, the other half is explaining what happens to other humans.

Alex

Quoted 744 lines · Vinay Kumar
---
 meta/classes/rust-common.bbclass              |   5 +-
 meta/conf/bitbake.conf                        |   2 +-
 meta/lib/oeqa/selftest/cases/rust.py          |  41 ++
 meta/lib/oeqa/utils/qemurunner.py             |   8 +-
 meta/recipes-devtools/rust/rust-test.inc      | 504 ++++++++++++++++++
 .../recipes-devtools/rust/rust-test_1.46.0.bb |  12 +
 scripts/runqemu                               |  15 +-
 7 files changed, 583 insertions(+), 4 deletions(-)
 create mode 100644 meta/lib/oeqa/selftest/cases/rust.py
 create mode 100644 meta/recipes-devtools/rust/rust-test.inc
 create mode 100644 meta/recipes-devtools/rust/rust-test_1.46.0.bb
meta/classes/rust-common.bbclass +4 -1
index ff7b9da8f3..fb75b07ba3 100644
@@ -84,7 +84,10 @@ def rust_base_triple(d, thing):
     # This catches ARM targets and appends the necessary hard float bits
     if os == "linux-gnueabi" or os == "linux-musleabi":
         libc = bb.utils.contains('TUNE_FEATURES', 'callconvention-hard',
 'hf', '', d)
-    return arch + vendor + '-' + os + libc
+    if d.getVar('TARGET_ARCH') == 'mips64':
+       return arch + vendor + '-' + os + libc + 'abi64'
+    else:
+       return arch + vendor + '-' + os + libc
 
 # Naming explanation

# Yocto

meta/conf/bitbake.conf +1 -1
index 3438be92b7..83e1b68071 100644
@@ -483,7 +483,7 @@ HOSTTOOLS_DIR = "${TMPDIR}/hosttools"
 HOSTTOOLS += " \
     [ ar as awk basename bash bzip2 cat chgrp chmod chown chrpath cmp
 comm cp cpio \
     cpp cut date dd diff diffstat dirname du echo egrep env expand expr
 false \
-    fgrep file find flock g++ gawk gcc getconf getopt git grep gunzip
 gzip \
+    fgrep file find flock g++ gawk gcc cc getconf getopt git grep gunzip

gzip \
head hostname iconv id install ld ldd ln ls make md5sum mkdir mkfifo

mknod \
     mktemp mv nm objcopy objdump od patch perl pr printf pwd \
     python3 ranlib readelf readlink realpath rm rmdir rpcgen sed seq sh \
meta/lib/oeqa/selftest/cases/rust.py new file +6 -0
new file mode 100644
index 0000000000..69a1a285a9
@@ -0,0 +1,41 @@
+# SPDX-License-Identifier: MIT
+import os
+from oeqa.core.decorator import OETestTag
+from oeqa.core.case import OEPTestResultTestCase
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars,

runqemu, Command

meta/lib/oeqa/selftest/cases/rust.py new file +9 -0
+
+class RustSelfTestBase(OESelftestTestCase, OEPTestResultTestCase):
+
+       def run_check(self, *suites, ssh = None):
+               # configure ssh target
+               features = []
+               if ssh is not None:
+                       features.append('TOOLCHAIN_TEST_TARGET = "ssh"')
+                       features.append('TOOLCHAIN_TEST_HOST =

"{0}"'.format(ssh))
+ features.append('TOOLCHAIN_TEST_HOST_USER =
"root"')

meta/lib/oeqa/selftest/cases/rust.py new file +12 -0
+                       features.append('TOOLCHAIN_TEST_HOST_PORT = "22"')
+               self.write_config("\n".join(features))
+
+               recipe = "rust-test"
+               bitbake("{} -c check".format(recipe))
+
+       def run_check_emulated(self, *args, **kwargs):
+               # build remote-test-server before image build
+               recipe = "rust-test"
+               bitbake("{} -c compile".format(recipe))
+               # build core-image-minimal with required packages
+               default_installed_packages = ["libgcc", "libstdc++",

"libatomic", "libgomp"]

meta/lib/oeqa/selftest/cases/rust.py new file +3 -0
+               features = []
+               features.append('IMAGE_FEATURES += "ssh-server-openssh"')
+               features.append('CORE_IMAGE_EXTRA_INSTALL +=

"{0}"'.format(" ".join(default_installed_packages)))

meta/lib/oeqa/selftest/cases/rust.py new file +4 -0
+               self.write_config("\n".join(features))
+               bitbake("core-image-minimal")
+               # wrap the execution with a qemu instance
+               with runqemu("core-image-minimal", runqemuparams =

"nographic slirp") as qemu:

meta/lib/oeqa/selftest/cases/rust.py new file +6 -0
+                       return self.run_check(*args, ssh=qemu.ip, **kwargs)
+
+@OETestTag("toolchain-system")
+class RustSelfTestSystemEmulated(RustSelfTestBase):
+       def test_rust(self):
+               self.run_check_emulated("rust")
meta/lib/oeqa/utils/qemurunner.py +6 -2
index 77ec939ad7..aea7c624ec 100644
@@ -184,7 +184,13 @@ class QemuRunner:
         # and analyze descendents in order to determine it.
         if os.path.exists(self.qemu_pidfile):
             os.remove(self.qemu_pidfile)
-        self.qemuparams = 'bootparams="{0}" qemuparams="-pidfile
 {1}"'.format(bootparams, self.qemu_pidfile)
+
+        if "slirp" in launch_cmd:
+            self.use_slirp = True
+            self.qemuparams = 'bootparams="{0}" qemuparams="-pidfile {1}
-monitor telnet:127.0.0.1:1234,server,nowait -serial mon:stdio -serial
 null"'.format(bootparams, self.qemu_pidfile)
+        else:
+            self.qemuparams = 'bootparams="{0}" qemuparams="-pidfile

{1}"'.format(bootparams, self.qemu_pidfile)
+
if qemuparams:
self.qemuparams = self.qemuparams[:-1] + " " + qemuparams + "
" + '\"'

meta/recipes-devtools/rust/rust-test.inc new file +11 -0
new file mode 100644
index 0000000000..0a13b3e0d8
@@ -0,0 +1,504 @@
+HOMEPAGE = "http://www.rust-lang.org"
+SECTION = "devel"
+LICENSE = "MIT | Apache-2.0"
+
+inherit rust
+inherit cargo_common
+
+DEPENDS += "file-native python3-native"
+DEPENDS_append_class-native = " rust-llvm-native"
+
+# In case of x86_64 target we setting this path to location of

"x86_64-poky-linux.json".

meta/recipes-devtools/rust/rust-test.inc new file +6 -0
+# This is to differentiate cross target and build in config.toml file.
+export RUST_TARGET_PATH = "${STAGING_LIBDIR_NATIVE}/rustlib"
+
+export FORCE_CRATE_HASH="${BB_TASKHASH}"
+
+#export YOCTO_ALTERNATE_EXE_PATH =

"${STAGING_LIBDIR}/llvm-rust/bin/llvm-config"

meta/recipes-devtools/rust/rust-test.inc new file +3 -0
+export YOCTO_ALTERNATE_MULTILIB_NAME = "/${BASELIB}"
+
+# We don't want to use bitbakes vendoring because the rust sources do

their

meta/recipes-devtools/rust/rust-test.inc new file +11 -0
+# own vendoring.
+CARGO_DISABLE_BITBAKE_VENDORING = "1"
+
+# We can't use RUST_BUILD_SYS here because that may be "musl" if
+# TCLIBC="musl". Snapshots are always -unknown-linux-gnu
+SNAPSHOT_BUILD_SYS = "${BUILD_ARCH}-unknown-linux-gnu"
+setup_cargo_environment () {
+    # The first step is to build bootstrap and some early stage tools,
+    # these are build for the same target as the snapshot, e.g.
+    # x86_64-unknown-linux-gnu.
+    # Later stages are build for the native target (i.e.

target.x86_64-linux)

meta/recipes-devtools/rust/rust-test.inc new file +8 -0
+    cargo_common_do_configure
+
+    printf '[target.%s]\n' "${SNAPSHOT_BUILD_SYS}" >> ${CARGO_HOME}/config
+    printf "linker = '%s'\n" "${RUST_BUILD_CCLD}" >> ${CARGO_HOME}/config
+}
+
+# Right now this is focused on arm-specific tune features.
+# We get away with this for now as one can only use x86-64 as the build

host

meta/recipes-devtools/rust/rust-test.inc new file +47 -0
+# (not arm).
+# Note that TUNE_FEATURES is _always_ refering to the target, so we really
+# don't want to use this for the host/build.
+def llvm_features_from_tune(d):
+    f = []
+    feat = d.getVar('TUNE_FEATURES')
+    if not feat:
+        return []
+    feat = frozenset(feat.split())
+
+    mach_overrides = d.getVar('MACHINEOVERRIDES')
+    mach_overrides = frozenset(mach_overrides.split(':'))
+
+    if 'vfpv4' in feat:
+        f.append("+vfp4")
+    if 'vfpv3' in feat:
+        f.append("+vfp3")
+    if 'vfpv3d16' in feat:
+        f.append("+d16")
+
+    if 'vfpv2' in feat or 'vfp' in feat:
+        f.append("+vfp2")
+
+    if 'neon' in feat:
+        f.append("+neon")
+
+    if 'aarch64' in feat:
+        f.append("+v8")
+
+    if 'mips32' in feat:
+        f.append("+mips32")
+
+    if 'mips32r2' in feat:
+        f.append("+mips32r2")
+
+    v7=frozenset(['armv7a', 'armv7r', 'armv7m', 'armv7ve'])
+    if (not mach_overrides.isdisjoint(v7)) or (not feat.isdisjoint(v7)):
+        f.append("+v7")
+    if ('armv6' in mach_overrides) or ('armv6' in feat):
+        f.append("+v6")
+
+    if 'dsp' in feat:
+        f.append("+dsp")
+
+    if 'thumb' in feat:
+        if d.getVar('ARM_THUMB_OPT') is "thumb":
+            if (not mach_overrides.isdisjoint(v7)) or (not

feat.isdisjoint(v7)):

meta/recipes-devtools/rust/rust-test.inc new file +17 -0
+                f.append("+thumb2")
+            f.append("+thumb-mode")
+
+    if 'cortexa5' in feat:
+        f.append("+a5")
+    if 'cortexa7' in feat:
+        f.append("+a7")
+    if 'cortexa9' in feat:
+        f.append("+a9")
+    if 'cortexa15' in feat:
+        f.append("+a15")
+    if 'cortexa17' in feat:
+        f.append("+a17")
+
+    return f
+
+# TARGET_CC_ARCH changes from build/cross/target so it'll do the right

thing
+# this should go away when https://github.com/rust-lang/rust/pull/31709
is

meta/recipes-devtools/rust/rust-test.inc new file +33 -0
+# stable (1.9.0?)
+def llvm_features_from_cc_arch(d):
+    f = []
+    feat = d.getVar('TARGET_CC_ARCH')
+    if not feat:
+        return []
+    feat = frozenset(feat.split())
+
+    if '-mmmx' in feat:
+        f.append("+mmx")
+    if '-msse' in feat:
+        f.append("+sse")
+    if '-msse2' in feat:
+        f.append("+sse2")
+    if '-msse3' in feat:
+        f.append("+sse3")
+    if '-mssse3' in feat:
+        f.append("+ssse3")
+    if '-msse4.1' in feat:
+        f.append("+sse4.1")
+    if '-msse4.2' in feat:
+        f.append("+sse4.2")
+    if '-msse4a' in feat:
+        f.append("+sse4a")
+    if '-mavx' in feat:
+        f.append("+avx")
+    if '-mavx2' in feat:
+        f.append("+avx2")
+
+    return f
+
+def llvm_features_from_target_fpu(d):
+    # TARGET_FPU can be hard or soft. +soft-float tell llvm to use soft

float

meta/recipes-devtools/rust/rust-test.inc new file +21 -0
+    # ABI. There is no option for hard.
+
+    fpu = d.getVar('TARGET_FPU', True)
+    return ["+soft-float"] if fpu == "soft" else []
+
+def llvm_features(d):
+    return ','.join(llvm_features_from_tune(d) +
+                    llvm_features_from_cc_arch(d) +
+                    llvm_features_from_target_fpu(d))
+
+## arm-unknown-linux-gnueabihf
+DATA_LAYOUT[arm] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+LLVM_TARGET[arm] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[arm] = "little"
+TARGET_POINTER_WIDTH[arm] = "32"
+TARGET_C_INT_WIDTH[arm] = "32"
+MAX_ATOMIC_WIDTH[arm] = "64"
+FEATURES[arm] = "+v6,+vfp2"
+
+## aarch64-unknown-linux-{gnu, musl}
+DATA_LAYOUT[aarch64] =

"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"

meta/recipes-devtools/rust/rust-test.inc new file +23 -0
+LLVM_TARGET[aarch64] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[aarch64] = "little"
+TARGET_POINTER_WIDTH[aarch64] = "64"
+TARGET_C_INT_WIDTH[aarch64] = "32"
+MAX_ATOMIC_WIDTH[aarch64] = "128"
+
+## x86_64-unknown-linux-{gnu, musl}
+DATA_LAYOUT[x86_64] = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+LLVM_TARGET[x86_64] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[x86_64] = "little"
+TARGET_POINTER_WIDTH[x86_64] = "64"
+TARGET_C_INT_WIDTH[x86_64] = "32"
+MAX_ATOMIC_WIDTH[x86_64] = "64"
+
+## i686-unknown-linux-{gnu, musl}
+DATA_LAYOUT[i686] = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
+LLVM_TARGET[i686] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[i686] = "little"
+TARGET_POINTER_WIDTH[i686] = "32"
+TARGET_C_INT_WIDTH[i686] = "32"
+MAX_ATOMIC_WIDTH[i686] = "64"
+
+## XXX: a bit of a hack so qemux86 builds, clone of

i686-unknown-linux-{gnu, musl} above

meta/recipes-devtools/rust/rust-test.inc new file +73 -0
+DATA_LAYOUT[i586] = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
+LLVM_TARGET[i586] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[i586] = "little"
+TARGET_POINTER_WIDTH[i586] = "32"
+TARGET_C_INT_WIDTH[i586] = "32"
+MAX_ATOMIC_WIDTH[i586] = "64"
+
+## mips-unknown-linux-{gnu, musl}
+DATA_LAYOUT[mips] = "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"
+LLVM_TARGET[mips] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[mips] = "big"
+TARGET_POINTER_WIDTH[mips] = "32"
+TARGET_C_INT_WIDTH[mips] = "32"
+MAX_ATOMIC_WIDTH[mips] = "32"
+
+## mipsel-unknown-linux-{gnu, musl}
+DATA_LAYOUT[mipsel] = "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"
+LLVM_TARGET[mipsel] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[mipsel] = "little"
+TARGET_POINTER_WIDTH[mipsel] = "32"
+TARGET_C_INT_WIDTH[mipsel] = "32"
+MAX_ATOMIC_WIDTH[mipsel] = "32"
+
+## mips64-unknown-linux-{gnu, musl}
+DATA_LAYOUT[mips64] = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+LLVM_TARGET[mips64] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[mips64] = "big"
+TARGET_POINTER_WIDTH[mips64] = "64"
+TARGET_C_INT_WIDTH[mips64] = "64"
+MAX_ATOMIC_WIDTH[mips64] = "64"
+
+## mips64el-unknown-linux-{gnu, musl}
+DATA_LAYOUT[mips64el] = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+LLVM_TARGET[mips64el] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[mips64el] = "little"
+TARGET_POINTER_WIDTH[mips64el] = "64"
+TARGET_C_INT_WIDTH[mips64el] = "64"
+MAX_ATOMIC_WIDTH[mips64el] = "64"
+
+## powerpc-unknown-linux-{gnu, musl}
+DATA_LAYOUT[powerpc] = "E-m:e-p:32:32-i64:64-n32"
+LLVM_TARGET[powerpc] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[powerpc] = "big"
+TARGET_POINTER_WIDTH[powerpc] = "32"
+TARGET_C_INT_WIDTH[powerpc] = "32"
+MAX_ATOMIC_WIDTH[powerpc] = "32"
+
+## riscv32-unknown-linux-{gnu, musl}
+DATA_LAYOUT[riscv32] = "e-m:e-p:64:64-i64:64-i128:128-n64-S128"
+LLVM_TARGET[riscv32] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[riscv32] = "little"
+TARGET_POINTER_WIDTH[riscv32] = "32"
+TARGET_C_INT_WIDTH[riscv32] = "32"
+MAX_ATOMIC_WIDTH[riscv32] = "32"
+
+## riscv64-unknown-linux-{gnu, musl}
+DATA_LAYOUT[riscv64] = "e-m:e-p:64:64-i64:64-i128:128-n64-S128"
+LLVM_TARGET[riscv64] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[riscv64] = "little"
+TARGET_POINTER_WIDTH[riscv64] = "64"
+TARGET_C_INT_WIDTH[riscv64] = "64"
+MAX_ATOMIC_WIDTH[riscv64] = "64"
+
+def arch_for(d, thing):
+    return d.getVar('{}_ARCH'.format(thing))
+
+def sys_for(d, thing):
+    return d.getVar('{}_SYS'.format(thing))
+
+def prefix_for(d, thing):
+    return d.getVar('{}_PREFIX'.format(thing))
+
+# Convert a normal arch (HOST_ARCH, TARGET_ARCH, BUILD_ARCH, etc) to

something

meta/recipes-devtools/rust/rust-test.inc new file +44 -0
+# rust's internals won't choke on.
+def arch_to_rust_target_arch(arch):
+    if arch == "i586" or arch == "i686":
+        return "x86"
+    elif arch == "mipsel":
+        return "mips"
+    elif arch == "mip64sel":
+        return "mips64"
+    else:
+        return arch
+
+# generates our target CPU value
+def llvm_cpu(d):
+    cpu = d.getVar('PACKAGE_ARCH')
+    target = d.getVar('TRANSLATED_TARGET_ARCH')
+
+    trans = {}
+    trans['corei7-64'] = "corei7"
+    trans['core2-32'] = "core2"
+    trans['x86-64'] = "x86-64"
+    trans['i686'] = "i686"
+    trans['i586'] = "i586"
+    trans['powerpc'] = "powerpc"
+    trans['mips64'] = "mips64"
+    trans['mips64el'] = "mips64"
+
+    if target in ["mips", "mipsel"]:
+        feat = frozenset(d.getVar('TUNE_FEATURES').split())
+        if "mips32r2" in feat:
+            trans['mipsel'] = "mips32r2"
+            trans['mips'] = "mips32r2"
+        elif "mips32" in feat:
+            trans['mipsel'] = "mips32"
+            trans['mips'] = "mips32"
+
+    try:
+        return trans[cpu]
+    except:
+        return trans.get(target, "generic")
+
+TARGET_LLVM_CPU="${@llvm_cpu(d)}"
+TARGET_LLVM_FEATURES = "${@llvm_features(d)}"
+
+# class-native implies TARGET=HOST, and TUNE_FEATURES only describes the

real

meta/recipes-devtools/rust/rust-test.inc new file +2 -0
+# (original) target.
+TARGET_LLVM_FEATURES_class-native =

"${@','.join(llvm_features_from_cc_arch(d))}"

meta/recipes-devtools/rust/rust-test.inc new file +16 -0
+
+def rust_gen_target(d, thing, wd, features, cpu):
+    import json
+    from distutils.version import LooseVersion
+    arch = arch_for(d, thing)
+    sys = sys_for(d, thing)
+    prefix = prefix_for(d, thing)
+
+    features = features or d.getVarFlag('FEATURES', arch) or ""
+    features = features.strip()
+
+    # build tspec
+    tspec = {}
+    tspec['llvm-target'] = d.getVarFlag('LLVM_TARGET', arch)
+    tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', arch)
+    tspec['max-atomic-width'] = int(d.getVarFlag('MAX_ATOMIC_WIDTH',

arch))
+ tspec['target-pointer-width'] = d.getVarFlag('TARGET_POINTER_WIDTH',
arch)

meta/recipes-devtools/rust/rust-test.inc new file +45 -0
+    tspec['target-c-int-width'] = d.getVarFlag('TARGET_C_INT_WIDTH', arch)
+    tspec['target-endian'] = d.getVarFlag('TARGET_ENDIAN', arch)
+    tspec['arch'] = arch_to_rust_target_arch(arch)
+    tspec['os'] = "linux"
+    if "musl" in tspec['llvm-target']:
+        tspec['env'] = "musl"
+    else:
+        tspec['env'] = "gnu"
+    tspec['vendor'] = "unknown"
+    tspec['target-family'] = "unix"
+    tspec['linker'] = "{}{}gcc".format(d.getVar('CCACHE'), prefix)
+    tspec['ar'] = "{}ar".format(prefix)
+    tspec['cpu'] = cpu
+    if features is not "":
+        tspec['features'] = features
+    tspec['dynamic-linking'] = True
+    tspec['executables'] = True
+    tspec['linker-is-gnu'] = True
+    tspec['linker-flavor'] = "gcc"
+    tspec['has-rpath'] = True
+    tspec['has-elf-tls'] = True
+    tspec['position-independent-executables'] = True
+    tspec['panic-strategy'] = d.getVar("RUST_PANIC_STRATEGY")
+
+    # Don't use jemalloc as it doesn't work for many targets.
+    # https://github.com/rust-lang/rust/pull/37392
+    # From 1.20.0 and forward, system allocator is the default.
+    if LooseVersion(d.getVar("PV")) < LooseVersion("1.20.0"):
+        tspec['exe-allocation-crate'] = "alloc_system"
+        tspec['lib-allocation-crate'] = "alloc_system"
+
+    # write out the target spec json file
+    with open(wd + sys + '.json', 'w') as f:
+        json.dump(tspec, f, indent=4)
+
+python do_rust_gen_targets () {
+    wd = d.getVar('WORKDIR') + '/targets/'
+    rust_gen_target(d, 'BUILD', wd, "", "generic")
+}
+
+addtask rust_gen_targets after do_patch before do_compile
+do_rust_gen_targets[dirs] += "${WORKDIR}/targets"
+
+do_rust_setup_snapshot () {
+    for installer in

"${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do

meta/recipes-devtools/rust/rust-test.inc new file +4 -1
+        "${installer}" --prefix="${WORKDIR}/rust-snapshot"
--disable-ldconfig
+    done
+
+    # Some versions of rust (e.g. 1.18.0) tries to find cargo in

stage0/bin/cargo

meta/recipes-devtools/rust/rust-test.inc new file +17 -0
+    # and fail without it there.
+    mkdir -p ${RUSTSRC}/build/${BUILD_SYS}
+    ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${BUILD_SYS}/stage0
+}
+addtask rust_setup_snapshot after do_unpack before do_configure
+do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
+
+
+python do_configure() {
+    import json
+    from distutils.version import LooseVersion
+    try:
+        import configparser
+    except ImportError:
+        import ConfigParser as configparser
+
+    # toml is rather similar to standard ini like format except it likes

values
+ # that look more JSON like. So for our purposes simply escaping all
values

meta/recipes-devtools/rust/rust-test.inc new file +8 -0
+    # as JSON seem to work fine.
+
+    e = lambda s: json.dumps(s)
+
+    config = configparser.RawConfigParser()
+
+    # [target.ARCH-unknown-linux-gnu]
+    if( d.getVar('RUST_TARGET_SYS', True) !=

d.getVar('SNAPSHOT_BUILD_SYS', True)):
+ target_section = "target.{}".format(d.getVar('RUST_TARGET_SYS',
True))

meta/recipes-devtools/rust/rust-test.inc new file +8 -0
+    else :
+       target_section = "target.{}".format(d.getVar('TARGET_SYS', True))
+
+    config.add_section(target_section)
+
+    config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
+    config.set(target_section, "linker",

e(d.expand("${RUST_TARGET_CCLD}")))

meta/recipes-devtools/rust/rust-test.inc new file +2 -0
+
+    # If we don't do this rust-native will compile it's own llvm for

BUILD.

meta/recipes-devtools/rust/rust-test.inc new file +2 -0
+    # [target.${BUILD_ARCH}-unknown-linux-gnu]
+    target_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS',

True))

meta/recipes-devtools/rust/rust-test.inc new file +17 -0
+    config.add_section(target_section)
+
+    config.set(target_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
+
+    # [rust]
+    config.add_section("rust")
+    config.set("rust", "rpath", e(True))
+    config.set("rust", "channel", e("stable"))
+
+    if LooseVersion(d.getVar("PV")) < LooseVersion("1.32.0"):
+        config.set("rust", "use-jemalloc", e(False))
+
+    # Whether or not to optimize the compiler and standard library
+    config.set("rust", "optimize", e(True))
+
+    # Emits extraneous output from tests to ensure that failures of the

test

meta/recipes-devtools/rust/rust-test.inc new file +17 -0
+    # harness are debuggable just from logfiles
+    config.set("rust", "verbose-tests", e(True))
+
+    # [build]
+    config.add_section("build")
+    config.set("build", "submodules", e(False))
+    config.set("build", "docs", e(False))
+
+    rustc = d.expand("${WORKDIR}/rust-snapshot/bin/rustc")
+    config.set("build", "rustc", e(rustc))
+
+    cargo = d.expand("${WORKDIR}/rust-snapshot/bin/cargo")
+    config.set("build", "cargo", e(cargo))
+
+    config.set("build", "vendor", e(True))
+
+    if( d.getVar('RUST_TARGET_SYS', True) !=

d.getVar('SNAPSHOT_BUILD_SYS', True)):

meta/recipes-devtools/rust/rust-test.inc new file +10 -0
+        targets = [d.getVar("RUST_TARGET_SYS", True)]
+    else:
+        targets = [d.getVar("TARGET_SYS", True)]
+
+    config.set("build", "target", e(targets))
+
+    hosts = [d.getVar("SNAPSHOT_BUILD_SYS", True)]
+    config.set("build", "host", e(hosts))
+
+    # We can't use BUILD_SYS since that is something the rust snapshot

knows
+ # nothing about when trying to build some stage0 tools (like
fabricate)

meta/recipes-devtools/rust/rust-test.inc new file +15 -0
+    config.set("build", "build", e(d.getVar("SNAPSHOT_BUILD_SYS", True)))
+
+    with open("config.toml", "w") as f:
+        config.write(f)
+
+    # set up ${WORKDIR}/cargo_home
+    bb.build.exec_func("setup_cargo_environment", d)
+}
+
+
+rust_runx () {
+    echo "COMPILE ${PN}" "$@"
+
+    # CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a
+    # wide range of targets (not just TARGET). Yocto's settings for them

will

meta/recipes-devtools/rust/rust-test.inc new file +9 -0
+    # be inappropriate, avoid using.
+    unset CFLAGS
+    unset LDFLAGS
+    unset CXXFLAGS
+    unset CPPFLAGS
+
+    oe_cargo_fix_env
+
+    nativepython3 src/bootstrap/bootstrap.py

${@oe.utils.parallel_make_argument(d, '-j %d')} "$@"

meta/recipes-devtools/rust/rust-test.inc new file +7 -0
+}
+rust_runx[vardepsexclude] += "PARALLEL_MAKE"
+
+do_compile () {
+    if [  "${SNAPSHOT_BUILD_SYS}" = "${RUST_TARGET_SYS}" ]
+    then
+       rust_runx build src/tools/remote-test-server --target

"${TARGET_SYS}"

meta/recipes-devtools/rust/rust-test.inc new file +2 -0
+    else
+       rust_runx build src/tools/remote-test-server --target

"${RUST_TARGET_SYS}"

meta/recipes-devtools/rust/rust-test.inc new file +7 -0
+    fi
+}
+
+do_check[dirs] += "${B}"
+do_check[nostamp] = "1"
+do_check () {
+    scp -P 2222 -o StrictHostKeyChecking=no

build/${SNAPSHOT_BUILD_SYS}/stage2-tools-bin/remote-test-server [email protected]:~/
+ ssh -p 2222 -o StrictHostKeyChecking=no -f [email protected]
"~/remote-test-server -v remote"

meta/recipes-devtools/rust/rust-test.inc new file +6 -0
+
+
+    export TEST_DEVICE_ADDR="127.0.0.1:12345"
+    if [  "${SNAPSHOT_BUILD_SYS}" = "${RUST_TARGET_SYS}" ]
+    then
+       rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" >

summary.txt 2> /dev/null

meta/recipes-devtools/rust/rust-test.inc new file +2 -0
+    else
+       rust_runx test --no-fail-fast --target "${RUST_TARGET_SYS}" >

summary.txt 2> /dev/null

meta/recipes-devtools/rust/rust-test.inc new file +5 -0
+    fi
+
+}
+addtask do_check after do_compile
+
meta/recipes-devtools/rust/rust-test_1.46.0.bb new file +12 -0
new file mode 100644
index 0000000000..b724ea5eb0
@@ -0,0 +1,12 @@
+require rust-test.inc
+require rust-source-${PV}.inc
+require rust-snapshot-${PV}.inc
+
+DEPENDS += "rust-llvm (=${PV})"
+
+# Otherwise we'll depend on what we provide
+INHIBIT_DEFAULT_RUST_DEPS_class-native = "1"
+# We don't need to depend on gcc-native because yocto assumes it exists
+PROVIDES_class-native = "virtual/${TARGET_PREFIX}rust"
+
+BBCLASSEXTEND = "native"
scripts/runqemu +1 -1
index dd92a64553..1a21a90add 100755
@@ -1055,7 +1055,7 @@ class BaseConfig(object):
         logger.info("Network configuration:%s", netconf)
         self.kernel_cmdline_script += netconf
         # Port mapping
-        hostfwd = ",hostfwd=tcp::2222-:22,hostfwd=tcp::2323-:23"
+        hostfwd =

",hostfwd=tcp::12345-:12345,hostfwd=tcp::2323-:23,hostfwd=tcp::2222-:22"

         qb_slirp_opt_default = "-netdev user,id=net0%s,tftp=%s" %

(hostfwd, self.get('DEPLOY_DIR_IMAGE'))
qb_slirp_opt = self.get('QB_SLIRP_OPT') or qb_slirp_opt_default # Figure out the port

scripts/runqemu +2 -0
@@ -1084,6 +1084,19 @@ class BaseConfig(object):
                         mac += 1
             if p != p_new:
                 ports.append(p_new)
+                temp=__file__.split(os.path.basename(__file__))[0]
+                with

open(temp+"../meta/recipes-devtools/rust/rust-test.inc", 'r+') as f:

scripts/runqemu +4 -0
+                    text = f.readlines()
+                    temp1=[]
+                    for i in text:
+                        temp = re.sub(r'(\S+\s)(-.)(\s\d+)( -o

StrictHostKeyChecking=no .*)', r'\1\2 '+str(p_new)+'\\4', i)

scripts/runqemu +7 -0
+                        temp1.append(temp)
+                    temp2=''
+                    for i in temp1:
+                        temp2=temp2+i
+                    f.seek(0)
+                    f.write(temp2)
+                    f.truncate()
                 qb_slirp_opt = re.sub(':%s-' % p, ':%s-' % p_new,

qb_slirp_opt)

                 logger.info("Port forward changed: %s -> %s" % (p,
p_new))
         mac = "%s%02x" % (self.mac_slirp, mac)

--
2.17.1

#2 lore raw

PATCH 1/8 We copied rust.inc to rust-test.inc file, since the rust.inc generates the rquired wrappers (which contains target compiler paths) in place. Which we can use in config.toml file for cross testing. We are trying to generate the config.toml through do_configure option in rust-test.inc file.

The config.toml we are generating throgh rust-test.inc is as below,
===============================================
[target.arm-poky-linux-gnueabi]
cxx = "{yocto-build-target-path}/rust-test/1.46.0-r0/wrapper/target-rust-cxx" cc = "{yocto-build-target-path}/rust-test/1.46.0-r0/wrapper/target-rust-cc" linker = "{yocto-build-target-path}/rust-test/1.46.0-r0/wrapper/target-rust-ccld"

[target.x86_64-unknown-linux-gnu]
cxx = "{yocto-build-target-path}/rust-test/1.46.0-r0/wrapper/build-rust-cxx" cc = "{yocto-build-target-path}/rust-test/1.46.0-r0/wrapper/build-rust-cc"

[rust]
rpath = true
channel = "stable"
optimize = true
verbose-tests = true

[build]
submodules = false
docs = false
rustc = "{yocto-build-target-path}/rust-test/1.46.0-r0/rust-snapshot/bin/rustc" cargo = "{yocto-build-target-path}/rust-test/1.46.0-r0/rust-snapshot/bin/cargo" vendor = true
verbose = 2
build-dir = "build-arm"
target = ["arm-poky-linux-gnueabi"]
host = ["x86_64-unknown-linux-gnu"]
build = "x86_64-unknown-linux-gnu"
===============================================

And "rust-test_1.46.0.bb" is copy of rust_1.46.0.bb so that we can use with changes specific to "rust-test.inc". Also, we removed "llvm_config" path from generating in the config.toml

---
 meta/recipes-devtools/rust/rust-test.inc      | 520 ++++++++++++++++++
 .../recipes-devtools/rust/rust-test_1.46.0.bb |  12 +
 2 files changed, 532 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-test.inc
 create mode 100644 meta/recipes-devtools/rust/rust-test_1.46.0.bb
meta/recipes-devtools/rust/rust-test.inc new file +520 -0
new file mode 100644
index 0000000000..0d3eaa10cf
@@ -0,0 +1,520 @@
+SUMMARY = "Rust compiler and runtime libaries"
+HOMEPAGE = "http://www.rust-lang.org"
+SECTION = "devel"
+LICENSE = "MIT | Apache-2.0"
+
+inherit rust
+inherit cargo_common
+
+DEPENDS += "file-native python3-native"
+DEPENDS_append_class-native = " rust-llvm-native"
+EXCLUDE_FROM_WORLD = "1"
+
+# We generate local targets, and need to be able to locate them
+export RUST_TARGET_PATH="${WORKDIR}/targets/"
+
+export FORCE_CRATE_HASH="${BB_TASKHASH}"
+
+export YOCTO_ALTERNATE_EXE_PATH = "${STAGING_LIBDIR}/llvm-rust/bin/llvm-config"
+export YOCTO_ALTERNATE_MULTILIB_NAME = "/${BASELIB}"
+
+# We don't want to use bitbakes vendoring because the rust sources do their
+# own vendoring.
+CARGO_DISABLE_BITBAKE_VENDORING = "1"
+
+# We can't use RUST_BUILD_SYS here because that may be "musl" if
+# TCLIBC="musl". Snapshots are always -unknown-linux-gnu
+SNAPSHOT_BUILD_SYS = "${BUILD_ARCH}-unknown-linux-gnu"
+setup_cargo_environment () {
+    # The first step is to build bootstrap and some early stage tools,
+    # these are build for the same target as the snapshot, e.g.
+    # x86_64-unknown-linux-gnu.
+    # Later stages are build for the native target (i.e. target.x86_64-linux)
+    cargo_common_do_configure
+
+    printf '[target.%s]\n' "${SNAPSHOT_BUILD_SYS}" >> ${CARGO_HOME}/config
+    printf "linker = '%s'\n" "${RUST_BUILD_CCLD}" >> ${CARGO_HOME}/config
+}
+
+# Right now this is focused on arm-specific tune features.
+# We get away with this for now as one can only use x86-64 as the build host
+# (not arm).
+# Note that TUNE_FEATURES is _always_ refering to the target, so we really
+# don't want to use this for the host/build.
+def llvm_features_from_tune(d):
+    f = []
+    feat = d.getVar('TUNE_FEATURES')
+    if not feat:
+        return []
+    feat = frozenset(feat.split())
+
+    mach_overrides = d.getVar('MACHINEOVERRIDES')
+    mach_overrides = frozenset(mach_overrides.split(':'))
+
+    if 'vfpv4' in feat:
+        f.append("+vfp4")
+    if 'vfpv3' in feat:
+        f.append("+vfp3")
+    if 'vfpv3d16' in feat:
+        f.append("+d16")
+
+    if 'vfpv2' in feat or 'vfp' in feat:
+        f.append("+vfp2")
+
+    if 'neon' in feat:
+        f.append("+neon")
+
+    if 'aarch64' in feat:
+        f.append("+v8")
+
+    if 'mips32' in feat:
+        f.append("+mips32")
+
+    if 'mips32r2' in feat:
+        f.append("+mips32r2")
+
+    if target_is_armv7(d):
+        f.append('+v7')
+
+    if ('armv6' in mach_overrides) or ('armv6' in feat):
+        f.append("+v6")
+
+    if 'dsp' in feat:
+        f.append("+dsp")
+
+    if 'thumb' in feat:
+        if d.getVar('ARM_THUMB_OPT') is "thumb":
+            if target_is_armv7(d):
+                f.append('+thumb2')
+            f.append("+thumb-mode")
+
+    if 'cortexa5' in feat:
+        f.append("+a5")
+    if 'cortexa7' in feat:
+        f.append("+a7")
+    if 'cortexa9' in feat:
+        f.append("+a9")
+    if 'cortexa15' in feat:
+        f.append("+a15")
+    if 'cortexa17' in feat:
+        f.append("+a17")
+    if ('riscv64' in feat) or ('riscv32' in feat):
+        f.append("+a,+c,+d,+f,+m")
+    return f
+
+# TARGET_CC_ARCH changes from build/cross/target so it'll do the right thing
+# this should go away when https://github.com/rust-lang/rust/pull/31709 is
+# stable (1.9.0?)
+def llvm_features_from_cc_arch(d):
+    f = []
+    feat = d.getVar('TARGET_CC_ARCH')
+    if not feat:
+        return []
+    feat = frozenset(feat.split())
+
+    if '-mmmx' in feat:
+        f.append("+mmx")
+    if '-msse' in feat:
+        f.append("+sse")
+    if '-msse2' in feat:
+        f.append("+sse2")
+    if '-msse3' in feat:
+        f.append("+sse3")
+    if '-mssse3' in feat:
+        f.append("+ssse3")
+    if '-msse4.1' in feat:
+        f.append("+sse4.1")
+    if '-msse4.2' in feat:
+        f.append("+sse4.2")
+    if '-msse4a' in feat:
+        f.append("+sse4a")
+    if '-mavx' in feat:
+        f.append("+avx")
+    if '-mavx2' in feat:
+        f.append("+avx2")
+
+    return f
+
+def llvm_features_from_target_fpu(d):
+    # TARGET_FPU can be hard or soft. +soft-float tell llvm to use soft float
+    # ABI. There is no option for hard.
+
+    fpu = d.getVar('TARGET_FPU', True)
+    return ["+soft-float"] if fpu == "soft" else []
+
+def llvm_features(d):
+    return ','.join(llvm_features_from_tune(d) +
+                    llvm_features_from_cc_arch(d) +
+                    llvm_features_from_target_fpu(d))
+
+## arm-unknown-linux-gnueabihf
+DATA_LAYOUT[arm] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+LLVM_TARGET[arm] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[arm] = "little"
+TARGET_POINTER_WIDTH[arm] = "32"
+TARGET_C_INT_WIDTH[arm] = "32"
+MAX_ATOMIC_WIDTH[arm] = "64"
+FEATURES[arm] = "+v6,+vfp2"
+
+## armv7-unknown-linux-gnueabihf
+DATA_LAYOUT[armv7] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+LLVM_TARGET[armv7] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[armv7] = "little"
+TARGET_POINTER_WIDTH[armv7] = "32"
+TARGET_C_INT_WIDTH[armv7] = "32"
+MAX_ATOMIC_WIDTH[armv7] = "64"
+FEATURES[armv7] = "+v7,+vfp2,+thumb2"
+
+## aarch64-unknown-linux-{gnu, musl}
+DATA_LAYOUT[aarch64] = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+LLVM_TARGET[aarch64] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[aarch64] = "little"
+TARGET_POINTER_WIDTH[aarch64] = "64"
+TARGET_C_INT_WIDTH[aarch64] = "32"
+MAX_ATOMIC_WIDTH[aarch64] = "128"
+
+## x86_64-unknown-linux-{gnu, musl}
+DATA_LAYOUT[x86_64] = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+LLVM_TARGET[x86_64] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[x86_64] = "little"
+TARGET_POINTER_WIDTH[x86_64] = "64"
+TARGET_C_INT_WIDTH[x86_64] = "32"
+MAX_ATOMIC_WIDTH[x86_64] = "64"
+
+## i686-unknown-linux-{gnu, musl}
+DATA_LAYOUT[i686] = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
+LLVM_TARGET[i686] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[i686] = "little"
+TARGET_POINTER_WIDTH[i686] = "32"
+TARGET_C_INT_WIDTH[i686] = "32"
+MAX_ATOMIC_WIDTH[i686] = "64"
+
+## XXX: a bit of a hack so qemux86 builds, clone of i686-unknown-linux-{gnu, musl} above
+DATA_LAYOUT[i586] = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
+LLVM_TARGET[i586] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[i586] = "little"
+TARGET_POINTER_WIDTH[i586] = "32"
+TARGET_C_INT_WIDTH[i586] = "32"
+MAX_ATOMIC_WIDTH[i586] = "64"
+
+## mips-unknown-linux-{gnu, musl}
+DATA_LAYOUT[mips] = "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"
+LLVM_TARGET[mips] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[mips] = "big"
+TARGET_POINTER_WIDTH[mips] = "32"
+TARGET_C_INT_WIDTH[mips] = "32"
+MAX_ATOMIC_WIDTH[mips] = "32"
+
+## mipsel-unknown-linux-{gnu, musl}
+DATA_LAYOUT[mipsel] = "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"
+LLVM_TARGET[mipsel] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[mipsel] = "little"
+TARGET_POINTER_WIDTH[mipsel] = "32"
+TARGET_C_INT_WIDTH[mipsel] = "32"
+MAX_ATOMIC_WIDTH[mipsel] = "32"
+
+## mips64-unknown-linux-{gnu, musl}
+DATA_LAYOUT[mips64] = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+LLVM_TARGET[mips64] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[mips64] = "big"
+TARGET_POINTER_WIDTH[mips64] = "64"
+TARGET_C_INT_WIDTH[mips64] = "64"
+MAX_ATOMIC_WIDTH[mips64] = "64"
+
+## mips64el-unknown-linux-{gnu, musl}
+DATA_LAYOUT[mips64el] = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+LLVM_TARGET[mips64el] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[mips64el] = "little"
+TARGET_POINTER_WIDTH[mips64el] = "64"
+TARGET_C_INT_WIDTH[mips64el] = "64"
+MAX_ATOMIC_WIDTH[mips64el] = "64"
+
+## powerpc-unknown-linux-{gnu, musl}
+DATA_LAYOUT[powerpc] = "E-m:e-p:32:32-i64:64-n32"
+LLVM_TARGET[powerpc] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[powerpc] = "big"
+TARGET_POINTER_WIDTH[powerpc] = "32"
+TARGET_C_INT_WIDTH[powerpc] = "32"
+MAX_ATOMIC_WIDTH[powerpc] = "32"
+
+## riscv32-unknown-linux-{gnu, musl}
+DATA_LAYOUT[riscv32] = "e-m:e-p:32:32-i64:64-n32-S128"
+LLVM_TARGET[riscv32] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[riscv32] = "little"
+TARGET_POINTER_WIDTH[riscv32] = "32"
+TARGET_C_INT_WIDTH[riscv32] = "32"
+MAX_ATOMIC_WIDTH[riscv32] = "32"
+
+## riscv64-unknown-linux-{gnu, musl}
+DATA_LAYOUT[riscv64] = "e-m:e-p:64:64-i64:64-i128:128-n64-S128"
+LLVM_TARGET[riscv64] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[riscv64] = "little"
+TARGET_POINTER_WIDTH[riscv64] = "64"
+TARGET_C_INT_WIDTH[riscv64] = "64"
+MAX_ATOMIC_WIDTH[riscv64] = "64"
+
+def arch_for(d, thing):
+    if thing == 'TARGET' and target_is_armv7(d):
+        return "armv7"
+    else:
+        return d.getVar('{}_ARCH'.format(thing))
+
+def sys_for(d, thing):
+    return d.getVar('{}_SYS'.format(thing))
+
+def prefix_for(d, thing):
+    return d.getVar('{}_PREFIX'.format(thing))
+
+# Convert a normal arch (HOST_ARCH, TARGET_ARCH, BUILD_ARCH, etc) to something
+# rust's internals won't choke on.
+def arch_to_rust_target_arch(arch):
+    if arch == "i586" or arch == "i686":
+        return "x86"
+    elif arch == "mipsel":
+        return "mips"
+    elif arch == "mip64sel":
+        return "mips64"
+    elif arch == "armv7":
+        return "arm"
+    else:
+        return arch
+
+# generates our target CPU value
+def llvm_cpu(d):
+    cpu = d.getVar('PACKAGE_ARCH')
+    target = d.getVar('TRANSLATED_TARGET_ARCH')
+
+    trans = {}
+    trans['corei7-64'] = "corei7"
+    trans['core2-32'] = "core2"
+    trans['x86-64'] = "x86-64"
+    trans['i686'] = "i686"
+    trans['i586'] = "i586"
+    trans['powerpc'] = "powerpc"
+    trans['mips64'] = "mips64"
+    trans['mips64el'] = "mips64"
+    trans['riscv64'] = "generic-rv64"
+    trans['riscv32'] = "generic-rv32"
+
+    if target in ["mips", "mipsel"]:
+        feat = frozenset(d.getVar('TUNE_FEATURES').split())
+        if "mips32r2" in feat:
+            trans['mipsel'] = "mips32r2"
+            trans['mips'] = "mips32r2"
+        elif "mips32" in feat:
+            trans['mipsel'] = "mips32"
+            trans['mips'] = "mips32"
+
+    try:
+        return trans[cpu]
+    except:
+        return trans.get(target, "generic")
+
+TARGET_LLVM_CPU="${@llvm_cpu(d)}"
+TARGET_LLVM_FEATURES = "${@llvm_features(d)}"
+
+# class-native implies TARGET=HOST, and TUNE_FEATURES only describes the real
+# (original) target.
+TARGET_LLVM_FEATURES_class-native = "${@','.join(llvm_features_from_cc_arch(d))}"
+
+def rust_gen_target(d, thing, wd, features, cpu):
+    import json
+    from distutils.version import LooseVersion
+    arch = arch_for(d, thing)
+    sys = sys_for(d, thing)
+    prefix = prefix_for(d, thing)
+
+    features = features or d.getVarFlag('FEATURES', arch) or ""
+    features = features.strip()
+
+    # build tspec
+    tspec = {}
+    tspec['llvm-target'] = d.getVarFlag('LLVM_TARGET', arch)
+    tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', arch)
+    tspec['max-atomic-width'] = int(d.getVarFlag('MAX_ATOMIC_WIDTH', arch))
+    tspec['target-pointer-width'] = d.getVarFlag('TARGET_POINTER_WIDTH', arch)
+    tspec['target-c-int-width'] = d.getVarFlag('TARGET_C_INT_WIDTH', arch)
+    tspec['target-endian'] = d.getVarFlag('TARGET_ENDIAN', arch)
+    tspec['arch'] = arch_to_rust_target_arch(arch)
+    tspec['os'] = "linux"
+    if "musl" in tspec['llvm-target']:
+        tspec['env'] = "musl"
+    else:
+        tspec['env'] = "gnu"
+    if "riscv64" in tspec['llvm-target']:
+        tspec['llvm-abiname'] = "lp64d"
+    if "riscv32" in tspec['llvm-target']:
+        tspec['llvm-abiname'] = "ilp32d"
+    tspec['vendor'] = "unknown"
+    tspec['target-family'] = "unix"
+    tspec['linker'] = "{}{}gcc".format(d.getVar('CCACHE'), prefix)
+    tspec['ar'] = "{}ar".format(prefix)
+    tspec['cpu'] = cpu
+    if features is not "":
+        tspec['features'] = features
+    tspec['dynamic-linking'] = True
+    tspec['executables'] = True
+    tspec['linker-is-gnu'] = True
+    tspec['linker-flavor'] = "gcc"
+    tspec['has-rpath'] = True
+    tspec['has-elf-tls'] = True
+    tspec['position-independent-executables'] = True
+    tspec['panic-strategy'] = d.getVar("RUST_PANIC_STRATEGY")
+
+    # Don't use jemalloc as it doesn't work for many targets.
+    # https://github.com/rust-lang/rust/pull/37392
+    # From 1.20.0 and forward, system allocator is the default.
+    if LooseVersion(d.getVar("PV")) < LooseVersion("1.20.0"):
+        tspec['exe-allocation-crate'] = "alloc_system"
+        tspec['lib-allocation-crate'] = "alloc_system"
+
+    # write out the target spec json file
+    with open(wd + sys + '.json', 'w') as f:
+        json.dump(tspec, f, indent=4)
+
+python do_rust_gen_targets () {
+    wd = d.getVar('WORKDIR') + '/targets/'
+    rust_gen_target(d, 'BUILD', wd, "", "generic")
+}
+
+addtask rust_gen_targets after do_patch before do_compile
+do_rust_gen_targets[dirs] += "${WORKDIR}/targets"
+
+do_rust_setup_snapshot () {
+    for installer in "${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do
+        "${installer}" --prefix="${WORKDIR}/rust-snapshot" --disable-ldconfig
+    done
+
+    # Some versions of rust (e.g. 1.18.0) tries to find cargo in stage0/bin/cargo
+    # and fail without it there.
+    mkdir -p ${RUSTSRC}/build/${BUILD_SYS}
+    ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${BUILD_SYS}/stage0
+}
+addtask rust_setup_snapshot after do_unpack before do_configure
+do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
+
+
+python do_configure() {
+    import json
+    from distutils.version import LooseVersion
+    try:
+        import configparser
+    except ImportError:
+        import ConfigParser as configparser
+
+    # toml is rather similar to standard ini like format except it likes values
+    # that look more JSON like. So for our purposes simply escaping all values
+    # as JSON seem to work fine.
+
+    e = lambda s: json.dumps(s)
+
+    config = configparser.RawConfigParser()
+
+    # [target.ARCH-poky-linux]
+    target_section = "target.{}".format(d.getVar('RUST_TARGET_SYS', True))
+    config.add_section(target_section)
+
+    # Points to wrapper files which contain target specific compiler and linker commands. 
+    config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
+    config.set(target_section, "linker", e(d.expand("${RUST_TARGET_CCLD}")))
+
+    # If we don't do this rust-native will compile it's own llvm for BUILD.
+    # [target.${BUILD_ARCH}-unknown-linux-gnu]
+    target_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS', True))
+    config.add_section(target_section)
+
+    # Wrapper scripts of build system.
+    config.set(target_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
+
+    # [rust]
+    config.add_section("rust")
+    config.set("rust", "rpath", e(True))
+    config.set("rust", "channel", e("stable"))
+
+    if LooseVersion(d.getVar("PV")) < LooseVersion("1.32.0"):
+        config.set("rust", "use-jemalloc", e(False))
+
+    # Whether or not to optimize the compiler and standard library
+    config.set("rust", "optimize", e(True))
+
+    # Emits extraneous output from tests to ensure that failures of the test
+    # harness are debuggable just from logfiles
+    config.set("rust", "verbose-tests", e(True))    
+
+    # [build]
+    config.add_section("build")
+    config.set("build", "submodules", e(False))
+    config.set("build", "docs", e(False))
+
+    rustc = d.expand("${WORKDIR}/rust-snapshot/bin/rustc")
+    config.set("build", "rustc", e(rustc))
+
+    cargo = d.expand("${WORKDIR}/rust-snapshot/bin/cargo")
+    config.set("build", "cargo", e(cargo))
+
+    config.set("build", "vendor", e(True))
+
+    # Here we are adding "RUST_TARGET_SYS" instead of "TARGET_SYS" as we are using rust supported target.
+    targets = [d.getVar("RUST_TARGET_SYS", True)]
+    config.set("build", "target", e(targets))
+
+    hosts = [d.getVar("SNAPSHOT_BUILD_SYS", True)]
+    config.set("build", "host", e(hosts))
+
+    # We can't use BUILD_SYS since that is something the rust snapshot knows
+    # nothing about when trying to build some stage0 tools (like fabricate)
+    config.set("build", "build", e(d.getVar("SNAPSHOT_BUILD_SYS", True)))
+
+    with open("config.toml", "w") as f:
+        config.write(f)
+
+    # set up ${WORKDIR}/cargo_home
+    bb.build.exec_func("setup_cargo_environment", d)
+}
+
+
+rust_runx () {
+    echo "COMPILE ${PN}" "$@"
+
+    # CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a
+    # wide range of targets (not just TARGET). Yocto's settings for them will
+    # be inappropriate, avoid using.
+    unset CFLAGS
+    unset LDFLAGS
+    unset CXXFLAGS
+    unset CPPFLAGS
+
+    oe_cargo_fix_env
+
+    python3 src/bootstrap/bootstrap.py ${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose
+}
+rust_runx[vardepsexclude] += "PARALLEL_MAKE"
+
+do_compile () {
+    rust_runx build
+}
+
+rust_do_install () {
+    mkdir -p ${D}${bindir}
+    cp build/${HOST_SYS}/stage2/bin/* ${D}${bindir}
+
+    mkdir -p ${D}${libdir}/rustlib
+    cp -pRd build/${HOST_SYS}/stage2/lib/* ${D}${libdir}
+    # Remove absolute symlink so bitbake doesn't complain
+    rm -f ${D}${libdir}/rustlib/src/rust
+
+    # Install our custom target.json files
+    local td="${D}${libdir}/rustlib/"
+    install -d "$td"
+    for tgt in "${WORKDIR}/targets/"* ; do
+        install -m 0644 "$tgt" "$td"
+    done
+}
+
+
+do_install () {
+    rust_do_install
+}
+# ex: sts=4 et sw=4 ts=8
meta/recipes-devtools/rust/rust-test_1.46.0.bb new file +12 -0
new file mode 100644
index 0000000000..b724ea5eb0
@@ -0,0 +1,12 @@
+require rust-test.inc
+require rust-source-${PV}.inc
+require rust-snapshot-${PV}.inc
+
+DEPENDS += "rust-llvm (=${PV})"
+
+# Otherwise we'll depend on what we provide
+INHIBIT_DEFAULT_RUST_DEPS_class-native = "1"
+# We don't need to depend on gcc-native because yocto assumes it exists
+PROVIDES_class-native = "virtual/${TARGET_PREFIX}rust"
+
+BBCLASSEXTEND = "native"
Signature · 1 line
2.17.1
#3 lore raw

PATCH 2/8 The function "do_compile" is to compile remote-test-server, and "do_check" to trigger the rust testing.

---
 meta/recipes-devtools/rust/rust-test.inc | 34 +++++++++---------------
 1 file changed, 13 insertions(+), 21 deletions(-)
meta/recipes-devtools/rust/rust-test.inc +13 -21
index 0d3eaa10cf..3a9b5b367c 100644
@@ -492,29 +492,21 @@ rust_runx () {
 }
 rust_runx[vardepsexclude] += "PARALLEL_MAKE"
 
+# We have to build target specific remote-test-server 
+# Reference link - https://rustc-dev-guide.rust-lang.org/tests/intro.html#running-tests-on-a-remote-machine
 do_compile () {
-    rust_runx build
+    rust_runx build src/tools/remote-test-server --target "${RUST_TARGET_SYS}"
 }
 
-rust_do_install () {
-    mkdir -p ${D}${bindir}
-    cp build/${HOST_SYS}/stage2/bin/* ${D}${bindir}
+# To test the rust
+# Copy remote-test-server to qemu-image and execute remote-test-server on qemu-image through ssh in background.
+do_check[dirs] += "${B}"
+do_check[nostamp] = "1"
+do_check () {
+    scp -P 2222 -o StrictHostKeyChecking=no build/${SNAPSHOT_BUILD_SYS}/stage2-tools-bin/remote-test-server [email protected]:~/
+    ssh -p 2222 -o StrictHostKeyChecking=no -f [email protected] "~/remote-test-server -v remote"
 
-    mkdir -p ${D}${libdir}/rustlib
-    cp -pRd build/${HOST_SYS}/stage2/lib/* ${D}${libdir}
-    # Remove absolute symlink so bitbake doesn't complain
-    rm -f ${D}${libdir}/rustlib/src/rust
-
-    # Install our custom target.json files
-    local td="${D}${libdir}/rustlib/"
-    install -d "$td"
-    for tgt in "${WORKDIR}/targets/"* ; do
-        install -m 0644 "$tgt" "$td"
-    done
-}
-
-
-do_install () {
-    rust_do_install
+    export TEST_DEVICE_ADDR="127.0.0.1:12345" 
+    rust_runx test --no-fail-fast --target "${RUST_TARGET_SYS}" > summary.txt 2> /dev/null
 }
-# ex: sts=4 et sw=4 ts=8
+addtask do_check after do_compile
Signature · 1 line
2.17.1
#4 lore raw

PATCH 3/8 The rust.py is oe-selftest script to build remote-test-server, qemu-image and boot image in slirp mode. Once the image gets booted throgh "check" the testing starts by copying the "remote-test-server" in to the image.

In reply to Vinay Kumar
---
 meta/lib/oeqa/selftest/cases/rust.py | 43 ++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/rust.py
meta/lib/oeqa/selftest/cases/rust.py new file +43 -0
new file mode 100644
index 0000000000..62851256c2
@@ -0,0 +1,43 @@
+# SPDX-License-Identifier: MIT
+import os
+from oeqa.core.decorator import OETestTag
+from oeqa.core.case import OEPTestResultTestCase
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars, runqemu, Command
+
+class RustSelfTestBase(OESelftestTestCase, OEPTestResultTestCase):
+
+	def run_check(self, *suites, ssh = None):
+		# configure ssh target
+		features = []
+		if ssh is not None:
+			features.append('TOOLCHAIN_TEST_TARGET = "ssh"')
+			features.append('TOOLCHAIN_TEST_HOST = "{0}"'.format(ssh))
+			features.append('TOOLCHAIN_TEST_HOST_USER = "root"')
+			features.append('TOOLCHAIN_TEST_HOST_PORT = "22"')
+		self.write_config("\n".join(features))
+
+		# Start testing once the remote-test-server is ready and image is booted.
+		recipe = "rust-test"
+		bitbake("{} -c check".format(recipe))
+
+	def run_check_emulated(self, *args, **kwargs):
+		# build remote-test-server before image build
+		recipe = "rust-test"	
+		bitbake("{} -c compile".format(recipe))
+
+		# build core-image-minimal with required packages
+		default_installed_packages = ["libgcc", "libstdc++", "libatomic", "libgomp"]
+		features = []
+		features.append('IMAGE_FEATURES += "ssh-server-openssh"')
+		features.append('CORE_IMAGE_EXTRA_INSTALL += "{0}"'.format(" ".join(default_installed_packages)))
+		self.write_config("\n".join(features))
+		bitbake("core-image-minimal")
+		# wrap the execution with a qemu instance
+		with runqemu("core-image-minimal", runqemuparams = "nographic slirp") as qemu:
+			return self.run_check(*args, ssh=qemu.ip, **kwargs)
+
+@OETestTag("toolchain-system")
+class RustSelfTestSystemEmulated(RustSelfTestBase):
+	def test_rust(self):
+		self.run_check_emulated("rust")
Signature · 1 line
2.17.1
#5 lore raw

PATCH 4/8 In rust testing we have to boot image in slirp mode along with qemu monitor via telnet. Also, we are passing "-serial mon:stdio -serial" to fix runtime errors like, "failed with Connection reset by peer" observed during execution on image.

In reply to Vinay Kumar
---
 meta/lib/oeqa/utils/qemurunner.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
meta/lib/oeqa/utils/qemurunner.py +8 -1
index 77ec939ad7..dd70a1d77d 100644
@@ -184,7 +184,14 @@ class QemuRunner:
         # and analyze descendents in order to determine it.
         if os.path.exists(self.qemu_pidfile):
             os.remove(self.qemu_pidfile)
-        self.qemuparams = 'bootparams="{0}" qemuparams="-pidfile {1}"'.format(bootparams, self.qemu_pidfile)
+
+        #In case of rust test we are explicitely passing slirp and qemu monitor via telnet.
+        if "slirp" in launch_cmd:
+            self.use_slirp = True
+            self.qemuparams = 'bootparams="{0}" qemuparams="-pidfile {1} -monitor telnet:127.0.0.1:1234,server,nowait -serial mon:stdio -serial null"'.format(bootparams, self.qemu_pidfile)
+        else:
+            self.qemuparams = 'bootparams="{0}" qemuparams="-pidfile {1}"'.format(bootparams, self.qemu_pidfile)
+
         if qemuparams:
             self.qemuparams = self.qemuparams[:-1] + " " + qemuparams + " " + '\"'
 
Signature · 1 line
2.17.1
#6 lore raw

PATCH 5/8 There are some error messages like, "error: linker `cc` not found" got fixed by adding "cc" in hosttools.

In reply to Vinay Kumar
---
 meta/conf/bitbake.conf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/conf/bitbake.conf +1 -1
index 3438be92b7..83e1b68071 100644
@@ -483,7 +483,7 @@ HOSTTOOLS_DIR = "${TMPDIR}/hosttools"
 HOSTTOOLS += " \
     [ ar as awk basename bash bzip2 cat chgrp chmod chown chrpath cmp comm cp cpio \
     cpp cut date dd diff diffstat dirname du echo egrep env expand expr false \
-    fgrep file find flock g++ gawk gcc getconf getopt git grep gunzip gzip \
+    fgrep file find flock g++ gawk gcc cc getconf getopt git grep gunzip gzip \
     head hostname iconv id install ld ldd ln ls make md5sum mkdir mkfifo mknod \
     mktemp mv nm objcopy objdump od patch perl pr printf pwd \
     python3 ranlib readelf readlink realpath rm rmdir rpcgen sed seq sh \
Signature · 1 line
2.17.1
#7 lore raw

Re: [OE-core] [PATCH 5/8] There are some error messages like, "error: linker `cc` not found" got fixed by adding "cc" in hosttools.

That doesn't look right to me - or it's not properly described - IMO CC should be picked from the recipe sysroot not the host tools, otherwise I see cases where cc silently falls back to host sided cc even for target recipes. Instead of patching host tools this should be addressed in the scope of rust invocation only

Quoted 18 lines · Vinay Kumar
meta/conf/bitbake.conf +1 -1
index 3438be92b7..83e1b68071 100644
@@ -483,7 +483,7 @@ HOSTTOOLS_DIR = "${TMPDIR}/hosttools"
  HOSTTOOLS += " \
      [ ar as awk basename bash bzip2 cat chgrp chmod chown chrpath cmp comm cp cpio \
      cpp cut date dd diff diffstat dirname du echo egrep env expand expr false \
-    fgrep file find flock g++ gawk gcc getconf getopt git grep gunzip gzip \
+    fgrep file find flock g++ gawk gcc cc getconf getopt git grep gunzip gzip \
      head hostname iconv id install ld ldd ln ls make md5sum mkdir mkfifo mknod \
      mktemp mv nm objcopy objdump od patch perl pr printf pwd \
      python3 ranlib readelf readlink realpath rm rmdir rpcgen sed seq sh \
#8 lore raw

Re: [OE-core] [PATCH 5/8] There are some error messages like, "error: linker `cc` not found" got fixed by adding "cc" in hosttools.

In reply to Vinay Kumar
Quoted 10 lines · Vinay Kumar

---
 meta/conf/bitbake.conf | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
meta/conf/bitbake.conf +0 -0
index 3438be92b7..83e1b68071 100644

meta/conf/bitbake.conf HOSTTOOLS_DIR = "${TMPDIR}/hosttools" · line 489

Quoted 8 lines
meta/conf/bitbake.conf +1 -1
@@ -483,7 +483,7 @@ HOSTTOOLS_DIR = "${TMPDIR}/hosttools"
  HOSTTOOLS += " \
      [ ar as awk basename bash bzip2 cat chgrp chmod chown chrpath cmp comm cp cpio \
      cpp cut date dd diff diffstat dirname du echo egrep env expand expr false \
-    fgrep file find flock g++ gawk gcc getconf getopt git grep gunzip gzip \
+    fgrep file find flock g++ gawk gcc cc getconf getopt git grep gunzip gzip \
      head hostname iconv id install ld ldd ln ls make md5sum mkdir mkfifo mknod \
      mktemp mv nm objcopy objdump od patch perl pr printf pwd \
      python3 ranlib readelf readlink realpath rm rmdir rpcgen sed seq sh \

I definitely agree this should be fixed elsewhere to use BUILD_CC. We've managed without 'cc' for this long, we shouldn't need to start now!

Also, I noticed your patches don't have shortlog entries so the subject lines in these emails are rather long. We'd need to have that fixed to be able to handle the patches.

Cheers,

Richard

#9 lore raw

PATCH v2 1/7 rust-testsuite.inc : Rust cross testing.

Below list of functions are part of rust-testsuite.inc setup_cargo_environment(): Build bootstrap and some early stage tools. do_rust_setup_snapshot(): Install the snapshot version of rust binaries. do_configure(): To generate config.toml
do_compile(): To build "remote-test-server" for qemutarget image. do_check(): To execute testing by copying remote-test-server to qmutarget image.

---
 meta/recipes-devtools/rust/rust-testsuite.inc | 166 ++++++++++++++++++
 1 file changed, 166 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-testsuite.inc
meta/recipes-devtools/rust/rust-testsuite.inc new file +166 -0
new file mode 100644
index 0000000000..d1c5496da4
@@ -0,0 +1,166 @@
+SUMMARY = "Rust testing"
+HOMEPAGE = "https://rustc-dev-guide.rust-lang.org/tests/intro.html"
+SECTION = "test"
+LICENSE = "MIT | Apache-2.0"
+
+inherit rust
+inherit cargo_common
+
+DEPENDS += "file-native python3-native"
+EXCLUDE_FROM_WORLD = "1"
+
+# Path of target specification file "target-poky-linux.json"
+export RUST_TARGET_PATH="${STAGING_LIBDIR_NATIVE}/rustlib"
+
+export FORCE_CRATE_HASH="${BB_TASKHASH}"
+
+# We don't want to use bitbakes vendoring because the rust sources do their
+# own vendoring.
+CARGO_DISABLE_BITBAKE_VENDORING = "1"
+
+# We can't use RUST_BUILD_SYS here because that may be "musl" if
+# TCLIBC="musl". Snapshots are always -unknown-linux-gnu
+SNAPSHOT_BUILD_SYS = "${BUILD_ARCH}-unknown-linux-gnu"
+setup_cargo_environment () {
+    # The first step is to build bootstrap and some early stage tools,
+    # these are build for the same target as the snapshot, e.g.
+    # x86_64-unknown-linux-gnu.
+    # Later stages are build for the native target (i.e. target.x86_64-linux)
+    cargo_common_do_configure
+
+    printf '[target.%s]\n' "${SNAPSHOT_BUILD_SYS}" >> ${CARGO_HOME}/config
+    printf "linker = '%s'\n" "${RUST_BUILD_CCLD}" >> ${CARGO_HOME}/config
+}
+
+do_rust_setup_snapshot () {
+    for installer in "${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do
+        "${installer}" --prefix="${WORKDIR}/rust-snapshot" --disable-ldconfig
+    done
+
+    # Some versions of rust (e.g. 1.18.0) tries to find cargo in stage0/bin/cargo
+    # and fail without it there.
+    mkdir -p ${RUSTSRC}/build/${BUILD_SYS}
+    ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${BUILD_SYS}/stage0
+}
+addtask rust_setup_snapshot after do_unpack before do_configure
+do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
+
+python do_configure() {
+    import json
+    from distutils.version import LooseVersion
+    try:
+        import configparser
+    except ImportError:
+        import ConfigParser as configparser
+
+    # toml is rather similar to standard ini like format except it likes values
+    # that look more JSON like. So for our purposes simply escaping all values
+    # as JSON seem to work fine.
+
+    e = lambda s: json.dumps(s)
+
+    config = configparser.RawConfigParser()
+
+    # [target.ARCH-unknown-linux-gnu] in case of x86_64 [target.ARCH-poky-linux] 
+    target_section = "target.{}".format(d.getVar('TARGET_SYS', True))
+    config.add_section(target_section)
+
+    # Points to wrapper files which contain target specific compiler and linker commands. 
+    config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
+    config.set(target_section, "linker", e(d.expand("${RUST_TARGET_CCLD}")))
+
+    # If we don't do this rust-native will compile it's own llvm for BUILD.
+    # [target.${BUILD_ARCH}-unknown-linux-gnu]
+    target_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS', True))
+    config.add_section(target_section)
+
+    # Wrapper scripts of build system.
+    config.set(target_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
+
+    # [llvm]
+    config.add_section("llvm")
+    config.set("llvm", "targets", e("ARM;AArch64;Mips;PowerPC;RISCV;X86"))
+
+    # [rust]
+    config.add_section("rust")
+    config.set("rust", "rpath", e(True))
+    config.set("rust", "channel", e("stable"))
+
+    if LooseVersion(d.getVar("PV")) < LooseVersion("1.32.0"):
+        config.set("rust", "use-jemalloc", e(False))
+
+    # Whether or not to optimize the compiler and standard library
+    config.set("rust", "optimize", e(True))
+
+    # Emits extraneous output from tests to ensure that failures of the test
+    # harness are debuggable just from logfiles
+    config.set("rust", "verbose-tests", e(True))    
+
+    # Override default linker cc.
+    config.set("rust", "default-linker", e(d.expand("${RUST_BUILD_CCLD}")))
+
+    # [build]
+    config.add_section("build")
+    config.set("build", "submodules", e(False))
+    config.set("build", "docs", e(False))
+
+    rustc = d.expand("${WORKDIR}/rust-snapshot/bin/rustc")
+    config.set("build", "rustc", e(rustc))
+
+    cargo = d.expand("${WORKDIR}/rust-snapshot/bin/cargo")
+    config.set("build", "cargo", e(cargo))
+
+    config.set("build", "vendor", e(True))
+
+    targets = [d.getVar("TARGET_SYS", True)]
+    config.set("build", "target", e(targets))
+
+    hosts = [d.getVar("SNAPSHOT_BUILD_SYS", True)]
+    config.set("build", "host", e(hosts))
+
+    # We can't use BUILD_SYS since that is something the rust snapshot knows
+    # nothing about when trying to build some stage0 tools (like fabricate)
+    config.set("build", "build", e(d.getVar("SNAPSHOT_BUILD_SYS", True)))
+
+    with open("config.toml", "w") as f:
+        config.write(f)
+
+    # set up ${WORKDIR}/cargo_home
+    bb.build.exec_func("setup_cargo_environment", d)
+}
+
+
+rust_runx () {
+    echo "COMPILE ${PN}" "$@"
+
+    # CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a
+    # wide range of targets (not just TARGET). Yocto's settings for them will
+    # be inappropriate, avoid using.
+    unset CFLAGS
+    unset LDFLAGS
+    unset CXXFLAGS
+    unset CPPFLAGS
+
+    oe_cargo_fix_env
+
+    python3 src/bootstrap/bootstrap.py ${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose
+}
+rust_runx[vardepsexclude] += "PARALLEL_MAKE"
+
+do_compile () {
+
+    rust_runx build src/tools/remote-test-server --target "${TARGET_SYS}"
+}
+
+do_check[dirs] += "${B}"
+do_check[nostamp] = "1"
+do_check () {
+    scp -P 2222 -o StrictHostKeyChecking=no build/${SNAPSHOT_BUILD_SYS}/stage2-tools-bin/remote-test-server [email protected]:~/
+    ssh -p 2222 -o StrictHostKeyChecking=no -f [email protected] "~/remote-test-server -v remote"
+
+    export TEST_DEVICE_ADDR="127.0.0.1:12345"
+    rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" > summary.txt 2> /dev/null
+}
+addtask do_check after do_compile
Signature · 1 line
2.17.1
#10 lore raw

PATCH v2 2/7 Add rust testsuite for 1.46.0

---
 meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb | 3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb
meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb new file +3 -0
new file mode 100644
index 0000000000..ad758b71f4
@@ -0,0 +1,3 @@
+require rust-testsuite.inc
+require rust-source-${PV}.inc
+require rust-snapshot-${PV}.inc
Signature · 1 line
2.17.1
#11 lore raw

PATCH v2 3/7 rust.inc : Changed target cpu for powerpc to "7400"

In reply to Vinay Kumar

While executing rust-testing observed some ui testfailures due to below warning message.

'powerpc' is not a recognized processor for this target in rust

So renamed target cpu for "powerpc" in "llvm_cpu" to "7400" as per default tune for qemuppc.

---
 meta/recipes-devtools/rust/rust.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/rust/rust.inc +1 -1
index a1223f45e7..ee3176b559 100644
@@ -290,7 +290,7 @@ def llvm_cpu(d):
     trans['x86-64'] = "x86-64"
     trans['i686'] = "i686"
     trans['i586'] = "i586"
-    trans['powerpc'] = "powerpc"
+    trans['powerpc'] = "7400"
     trans['mips64'] = "mips64"
     trans['mips64el'] = "mips64"
     trans['riscv64'] = "generic-rv64"
Signature · 1 line
2.17.1
#12 lore raw

PATCH v2 4/7 runqemu: Add hostfwd for rust testing.

In reply to Vinay Kumar

Set hostfwd for rust 12345 -> 12345. This port is used for "remote-test-server" and "remote-test-client" communication while executing on qemutarget remotely.

---
 scripts/runqemu | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/runqemu +2 -1
index dd92a64553..9569dbe72f 100755
@@ -1056,7 +1056,8 @@ class BaseConfig(object):
         self.kernel_cmdline_script += netconf
         # Port mapping
         hostfwd = ",hostfwd=tcp::2222-:22,hostfwd=tcp::2323-:23"
-        qb_slirp_opt_default = "-netdev user,id=net0%s,tftp=%s" % (hostfwd, self.get('DEPLOY_DIR_IMAGE'))
+        rustport = "hostfwd=tcp::12345-:12345"
+        qb_slirp_opt_default = "-netdev user,id=net0%s,%s,tftp=%s" % (hostfwd, rustport, self.get('DEPLOY_DIR_IMAGE'))
         qb_slirp_opt = self.get('QB_SLIRP_OPT') or qb_slirp_opt_default
         # Figure out the port
         ports = re.findall('hostfwd=[^-]*:([0-9]+)-[^,-]*', qb_slirp_opt)
Signature · 1 line
2.17.1
#13 lore raw

Re: [PATCH v2 4/7] runqemu: Add hostfwd for rust testing.

This is better to set via QB_SLIRP_OPT, rather than hardcode a special case directly into the script.

Alex

Quoted 29 lines · Vinay Kumar

Set hostfwd for rust 12345 -> 12345. This port is used for "remote-test-server" and "remote-test-client" communication while executing on qemutarget remotely.

---
 scripts/runqemu | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/runqemu +2 -1
index dd92a64553..9569dbe72f 100755
@@ -1056,7 +1056,8 @@ class BaseConfig(object):
         self.kernel_cmdline_script += netconf
         # Port mapping
         hostfwd = ",hostfwd=tcp::2222-:22,hostfwd=tcp::2323-:23"
-        qb_slirp_opt_default = "-netdev user,id=net0%s,tftp=%s" %
 (hostfwd, self.get('DEPLOY_DIR_IMAGE'))
+        rustport = "hostfwd=tcp::12345-:12345"
+        qb_slirp_opt_default = "-netdev user,id=net0%s,%s,tftp=%s" %
 (hostfwd, rustport, self.get('DEPLOY_DIR_IMAGE'))
         qb_slirp_opt = self.get('QB_SLIRP_OPT') or qb_slirp_opt_default

# Figure out the port
ports = re.findall('hostfwd=[^-]*:([0-9]+)-[^,-]*', qb_slirp_opt)
--
2.17.1

#14 lore raw

PATCH v2 5/7 oeqa/utils/qemurunner.py: Enable self.use_slirp

In reply to Vinay Kumar

The qemu is booted with slirp mode. We are setting "self.use_slirp" as "True" to avoid the error during qemuboot.

ERROR: Couldn't get ip from qemu command line and runqemu output! Here is the qemu command line used:

We are setting "self.use_slirp=True" only when "slirp" is passed "launch_cmd" through "runqemuparams".

---
 meta/lib/oeqa/utils/qemurunner.py | 2 ++
 1 file changed, 2 insertions(+)
meta/lib/oeqa/utils/qemurunner.py +2 -0
index 77ec939ad7..13abf6690d 100644
@@ -184,6 +184,8 @@ class QemuRunner:
         # and analyze descendents in order to determine it.
         if os.path.exists(self.qemu_pidfile):
             os.remove(self.qemu_pidfile)
+        if "slirp" in launch_cmd:
+            self.use_slirp=True
         self.qemuparams = 'bootparams="{0}" qemuparams="-pidfile {1}"'.format(bootparams, self.qemu_pidfile)
         if qemuparams:
             self.qemuparams = self.qemuparams[:-1] + " " + qemuparams + " " + '\"'
Signature · 1 line
2.17.1
#15 lore raw

Re: [PATCH v2 5/7] oeqa/utils/qemurunner.py: Enable self.use_slirp

Quoted 18 lines · Vinay Kumar

The qemu is booted with slirp mode. We are setting "self.use_slirp" as "True" to avoid the error during qemuboot.

ERROR: Couldn't get ip from qemu command line and runqemu output! Here is the qemu command line used:

We are setting "self.use_slirp=True" only when "slirp" is passed "launch_cmd" through "runqemuparams".

---
  meta/lib/oeqa/utils/qemurunner.py | 2 ++
  1 file changed, 2 insertions(+)
meta/lib/oeqa/utils/qemurunner.py +0 -0
index 77ec939ad7..13abf6690d 100644

meta/lib/oeqa/utils/qemurunner.py class QemuRunner: · line 188

Quoted 5 lines
meta/lib/oeqa/utils/qemurunner.py +2 -0
@@ -184,6 +184,8 @@ class QemuRunner:
          # and analyze descendents in order to determine it.
          if os.path.exists(self.qemu_pidfile):
              os.remove(self.qemu_pidfile)
+        if "slirp" in launch_cmd:
+            self.use_slirp=True

That doesn't look right to me - AFAIK slirp mode is activated from the outside (by the class constructor) so it's the choice of the user to enable slirp or not. With this change a launchcmd containing image=this-is-a-non-slirp-image.tar.gz would accidentally activate the option.

I truly think this should be only set as part of the init() function and not at this point

Quoted 4 lines
meta/lib/oeqa/utils/qemurunner.py +0 -0
          self.qemuparams = 'bootparams="{0}" qemuparams="-pidfile {1}"'.format(bootparams, self.qemu_pidfile)
          if qemuparams:
              self.qemuparams = self.qemuparams[:-1] + " " + qemuparams + " " + '\"'
#16 lore raw

PATCH v2 6/7 oeqa/selftest/cases/rust.py: Rust oe-selftest script.

In reply to Vinay Kumar

The rust test involves qemuimage for testing, so "run_check_emulated" involves building of "remote-test-server", qemuimage and test execution.

We are booting qemuimage in "nographic" and "slirp" mode along with additional qemuparams,
'-monitor telnet:127.0.0.1:1234,server,nowait -serial mon:stdio -serial null'

Note:
'-serial mon:stdio -serial' : To fix below run-time errors while testing "failed with Connection reset by peer"

---
 meta/lib/oeqa/selftest/cases/rust.py | 32 ++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/rust.py
meta/lib/oeqa/selftest/cases/rust.py new file +32 -0
new file mode 100644
index 0000000000..4efbf9306f
@@ -0,0 +1,32 @@
+# SPDX-License-Identifier: MIT
+import os
+from oeqa.core.decorator import OETestTag
+from oeqa.core.case import OEPTestResultTestCase
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars, runqemu, Command
+
+class RustSelfTestBase(OESelftestTestCase, OEPTestResultTestCase):
+
+	def run_check_emulated(self, *args, **kwargs):
+		# build remote-test-server before image build
+		recipe = "rust-testsuite"	
+		bitbake("{} -c compile".format(recipe))
+
+		# build core-image-minimal with required packages
+		default_installed_packages = ["libgcc", "libstdc++", "libatomic", "libgomp"]
+		features = []
+		features.append('IMAGE_FEATURES += "ssh-server-openssh"')
+		features.append('CORE_IMAGE_EXTRA_INSTALL += "{0}"'.format(" ".join(default_installed_packages)))
+		self.write_config("\n".join(features))
+		bitbake("core-image-minimal")
+		# wrap the execution with a qemu instance
+		with runqemu("core-image-minimal", runqemuparams = "nographic slirp", qemuparams= " -monitor \
+                        telnet:127.0.0.1:1234,server,nowait -serial mon:stdio -serial null") as qemu:
+			recipe = "rust-testsuite"
+			bitbake("{} -c check".format(recipe))
+
+
+@OETestTag("toolchain-system")
+class RustSelfTestSystemEmulated(RustSelfTestBase):
+	def test_rust(self):
+		self.run_check_emulated("rust")
Signature · 1 line
2.17.1
#17 lore raw

Re: [PATCH v2 6/7] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Is slirp really required? Is it possible to use the standard tap setup instead?

Alex

Quoted 67 lines · Vinay Kumar

The rust test involves qemuimage for testing, so "run_check_emulated" involves building of "remote-test-server", qemuimage and test execution.

We are booting qemuimage in "nographic" and "slirp" mode along with additional qemuparams,
'-monitor telnet:127.0.0.1:1234,server,nowait -serial mon:stdio -serial null'

Note:
'-serial mon:stdio -serial' : To fix below run-time errors while testing "failed with Connection reset by peer"

---
 meta/lib/oeqa/selftest/cases/rust.py | 32 ++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/rust.py
meta/lib/oeqa/selftest/cases/rust.py new file +6 -0
new file mode 100644
index 0000000000..4efbf9306f
@@ -0,0 +1,32 @@
+# SPDX-License-Identifier: MIT
+import os
+from oeqa.core.decorator import OETestTag
+from oeqa.core.case import OEPTestResultTestCase
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars,

runqemu, Command

meta/lib/oeqa/selftest/cases/rust.py new file +10 -0
+
+class RustSelfTestBase(OESelftestTestCase, OEPTestResultTestCase):
+
+       def run_check_emulated(self, *args, **kwargs):
+               # build remote-test-server before image build
+               recipe = "rust-testsuite"
+               bitbake("{} -c compile".format(recipe))
+
+               # build core-image-minimal with required packages
+               default_installed_packages = ["libgcc", "libstdc++",

"libatomic", "libgomp"]

meta/lib/oeqa/selftest/cases/rust.py new file +3 -0
+               features = []
+               features.append('IMAGE_FEATURES += "ssh-server-openssh"')
+               features.append('CORE_IMAGE_EXTRA_INSTALL +=

"{0}"'.format(" ".join(default_installed_packages)))

meta/lib/oeqa/selftest/cases/rust.py new file +4 -0
+               self.write_config("\n".join(features))
+               bitbake("core-image-minimal")
+               # wrap the execution with a qemu instance
+               with runqemu("core-image-minimal", runqemuparams =

"nographic slirp", qemuparams= " -monitor \
+ telnet:127.0.0.1:1234,server,nowait -serial
mon:stdio -serial null") as qemu:

meta/lib/oeqa/selftest/cases/rust.py new file +8 -1
+                       recipe = "rust-testsuite"
+                       bitbake("{} -c check".format(recipe))
+
+
+@OETestTag("toolchain-system")
+class RustSelfTestSystemEmulated(RustSelfTestBase):
+       def test_rust(self):
+               self.run_check_emulated("rust")
--

2.17.1

#18 lore raw

Re: [PATCH v2 6/7] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Hi Alex,

"remote-test-server" on qemu-image with a tap interface throws an error. The emulators for rust testing are with tcp port forwarding so used slirp method with added rust port.

References:
https://github.com/rust-lang/rust/issues/33114
https://github.com/rust-lang/rust/blob/master/src/tools/remote-test-client/src/main.rs

Regards,
Vinay

Regards,
Vinay

Quoted 66 lines · Alexander Kanavin

Is slirp really required? Is it possible to use the standard tap setup instead?

Alex

Quoted 60 lines · Vinay Kumar

The rust test involves qemuimage for testing, so "run_check_emulated" involves building of "remote-test-server", qemuimage and test execution.

We are booting qemuimage in "nographic" and "slirp" mode along with additional qemuparams,
'-monitor telnet:127.0.0.1:1234,server,nowait -serial mon:stdio -serial null'

Note:
'-serial mon:stdio -serial' : To fix below run-time errors while testing "failed with Connection reset by peer"

---
 meta/lib/oeqa/selftest/cases/rust.py | 32 ++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/rust.py
meta/lib/oeqa/selftest/cases/rust.py new file +32 -1
new file mode 100644
index 0000000000..4efbf9306f
@@ -0,0 +1,32 @@
+# SPDX-License-Identifier: MIT
+import os
+from oeqa.core.decorator import OETestTag
+from oeqa.core.case import OEPTestResultTestCase
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars, runqemu, Command
+
+class RustSelfTestBase(OESelftestTestCase, OEPTestResultTestCase):
+
+       def run_check_emulated(self, *args, **kwargs):
+               # build remote-test-server before image build
+               recipe = "rust-testsuite"
+               bitbake("{} -c compile".format(recipe))
+
+               # build core-image-minimal with required packages
+               default_installed_packages = ["libgcc", "libstdc++", "libatomic", "libgomp"]
+               features = []
+               features.append('IMAGE_FEATURES += "ssh-server-openssh"')
+               features.append('CORE_IMAGE_EXTRA_INSTALL += "{0}"'.format(" ".join(default_installed_packages)))
+               self.write_config("\n".join(features))
+               bitbake("core-image-minimal")
+               # wrap the execution with a qemu instance
+               with runqemu("core-image-minimal", runqemuparams = "nographic slirp", qemuparams= " -monitor \
+                        telnet:127.0.0.1:1234,server,nowait -serial mon:stdio -serial null") as qemu:
+                       recipe = "rust-testsuite"
+                       bitbake("{} -c check".format(recipe))
+
+
+@OETestTag("toolchain-system")
+class RustSelfTestSystemEmulated(RustSelfTestBase):
+       def test_rust(self):
+               self.run_check_emulated("rust")
--

2.17.1

#19 lore raw

Re: [PATCH v2 6/7] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Quoted 3 lines · Vinay Kumar

"remote-test-server" on qemu-image with a tap interface throws an error. The emulators for rust testing are with tcp port forwarding so used slirp method with added rust port.

I'm not sure I understand - what kind of error? In both cases the server starts listening on a port, so in slirp scenario the address is 127.0.0.1:12345 (prone to breakage if something else on the build host took that port btw, including another instance of the same test), in tap it would be 192.168.7.2:12345. For the client you simply supply that via TEST_DEVICE_ADDR. No?

Alex

#20 lore raw

Re: [PATCH v2 6/7] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Hi Alex,

Error on qemu image (ex. Aarch64) booted with tap interface.
===========================

root@qemuarm64:~# ./remote-test-server
starting test server
thread 'main' panicked at 'TcpListener::bind(bind_addr) failed with
Cannot assign requested address (os error 99)',
src/tools/remote-test-server/src/main.rs:90:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
===========================
Quoted 11 lines · Alexander Kanavin
Quoted 4 lines · Vinay Kumar

"remote-test-server" on qemu-image with a tap interface throws an error. The emulators for rust testing are with tcp port forwarding so used slirp method with added rust port.

I'm not sure I understand - what kind of error? In both cases the server starts listening on a port, so in slirp scenario the address is 127.0.0.1:12345 (prone to breakage if something else on the build host took that port btw, including another instance of the same test), in tap it would be 192.168.7.2:12345. For the client you simply supply that via TEST_DEVICE_ADDR. No?

Alex

#21 lore raw

Re: [PATCH v2 6/7] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Thanks, can you please look into the error? The line where it happens and the way to get a backtrace is right there :)
There's no reason it shouldn't work.

Alex

Quoted 33 lines · Vinay Kumar

Hi Alex,

Error on qemu image (ex. Aarch64) booted with tap interface.
===========================

root@qemuarm64:~# ./remote-test-server
starting test server
thread 'main' panicked at 'TcpListener::bind(bind_addr) failed with
Cannot assign requested address (os error 99)',
src/tools/remote-test-server/src/main.rs:90:20
note: run with `RUST_BACKTRACE=1` environment variable to display a
backtrace
===========================
Quoted 2 lines · Alexander Kanavin

On Mon, 17 May 2021 at 13:34, Vinay Kumar <[email protected]>

Quoted 7 lines · wrote:
Quoted 4 lines

"remote-test-server" on qemu-image with a tap interface throws an error. The emulators for rust testing are with tcp port forwarding so used slirp method with added rust port.

I'm not sure I understand - what kind of error? In both cases the server

starts listening on a port, so in slirp scenario the address is 127.0.0.1:12345 (prone to breakage if something else on the build host took that port btw, including another instance of the same test), in tap it would be 192.168.7.2:12345. For the client you simply supply that via TEST_DEVICE_ADDR. No?

Quoted 2 lines

Alex

#22 lore raw

Re: [PATCH v2 6/7] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Checking suggestions, the booted image with tap seems to be working by passing "-monitor telnet:127.0.0.1:1234,server,nowait"
so I will execute testing and update you.
==========================

root@qemuarm64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.4  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:116 errors:0 dropped:0 overruns:0 frame:0
          TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:945121 (922.9 KiB)  TX bytes:9529 (9.3 KiB)
root@qemuarm64:~# ./remote-test-server -v remote
starting test server
listening on 0.0.0.0:12345!
==========================

Regards,
Vinay

Quoted 33 lines · Alexander Kanavin

Thanks, can you please look into the error? The line where it happens and the way to get a backtrace is right there :) There's no reason it shouldn't work.

Alex

Quoted 26 lines · Vinay Kumar

Hi Alex,

Error on qemu image (ex. Aarch64) booted with tap interface.
===========================

root@qemuarm64:~# ./remote-test-server
starting test server
thread 'main' panicked at 'TcpListener::bind(bind_addr) failed with
Cannot assign requested address (os error 99)',
src/tools/remote-test-server/src/main.rs:90:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
===========================
Quoted 11 lines · Alexander Kanavin
Quoted 4 lines · Vinay Kumar

"remote-test-server" on qemu-image with a tap interface throws an error. The emulators for rust testing are with tcp port forwarding so used slirp method with added rust port.

I'm not sure I understand - what kind of error? In both cases the server starts listening on a port, so in slirp scenario the address is 127.0.0.1:12345 (prone to breakage if something else on the build host took that port btw, including another instance of the same test), in tap it would be 192.168.7.2:12345. For the client you simply supply that via TEST_DEVICE_ADDR. No?

Alex

#23 lore raw

Re: [PATCH v2 6/7] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Hi Alex,

Tried testing outside oe-selftest framework, it works fine without any errors,

export TEST_DEVICE_ADDR="192.168.7.4:12345"
rust_runx test --no-fail-fast --bless --target "aarch64-poky-linux" > summary.txt 2> /dev/null

Also, log (summary.txt) shows "remote-test-client" is connecting to
the image without any issue.
=======================================
running: "/ala-lpggp31/vinay/review-2/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/x86_64-unknown-linux-gnu/stage0-tools-bin/remote-test-client" "spawn-emulator" "aarch64-poky-linux" "/ala-lpggp31/vinay/review-2/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/x86_64-unknown-linux-gnu/stage0-tools-bin/remote-test-server" "/ala-lpggp31/vinay/review-2/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/tmp"
Connecting to remote device 192.168.7.4:12345 ...

Will integrate these changes in oe-selftest and let you know.

Regards,
Vinay

Quoted 58 lines · Vinay Kumar

Checking suggestions, the booted image with tap seems to be working by passing "-monitor telnet:127.0.0.1:1234,server,nowait"
so I will execute testing and update you.
==========================

root@qemuarm64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.4  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:116 errors:0 dropped:0 overruns:0 frame:0
          TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:945121 (922.9 KiB)  TX bytes:9529 (9.3 KiB)
root@qemuarm64:~# ./remote-test-server -v remote
starting test server
listening on 0.0.0.0:12345!
==========================

Regards,
Vinay

Quoted 33 lines · Alexander Kanavin

Thanks, can you please look into the error? The line where it happens and the way to get a backtrace is right there :) There's no reason it shouldn't work.

Alex

Quoted 26 lines · Vinay Kumar

Hi Alex,

Error on qemu image (ex. Aarch64) booted with tap interface.
===========================

root@qemuarm64:~# ./remote-test-server
starting test server
thread 'main' panicked at 'TcpListener::bind(bind_addr) failed with
Cannot assign requested address (os error 99)',
src/tools/remote-test-server/src/main.rs:90:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
===========================
Quoted 11 lines · Alexander Kanavin
Quoted 4 lines · Vinay Kumar

"remote-test-server" on qemu-image with a tap interface throws an error. The emulators for rust testing are with tcp port forwarding so used slirp method with added rust port.

I'm not sure I understand - what kind of error? In both cases the server starts listening on a port, so in slirp scenario the address is 127.0.0.1:12345 (prone to breakage if something else on the build host took that port btw, including another instance of the same test), in tap it would be 192.168.7.2:12345. For the client you simply supply that via TEST_DEVICE_ADDR. No?

Alex

A message that is not in the archive (sent off-list or not yet received): [email protected]

#25 lore raw

Re: [OE-core] [PATCH v2 6/7] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Hi Alex,

Tried your suggestions to copy and run in rust.py without any issue as below.
===============================
builddir = get_bb_var("B", "rust-testsuite")
ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user="root", timeout=600) ssh.copy_to(builddir + "/" + "build/x86_64-unknown-linux-gnu/stage2-tools-bin/remote-test-server","~/") t_thread = threading.Thread(target=ssh.run, args=("~/remote-test-server -v remote",))
t_thread.start()
===============================

If we set "TEST_DEVICE_ADDR" in rust.py through "runCmd" as shown below, the remote-test-client does not connect to the image. So a lot of tests fail.
===============================
"cmd = "export TEST_DEVICE_ADDR=%s:12345;" % qemu.ip" runCmd(cmd)
bitbake("{} -c check".format(recipe))
===============================

Also, I tried to move do_check content to rust.py without any success.
===============================
cmd = "export PATH=%s/../recipe-sysroot-native/usr/lib/rustlib/:" % builddir cmd= cmd + "%s/../recipe-sysroot-native/usr/bin:$PATH;" % builddir cmd = cmd + "export RUST_TARGET_PATH=%s/../recipe-sysroot-native/usr/lib/rustlib/;" % builddir
cmd = cmd + "cd " + builddir + ";"
cmd = "export TEST_DEVICE_ADDR=\"%s:12345\";" % qemu.ip
cmd = cmd + "python3 src/bootstrap/bootstrap.py -j 40 --verbose test --no-fail-fast --bless --target aarch64-poky-linux > summary.txt 2>&1"

Error:
File "/ala-lpggp31/vinay/review-2/poky-contrib/meta/lib/oeqa/utils/commands.py", line 210, in runCmd
raise AssertionError("Command '%s' returned non-zero exit status %d:\n%s" % (command, result.status, exc_output))
AssertionError: Command 'export TEST_DEVICE_ADDR="192.168.7.2:12345";python3 src/bootstrap/bootstrap.py -j 40 --verbose test --no-fail-fast --bless --target aarch64-poky-linux > summary.txt 2>&1' returned non-zero exit status 2:
===============================

So in rust.py only copy and execution of "remote-test-server" is taken care of. And the test execution is by do_check of rust-testsuite.inc as below,
===============================

do_check () {
    export TEST_DEVICE_ADDR="192.168.7.2:12345"
    rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" >

summary.txt 2> /dev/null
}

Let me know if this ok. will send patches with changes for review.

Regards,
Vinay

Quoted 85 lines · Vinay Kumar via lists.openembedded.org

Hi Alex,

Tried testing outside oe-selftest framework, it works fine without any errors,

export TEST_DEVICE_ADDR="192.168.7.4:12345"
rust_runx test --no-fail-fast --bless --target "aarch64-poky-linux" > summary.txt 2> /dev/null

Also, log (summary.txt) shows "remote-test-client" is connecting to
the image without any issue.
=======================================
running: "/ala-lpggp31/vinay/review-2/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/x86_64-unknown-linux-gnu/stage0-tools-bin/remote-test-client" "spawn-emulator" "aarch64-poky-linux" "/ala-lpggp31/vinay/review-2/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/x86_64-unknown-linux-gnu/stage0-tools-bin/remote-test-server" "/ala-lpggp31/vinay/review-2/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/tmp"
Connecting to remote device 192.168.7.4:12345 ...

Will integrate these changes in oe-selftest and let you know.

Regards,
Vinay

Quoted 58 lines · Vinay Kumar

Checking suggestions, the booted image with tap seems to be working by passing "-monitor telnet:127.0.0.1:1234,server,nowait"
so I will execute testing and update you.
==========================

root@qemuarm64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.4  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:116 errors:0 dropped:0 overruns:0 frame:0
          TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:945121 (922.9 KiB)  TX bytes:9529 (9.3 KiB)
root@qemuarm64:~# ./remote-test-server -v remote
starting test server
listening on 0.0.0.0:12345!
==========================

Regards,
Vinay

Quoted 33 lines · Alexander Kanavin

Thanks, can you please look into the error? The line where it happens and the way to get a backtrace is right there :) There's no reason it shouldn't work.

Alex

Quoted 26 lines · Vinay Kumar

Hi Alex,

Error on qemu image (ex. Aarch64) booted with tap interface.
===========================

root@qemuarm64:~# ./remote-test-server
starting test server
thread 'main' panicked at 'TcpListener::bind(bind_addr) failed with
Cannot assign requested address (os error 99)',
src/tools/remote-test-server/src/main.rs:90:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
===========================
Quoted 11 lines · Alexander Kanavin
Quoted 4 lines · Vinay Kumar

"remote-test-server" on qemu-image with a tap interface throws an error. The emulators for rust testing are with tcp port forwarding so used slirp method with added rust port.

I'm not sure I understand - what kind of error? In both cases the server starts listening on a port, so in slirp scenario the address is 127.0.0.1:12345 (prone to breakage if something else on the build host took that port btw, including another instance of the same test), in tap it would be 192.168.7.2:12345. For the client you simply supply that via TEST_DEVICE_ADDR. No?

Alex

#26 lore raw

Re: [OE-core] [PATCH v2 6/7] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

You cannot hardcode the ip address like that; it's set dynamically when qemu starts, and you can only access it from selftest or runtime test.

Alex

Quoted 169 lines · Vinay Kumar

Hi Alex,

Tried your suggestions to copy and run in rust.py without any issue as below.
===============================
builddir = get_bb_var("B", "rust-testsuite")
ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user="root", timeout=600) ssh.copy_to(builddir + "/" + "build/x86_64-unknown-linux-gnu/stage2-tools-bin/remote-test-server","~/") t_thread = threading.Thread(target=ssh.run, args=("~/remote-test-server -v remote",))
t_thread.start()
===============================

If we set "TEST_DEVICE_ADDR" in rust.py through "runCmd" as shown below, the remote-test-client does not connect to the image. So a lot of tests fail.
===============================
"cmd = "export TEST_DEVICE_ADDR=%s:12345;" % qemu.ip" runCmd(cmd)
bitbake("{} -c check".format(recipe))
===============================

Also, I tried to move do_check content to rust.py without any success.
===============================
cmd = "export PATH=%s/../recipe-sysroot-native/usr/lib/rustlib/:" % builddir
cmd= cmd + "%s/../recipe-sysroot-native/usr/bin:$PATH;" % builddir cmd = cmd + "export RUST_TARGET_PATH=%s/../recipe-sysroot-native/usr/lib/rustlib/;" % builddir
cmd = cmd + "cd " + builddir + ";"
cmd = "export TEST_DEVICE_ADDR=\"%s:12345\";" % qemu.ip cmd = cmd + "python3 src/bootstrap/bootstrap.py -j 40 --verbose test --no-fail-fast --bless --target aarch64-poky-linux > summary.txt 2>&1"

Error:
File "/ala-lpggp31/vinay/review-2/poky-contrib/meta/lib/oeqa/utils/commands.py", line 210, in runCmd
raise AssertionError("Command '%s' returned non-zero exit status %d:\n%s" % (command, result.status, exc_output))
AssertionError: Command 'export TEST_DEVICE_ADDR="192.168.7.2:12345";python3 src/bootstrap/bootstrap.py -j 40 --verbose test --no-fail-fast --bless --target aarch64-poky-linux > summary.txt 2>&1' returned non-zero exit status 2:
===============================

So in rust.py only copy and execution of "remote-test-server" is taken care of.
And the test execution is by do_check of rust-testsuite.inc as below,
===============================

do_check () {
    export TEST_DEVICE_ADDR="192.168.7.2:12345"
    rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" >

summary.txt 2> /dev/null
}

Let me know if this ok. will send patches with changes for review.

Regards,
Vinay

Quoted 4 lines · Vinay Kumar via lists.openembedded.org

Hi Alex,

Tried testing outside oe-selftest framework, it works fine without any

errors,

Quoted 9 lines

export TEST_DEVICE_ADDR="192.168.7.4:12345"
rust_runx test --no-fail-fast --bless --target "aarch64-poky-linux" > summary.txt 2> /dev/null

Also, log (summary.txt) shows "remote-test-client" is connecting to the image without any issue.
=======================================
running:

"/ala-lpggp31/vinay/review-2/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/x86_64-unknown-linux-gnu/stage0-tools-bin/remote-test-client"

Quoted 2 lines

"spawn-emulator" "aarch64-poky-linux"

"/ala-lpggp31/vinay/review-2/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/x86_64-unknown-linux-gnu/stage0-tools-bin/remote-test-server"

Quoted 1 line

"/ala-lpggp31/vinay/review-2/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/tmp"

Quoted 8 lines

Connecting to remote device 192.168.7.4:12345 ...

Will integrate these changes in oe-selftest and let you know.

Regards,
Vinay

On Mon, May 17, 2021 at 8:11 PM Vinay Kumar <[email protected]>

Quoted 8 lines · wrote:
Quoted 8 lines

Checking suggestions, the booted image with tap seems to be working by passing "-monitor telnet:127.0.0.1:1234,server,nowait"
so I will execute testing and update you.
==========================

root@qemuarm64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.4  Bcast:192.168.7.255

Mask:255.255.255.0

Quoted 12 lines
Quoted 12 lines

inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:116 errors:0 dropped:0 overruns:0 frame:0 TX packets:98 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:945121 (922.9 KiB) TX bytes:9529 (9.3 KiB)

root@qemuarm64:~# ./remote-test-server -v remote
starting test server
listening on 0.0.0.0:12345!
==========================
Quoted 7 lines
Quoted 7 lines

Regards,
Vinay

Quoted 2 lines · Alexander Kanavin

Thanks, can you please look into the error? The line where it

happens and the way to get a backtrace is right there :)

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

There's no reason it shouldn't work.

Alex

On Mon, 17 May 2021 at 15:21, Vinay Kumar <[email protected]>

Quoted 11 lines · wrote:
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

Hi Alex,

Error on qemu image (ex. Aarch64) booted with tap interface.
===========================

root@qemuarm64:~# ./remote-test-server
starting test server
thread 'main' panicked at 'TcpListener::bind(bind_addr) failed with
Cannot assign requested address (os error 99)',
src/tools/remote-test-server/src/main.rs:90:20
note: run with `RUST_BACKTRACE=1` environment variable to display a

backtrace

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

===========================

Quoted 2 lines · Alexander Kanavin

On Mon, 17 May 2021 at 13:34, Vinay Kumar <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

"remote-test-server" on qemu-image with a tap interface throws

an error.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

The emulators for rust testing are with tcp port forwarding so

used

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

slirp method with added rust port.

I'm not sure I understand - what kind of error? In both cases the

server starts listening on a port, so in slirp scenario the address is 127.0.0.1:12345 (prone to breakage if something else on the build host took that port btw, including another instance of the same test), in tap it would be 192.168.7.2:12345. For the client you simply supply that via TEST_DEVICE_ADDR. No?

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Alex

#27 lore raw

Re: [OE-core] [PATCH v2 6/7] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

If you publish the code to a branch, and show exactly the errors you get, I could try to look at it.

Alex

Quoted 178 lines · Alexander Kanavin

You cannot hardcode the ip address like that; it's set dynamically when qemu starts, and you can only access it from selftest or runtime test.

Alex

Quoted 170 lines · Vinay Kumar

Hi Alex,

Tried your suggestions to copy and run in rust.py without any issue as below.
===============================
builddir = get_bb_var("B", "rust-testsuite")
ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user="root", timeout=600)
ssh.copy_to(builddir + "/" + "build/x86_64-unknown-linux-gnu/stage2-tools-bin/remote-test-server","~/") t_thread = threading.Thread(target=ssh.run, args=("~/remote-test-server -v remote",))
t_thread.start()
===============================

If we set "TEST_DEVICE_ADDR" in rust.py through "runCmd" as shown below, the remote-test-client does not connect to the image. So a lot of tests fail.
===============================
"cmd = "export TEST_DEVICE_ADDR=%s:12345;" % qemu.ip" runCmd(cmd)
bitbake("{} -c check".format(recipe))
===============================

Also, I tried to move do_check content to rust.py without any success.
===============================
cmd = "export PATH=%s/../recipe-sysroot-native/usr/lib/rustlib/:" % builddir
cmd= cmd + "%s/../recipe-sysroot-native/usr/bin:$PATH;" % builddir cmd = cmd + "export RUST_TARGET_PATH=%s/../recipe-sysroot-native/usr/lib/rustlib/;" % builddir
cmd = cmd + "cd " + builddir + ";"
cmd = "export TEST_DEVICE_ADDR=\"%s:12345\";" % qemu.ip cmd = cmd + "python3 src/bootstrap/bootstrap.py -j 40 --verbose test --no-fail-fast --bless --target aarch64-poky-linux > summary.txt 2>&1"

Error:
File "/ala-lpggp31/vinay/review-2/poky-contrib/meta/lib/oeqa/utils/commands.py", line 210, in runCmd
raise AssertionError("Command '%s' returned non-zero exit status %d:\n%s" % (command, result.status, exc_output))
AssertionError: Command 'export TEST_DEVICE_ADDR="192.168.7.2:12345";python3 src/bootstrap/bootstrap.py -j 40 --verbose test --no-fail-fast --bless --target aarch64-poky-linux > summary.txt 2>&1' returned non-zero exit status 2:
===============================

So in rust.py only copy and execution of "remote-test-server" is taken care of.
And the test execution is by do_check of rust-testsuite.inc as below,
===============================

do_check () {
    export TEST_DEVICE_ADDR="192.168.7.2:12345"
    rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" >

summary.txt 2> /dev/null
}

Let me know if this ok. will send patches with changes for review.

Regards,
Vinay

Quoted 4 lines · Vinay Kumar via lists.openembedded.org

Hi Alex,

Tried testing outside oe-selftest framework, it works fine without any

errors,

Quoted 9 lines

export TEST_DEVICE_ADDR="192.168.7.4:12345"
rust_runx test --no-fail-fast --bless --target "aarch64-poky-linux" > summary.txt 2> /dev/null

Also, log (summary.txt) shows "remote-test-client" is connecting to the image without any issue.
=======================================
running:

"/ala-lpggp31/vinay/review-2/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/x86_64-unknown-linux-gnu/stage0-tools-bin/remote-test-client"

Quoted 2 lines

"spawn-emulator" "aarch64-poky-linux"

"/ala-lpggp31/vinay/review-2/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/x86_64-unknown-linux-gnu/stage0-tools-bin/remote-test-server"

Quoted 1 line

"/ala-lpggp31/vinay/review-2/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/tmp"

Quoted 8 lines

Connecting to remote device 192.168.7.4:12345 ...

Will integrate these changes in oe-selftest and let you know.

Regards,
Vinay

On Mon, May 17, 2021 at 8:11 PM Vinay Kumar <[email protected]>

Quoted 8 lines · wrote:
Quoted 8 lines

Checking suggestions, the booted image with tap seems to be working by passing "-monitor telnet:127.0.0.1:1234,server,nowait"
so I will execute testing and update you.
==========================

root@qemuarm64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.4  Bcast:192.168.7.255

Mask:255.255.255.0

Quoted 12 lines
Quoted 12 lines

inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:116 errors:0 dropped:0 overruns:0 frame:0 TX packets:98 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:945121 (922.9 KiB) TX bytes:9529 (9.3 KiB)

root@qemuarm64:~# ./remote-test-server -v remote
starting test server
listening on 0.0.0.0:12345!
==========================
Quoted 7 lines
Quoted 7 lines

Regards,
Vinay

Quoted 2 lines · Alexander Kanavin

Thanks, can you please look into the error? The line where it

happens and the way to get a backtrace is right there :)

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

There's no reason it shouldn't work.

Alex

On Mon, 17 May 2021 at 15:21, Vinay Kumar <[email protected]>

Quoted 11 lines · wrote:
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

Hi Alex,

Error on qemu image (ex. Aarch64) booted with tap interface.
===========================

root@qemuarm64:~# ./remote-test-server
starting test server
thread 'main' panicked at 'TcpListener::bind(bind_addr) failed with
Cannot assign requested address (os error 99)',
src/tools/remote-test-server/src/main.rs:90:20
note: run with `RUST_BACKTRACE=1` environment variable to display

a backtrace

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

===========================

Quoted 2 lines · Alexander Kanavin

On Mon, 17 May 2021 at 13:34, Vinay Kumar <

Quoted 2 lines · [email protected]> wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

"remote-test-server" on qemu-image with a tap interface throws

an error.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

The emulators for rust testing are with tcp port forwarding so

used

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

slirp method with added rust port.

I'm not sure I understand - what kind of error? In both cases

the server starts listening on a port, so in slirp scenario the address is 127.0.0.1:12345 (prone to breakage if something else on the build host took that port btw, including another instance of the same test), in tap it would be 192.168.7.2:12345. For the client you simply supply that via TEST_DEVICE_ADDR. No?

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Alex

#28 lore raw

PATCH v3 1/5 rust-testsuite.inc : Rust cross testing.

Below list of functions are part of rust-testsuite.inc setup_cargo_environment(): Build bootstrap and some early stage tools. do_rust_setup_snapshot(): Install the snapshot version of rust binaries. do_configure(): To generate config.toml
do_compile(): To build "remote-test-server" for qemutarget image. do_check(): To execute testing on qmutarget image.

---
 meta/recipes-devtools/rust/rust-testsuite.inc | 163 ++++++++++++++++++
 1 file changed, 163 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-testsuite.inc
meta/recipes-devtools/rust/rust-testsuite.inc new file +163 -0
new file mode 100644
index 0000000000..88fb4e70d9
@@ -0,0 +1,163 @@
+SUMMARY = "Rust testing"
+HOMEPAGE = "https://rustc-dev-guide.rust-lang.org/tests/intro.html"
+SECTION = "test"
+LICENSE = "MIT | Apache-2.0"
+
+inherit rust
+inherit cargo_common
+
+DEPENDS += "file-native python3-native"
+EXCLUDE_FROM_WORLD = "1"
+
+# Path of target specification file "target-poky-linux.json"
+export RUST_TARGET_PATH="${STAGING_LIBDIR_NATIVE}/rustlib"
+
+export FORCE_CRATE_HASH="${BB_TASKHASH}"
+
+# We don't want to use bitbakes vendoring because the rust sources do their
+# own vendoring.
+CARGO_DISABLE_BITBAKE_VENDORING = "1"
+
+# We can't use RUST_BUILD_SYS here because that may be "musl" if
+# TCLIBC="musl". Snapshots are always -unknown-linux-gnu
+SNAPSHOT_BUILD_SYS = "${BUILD_ARCH}-unknown-linux-gnu"
+setup_cargo_environment () {
+    # The first step is to build bootstrap and some early stage tools,
+    # these are build for the same target as the snapshot, e.g.
+    # x86_64-unknown-linux-gnu.
+    # Later stages are build for the native target (i.e. target.x86_64-linux)
+    cargo_common_do_configure
+
+    printf '[target.%s]\n' "${SNAPSHOT_BUILD_SYS}" >> ${CARGO_HOME}/config
+    printf "linker = '%s'\n" "${RUST_BUILD_CCLD}" >> ${CARGO_HOME}/config
+}
+
+do_rust_setup_snapshot () {
+    for installer in "${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do
+        "${installer}" --prefix="${WORKDIR}/rust-snapshot" --disable-ldconfig
+    done
+
+    # Some versions of rust (e.g. 1.18.0) tries to find cargo in stage0/bin/cargo
+    # and fail without it there.
+    mkdir -p ${RUSTSRC}/build/${BUILD_SYS}
+    ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${BUILD_SYS}/stage0
+}
+addtask rust_setup_snapshot after do_unpack before do_configure
+do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
+
+python do_configure() {
+    import json
+    from distutils.version import LooseVersion
+    try:
+        import configparser
+    except ImportError:
+        import ConfigParser as configparser
+
+    # toml is rather similar to standard ini like format except it likes values
+    # that look more JSON like. So for our purposes simply escaping all values
+    # as JSON seem to work fine.
+
+    e = lambda s: json.dumps(s)
+
+    config = configparser.RawConfigParser()
+
+    # [target.ARCH-unknown-linux-gnu] in case of x86_64 [target.ARCH-poky-linux] 
+    target_section = "target.{}".format(d.getVar('TARGET_SYS', True))
+    config.add_section(target_section)
+
+    # Points to wrapper files which contain target specific compiler and linker commands. 
+    config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
+    config.set(target_section, "linker", e(d.expand("${RUST_TARGET_CCLD}")))
+
+    # If we don't do this rust-native will compile it's own llvm for BUILD.
+    # [target.${BUILD_ARCH}-unknown-linux-gnu]
+    target_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS', True))
+    config.add_section(target_section)
+
+    # Wrapper scripts of build system.
+    config.set(target_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
+
+    # [llvm]
+    config.add_section("llvm")
+    config.set("llvm", "targets", e("ARM;AArch64;Mips;PowerPC;RISCV;X86"))
+
+    # [rust]
+    config.add_section("rust")
+    config.set("rust", "rpath", e(True))
+    config.set("rust", "channel", e("stable"))
+
+    if LooseVersion(d.getVar("PV")) < LooseVersion("1.32.0"):
+        config.set("rust", "use-jemalloc", e(False))
+
+    # Whether or not to optimize the compiler and standard library
+    config.set("rust", "optimize", e(True))
+
+    # Emits extraneous output from tests to ensure that failures of the test
+    # harness are debuggable just from logfiles
+    config.set("rust", "verbose-tests", e(True))    
+
+    # Override default linker cc.
+    config.set("rust", "default-linker", e(d.expand("${RUST_BUILD_CCLD}")))
+
+    # [build]
+    config.add_section("build")
+    config.set("build", "submodules", e(False))
+    config.set("build", "docs", e(False))
+
+    rustc = d.expand("${WORKDIR}/rust-snapshot/bin/rustc")
+    config.set("build", "rustc", e(rustc))
+
+    cargo = d.expand("${WORKDIR}/rust-snapshot/bin/cargo")
+    config.set("build", "cargo", e(cargo))
+
+    config.set("build", "vendor", e(True))
+
+    targets = [d.getVar("TARGET_SYS", True)]
+    config.set("build", "target", e(targets))
+
+    hosts = [d.getVar("SNAPSHOT_BUILD_SYS", True)]
+    config.set("build", "host", e(hosts))
+
+    # We can't use BUILD_SYS since that is something the rust snapshot knows
+    # nothing about when trying to build some stage0 tools (like fabricate)
+    config.set("build", "build", e(d.getVar("SNAPSHOT_BUILD_SYS", True)))
+
+    with open("config.toml", "w") as f:
+        config.write(f)
+
+    # set up ${WORKDIR}/cargo_home
+    bb.build.exec_func("setup_cargo_environment", d)
+}
+
+
+rust_runx () {
+    echo "COMPILE ${PN}" "$@"
+
+    # CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a
+    # wide range of targets (not just TARGET). Yocto's settings for them will
+    # be inappropriate, avoid using.
+    unset CFLAGS
+    unset LDFLAGS
+    unset CXXFLAGS
+    unset CPPFLAGS
+
+    oe_cargo_fix_env
+
+    python3 src/bootstrap/bootstrap.py ${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose
+}
+rust_runx[vardepsexclude] += "PARALLEL_MAKE"
+
+do_compile () {
+
+    rust_runx build src/tools/remote-test-server --target "${TARGET_SYS}"
+}
+
+do_check[dirs] += "${B}"
+do_check[nostamp] = "1"
+do_check () {
+
+    rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" > summary.txt 2> /dev/null
+}
+addtask do_check after do_compile
Signature · 1 line
2.17.1
#29 lore raw

PATCH v3 2/5 Add rust testsuite for 1.46.0

---
 meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb | 3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb
meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb new file +3 -0
new file mode 100644
index 0000000000..ad758b71f4
@@ -0,0 +1,3 @@
+require rust-testsuite.inc
+require rust-source-${PV}.inc
+require rust-snapshot-${PV}.inc
Signature · 1 line
2.17.1
#30 lore raw

PATCH v3 3/5 rust.inc : Changed target cpu for powerpc to "7400"

In reply to Vinay Kumar

While executing rust-testing observed some ui testfailures due to below warning message.

'powerpc' is not a recognized processor for this target in rust

So renamed target cpu for "powerpc" in "llvm_cpu" to "7400" as per default tune for qemuppc.

---
 meta/recipes-devtools/rust/rust.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/rust/rust.inc +1 -1
index a1223f45e7..ee3176b559 100644
@@ -290,7 +290,7 @@ def llvm_cpu(d):
     trans['x86-64'] = "x86-64"
     trans['i686'] = "i686"
     trans['i586'] = "i586"
-    trans['powerpc'] = "powerpc"
+    trans['powerpc'] = "7400"
     trans['mips64'] = "mips64"
     trans['mips64el'] = "mips64"
     trans['riscv64'] = "generic-rv64"
Signature · 1 line
2.17.1
#31 lore raw

PATCH v3 4/5 oeqa/selftest/cases/rust.py: Rust oe-selftest script.

In reply to Vinay Kumar

Build remote-test-server copy to image and execute remotely through background ssh. Execute testing through do_check.

We are booting qemuimage in "nographic" mode along with additional qemuparams,
'-monitor telnet:127.0.0.1:1234,server,nowait -serial mon:stdio -serial null'

Note:
'-serial mon:stdio -serial': To fix below run-time errors while testing "failed with Connection reset by peer"

---
 meta/lib/oeqa/selftest/cases/rust.py | 50 ++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/rust.py
meta/lib/oeqa/selftest/cases/rust.py new file +50 -0
new file mode 100644
index 0000000000..fc900d536f
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: MIT
+import os
+from oeqa.core.decorator import OETestTag
+from oeqa.core.case import OEPTestResultTestCase
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu, Command
+from oeqa.utils.sshcontrol import SSHControl
+import threading
+
+class RustSelfTestBase(OESelftestTestCase, OEPTestResultTestCase):
+
+	def run_check_emulated(self, *args, **kwargs):
+		# build remote-test-server before image build
+		recipe = "rust-testsuite"
+		bitbake("{} -c compile".format(recipe))
+
+		# Get build directory path
+		builddir = get_bb_var("B", "rust-testsuite")
+
+		# build core-image-minimal with required packages
+		default_installed_packages = ["libgcc", "libstdc++", "libatomic", "libgomp"]
+		features = []
+		features.append('IMAGE_FEATURES += "ssh-server-openssh"')
+		features.append('CORE_IMAGE_EXTRA_INSTALL += "{0}"'.format(" ".join(default_installed_packages)))
+		self.write_config("\n".join(features))
+		bitbake("core-image-minimal")
+
+		# wrap the execution with a qemu instance
+		with runqemu("core-image-minimal", runqemuparams = "nographic", qemuparams= " -monitor \
+                        telnet:127.0.0.1:1234,server,nowait -serial mon:stdio -serial null") as qemu:
+
+			# Copy remote-test-server through scp and execute through background ssh
+			ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user="root", timeout=600)
+			ssh.copy_to(builddir + "/" + "build/x86_64-unknown-linux-gnu/stage2-tools-bin/remote-test-server","~/")
+			t_thread = threading.Thread(target=ssh.run, args=("~/remote-test-server -v remote",))
+			t_thread.start()
+
+			# Set TEST_DEVICE_ADDR to image ip
+			cmd  = "export TEST_DEVICE_ADDR=%s:12345;" % qemu.ip
+			runCmd(cmd)
+
+                        # Test execution
+			bitbake("{} -c check".format(recipe))
+			# Stop ssh background execution
+			t_thread.stop()
+
+@OETestTag("toolchain-system")
+class RustSelfTestSystemEmulated(RustSelfTestBase):
+	def test_rust(self):
+		self.run_check_emulated("rust")
Signature · 1 line
2.17.1
#32 lore raw

Re: [PATCH v3 4/5] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

meta/lib/oeqa/selftest/cases/rust.py line 45

Quoted 11 lines · Vinay Kumar
(quoted diff) +2 -0
+                       # Set TEST_DEVICE_ADDR to image ip
+                       cmd  = "export TEST_DEVICE_ADDR=%s:12345;" %

qemu.ip

meta/lib/oeqa/selftest/cases/rust.py new file +6 -0
+                       runCmd(cmd)
+
+                        # Test execution
+                       bitbake("{} -c check".format(recipe))
+                       # Stop ssh background execution
+                       t_thread.stop()

TEST_DEVICE_ADDR set this way will not propagate into the task environment. The task itself consists only of:

do_check () {

    rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" >

summary.txt 2> /dev/null
}

so you can simply move that directly into selftest:

runCmd("export TEST_DEVICE_ADDR=%s:12345 rust_runx test --no-fail-fast --bless --target "%s"" %(....))

Alex

#33 lore raw

Re: [PATCH v3 4/5] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Hi Alex,

I made changes as you suggested, getting expected results. Verifying with a fresh run. Will send the final patch for review.

Regards,
Vinay

Quoted 26 lines · Alexander Kanavin

meta/lib/oeqa/selftest/cases/rust.py line 45

Quoted 10 lines · Vinay Kumar
meta/lib/oeqa/selftest/cases/rust.py new file +8 -0
+                       # Set TEST_DEVICE_ADDR to image ip
+                       cmd  = "export TEST_DEVICE_ADDR=%s:12345;" % qemu.ip
+                       runCmd(cmd)
+
+                        # Test execution
+                       bitbake("{} -c check".format(recipe))
+                       # Stop ssh background execution
+                       t_thread.stop()

TEST_DEVICE_ADDR set this way will not propagate into the task environment. The task itself consists only of:

do_check () {

    rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" > summary.txt 2> /dev/null
}

so you can simply move that directly into selftest:

runCmd("export TEST_DEVICE_ADDR=%s:12345 rust_runx test --no-fail-fast --bless --target "%s"" %(....))

Alex

#34 lore raw

PATCH v4 1/5 rust-testsuite.inc : Rust cross testing.

In reply to Alexander Kanavin

Below list of functions are part of rust-testsuite.inc setup_cargo_environment(): Build bootstrap and some early stage tools. do_rust_setup_snapshot(): Install the snapshot version of rust binaries. do_configure(): To generate config.toml
do_compile(): To build "remote-test-server" for qemutarget image.

---
 meta/recipes-devtools/rust/rust-testsuite.inc | 156 ++++++++++++++++++
 1 file changed, 156 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-testsuite.inc
meta/recipes-devtools/rust/rust-testsuite.inc new file +156 -0
new file mode 100644
index 0000000000..8dd2855e67
@@ -0,0 +1,156 @@
+SUMMARY = "Rust testing"
+HOMEPAGE = "https://rustc-dev-guide.rust-lang.org/tests/intro.html"
+SECTION = "test"
+LICENSE = "MIT | Apache-2.0"
+
+inherit rust
+inherit cargo_common
+
+DEPENDS += "file-native python3-native"
+EXCLUDE_FROM_WORLD = "1"
+
+# Path of target specification file "target-poky-linux.json"
+export RUST_TARGET_PATH="${STAGING_LIBDIR_NATIVE}/rustlib"
+
+export FORCE_CRATE_HASH="${BB_TASKHASH}"
+
+# We don't want to use bitbakes vendoring because the rust sources do their
+# own vendoring.
+CARGO_DISABLE_BITBAKE_VENDORING = "1"
+
+# We can't use RUST_BUILD_SYS here because that may be "musl" if
+# TCLIBC="musl". Snapshots are always -unknown-linux-gnu
+SNAPSHOT_BUILD_SYS = "${BUILD_ARCH}-unknown-linux-gnu"
+setup_cargo_environment () {
+    # The first step is to build bootstrap and some early stage tools,
+    # these are build for the same target as the snapshot, e.g.
+    # x86_64-unknown-linux-gnu.
+    # Later stages are build for the native target (i.e. target.x86_64-linux)
+    cargo_common_do_configure
+
+    printf '[target.%s]\n' "${SNAPSHOT_BUILD_SYS}" >> ${CARGO_HOME}/config
+    printf "linker = '%s'\n" "${RUST_BUILD_CCLD}" >> ${CARGO_HOME}/config
+}
+
+do_rust_setup_snapshot () {
+    for installer in "${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do
+        "${installer}" --prefix="${WORKDIR}/rust-snapshot" --disable-ldconfig
+    done
+
+    # Some versions of rust (e.g. 1.18.0) tries to find cargo in stage0/bin/cargo
+    # and fail without it there.
+    mkdir -p ${RUSTSRC}/build/${BUILD_SYS}
+    ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${BUILD_SYS}/stage0
+}
+addtask rust_setup_snapshot after do_unpack before do_configure
+do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
+
+python do_configure() {
+    import json
+    from distutils.version import LooseVersion
+    try:
+        import configparser
+    except ImportError:
+        import ConfigParser as configparser
+
+    # toml is rather similar to standard ini like format except it likes values
+    # that look more JSON like. So for our purposes simply escaping all values
+    # as JSON seem to work fine.
+
+    e = lambda s: json.dumps(s)
+
+    config = configparser.RawConfigParser()
+
+    # [target.ARCH-unknown-linux-gnu] in case of x86_64 [target.ARCH-poky-linux] 
+    target_section = "target.{}".format(d.getVar('TARGET_SYS', True))
+    config.add_section(target_section)
+
+    # Points to wrapper files which contain target specific compiler and linker commands. 
+    config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
+    config.set(target_section, "linker", e(d.expand("${RUST_TARGET_CCLD}")))
+
+    # If we don't do this rust-native will compile it's own llvm for BUILD.
+    # [target.${BUILD_ARCH}-unknown-linux-gnu]
+    target_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS', True))
+    config.add_section(target_section)
+
+    # Wrapper scripts of build system.
+    config.set(target_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
+
+    # [llvm]
+    config.add_section("llvm")
+    config.set("llvm", "targets", e("ARM;AArch64;Mips;PowerPC;RISCV;X86"))
+
+    # [rust]
+    config.add_section("rust")
+    config.set("rust", "rpath", e(True))
+    config.set("rust", "channel", e("stable"))
+
+    if LooseVersion(d.getVar("PV")) < LooseVersion("1.32.0"):
+        config.set("rust", "use-jemalloc", e(False))
+
+    # Whether or not to optimize the compiler and standard library
+    config.set("rust", "optimize", e(True))
+
+    # Emits extraneous output from tests to ensure that failures of the test
+    # harness are debuggable just from logfiles
+    config.set("rust", "verbose-tests", e(True))    
+
+    # Override default linker cc.
+    config.set("rust", "default-linker", e(d.expand("${RUST_BUILD_CCLD}")))
+
+    # [build]
+    config.add_section("build")
+    config.set("build", "submodules", e(False))
+    config.set("build", "docs", e(False))
+
+    rustc = d.expand("${WORKDIR}/rust-snapshot/bin/rustc")
+    config.set("build", "rustc", e(rustc))
+
+    cargo = d.expand("${WORKDIR}/rust-snapshot/bin/cargo")
+    config.set("build", "cargo", e(cargo))
+
+    config.set("build", "vendor", e(True))
+
+    targets = [d.getVar("TARGET_SYS", True)]
+    config.set("build", "target", e(targets))
+
+    hosts = [d.getVar("SNAPSHOT_BUILD_SYS", True)]
+    config.set("build", "host", e(hosts))
+
+    # We can't use BUILD_SYS since that is something the rust snapshot knows
+    # nothing about when trying to build some stage0 tools (like fabricate)
+    config.set("build", "build", e(d.getVar("SNAPSHOT_BUILD_SYS", True)))
+
+    with open("config.toml", "w") as f:
+        config.write(f)
+
+    # set up ${WORKDIR}/cargo_home
+    bb.build.exec_func("setup_cargo_environment", d)
+}
+
+
+rust_runx () {
+    echo "COMPILE ${PN}" "$@"
+
+    # CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a
+    # wide range of targets (not just TARGET). Yocto's settings for them will
+    # be inappropriate, avoid using.
+    unset CFLAGS
+    unset LDFLAGS
+    unset CXXFLAGS
+    unset CPPFLAGS
+
+    oe_cargo_fix_env
+
+    python3 src/bootstrap/bootstrap.py ${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose
+}
+rust_runx[vardepsexclude] += "PARALLEL_MAKE"
+
+do_compile () {
+
+    rust_runx build src/tools/remote-test-server --target "${TARGET_SYS}"
+}
+
Signature · 1 line
2.17.1
#35 lore raw

PATCH v4 2/5 Add rust testsuite for 1.46.0

---
 meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb | 3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb
meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb new file +3 -0
new file mode 100644
index 0000000000..ad758b71f4
@@ -0,0 +1,3 @@
+require rust-testsuite.inc
+require rust-source-${PV}.inc
+require rust-snapshot-${PV}.inc
Signature · 1 line
2.17.1
#36 lore raw

PATCH v4 3/5 rust.inc : Changed target cpu for powerpc to "7400"

In reply to Vinay Kumar

While executing rust-testing observed some ui testfailures due to below warning message.

'powerpc' is not a recognized processor for this target in rust

So renamed target cpu for "powerpc" in "llvm_cpu" to "7400" as per default tune for qemuppc.

---
 meta/recipes-devtools/rust/rust.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/rust/rust.inc +1 -1
index a1223f45e7..ee3176b559 100644
@@ -290,7 +290,7 @@ def llvm_cpu(d):
     trans['x86-64'] = "x86-64"
     trans['i686'] = "i686"
     trans['i586'] = "i586"
-    trans['powerpc'] = "powerpc"
+    trans['powerpc'] = "7400"
     trans['mips64'] = "mips64"
     trans['mips64el'] = "mips64"
     trans['riscv64'] = "generic-rv64"
Signature · 1 line
2.17.1
#37 lore raw

PATCH v4 4/5 oeqa/selftest/cases/rust.py: Rust oe-selftest script.

In reply to Vinay Kumar

Build remote-test-server copy to image and execute remotely through background ssh.

Execute rust testing by exporting required paths. Capturing test results in summary.txt at rust source folder.

We are booting qemuimage in "nographic" mode along with additional qemuparams,
'-monitor telnet:127.0.0.1:1234,server,nowait -serial mon:stdio -serial null'

Note:
'-serial mon:stdio -serial': To fix below run-time errors while testing "failed with Connection reset by peer"

---
 meta/lib/oeqa/selftest/cases/rust.py | 51 ++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/rust.py
meta/lib/oeqa/selftest/cases/rust.py new file +51 -0
new file mode 100644
index 0000000000..398fb35ccb
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: MIT
+import os
+from oeqa.core.decorator import OETestTag
+from oeqa.core.case import OEPTestResultTestCase
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu, Command
+from oeqa.utils.sshcontrol import SSHControl
+import threading
+
+class RustSelfTestBase(OESelftestTestCase, OEPTestResultTestCase):
+
+	def run_check_emulated(self, *args, **kwargs):
+		# build remote-test-server before image build
+		recipe = "rust-testsuite"
+		bitbake("{} -c compile".format(recipe))
+		builddir = get_bb_var("B", "rust-testsuite")
+		# build core-image-minimal with required packages
+		default_installed_packages = ["libgcc", "libstdc++", "libatomic", "libgomp"]
+		features = []
+		features.append('IMAGE_FEATURES += "ssh-server-openssh"')
+		features.append('CORE_IMAGE_EXTRA_INSTALL += "{0}"'.format(" ".join(default_installed_packages)))
+		self.write_config("\n".join(features))
+		bitbake("core-image-minimal")
+		# wrap the execution with a qemu instance
+		with runqemu("core-image-minimal", runqemuparams = "nographic", qemuparams= " -monitor \
+                        telnet:127.0.0.1:1234,server,nowait -serial mon:stdio -serial null") as qemu:
+			#Copy remote-test-server through scp and execute through background ssh
+			ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user="root", timeout=600)
+			ssh.copy_to(builddir + "/" + "build/x86_64-unknown-linux-gnu/stage2-tools-bin/remote-test-server","~/")
+			t_thread = threading.Thread(target=ssh.run, args=("~/remote-test-server -v remote",))
+			t_thread.start()
+			# Get the values of variables.
+			targetsys = get_bb_var("TARGET_SYS", "rust-testsuite")
+			rustlibpath = get_bb_var("STAGING_LIBDIR_NATIVE", "rust-testsuite")
+			tmpdir = get_bb_var("TMPDIR", "rust-testsuite")
+			testargs = "--no-fail-fast --bless"
+			# Set path for target-poky-linux-gcc, RUST_TARGET_PATH and hosttools.                        
+			cmd = "export PATH=%s/../bin:$PATH;" % rustlibpath
+			cmd = cmd + " export PATH=%s/../bin/%s:%s/hosttools:$PATH;" % (rustlibpath, targetsys, tmpdir) 
+			cmd = cmd + " export RUST_TARGET_PATH=%s/rustlib;" % rustlibpath
+			# Trigger testing.                        
+			cmd = cmd + " export TEST_DEVICE_ADDR=\"%s:12345\";" % qemu.ip
+			cmd = cmd + " cd %s;  python3 src/bootstrap/bootstrap.py -j 40 --verbose test %s --target %s > summary.txt 2> /dev/null " % (builddir, testargs, targetsys)
+			runCmd(cmd)                        
+			# Stop ssh background execution
+			t_thread.stop()
+
+@OETestTag("toolchain-system")
+class RustSelfTestSystemEmulated(RustSelfTestBase):
+	def test_rust(self):
+		self.run_check_emulated("rust")
Signature · 1 line
2.17.1
#38 lore raw

Re: [PATCH v4 4/5] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Quoted 3 lines · Vinay Kumar

Build remote-test-server copy to image and execute remotely through background ssh.

Thanks, I do not have any further comments about the overall structure, the below are more specific concerns.

Quoted 5 lines

+ with runqemu("core-image-minimal", runqemuparams =
"nographic", qemuparams= " -monitor \
+ telnet:127.0.0.1:1234,server,nowait -serial
mon:stdio -serial null") as qemu:

Hardcoding the ip port this way is problematic and prone to conflicts. What is -monitor used for?

Quoted 4 lines

+ cmd = cmd + " cd %s; python3
src/bootstrap/bootstrap.py -j 40 --verbose test %s --target %s > summary.txt 2> /dev/null " % (builddir, testargs, targetsys)

What does -j 40 do? Keep in mind that qemu has only 4 virtual cpu cores.

Quoted 2 lines

+ runCmd(cmd)

What happens if the test executed via runCmd fails? Specifically, will the failure be properly reported?

I'm wondering because the output of the test is redirected to summary.txt (which is then left unused), and stderr is discarded altogether.

meta/lib/oeqa/selftest/cases/rust.py line 46

Quoted 3 lines
meta/lib/oeqa/selftest/cases/rust.py new file +2 -0
+                       # Stop ssh background execution
+                       t_thread.stop()

Will t_thread be stopped if runCmd fails?

Alex

#39 lore raw

Re: [PATCH v4 4/5] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Hi Alex,

Quoted 1 line
Quoted 1 line

Hardcoding the ip port this way is problematic and prone to conflicts. What is -monitor used for?

When we were testing outside oe-selftest framework ( booting image manually and trigger testing),
the "remote-test-server" used to give connection issues. However, right now without this option the testing is working without any issue. So removed from qemuboot.

Quoted 1 line
Quoted 1 line

What does -j 40 do? Keep in mind that qemu has only 4 virtual cpu cores.

This one passed to speed up the testing while using the "do_check" method. So I removed parallel builds.

Quoted 1 line
Quoted 1 line

What happens if the test executed via runCmd fails? Specifically, will the failure be properly reported?

While executing testing, if there any testcase failures testing gets terminated with below message,
"command did not execute successfully:"

So we are passing "--no-fail-fast" as a test argument, which wont exit the shell and the testing continues even if there are failures.

Quoted 1 line
Quoted 1 line

I'm wondering because the output of the test is redirected to summary.txt (which is then left unused), and stderr is discarded altogether.

This is because I only capture the test results as much as possible. Now modified to consider stderr also.

Quoted 1 line
Quoted 1 line

Will t_thread be stopped if runCmd fails?

Now changed the implementation to discard thread usage. Even in case of any failure the test used to end after timeout set in "SShcontrol" if the timeout is less (60 seconds) then some of the tests used to get missed.

So instead of using copy_to and run from sshcontrol.py, I tried copying the remote-test-server to the image and executing in the background as below,

#Copy remote-test-server through scp and execute through background ssh sshargs = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR'
cmd = "scp %s %s/build/x86_64-unknown-linux-gnu/stage2-tools-bin/remote-test-server root@%s:~/ ;" % (sshargs, builddir, qemu.ip)
testcommand = '~/remote-test-server -v remote'
cmd = cmd + "ssh %s -f root@%s \"%s\";" % (sshargs, qemu.ip, testcommand)

And kill "remote-test-server" through ssh once testing is complete killcommand = "kill -9 \$(ps | grep remote-test-server | grep -v \"grep\" | awk '{print \$1}')"
cmd = cmd + "ssh %s root@%s \"%s\";" % (sshargs, qemu.ip, killcommand)

Testing in progress will send the v5 version patches.

Regards,
Vinay

Quoted 38 lines · Alexander Kanavin
Quoted 3 lines · Vinay Kumar

Build remote-test-server copy to image and execute remotely through background ssh.

Thanks, I do not have any further comments about the overall structure, the below are more specific concerns.

meta/lib/oeqa/selftest/cases/rust.py line 26

Quoted 3 lines
meta/lib/oeqa/selftest/cases/rust.py new file +2 -0
+               with runqemu("core-image-minimal", runqemuparams = "nographic", qemuparams= " -monitor \
+                        telnet:127.0.0.1:1234,server,nowait -serial mon:stdio -serial null") as qemu:

Hardcoding the ip port this way is problematic and prone to conflicts. What is -monitor used for?

Quoted 2 lines

+ cmd = cmd + " cd %s; python3 src/bootstrap/bootstrap.py -j 40 --verbose test %s --target %s > summary.txt 2> /dev/null " % (builddir, testargs, targetsys)

What does -j 40 do? Keep in mind that qemu has only 4 virtual cpu cores.

Quoted 2 lines

+ runCmd(cmd)

What happens if the test executed via runCmd fails? Specifically, will the failure be properly reported?

I'm wondering because the output of the test is redirected to summary.txt (which is then left unused), and stderr is discarded altogether.

meta/lib/oeqa/selftest/cases/rust.py line 46

Quoted 3 lines
meta/lib/oeqa/selftest/cases/rust.py new file +2 -0
+                       # Stop ssh background execution
+                       t_thread.stop()

Will t_thread be stopped if runCmd fails?

Alex

#40 lore raw

PATCH v5 1/5 rust-testsuite.inc : Rust cross testing.

Below list of functions are part of rust-testsuite.inc setup_cargo_environment(): Build bootstrap and some early stage tools. do_rust_setup_snapshot(): Install the snapshot version of rust binaries. do_configure(): To generate config.toml
do_compile(): To build "remote-test-server" for qemutarget image.

---
 meta/recipes-devtools/rust/rust-testsuite.inc | 156 ++++++++++++++++++
 1 file changed, 156 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-testsuite.inc
meta/recipes-devtools/rust/rust-testsuite.inc new file +156 -0
new file mode 100644
index 0000000000..8dd2855e67
@@ -0,0 +1,156 @@
+SUMMARY = "Rust testing"
+HOMEPAGE = "https://rustc-dev-guide.rust-lang.org/tests/intro.html"
+SECTION = "test"
+LICENSE = "MIT | Apache-2.0"
+
+inherit rust
+inherit cargo_common
+
+DEPENDS += "file-native python3-native"
+EXCLUDE_FROM_WORLD = "1"
+
+# Path of target specification file "target-poky-linux.json"
+export RUST_TARGET_PATH="${STAGING_LIBDIR_NATIVE}/rustlib"
+
+export FORCE_CRATE_HASH="${BB_TASKHASH}"
+
+# We don't want to use bitbakes vendoring because the rust sources do their
+# own vendoring.
+CARGO_DISABLE_BITBAKE_VENDORING = "1"
+
+# We can't use RUST_BUILD_SYS here because that may be "musl" if
+# TCLIBC="musl". Snapshots are always -unknown-linux-gnu
+SNAPSHOT_BUILD_SYS = "${BUILD_ARCH}-unknown-linux-gnu"
+setup_cargo_environment () {
+    # The first step is to build bootstrap and some early stage tools,
+    # these are build for the same target as the snapshot, e.g.
+    # x86_64-unknown-linux-gnu.
+    # Later stages are build for the native target (i.e. target.x86_64-linux)
+    cargo_common_do_configure
+
+    printf '[target.%s]\n' "${SNAPSHOT_BUILD_SYS}" >> ${CARGO_HOME}/config
+    printf "linker = '%s'\n" "${RUST_BUILD_CCLD}" >> ${CARGO_HOME}/config
+}
+
+do_rust_setup_snapshot () {
+    for installer in "${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do
+        "${installer}" --prefix="${WORKDIR}/rust-snapshot" --disable-ldconfig
+    done
+
+    # Some versions of rust (e.g. 1.18.0) tries to find cargo in stage0/bin/cargo
+    # and fail without it there.
+    mkdir -p ${RUSTSRC}/build/${BUILD_SYS}
+    ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${BUILD_SYS}/stage0
+}
+addtask rust_setup_snapshot after do_unpack before do_configure
+do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
+
+python do_configure() {
+    import json
+    from distutils.version import LooseVersion
+    try:
+        import configparser
+    except ImportError:
+        import ConfigParser as configparser
+
+    # toml is rather similar to standard ini like format except it likes values
+    # that look more JSON like. So for our purposes simply escaping all values
+    # as JSON seem to work fine.
+
+    e = lambda s: json.dumps(s)
+
+    config = configparser.RawConfigParser()
+
+    # [target.ARCH-unknown-linux-gnu] in case of x86_64 [target.ARCH-poky-linux] 
+    target_section = "target.{}".format(d.getVar('TARGET_SYS', True))
+    config.add_section(target_section)
+
+    # Points to wrapper files which contain target specific compiler and linker commands. 
+    config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
+    config.set(target_section, "linker", e(d.expand("${RUST_TARGET_CCLD}")))
+
+    # If we don't do this rust-native will compile it's own llvm for BUILD.
+    # [target.${BUILD_ARCH}-unknown-linux-gnu]
+    target_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS', True))
+    config.add_section(target_section)
+
+    # Wrapper scripts of build system.
+    config.set(target_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
+
+    # [llvm]
+    config.add_section("llvm")
+    config.set("llvm", "targets", e("ARM;AArch64;Mips;PowerPC;RISCV;X86"))
+
+    # [rust]
+    config.add_section("rust")
+    config.set("rust", "rpath", e(True))
+    config.set("rust", "channel", e("stable"))
+
+    if LooseVersion(d.getVar("PV")) < LooseVersion("1.32.0"):
+        config.set("rust", "use-jemalloc", e(False))
+
+    # Whether or not to optimize the compiler and standard library
+    config.set("rust", "optimize", e(True))
+
+    # Emits extraneous output from tests to ensure that failures of the test
+    # harness are debuggable just from logfiles
+    config.set("rust", "verbose-tests", e(True))    
+
+    # Override default linker cc.
+    config.set("rust", "default-linker", e(d.expand("${RUST_BUILD_CCLD}")))
+
+    # [build]
+    config.add_section("build")
+    config.set("build", "submodules", e(False))
+    config.set("build", "docs", e(False))
+
+    rustc = d.expand("${WORKDIR}/rust-snapshot/bin/rustc")
+    config.set("build", "rustc", e(rustc))
+
+    cargo = d.expand("${WORKDIR}/rust-snapshot/bin/cargo")
+    config.set("build", "cargo", e(cargo))
+
+    config.set("build", "vendor", e(True))
+
+    targets = [d.getVar("TARGET_SYS", True)]
+    config.set("build", "target", e(targets))
+
+    hosts = [d.getVar("SNAPSHOT_BUILD_SYS", True)]
+    config.set("build", "host", e(hosts))
+
+    # We can't use BUILD_SYS since that is something the rust snapshot knows
+    # nothing about when trying to build some stage0 tools (like fabricate)
+    config.set("build", "build", e(d.getVar("SNAPSHOT_BUILD_SYS", True)))
+
+    with open("config.toml", "w") as f:
+        config.write(f)
+
+    # set up ${WORKDIR}/cargo_home
+    bb.build.exec_func("setup_cargo_environment", d)
+}
+
+
+rust_runx () {
+    echo "COMPILE ${PN}" "$@"
+
+    # CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a
+    # wide range of targets (not just TARGET). Yocto's settings for them will
+    # be inappropriate, avoid using.
+    unset CFLAGS
+    unset LDFLAGS
+    unset CXXFLAGS
+    unset CPPFLAGS
+
+    oe_cargo_fix_env
+
+    python3 src/bootstrap/bootstrap.py ${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose
+}
+rust_runx[vardepsexclude] += "PARALLEL_MAKE"
+
+do_compile () {
+
+    rust_runx build src/tools/remote-test-server --target "${TARGET_SYS}"
+}
+
Signature · 1 line
2.17.1
#41 lore raw

PATCH v5 2/5 Add rust testsuite for 1.46.0

---
 meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb | 3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb
meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb new file +3 -0
new file mode 100644
index 0000000000..ad758b71f4
@@ -0,0 +1,3 @@
+require rust-testsuite.inc
+require rust-source-${PV}.inc
+require rust-snapshot-${PV}.inc
Signature · 1 line
2.17.1
#42 lore raw

PATCH v5 3/5 rust.inc : Changed target cpu for powerpc to "7400"

In reply to Vinay Kumar

While executing rust-testing observed some ui testfailures due to below warning message.

'powerpc' is not a recognized processor for this target in rust

So renamed target cpu for "powerpc" in "llvm_cpu" to "7400" as per default tune for qemuppc.

---
 meta/recipes-devtools/rust/rust.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/rust/rust.inc +1 -1
index a1223f45e7..ee3176b559 100644
@@ -290,7 +290,7 @@ def llvm_cpu(d):
     trans['x86-64'] = "x86-64"
     trans['i686'] = "i686"
     trans['i586'] = "i586"
-    trans['powerpc'] = "powerpc"
+    trans['powerpc'] = "7400"
     trans['mips64'] = "mips64"
     trans['mips64el'] = "mips64"
     trans['riscv64'] = "generic-rv64"
Signature · 1 line
2.17.1
#43 lore raw

PATCH v5 4/5 oeqa/selftest/cases/rust.py: Rust oe-selftest script.

In reply to Vinay Kumar

Build remote-test-server copy to image and execute remotely through background ssh.

Execute rust testing by exporting required paths. Capturing test results in summary.txt at rust source folder.

Kill "remote-test-server" on the image through ssh, once testing is completed.

---
 meta/lib/oeqa/selftest/cases/rust.py | 50 ++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/rust.py
meta/lib/oeqa/selftest/cases/rust.py new file +50 -0
new file mode 100644
index 0000000000..066a28c046
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: MIT
+import os
+from oeqa.core.decorator import OETestTag
+from oeqa.core.case import OEPTestResultTestCase
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu, Command
+
+class RustSelfTestBase(OESelftestTestCase, OEPTestResultTestCase):
+
+	def run_check_emulated(self, *args, **kwargs):
+		# build remote-test-server before image build
+		recipe = "rust-testsuite"
+		bitbake("{} -c compile".format(recipe))
+		builddir = get_bb_var("B", "rust-testsuite")
+		# build core-image-minimal with required packages
+		default_installed_packages = ["libgcc", "libstdc++", "libatomic", "libgomp"]
+		features = []
+		features.append('IMAGE_FEATURES += "ssh-server-openssh"')
+		features.append('CORE_IMAGE_EXTRA_INSTALL += "{0}"'.format(" ".join(default_installed_packages)))
+		self.write_config("\n".join(features))
+		bitbake("core-image-minimal")
+		# wrap the execution with a qemu instance
+		with runqemu("core-image-minimal", runqemuparams = "nographic") as qemu:
+			#Copy remote-test-server through scp and execute through background ssh
+			sshargs = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR'
+			cmd = "scp %s %s/build/x86_64-unknown-linux-gnu/stage2-tools-bin/remote-test-server root@%s:~/ ;" % (sshargs, builddir, qemu.ip)
+			testcommand = '~/remote-test-server -v remote'
+			cmd = cmd + "ssh %s -f root@%s \"%s\";" % (sshargs, qemu.ip, testcommand)
+			# Get the values of variables.
+			targetsys = get_bb_var("TARGET_SYS", "rust-testsuite")
+			rustlibpath = get_bb_var("STAGING_LIBDIR_NATIVE", "rust-testsuite")
+			tmpdir = get_bb_var("TMPDIR", "rust-testsuite")
+			testargs = "--no-fail-fast --bless"
+			# Set path for target-poky-linux-gcc, RUST_TARGET_PATH and hosttools.                        
+			cmd = cmd + " export PATH=%s/../bin:$PATH;" % rustlibpath
+			cmd = cmd + " export PATH=%s/../bin/%s:%s/hosttools:$PATH;" % (rustlibpath, targetsys, tmpdir) 
+			cmd = cmd + " export RUST_TARGET_PATH=%s/rustlib;" % rustlibpath
+			# Trigger testing.                        
+			cmd = cmd + " export TEST_DEVICE_ADDR=\"%s:12345\";" % qemu.ip
+			cmd = cmd + " cd %s;  python3 src/bootstrap/bootstrap.py test %s --target %s > summary.txt 2>&1;" % (builddir, testargs, targetsys)
+			# To kill remote-test-server executing through background ssh
+			killcommand = "kill -9 \$(ps | grep remote-test-server |  grep -v \"grep\" | awk '{print \$1}')"
+			cmd = cmd + "ssh %s root@%s \"%s\";" % (sshargs, qemu.ip, killcommand)
+			result = runCmd(cmd)
+			self.assertEqual(0, result.status, 'oe-selftest returned a non 0 status:%s' % result.output)                        
+
+@OETestTag("toolchain-system")
+class RustSelfTestSystemEmulated(RustSelfTestBase):
+	def test_rust(self):
+		self.run_check_emulated("rust")
Signature · 1 line
2.17.1
#44 lore raw

Re: [PATCH v5 4/5] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Quoted 11 lines · Vinay Kumar

+ cmd = cmd + " cd %s; python3
src/bootstrap/bootstrap.py test %s --target %s > summary.txt 2>&1;" % (builddir, testargs, targetsys)
+ # To kill remote-test-server executing through
background ssh
+ killcommand = "kill -9 \$(ps | grep
remote-test-server | grep -v \"grep\" | awk '{print \$1}')"
+ cmd = cmd + "ssh %s root@%s \"%s\";" % (sshargs,
qemu.ip, killcommand)

(quoted diff) +2 -0
+                       result = runCmd(cmd)
+                       self.assertEqual(0, result.status, 'oe-selftest
Quoted 1 line

returned a non 0 status:%s' % result.output)

What does result.output contains if the test fails? Since both stdout and stderr are redirected to a file, there might be nothing at all there?

I'd suggest you actually print all of summary.txt in case of failure (yes it's over a megabyte, that is fine), and also point out where the file can be found for further inspection.

Alex

A message that is not in the archive (sent off-list or not yet received): [email protected]

#46 lore raw

Re: [OE-core] [PATCH v5 4/5] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Alternatively, simply capture the output in result.output without summary.txt redirection
(e.g. drop the '> summary.txt' bit); we can fine-tune the failure processing later on.

Alex

Quoted 28 lines · Alexander Kanavin via lists.openembedded.org
Quoted 11 lines · Vinay Kumar

+ cmd = cmd + " cd %s; python3
src/bootstrap/bootstrap.py test %s --target %s > summary.txt 2>&1;" % (builddir, testargs, targetsys)
+ # To kill remote-test-server executing through
background ssh
+ killcommand = "kill -9 \$(ps | grep
remote-test-server | grep -v \"grep\" | awk '{print \$1}')"
+ cmd = cmd + "ssh %s root@%s \"%s\";" % (sshargs,
qemu.ip, killcommand)

(quoted diff) +2 -0
+                       result = runCmd(cmd)
+                       self.assertEqual(0, result.status, 'oe-selftest
Quoted 1 line

returned a non 0 status:%s' % result.output)

What does result.output contains if the test fails? Since both stdout and stderr are redirected to a file, there might be nothing at all there?

I'd suggest you actually print all of summary.txt in case of failure (yes it's over a megabyte, that is fine), and also point out where the file can be found for further inspection.

Alex

#47 lore raw

Re: [PATCH v5 4/5] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

In reply to Vinay Kumar
Quoted 7 lines · Vinay Kumar

+ # To kill remote-test-server executing through
background ssh
+ killcommand = "kill -9 \$(ps | grep
remote-test-server | grep -v \"grep\" | awk '{print \$1}')"
+ cmd = cmd + "ssh %s root@%s \"%s\";" % (sshargs,
qemu.ip, killcommand)

I don't think you actually need to kill the remote test server. As qemu will be stopped anyway, and with it, all the processes that run inside qemu.

Also, it's better to use cmd only to execute the tests. Starting the server is better done through SSHControl.run(), and copying the binary via SSHControl.copy_to() - see examples in selfttest's imagefeatures.py or runtime_test.py.

Alex

#48 lore raw

Re: [PATCH v5 4/5] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Hi Alex,

The reason why I changed this is, we have to execute "remote-test-server" on the image through background ssh. So that the "remote-test-server" will be alive waiting for connection. Then in the rust.py control passed to the next command (cmd) for execution.
If we use the sshcontrol.py method we have to set a timeout of 600 otherwise default timeout is 300. Even if the test execution completes early due to failure then we have to wait till this timeout.

I tried reducing the timeout to 60 seconds and some of the tests got skipped.

If that is ok I will use that copy_to and run from sshcontrol.py as we did in v4 patches and work for the result.output

Regards,
Vinay

Quoted 14 lines · Alexander Kanavin

meta/lib/oeqa/selftest/cases/rust.py line 43

Quoted 4 lines · Vinay Kumar
meta/lib/oeqa/selftest/cases/rust.py new file +3 -0
+                       # To kill remote-test-server executing through background ssh
+                       killcommand = "kill -9 \$(ps | grep remote-test-server |  grep -v \"grep\" | awk '{print \$1}')"
+                       cmd = cmd + "ssh %s root@%s \"%s\";" % (sshargs, qemu.ip, killcommand)

I don't think you actually need to kill the remote test server. As qemu will be stopped anyway, and with it, all the processes that run inside qemu.

Also, it's better to use cmd only to execute the tests. Starting the server is better done through SSHControl.run(), and copying the binary via SSHControl.copy_to() - see examples in selfttest's imagefeatures.py or runtime_test.py.

Alex

#49 lore raw

Re: [PATCH v5 4/5] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Hello Vinay,

sure, no problem. I see that SSHControl.run() isn't designed for starting background processes on the target. But I still think it's then better to use subprocess module for starting the server over ssh, rather than bundle everything into one gigantic runCmd().

Alex

Quoted 45 lines · Vinay Kumar

Hi Alex,

The reason why I changed this is, we have to execute "remote-test-server" on the image through background ssh. So that the "remote-test-server" will be alive waiting for connection. Then in the rust.py control passed to the next command (cmd) for execution.
If we use the sshcontrol.py method we have to set a timeout of 600 otherwise default timeout is 300. Even if the test execution completes early due to failure then we have to wait till this timeout.

I tried reducing the timeout to 60 seconds and some of the tests got skipped.

If that is ok I will use that copy_to and run from sshcontrol.py as we did in v4 patches and work for the result.output

Regards,
Vinay

Quoted 2 lines · Alexander Kanavin

On Thu, 27 May 2021 at 10:11, Vinay Kumar <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines

+ # To kill remote-test-server executing through

background ssh

Quoted 1 line
Quoted 1 line

+ killcommand = "kill -9 \$(ps | grep

remote-test-server | grep -v \"grep\" | awk '{print \$1}')"

Quoted 1 line
Quoted 1 line

+ cmd = cmd + "ssh %s root@%s \"%s\";" %

(sshargs, qemu.ip, killcommand)

Quoted 3 lines

I don't think you actually need to kill the remote test server. As qemu

will be stopped anyway, and with it, all the processes that run inside qemu.

Quoted 2 lines

Also, it's better to use cmd only to execute the tests. Starting the

server is better done through SSHControl.run(), and copying the binary via SSHControl.copy_to() - see examples in selfttest's imagefeatures.py or runtime_test.py.

Quoted 3 lines

Alex

#50 lore raw

PATCH v6 1/5 rust-testsuite.inc : Rust cross testing.

Below list of functions are part of rust-testsuite.inc setup_cargo_environment(): Build bootstrap and some early stage tools. do_rust_setup_snapshot(): Install the snapshot version of rust binaries. do_configure(): To generate config.toml
do_compile(): To build "remote-test-server" for qemutarget image.

---
 meta/recipes-devtools/rust/rust-testsuite.inc | 156 ++++++++++++++++++
 1 file changed, 156 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-testsuite.inc
meta/recipes-devtools/rust/rust-testsuite.inc new file +156 -0
new file mode 100644
index 0000000000..8dd2855e67
@@ -0,0 +1,156 @@
+SUMMARY = "Rust testing"
+HOMEPAGE = "https://rustc-dev-guide.rust-lang.org/tests/intro.html"
+SECTION = "test"
+LICENSE = "MIT | Apache-2.0"
+
+inherit rust
+inherit cargo_common
+
+DEPENDS += "file-native python3-native"
+EXCLUDE_FROM_WORLD = "1"
+
+# Path of target specification file "target-poky-linux.json"
+export RUST_TARGET_PATH="${STAGING_LIBDIR_NATIVE}/rustlib"
+
+export FORCE_CRATE_HASH="${BB_TASKHASH}"
+
+# We don't want to use bitbakes vendoring because the rust sources do their
+# own vendoring.
+CARGO_DISABLE_BITBAKE_VENDORING = "1"
+
+# We can't use RUST_BUILD_SYS here because that may be "musl" if
+# TCLIBC="musl". Snapshots are always -unknown-linux-gnu
+SNAPSHOT_BUILD_SYS = "${BUILD_ARCH}-unknown-linux-gnu"
+setup_cargo_environment () {
+    # The first step is to build bootstrap and some early stage tools,
+    # these are build for the same target as the snapshot, e.g.
+    # x86_64-unknown-linux-gnu.
+    # Later stages are build for the native target (i.e. target.x86_64-linux)
+    cargo_common_do_configure
+
+    printf '[target.%s]\n' "${SNAPSHOT_BUILD_SYS}" >> ${CARGO_HOME}/config
+    printf "linker = '%s'\n" "${RUST_BUILD_CCLD}" >> ${CARGO_HOME}/config
+}
+
+do_rust_setup_snapshot () {
+    for installer in "${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do
+        "${installer}" --prefix="${WORKDIR}/rust-snapshot" --disable-ldconfig
+    done
+
+    # Some versions of rust (e.g. 1.18.0) tries to find cargo in stage0/bin/cargo
+    # and fail without it there.
+    mkdir -p ${RUSTSRC}/build/${BUILD_SYS}
+    ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${BUILD_SYS}/stage0
+}
+addtask rust_setup_snapshot after do_unpack before do_configure
+do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
+
+python do_configure() {
+    import json
+    from distutils.version import LooseVersion
+    try:
+        import configparser
+    except ImportError:
+        import ConfigParser as configparser
+
+    # toml is rather similar to standard ini like format except it likes values
+    # that look more JSON like. So for our purposes simply escaping all values
+    # as JSON seem to work fine.
+
+    e = lambda s: json.dumps(s)
+
+    config = configparser.RawConfigParser()
+
+    # [target.ARCH-unknown-linux-gnu] in case of x86_64 [target.ARCH-poky-linux] 
+    target_section = "target.{}".format(d.getVar('TARGET_SYS', True))
+    config.add_section(target_section)
+
+    # Points to wrapper files which contain target specific compiler and linker commands. 
+    config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
+    config.set(target_section, "linker", e(d.expand("${RUST_TARGET_CCLD}")))
+
+    # If we don't do this rust-native will compile it's own llvm for BUILD.
+    # [target.${BUILD_ARCH}-unknown-linux-gnu]
+    target_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS', True))
+    config.add_section(target_section)
+
+    # Wrapper scripts of build system.
+    config.set(target_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
+
+    # [llvm]
+    config.add_section("llvm")
+    config.set("llvm", "targets", e("ARM;AArch64;Mips;PowerPC;RISCV;X86"))
+
+    # [rust]
+    config.add_section("rust")
+    config.set("rust", "rpath", e(True))
+    config.set("rust", "channel", e("stable"))
+
+    if LooseVersion(d.getVar("PV")) < LooseVersion("1.32.0"):
+        config.set("rust", "use-jemalloc", e(False))
+
+    # Whether or not to optimize the compiler and standard library
+    config.set("rust", "optimize", e(True))
+
+    # Emits extraneous output from tests to ensure that failures of the test
+    # harness are debuggable just from logfiles
+    config.set("rust", "verbose-tests", e(True))    
+
+    # Override default linker cc.
+    config.set("rust", "default-linker", e(d.expand("${RUST_BUILD_CCLD}")))
+
+    # [build]
+    config.add_section("build")
+    config.set("build", "submodules", e(False))
+    config.set("build", "docs", e(False))
+
+    rustc = d.expand("${WORKDIR}/rust-snapshot/bin/rustc")
+    config.set("build", "rustc", e(rustc))
+
+    cargo = d.expand("${WORKDIR}/rust-snapshot/bin/cargo")
+    config.set("build", "cargo", e(cargo))
+
+    config.set("build", "vendor", e(True))
+
+    targets = [d.getVar("TARGET_SYS", True)]
+    config.set("build", "target", e(targets))
+
+    hosts = [d.getVar("SNAPSHOT_BUILD_SYS", True)]
+    config.set("build", "host", e(hosts))
+
+    # We can't use BUILD_SYS since that is something the rust snapshot knows
+    # nothing about when trying to build some stage0 tools (like fabricate)
+    config.set("build", "build", e(d.getVar("SNAPSHOT_BUILD_SYS", True)))
+
+    with open("config.toml", "w") as f:
+        config.write(f)
+
+    # set up ${WORKDIR}/cargo_home
+    bb.build.exec_func("setup_cargo_environment", d)
+}
+
+
+rust_runx () {
+    echo "COMPILE ${PN}" "$@"
+
+    # CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a
+    # wide range of targets (not just TARGET). Yocto's settings for them will
+    # be inappropriate, avoid using.
+    unset CFLAGS
+    unset LDFLAGS
+    unset CXXFLAGS
+    unset CPPFLAGS
+
+    oe_cargo_fix_env
+
+    python3 src/bootstrap/bootstrap.py ${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose
+}
+rust_runx[vardepsexclude] += "PARALLEL_MAKE"
+
+do_compile () {
+
+    rust_runx build src/tools/remote-test-server --target "${TARGET_SYS}"
+}
+
Signature · 1 line
2.17.1
#51 lore raw

PATCH v6 2/5 Add rust testsuite for 1.46.0

---
 meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb | 3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb
meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb new file +3 -0
new file mode 100644
index 0000000000..ad758b71f4
@@ -0,0 +1,3 @@
+require rust-testsuite.inc
+require rust-source-${PV}.inc
+require rust-snapshot-${PV}.inc
Signature · 1 line
2.17.1
#52 lore raw

PATCH v6 3/5 rust.inc : Changed target cpu for powerpc to "7400"

In reply to Vinay Kumar

While executing rust-testing observed some ui testfailures due to below warning message.

'powerpc' is not a recognized processor for this target in rust

So renamed target cpu for "powerpc" in "llvm_cpu" to "7400" as per default tune for qemuppc.

---
 meta/recipes-devtools/rust/rust.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/rust/rust.inc +1 -1
index a1223f45e7..ee3176b559 100644
@@ -290,7 +290,7 @@ def llvm_cpu(d):
     trans['x86-64'] = "x86-64"
     trans['i686'] = "i686"
     trans['i586'] = "i586"
-    trans['powerpc'] = "powerpc"
+    trans['powerpc'] = "7400"
     trans['mips64'] = "mips64"
     trans['mips64el'] = "mips64"
     trans['riscv64'] = "generic-rv64"
Signature · 1 line
2.17.1
#53 lore raw

PATCH v6 4/5 oeqa/selftest/cases/rust.py: Rust oe-selftest script.

In reply to Vinay Kumar

Build remote-test-server copy to image and execute remotely through background ssh.

Execute rust testing by exporting required paths.
And capture the output in result.output

Print the results in case of failure of runCmd().

---
 meta/lib/oeqa/selftest/cases/rust.py | 52 ++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/rust.py
meta/lib/oeqa/selftest/cases/rust.py new file +52 -0
new file mode 100644
index 0000000000..19206e7b07
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: MIT
+import os
+import subprocess
+from oeqa.core.decorator import OETestTag
+from oeqa.core.case import OEPTestResultTestCase
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu, Command
+from oeqa.utils.sshcontrol import SSHControl
+
+class RustSelfTestBase(OESelftestTestCase, OEPTestResultTestCase):
+
+	def run_check_emulated(self, *args, **kwargs):
+		# build remote-test-server before image build
+		recipe = "rust-testsuite"
+		bitbake("{} -c compile".format(recipe))
+		builddir = get_bb_var("B", "rust-testsuite")
+		# build core-image-minimal with required packages
+		default_installed_packages = ["libgcc", "libstdc++", "libatomic", "libgomp"]
+		features = []
+		features.append('IMAGE_FEATURES += "ssh-server-openssh"')
+		features.append('CORE_IMAGE_EXTRA_INSTALL += "{0}"'.format(" ".join(default_installed_packages)))
+		self.write_config("\n".join(features))
+		bitbake("core-image-minimal")
+		# wrap the execution with a qemu instance
+		with runqemu("core-image-minimal", runqemuparams = "nographic") as qemu:
+			# Copy remote-test-server to image through scp
+			ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user="root")
+			ssh.copy_to(builddir + "/" + "build/x86_64-unknown-linux-gnu/stage2-tools-bin/remote-test-server","~/")
+			# Execute remote-test-server on image through background ssh
+			command = '~/remote-test-server -v remote'
+			sshrun=subprocess.Popen(("ssh", '-o',  'UserKnownHostsFile=/dev/null', '-o',  'StrictHostKeyChecking=no', '-f', "root@%s" % qemu.ip, command),
+                                shell=False,
+                                stdout=subprocess.PIPE,
+                                stderr=subprocess.PIPE)
+			# Get the values of variables.
+			targetsys = get_bb_var("TARGET_SYS", "rust-testsuite")
+			rustlibpath = get_bb_var("STAGING_LIBDIR_NATIVE", "rust-testsuite")
+			tmpdir = get_bb_var("TMPDIR", "rust-testsuite")
+			testargs = "--no-fail-fast --bless"
+			# Set path for target-poky-linux-gcc, RUST_TARGET_PATH and hosttools.                        
+			cmd = " export PATH=%s/../bin:$PATH;" % rustlibpath
+			cmd = cmd + " export PATH=%s/../bin/%s:%s/hosttools:$PATH;" % (rustlibpath, targetsys, tmpdir) 
+			cmd = cmd + " export RUST_TARGET_PATH=%s/rustlib;" % rustlibpath
+			# Trigger testing.                        
+			cmd = cmd + " export TEST_DEVICE_ADDR=\"%s:12345\";" % qemu.ip
+			cmd = cmd + " cd %s;  python3 src/bootstrap/bootstrap.py test codegen %s --target %s ;" % (builddir, testargs, targetsys)
+			result = runCmd(cmd)
+
+@OETestTag("toolchain-system")
+class RustSelfTestSystemEmulated(RustSelfTestBase):
+	def test_rust(self):
+		self.run_check_emulated("rust")
Signature · 1 line
2.17.1
#54 lore raw

PATCH v6 5/5 rust.inc : Fix for aarch64 feature.

In reply to Vinay Kumar

While executing ui testing observed failures due to below warning,

"'+v8' is not a recognized feature for this target (ignoring feature)"

Same got fixed by backporting below patch,
http://git.yoctoproject.org/cgit.cgi/poky-contrib/commit/?h=rmacleod/rust-wip-2021-02-16&id=f243e4bbd5414ce519336753a68c53ee60cbe89e

---
 meta/recipes-devtools/rust/rust.inc | 3 ---
 1 file changed, 3 deletions(-)
meta/recipes-devtools/rust/rust.inc +0 -3
index ee3176b559..fb20bbd0fb 100644
@@ -64,9 +64,6 @@ def llvm_features_from_tune(d):
     if 'neon' in feat:
         f.append("+neon")
 
-    if 'aarch64' in feat:
-        f.append("+v8")
-
     if 'mips32' in feat:
         f.append("+mips32")
 
Signature · 1 line
2.17.1
#55 lore raw

PATCH v7 1/5 rust-testsuite.inc : Rust cross testing.

In reply to Alexander Kanavin

Below list of functions are part of rust-testsuite.inc setup_cargo_environment(): Build bootstrap and some early stage tools. do_rust_setup_snapshot(): Install the snapshot version of rust binaries. do_configure(): To generate config.toml
do_compile(): To build "remote-test-server" for qemutarget image.

---
 meta/recipes-devtools/rust/rust-testsuite.inc | 156 ++++++++++++++++++
 1 file changed, 156 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-testsuite.inc
meta/recipes-devtools/rust/rust-testsuite.inc new file +156 -0
new file mode 100644
index 0000000000..8dd2855e67
@@ -0,0 +1,156 @@
+SUMMARY = "Rust testing"
+HOMEPAGE = "https://rustc-dev-guide.rust-lang.org/tests/intro.html"
+SECTION = "test"
+LICENSE = "MIT | Apache-2.0"
+
+inherit rust
+inherit cargo_common
+
+DEPENDS += "file-native python3-native"
+EXCLUDE_FROM_WORLD = "1"
+
+# Path of target specification file "target-poky-linux.json"
+export RUST_TARGET_PATH="${STAGING_LIBDIR_NATIVE}/rustlib"
+
+export FORCE_CRATE_HASH="${BB_TASKHASH}"
+
+# We don't want to use bitbakes vendoring because the rust sources do their
+# own vendoring.
+CARGO_DISABLE_BITBAKE_VENDORING = "1"
+
+# We can't use RUST_BUILD_SYS here because that may be "musl" if
+# TCLIBC="musl". Snapshots are always -unknown-linux-gnu
+SNAPSHOT_BUILD_SYS = "${BUILD_ARCH}-unknown-linux-gnu"
+setup_cargo_environment () {
+    # The first step is to build bootstrap and some early stage tools,
+    # these are build for the same target as the snapshot, e.g.
+    # x86_64-unknown-linux-gnu.
+    # Later stages are build for the native target (i.e. target.x86_64-linux)
+    cargo_common_do_configure
+
+    printf '[target.%s]\n' "${SNAPSHOT_BUILD_SYS}" >> ${CARGO_HOME}/config
+    printf "linker = '%s'\n" "${RUST_BUILD_CCLD}" >> ${CARGO_HOME}/config
+}
+
+do_rust_setup_snapshot () {
+    for installer in "${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do
+        "${installer}" --prefix="${WORKDIR}/rust-snapshot" --disable-ldconfig
+    done
+
+    # Some versions of rust (e.g. 1.18.0) tries to find cargo in stage0/bin/cargo
+    # and fail without it there.
+    mkdir -p ${RUSTSRC}/build/${BUILD_SYS}
+    ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${BUILD_SYS}/stage0
+}
+addtask rust_setup_snapshot after do_unpack before do_configure
+do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
+
+python do_configure() {
+    import json
+    from distutils.version import LooseVersion
+    try:
+        import configparser
+    except ImportError:
+        import ConfigParser as configparser
+
+    # toml is rather similar to standard ini like format except it likes values
+    # that look more JSON like. So for our purposes simply escaping all values
+    # as JSON seem to work fine.
+
+    e = lambda s: json.dumps(s)
+
+    config = configparser.RawConfigParser()
+
+    # [target.ARCH-unknown-linux-gnu] in case of x86_64 [target.ARCH-poky-linux] 
+    target_section = "target.{}".format(d.getVar('TARGET_SYS', True))
+    config.add_section(target_section)
+
+    # Points to wrapper files which contain target specific compiler and linker commands. 
+    config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
+    config.set(target_section, "linker", e(d.expand("${RUST_TARGET_CCLD}")))
+
+    # If we don't do this rust-native will compile it's own llvm for BUILD.
+    # [target.${BUILD_ARCH}-unknown-linux-gnu]
+    target_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS', True))
+    config.add_section(target_section)
+
+    # Wrapper scripts of build system.
+    config.set(target_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
+
+    # [llvm]
+    config.add_section("llvm")
+    config.set("llvm", "targets", e("ARM;AArch64;Mips;PowerPC;RISCV;X86"))
+
+    # [rust]
+    config.add_section("rust")
+    config.set("rust", "rpath", e(True))
+    config.set("rust", "channel", e("stable"))
+
+    if LooseVersion(d.getVar("PV")) < LooseVersion("1.32.0"):
+        config.set("rust", "use-jemalloc", e(False))
+
+    # Whether or not to optimize the compiler and standard library
+    config.set("rust", "optimize", e(True))
+
+    # Emits extraneous output from tests to ensure that failures of the test
+    # harness are debuggable just from logfiles
+    config.set("rust", "verbose-tests", e(True))    
+
+    # Override default linker cc.
+    config.set("rust", "default-linker", e(d.expand("${RUST_BUILD_CCLD}")))
+
+    # [build]
+    config.add_section("build")
+    config.set("build", "submodules", e(False))
+    config.set("build", "docs", e(False))
+
+    rustc = d.expand("${WORKDIR}/rust-snapshot/bin/rustc")
+    config.set("build", "rustc", e(rustc))
+
+    cargo = d.expand("${WORKDIR}/rust-snapshot/bin/cargo")
+    config.set("build", "cargo", e(cargo))
+
+    config.set("build", "vendor", e(True))
+
+    targets = [d.getVar("TARGET_SYS", True)]
+    config.set("build", "target", e(targets))
+
+    hosts = [d.getVar("SNAPSHOT_BUILD_SYS", True)]
+    config.set("build", "host", e(hosts))
+
+    # We can't use BUILD_SYS since that is something the rust snapshot knows
+    # nothing about when trying to build some stage0 tools (like fabricate)
+    config.set("build", "build", e(d.getVar("SNAPSHOT_BUILD_SYS", True)))
+
+    with open("config.toml", "w") as f:
+        config.write(f)
+
+    # set up ${WORKDIR}/cargo_home
+    bb.build.exec_func("setup_cargo_environment", d)
+}
+
+
+rust_runx () {
+    echo "COMPILE ${PN}" "$@"
+
+    # CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a
+    # wide range of targets (not just TARGET). Yocto's settings for them will
+    # be inappropriate, avoid using.
+    unset CFLAGS
+    unset LDFLAGS
+    unset CXXFLAGS
+    unset CPPFLAGS
+
+    oe_cargo_fix_env
+
+    python3 src/bootstrap/bootstrap.py ${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose
+}
+rust_runx[vardepsexclude] += "PARALLEL_MAKE"
+
+do_compile () {
+
+    rust_runx build src/tools/remote-test-server --target "${TARGET_SYS}"
+}
+
Signature · 1 line
2.17.1
#56 lore raw

PATCH v7 2/5 rust-testsuite_1.46.0.bb

---
 meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb | 3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb
meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb new file +3 -0
new file mode 100644
index 0000000000..ad758b71f4
@@ -0,0 +1,3 @@
+require rust-testsuite.inc
+require rust-source-${PV}.inc
+require rust-snapshot-${PV}.inc
Signature · 1 line
2.17.1
#57 lore raw

PATCH v7 3/5 rust.inc : Changed target cpu for powerpc to "7400"

In reply to Vinay Kumar

While executing rust-testing observed some ui testfailures due to below warning message.

'powerpc' is not a recognized processor for this target in rust

So renamed target cpu for "powerpc" in "llvm_cpu" to "7400" as per default tune for qemuppc.

---
 meta/recipes-devtools/rust/rust.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/rust/rust.inc +1 -1
index a1223f45e7..ee3176b559 100644
@@ -290,7 +290,7 @@ def llvm_cpu(d):
     trans['x86-64'] = "x86-64"
     trans['i686'] = "i686"
     trans['i586'] = "i586"
-    trans['powerpc'] = "powerpc"
+    trans['powerpc'] = "7400"
     trans['mips64'] = "mips64"
     trans['mips64el'] = "mips64"
     trans['riscv64'] = "generic-rv64"
Signature · 1 line
2.17.1
#58 lore raw

PATCH v7 4/5 oeqa/selftest/cases/rust.py: Rust oe-selftest script.

In reply to Vinay Kumar

Build remote-test-server copy to image and execute remotely through background ssh.

Execute rust testing by exporting required paths.
And capture the output in result.output

Print the results in case of failure of runCmd().

---
 meta/lib/oeqa/selftest/cases/rust.py | 52 ++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/rust.py
meta/lib/oeqa/selftest/cases/rust.py new file +52 -0
new file mode 100644
index 0000000000..8643d8120d
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: MIT
+import os
+import subprocess
+from oeqa.core.decorator import OETestTag
+from oeqa.core.case import OEPTestResultTestCase
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu, Command
+from oeqa.utils.sshcontrol import SSHControl
+
+class RustSelfTestBase(OESelftestTestCase, OEPTestResultTestCase):
+
+	def run_check_emulated(self, *args, **kwargs):
+		# build remote-test-server before image build
+		recipe = "rust-testsuite"
+		bitbake("{} -c compile".format(recipe))
+		builddir = get_bb_var("B", "rust-testsuite")
+		# build core-image-minimal with required packages
+		default_installed_packages = ["libgcc", "libstdc++", "libatomic", "libgomp"]
+		features = []
+		features.append('IMAGE_FEATURES += "ssh-server-openssh"')
+		features.append('CORE_IMAGE_EXTRA_INSTALL += "{0}"'.format(" ".join(default_installed_packages)))
+		self.write_config("\n".join(features))
+		bitbake("core-image-minimal")
+		# wrap the execution with a qemu instance
+		with runqemu("core-image-minimal", runqemuparams = "nographic") as qemu:
+			# Copy remote-test-server to image through scp
+			ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user="root")
+			ssh.copy_to(builddir + "/" + "build/x86_64-unknown-linux-gnu/stage2-tools-bin/remote-test-server","~/")
+			# Execute remote-test-server on image through background ssh
+			command = '~/remote-test-server -v remote'
+			sshrun=subprocess.Popen(("ssh", '-o',  'UserKnownHostsFile=/dev/null', '-o',  'StrictHostKeyChecking=no', '-f', "root@%s" % qemu.ip, command),
+                                shell=False,
+                                stdout=subprocess.PIPE,
+                                stderr=subprocess.PIPE)
+			# Get the values of variables.
+			targetsys = get_bb_var("TARGET_SYS", "rust-testsuite")
+			rustlibpath = get_bb_var("STAGING_LIBDIR_NATIVE", "rust-testsuite")
+			tmpdir = get_bb_var("TMPDIR", "rust-testsuite")
+			testargs = "--no-fail-fast --bless"
+			# Set path for target-poky-linux-gcc, RUST_TARGET_PATH and hosttools.                        
+			cmd = " export PATH=%s/../bin:$PATH;" % rustlibpath
+			cmd = cmd + " export PATH=%s/../bin/%s:%s/hosttools:$PATH;" % (rustlibpath, targetsys, tmpdir) 
+			cmd = cmd + " export RUST_TARGET_PATH=%s/rustlib;" % rustlibpath
+			# Trigger testing.                        
+			cmd = cmd + " export TEST_DEVICE_ADDR=\"%s:12345\";" % qemu.ip
+			cmd = cmd + " cd %s;  python3 src/bootstrap/bootstrap.py test %s --target %s ;" % (builddir, testargs, targetsys)
+			result = runCmd(cmd)
+
+@OETestTag("toolchain-system")
+class RustSelfTestSystemEmulated(RustSelfTestBase):
+	def test_rust(self):
+		self.run_check_emulated("rust")
Signature · 1 line
2.17.1
#59 lore raw

PATCH v7 5/5 rust.inc : Fix for aarch64 feature.

In reply to Vinay Kumar

While executing ui testing observed failures due to below warning,

"'+v8' is not a recognized feature for this target (ignoring feature)"

Same got fixed by backporting below patch,
http://git.yoctoproject.org/cgit.cgi/poky-contrib/commit/?h=rmacleod/rust-wip-2021-02-16&id=f243e4bbd5414ce519336753a68c53ee60cbe89e

---
 meta/recipes-devtools/rust/rust.inc | 3 ---
 1 file changed, 3 deletions(-)
meta/recipes-devtools/rust/rust.inc +0 -3
index ee3176b559..fb20bbd0fb 100644
@@ -64,9 +64,6 @@ def llvm_features_from_tune(d):
     if 'neon' in feat:
         f.append("+neon")
 
-    if 'aarch64' in feat:
-        f.append("+v8")
-
     if 'mips32' in feat:
         f.append("+mips32")
 
Signature · 1 line
2.17.1
#60 lore raw

Re: [PATCH v5 4/5] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

In reply to Alexander Kanavin

Hi Alex,

Please ignore the v6 patch set. As there is minor correction in rust.py
- cmd = cmd + " cd %s; python3 src/bootstrap/bootstrap.py test codegen %s --target %s ;" % (builddir, testargs, targetsys)
+ cmd = cmd + " cd %s; python3 src/bootstrap/bootstrap.py test %s --target %s ;" % (builddir, testargs, targetsys)

Sent v7 patches with corrections of runCmd and ssh.

For copying "remote-test-server" used copy_to from sshcontrol.py, and for ssh background execution used "subprocess" module.

Regarding result.output, whenever there is failure it gets printed test summary and also captured in "oe-selftest-results.log". And when there is failure with runCmd then no test summary details or printed. This is taken care of by runCmd() itself from commands.py.

Verified with 2 independent test modules "compile-fail" and "codegen" which are part of rust testing.

compile-test : All tests get passed and no errors thrown, so oe-selftes does not print the test results.

codegen : Some of the tests fail, making the shell exit. In this case oe-selftest prints test details with stdout and stderr.

Regards,
Vinay

Quoted 44 lines · Alexander Kanavin

Hello Vinay,

sure, no problem. I see that SSHControl.run() isn't designed for starting background processes on the target. But I still think it's then better to use subprocess module for starting the server over ssh, rather than bundle everything into one gigantic runCmd().

Alex

Quoted 36 lines · Vinay Kumar

Hi Alex,

The reason why I changed this is, we have to execute "remote-test-server" on the image through background ssh. So that the "remote-test-server" will be alive waiting for connection. Then in the rust.py control passed to the next command (cmd) for execution.
If we use the sshcontrol.py method we have to set a timeout of 600 otherwise default timeout is 300. Even if the test execution completes early due to failure then we have to wait till this timeout.

I tried reducing the timeout to 60 seconds and some of the tests got skipped.

If that is ok I will use that copy_to and run from sshcontrol.py as we did in v4 patches and work for the result.output

Regards,
Vinay

Quoted 14 lines · Alexander Kanavin

meta/lib/oeqa/selftest/cases/rust.py line 43

Quoted 4 lines · Vinay Kumar
meta/lib/oeqa/selftest/cases/rust.py new file +3 -0
+                       # To kill remote-test-server executing through background ssh
+                       killcommand = "kill -9 \$(ps | grep remote-test-server |  grep -v \"grep\" | awk '{print \$1}')"
+                       cmd = cmd + "ssh %s root@%s \"%s\";" % (sshargs, qemu.ip, killcommand)

I don't think you actually need to kill the remote test server. As qemu will be stopped anyway, and with it, all the processes that run inside qemu.

Also, it's better to use cmd only to execute the tests. Starting the server is better done through SSHControl.run(), and copying the binary via SSHControl.copy_to() - see examples in selfttest's imagefeatures.py or runtime_test.py.

Alex

#61 lore raw

Re: [PATCH v5 4/5] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Thanks Vinay, the code looks nice and clean now, and I have no further comments about it.

I would only ask that you put the amount of time it takes to (successfully) execute as a comment just before the class definition, so that anyone who needs to allocate CI resources for this test knows what is the reasonable way to run it.

Alex

Quoted 92 lines · Vinay Kumar

Hi Alex,

Please ignore the v6 patch set. As there is minor correction in rust.py
- cmd = cmd + " cd %s; python3 src/bootstrap/bootstrap.py test codegen %s --target %s ;" % (builddir, testargs, targetsys)
+ cmd = cmd + " cd %s; python3 src/bootstrap/bootstrap.py test %s --target %s ;" % (builddir, testargs, targetsys)

Sent v7 patches with corrections of runCmd and ssh.

For copying "remote-test-server" used copy_to from sshcontrol.py, and for ssh background execution used "subprocess" module.

Regarding result.output, whenever there is failure it gets printed test summary and also captured in "oe-selftest-results.log". And when there is failure with runCmd then no test summary details or printed. This is taken care of by runCmd() itself from commands.py.

Verified with 2 independent test modules "compile-fail" and "codegen" which are part of rust testing.

compile-test : All tests get passed and no errors thrown, so oe-selftes does not print the test results.

codegen : Some of the tests fail, making the shell exit. In this case oe-selftest prints test details with stdout and stderr.

Regards,
Vinay

Quoted 4 lines · Alexander Kanavin

Hello Vinay,

sure, no problem. I see that SSHControl.run() isn't designed for

starting background processes on the target. But I still think it's then better to use subprocess module for starting the server over ssh, rather than bundle everything into one gigantic runCmd().

Quoted 4 lines

Alex

On Thu, 27 May 2021 at 14:18, Vinay Kumar <[email protected]>

Quoted 13 lines · wrote:
Quoted 13 lines

Hi Alex,

The reason why I changed this is, we have to execute "remote-test-server" on the image through background ssh. So that the "remote-test-server" will be alive waiting for connection. Then in the rust.py control passed to the next command (cmd) for execution.
If we use the sshcontrol.py method we have to set a timeout of 600 otherwise default timeout is 300. Even if the test execution completes early due to failure then we have to wait till this timeout.

I tried reducing the timeout to 60 seconds and some of the tests got

skipped.

Quoted 11 lines
Quoted 11 lines

If that is ok I will use that copy_to and run from sshcontrol.py as we did in v4 patches and work for the result.output

Regards,
Vinay

Quoted 2 lines · Alexander Kanavin

On Thu, 27 May 2021 at 10:11, Vinay Kumar <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+ # To kill remote-test-server executing

through background ssh

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ killcommand = "kill -9 \$(ps | grep

remote-test-server | grep -v \"grep\" | awk '{print \$1}')"

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ cmd = cmd + "ssh %s root@%s \"%s\";" %

(sshargs, qemu.ip, killcommand)

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I don't think you actually need to kill the remote test server. As

qemu will be stopped anyway, and with it, all the processes that run inside qemu.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Also, it's better to use cmd only to execute the tests. Starting the

server is better done through SSHControl.run(), and copying the binary via SSHControl.copy_to() - see examples in selfttest's imagefeatures.py or runtime_test.py.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Alex

#62 lore raw

Re: [PATCH v5 4/5] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Hi Alex,

Is the below comment about execution time is ok ?

+# Total time taken for testing is of about 2hr 20min, with PARALLEL_MAKE set to 40 number of jobs.
class RustSelfTestBase(OESelftestTestCase, OEPTestResultTestCase):

And, should I send v8 version of patches (all 5 patches) or only the patch of rust.py with this comment as v8 patch ?

Regards,
Vinay

Quoted 86 lines · Alexander Kanavin

Thanks Vinay, the code looks nice and clean now, and I have no further comments about it.

I would only ask that you put the amount of time it takes to (successfully) execute as a comment just before the class definition, so that anyone who needs to allocate CI resources for this test knows what is the reasonable way to run it.

Alex

Quoted 78 lines · Vinay Kumar

Hi Alex,

Please ignore the v6 patch set. As there is minor correction in rust.py
- cmd = cmd + " cd %s; python3 src/bootstrap/bootstrap.py test codegen %s --target %s ;" % (builddir, testargs, targetsys)
+ cmd = cmd + " cd %s; python3 src/bootstrap/bootstrap.py test %s --target %s ;" % (builddir, testargs, targetsys)

Sent v7 patches with corrections of runCmd and ssh.

For copying "remote-test-server" used copy_to from sshcontrol.py, and for ssh background execution used "subprocess" module.

Regarding result.output, whenever there is failure it gets printed test summary and also captured in "oe-selftest-results.log". And when there is failure with runCmd then no test summary details or printed. This is taken care of by runCmd() itself from commands.py.

Verified with 2 independent test modules "compile-fail" and "codegen" which are part of rust testing.

compile-test : All tests get passed and no errors thrown, so oe-selftes does not print the test results.

codegen : Some of the tests fail, making the shell exit. In this case oe-selftest prints test details with stdout and stderr.

Regards,
Vinay

Quoted 44 lines · Alexander Kanavin

Hello Vinay,

sure, no problem. I see that SSHControl.run() isn't designed for starting background processes on the target. But I still think it's then better to use subprocess module for starting the server over ssh, rather than bundle everything into one gigantic runCmd().

Alex

Quoted 36 lines · Vinay Kumar

Hi Alex,

The reason why I changed this is, we have to execute "remote-test-server" on the image through background ssh. So that the "remote-test-server" will be alive waiting for connection. Then in the rust.py control passed to the next command (cmd) for execution.
If we use the sshcontrol.py method we have to set a timeout of 600 otherwise default timeout is 300. Even if the test execution completes early due to failure then we have to wait till this timeout.

I tried reducing the timeout to 60 seconds and some of the tests got skipped.

If that is ok I will use that copy_to and run from sshcontrol.py as we did in v4 patches and work for the result.output

Regards,
Vinay

Quoted 14 lines · Alexander Kanavin

meta/lib/oeqa/selftest/cases/rust.py line 43

Quoted 4 lines · Vinay Kumar
meta/lib/oeqa/selftest/cases/rust.py new file +3 -0
+                       # To kill remote-test-server executing through background ssh
+                       killcommand = "kill -9 \$(ps | grep remote-test-server |  grep -v \"grep\" | awk '{print \$1}')"
+                       cmd = cmd + "ssh %s root@%s \"%s\";" % (sshargs, qemu.ip, killcommand)

I don't think you actually need to kill the remote test server. As qemu will be stopped anyway, and with it, all the processes that run inside qemu.

Also, it's better to use cmd only to execute the tests. Starting the server is better done through SSHControl.run(), and copying the binary via SSHControl.copy_to() - see examples in selfttest's imagefeatures.py or runtime_test.py.

Alex

#63 lore raw

Re: [PATCH v5 4/5] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Thanks, that is fine and please resend once more the whole set.

Alex

Quoted 125 lines · Vinay Kumar

Hi Alex,

Is the below comment about execution time is ok ?

+# Total time taken for testing is of about 2hr 20min, with PARALLEL_MAKE set to 40 number of jobs.
class RustSelfTestBase(OESelftestTestCase, OEPTestResultTestCase):

And, should I send v8 version of patches (all 5 patches) or only the patch of rust.py with this comment as v8 patch ?

Regards,
Vinay

Quoted 2 lines · Alexander Kanavin

Thanks Vinay, the code looks nice and clean now, and I have no further

comments about it.

Quoted 2 lines

I would only ask that you put the amount of time it takes to

(successfully) execute as a comment just before the class definition, so that anyone who needs to allocate CI resources for this test knows what is the reasonable way to run it.

Quoted 4 lines

Alex

On Fri, 28 May 2021 at 18:13, Vinay Kumar <[email protected]>

Quoted 32 lines · wrote:
Quoted 32 lines

Hi Alex,

Please ignore the v6 patch set. As there is minor correction in rust.py
- cmd = cmd + " cd %s; python3 src/bootstrap/bootstrap.py test codegen %s --target %s ;" % (builddir, testargs, targetsys)
+ cmd = cmd + " cd %s; python3 src/bootstrap/bootstrap.py test %s --target %s ;" % (builddir, testargs, targetsys)

Sent v7 patches with corrections of runCmd and ssh.

For copying "remote-test-server" used copy_to from sshcontrol.py, and for ssh background execution used "subprocess" module.

Regarding result.output, whenever there is failure it gets printed test summary and also captured in "oe-selftest-results.log". And when there is failure with runCmd then no test summary details or printed. This is taken care of by runCmd() itself from commands.py.

Verified with 2 independent test modules "compile-fail" and "codegen" which are part of rust testing.

compile-test : All tests get passed and no errors thrown, so oe-selftes does not print the test results.

codegen : Some of the tests fail, making the shell exit. In this case oe-selftest prints test details with stdout and stderr.

Regards,
Vinay

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines · Alexander Kanavin

Hello Vinay,

sure, no problem. I see that SSHControl.run() isn't designed for

starting background processes on the target. But I still think it's then better to use subprocess module for starting the server over ssh, rather than bundle everything into one gigantic runCmd().

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Alex

On Thu, 27 May 2021 at 14:18, Vinay Kumar <[email protected]>

Quoted 6 lines · wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Hi Alex,

The reason why I changed this is, we have to execute "remote-test-server" on the image through background ssh. So that the "remote-test-server" will be alive waiting for

connection.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Then in the rust.py control passed to the next command (cmd) for execution.
If we use the sshcontrol.py method we have to set a timeout of 600 otherwise default timeout is 300. Even if the test execution

completes

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

early due to failure then we have to wait till this timeout.

I tried reducing the timeout to 60 seconds and some of the tests got

skipped.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

If that is ok I will use that copy_to and run from sshcontrol.py as

we

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

did in v4 patches and work for the result.output

Regards,
Vinay

Quoted 2 lines · Alexander Kanavin

On Thu, 27 May 2021 at 10:11, Vinay Kumar <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+ # To kill remote-test-server executing

through background ssh

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ killcommand = "kill -9 \$(ps | grep

remote-test-server | grep -v \"grep\" | awk '{print \$1}')"

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ cmd = cmd + "ssh %s root@%s \"%s\";" %

(sshargs, qemu.ip, killcommand)

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I don't think you actually need to kill the remote test server. As

qemu will be stopped anyway, and with it, all the processes that run inside qemu.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Also, it's better to use cmd only to execute the tests. Starting

the server is better done through SSHControl.run(), and copying the binary via SSHControl.copy_to() - see examples in selfttest's imagefeatures.py or runtime_test.py.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Alex

#64 lore raw

PATCH v8 1/5 rust-testsuite.inc : Rust cross testing.

Below list of functions are part of rust-testsuite.inc setup_cargo_environment(): Build bootstrap and some early stage tools. do_rust_setup_snapshot(): Install the snapshot version of rust binaries. do_configure(): To generate config.toml
do_compile(): To build "remote-test-server" for qemutarget image.

---
 meta/recipes-devtools/rust/rust-testsuite.inc | 155 ++++++++++++++++++
 1 file changed, 155 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-testsuite.inc
meta/recipes-devtools/rust/rust-testsuite.inc new file +155 -0
new file mode 100644
index 0000000000..ef9b660c79
@@ -0,0 +1,155 @@
+SUMMARY = "Rust testing"
+HOMEPAGE = "https://rustc-dev-guide.rust-lang.org/tests/intro.html"
+SECTION = "test"
+LICENSE = "MIT | Apache-2.0"
+
+inherit rust
+inherit cargo_common
+
+DEPENDS += "file-native python3-native"
+EXCLUDE_FROM_WORLD = "1"
+
+# Path of target specification file "target-poky-linux.json"
+export RUST_TARGET_PATH="${STAGING_LIBDIR_NATIVE}/rustlib"
+
+export FORCE_CRATE_HASH="${BB_TASKHASH}"
+
+# We don't want to use bitbakes vendoring because the rust sources do their
+# own vendoring.
+CARGO_DISABLE_BITBAKE_VENDORING = "1"
+
+# We can't use RUST_BUILD_SYS here because that may be "musl" if
+# TCLIBC="musl". Snapshots are always -unknown-linux-gnu
+SNAPSHOT_BUILD_SYS = "${BUILD_ARCH}-unknown-linux-gnu"
+setup_cargo_environment () {
+    # The first step is to build bootstrap and some early stage tools,
+    # these are build for the same target as the snapshot, e.g.
+    # x86_64-unknown-linux-gnu.
+    # Later stages are build for the native target (i.e. target.x86_64-linux)
+    cargo_common_do_configure
+
+    printf '[target.%s]\n' "${SNAPSHOT_BUILD_SYS}" >> ${CARGO_HOME}/config
+    printf "linker = '%s'\n" "${RUST_BUILD_CCLD}" >> ${CARGO_HOME}/config
+}
+
+do_rust_setup_snapshot () {
+    for installer in "${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do
+        "${installer}" --prefix="${WORKDIR}/rust-snapshot" --disable-ldconfig
+    done
+
+    # Some versions of rust (e.g. 1.18.0) tries to find cargo in stage0/bin/cargo
+    # and fail without it there.
+    mkdir -p ${RUSTSRC}/build/${BUILD_SYS}
+    ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${BUILD_SYS}/stage0
+}
+addtask rust_setup_snapshot after do_unpack before do_configure
+do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
+
+python do_configure() {
+    import json
+    from distutils.version import LooseVersion
+    try:
+        import configparser
+    except ImportError:
+        import ConfigParser as configparser
+
+    # toml is rather similar to standard ini like format except it likes values
+    # that look more JSON like. So for our purposes simply escaping all values
+    # as JSON seem to work fine.
+
+    e = lambda s: json.dumps(s)
+
+    config = configparser.RawConfigParser()
+
+    # [target.ARCH-unknown-linux-gnu] in case of x86_64 [target.ARCH-poky-linux]
+    target_section = "target.{}".format(d.getVar('TARGET_SYS', True))
+    config.add_section(target_section)
+
+    # Points to wrapper files which contain target specific compiler and linker commands.
+    config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
+    config.set(target_section, "linker", e(d.expand("${RUST_TARGET_CCLD}")))
+
+    # If we don't do this rust-native will compile it's own llvm for BUILD.
+    # [target.${BUILD_ARCH}-unknown-linux-gnu]
+    target_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS', True))
+    config.add_section(target_section)
+
+    # Wrapper scripts of build system.
+    config.set(target_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
+
+    # [llvm]
+    config.add_section("llvm")
+    config.set("llvm", "targets", e("ARM;AArch64;Mips;PowerPC;RISCV;X86"))
+
+    # [rust]
+    config.add_section("rust")
+    config.set("rust", "rpath", e(True))
+    config.set("rust", "channel", e("stable"))
+
+    if LooseVersion(d.getVar("PV")) < LooseVersion("1.32.0"):
+        config.set("rust", "use-jemalloc", e(False))
+
+    # Whether or not to optimize the compiler and standard library
+    config.set("rust", "optimize", e(True))
+
+    # Emits extraneous output from tests to ensure that failures of the test
+    # harness are debuggable just from logfiles
+    config.set("rust", "verbose-tests", e(True))
+
+    # Override default linker cc.
+    config.set("rust", "default-linker", e(d.expand("${RUST_BUILD_CCLD}")))
+
+    # [build]
+    config.add_section("build")
+    config.set("build", "submodules", e(False))
+    config.set("build", "docs", e(False))
+
+    rustc = d.expand("${WORKDIR}/rust-snapshot/bin/rustc")
+    config.set("build", "rustc", e(rustc))
+
+    cargo = d.expand("${WORKDIR}/rust-snapshot/bin/cargo")
+    config.set("build", "cargo", e(cargo))
+
+    config.set("build", "vendor", e(True))
+
+    targets = [d.getVar("TARGET_SYS", True)]
+    config.set("build", "target", e(targets))
+
+    hosts = [d.getVar("SNAPSHOT_BUILD_SYS", True)]
+    config.set("build", "host", e(hosts))
+
+    # We can't use BUILD_SYS since that is something the rust snapshot knows
+    # nothing about when trying to build some stage0 tools (like fabricate)
+    config.set("build", "build", e(d.getVar("SNAPSHOT_BUILD_SYS", True)))
+
+    with open("config.toml", "w") as f:
+        config.write(f)
+
+    # set up ${WORKDIR}/cargo_home
+    bb.build.exec_func("setup_cargo_environment", d)
+}
+
+
+rust_runx () {
+    echo "COMPILE ${PN}" "$@"
+
+    # CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a
+    # wide range of targets (not just TARGET). Yocto's settings for them will
+    # be inappropriate, avoid using.
+    unset CFLAGS
+    unset LDFLAGS
+    unset CXXFLAGS
+    unset CPPFLAGS
+
+    oe_cargo_fix_env
+
+    python3 src/bootstrap/bootstrap.py ${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose
+}
+rust_runx[vardepsexclude] += "PARALLEL_MAKE"
+
+do_compile () {
+
+    rust_runx build src/tools/remote-test-server --target "${TARGET_SYS}"
+}
Signature · 1 line
2.17.1
#65 lore raw

PATCH v8 2/5 Add rust testsuite for 1.46.0

---
 meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb | 3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb
meta/recipes-devtools/rust/rust-testsuite_1.46.0.bb new file +3 -0
new file mode 100644
index 0000000000..ad758b71f4
@@ -0,0 +1,3 @@
+require rust-testsuite.inc
+require rust-source-${PV}.inc
+require rust-snapshot-${PV}.inc
Signature · 1 line
2.17.1
#66 lore raw

PATCH v8 3/5 rust.inc : Changed target cpu for powerpc to "7400"

In reply to Vinay Kumar

While executing rust-testing observed some ui testfailures due to below warning message.

'powerpc' is not a recognized processor for this target in rust

So renamed target cpu for "powerpc" in "llvm_cpu" to "7400" as per default tune for qemuppc.

---
 meta/recipes-devtools/rust/rust.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/rust/rust.inc +1 -1
index a1223f45e7..ee3176b559 100644
@@ -290,7 +290,7 @@ def llvm_cpu(d):
     trans['x86-64'] = "x86-64"
     trans['i686'] = "i686"
     trans['i586'] = "i586"
-    trans['powerpc'] = "powerpc"
+    trans['powerpc'] = "7400"
     trans['mips64'] = "mips64"
     trans['mips64el'] = "mips64"
     trans['riscv64'] = "generic-rv64"
Signature · 1 line
2.17.1
#67 lore raw

PATCH v8 4/5 oeqa/selftest/cases/rust.py: Rust oe-selftest script.

In reply to Vinay Kumar

Build remote-test-server copy to image and execute remotely through background ssh.

Execute rust testing by exporting required paths.
And capture the output in result.output

Print the results in case of failure of runCmd().

---
 meta/lib/oeqa/selftest/cases/rust.py | 53 ++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/rust.py
meta/lib/oeqa/selftest/cases/rust.py new file +53 -0
new file mode 100644
index 0000000000..ee61216e02
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: MIT
+import os
+import subprocess
+from oeqa.core.decorator import OETestTag
+from oeqa.core.case import OEPTestResultTestCase
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu, Command
+from oeqa.utils.sshcontrol import SSHControl
+
+# Total time taken for testing is of about 2hr 20min, with PARALLEL_MAKE set to 40 number of jobs.
+class RustSelfTestBase(OESelftestTestCase, OEPTestResultTestCase):
+
+	def run_check_emulated(self, *args, **kwargs):
+		# build remote-test-server before image build
+		recipe = "rust-testsuite"
+		bitbake("{} -c compile".format(recipe))
+		builddir = get_bb_var("B", "rust-testsuite")
+		# build core-image-minimal with required packages
+		default_installed_packages = ["libgcc", "libstdc++", "libatomic", "libgomp"]
+		features = []
+		features.append('IMAGE_FEATURES += "ssh-server-openssh"')
+		features.append('CORE_IMAGE_EXTRA_INSTALL += "{0}"'.format(" ".join(default_installed_packages)))
+		self.write_config("\n".join(features))
+		bitbake("core-image-minimal")
+		# wrap the execution with a qemu instance
+		with runqemu("core-image-minimal", runqemuparams = "nographic") as qemu:
+			# Copy remote-test-server to image through scp
+			ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user="root")
+			ssh.copy_to(builddir + "/" + "build/x86_64-unknown-linux-gnu/stage2-tools-bin/remote-test-server","~/")
+			# Execute remote-test-server on image through background ssh
+			command = '~/remote-test-server -v remote'
+			sshrun=subprocess.Popen(("ssh", '-o',  'UserKnownHostsFile=/dev/null', '-o',  'StrictHostKeyChecking=no', '-f', "root@%s" % qemu.ip, command),
+                                shell=False,
+                                stdout=subprocess.PIPE,
+                                stderr=subprocess.PIPE)
+			# Get the values of variables.
+			targetsys = get_bb_var("TARGET_SYS", "rust-testsuite")
+			rustlibpath = get_bb_var("STAGING_LIBDIR_NATIVE", "rust-testsuite")
+			tmpdir = get_bb_var("TMPDIR", "rust-testsuite")
+			testargs = "--no-fail-fast --bless"
+			# Set path for target-poky-linux-gcc, RUST_TARGET_PATH and hosttools.
+			cmd = " export PATH=%s/../bin:$PATH;" % rustlibpath
+			cmd = cmd + " export PATH=%s/../bin/%s:%s/hosttools:$PATH;" % (rustlibpath, targetsys, tmpdir)
+			cmd = cmd + " export RUST_TARGET_PATH=%s/rustlib;" % rustlibpath
+			# Trigger testing.
+			cmd = cmd + " export TEST_DEVICE_ADDR=\"%s:12345\";" % qemu.ip
+			cmd = cmd + " cd %s;  python3 src/bootstrap/bootstrap.py test %s --target %s ;" % (builddir, testargs, targetsys)
+			result = runCmd(cmd)
+
+@OETestTag("toolchain-system")
+class RustSelfTestSystemEmulated(RustSelfTestBase):
+	def test_rust(self):
+		self.run_check_emulated("rust")
Signature · 1 line
2.17.1
#68 lore raw

PATCH v8 5/5 While executing ui testing observed failures due to below warning,

In reply to Vinay Kumar

"'+v8' is not a recognized feature for this target (ignoring feature)"

Same got fixed by backporting below patch,
http://git.yoctoproject.org/cgit.cgi/poky-contrib/commit/?h=rmacleod/rust-wip-2021-02-16&id=f243e4bbd5414ce519336753a68c53ee60cbe89e

---
 meta/recipes-devtools/rust/rust.inc | 3 ---
 1 file changed, 3 deletions(-)
meta/recipes-devtools/rust/rust.inc +0 -3
index ee3176b559..fb20bbd0fb 100644
@@ -64,9 +64,6 @@ def llvm_features_from_tune(d):
     if 'neon' in feat:
         f.append("+neon")
 
-    if 'aarch64' in feat:
-        f.append("+v8")
-
     if 'mips32' in feat:
         f.append("+mips32")
 
Signature · 1 line
2.17.1
#69 lore raw

Re: [PATCH v5 4/5] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

In reply to Alexander Kanavin

Hi Alex,

Sent v8 version patches.

Thanks for your quick and timely review comments.
Also, thanks for your help and suggestions in successfully implementing it.

Regards,
Vinay

Quoted 110 lines · Alexander Kanavin

Thanks, that is fine and please resend once more the whole set.

Alex

Quoted 103 lines · Vinay Kumar

Hi Alex,

Is the below comment about execution time is ok ?

+# Total time taken for testing is of about 2hr 20min, with PARALLEL_MAKE set to 40 number of jobs.
class RustSelfTestBase(OESelftestTestCase, OEPTestResultTestCase):

And, should I send v8 version of patches (all 5 patches) or only the patch of rust.py with this comment as v8 patch ?

Regards,
Vinay

Quoted 86 lines · Alexander Kanavin

Thanks Vinay, the code looks nice and clean now, and I have no further comments about it.

I would only ask that you put the amount of time it takes to (successfully) execute as a comment just before the class definition, so that anyone who needs to allocate CI resources for this test knows what is the reasonable way to run it.

Alex

Quoted 78 lines · Vinay Kumar

Hi Alex,

Please ignore the v6 patch set. As there is minor correction in rust.py
- cmd = cmd + " cd %s; python3 src/bootstrap/bootstrap.py test codegen %s --target %s ;" % (builddir, testargs, targetsys)
+ cmd = cmd + " cd %s; python3 src/bootstrap/bootstrap.py test %s --target %s ;" % (builddir, testargs, targetsys)

Sent v7 patches with corrections of runCmd and ssh.

For copying "remote-test-server" used copy_to from sshcontrol.py, and for ssh background execution used "subprocess" module.

Regarding result.output, whenever there is failure it gets printed test summary and also captured in "oe-selftest-results.log". And when there is failure with runCmd then no test summary details or printed. This is taken care of by runCmd() itself from commands.py.

Verified with 2 independent test modules "compile-fail" and "codegen" which are part of rust testing.

compile-test : All tests get passed and no errors thrown, so oe-selftes does not print the test results.

codegen : Some of the tests fail, making the shell exit. In this case oe-selftest prints test details with stdout and stderr.

Regards,
Vinay

Quoted 44 lines · Alexander Kanavin

Hello Vinay,

sure, no problem. I see that SSHControl.run() isn't designed for starting background processes on the target. But I still think it's then better to use subprocess module for starting the server over ssh, rather than bundle everything into one gigantic runCmd().

Alex

Quoted 36 lines · Vinay Kumar

Hi Alex,

The reason why I changed this is, we have to execute "remote-test-server" on the image through background ssh. So that the "remote-test-server" will be alive waiting for connection. Then in the rust.py control passed to the next command (cmd) for execution.
If we use the sshcontrol.py method we have to set a timeout of 600 otherwise default timeout is 300. Even if the test execution completes early due to failure then we have to wait till this timeout.

I tried reducing the timeout to 60 seconds and some of the tests got skipped.

If that is ok I will use that copy_to and run from sshcontrol.py as we did in v4 patches and work for the result.output

Regards,
Vinay

Quoted 14 lines · Alexander Kanavin

Review

Quoted 4 lines · Vinay Kumar
(quoted diff) +3 -0
+                       # To kill remote-test-server executing through background ssh
+                       killcommand = "kill -9 \$(ps | grep remote-test-server |  grep -v \"grep\" | awk '{print \$1}')"
+                       cmd = cmd + "ssh %s root@%s \"%s\";" % (sshargs, qemu.ip, killcommand)

I don't think you actually need to kill the remote test server. As qemu will be stopped anyway, and with it, all the processes that run inside qemu.

Also, it's better to use cmd only to execute the tests. Starting the server is better done through SSHControl.run(), and copying the binary via SSHControl.copy_to() - see examples in selfttest's imagefeatures.py or runtime_test.py.

Alex

#70 lore raw

PATCH v5 5/5 rust.inc : Fix for aarch64 feature.

In reply to Vinay Kumar

While executing ui testing observed failures due to below warning,

"'+v8' is not a recognized feature for this target (ignoring feature)"

Same got fixed by backporting below patch,
http://git.yoctoproject.org/cgit.cgi/poky-contrib/commit/?h=rmacleod/rust-wip-2021-02-16&id=f243e4bbd5414ce519336753a68c53ee60cbe89e

---
 meta/recipes-devtools/rust/rust.inc | 3 ---
 1 file changed, 3 deletions(-)
meta/recipes-devtools/rust/rust.inc +0 -3
index ee3176b559..fb20bbd0fb 100644
@@ -64,9 +64,6 @@ def llvm_features_from_tune(d):
     if 'neon' in feat:
         f.append("+neon")
 
-    if 'aarch64' in feat:
-        f.append("+v8")
-
     if 'mips32' in feat:
         f.append("+mips32")
 
Signature · 1 line
2.17.1
#71 lore raw

Re: [PATCH v4 4/5] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

In reply to Vinay Kumar

Hi Alex,

Sent v5 version of patches with changes as per my last mail. Also, attached "summary.txt" of rust testing with arm64 target, for your reference.

Regards,
Vinay

Quoted 48 lines · Vinay Kumar

Hi Alex,

Quoted 1 line
Quoted 1 line

Hardcoding the ip port this way is problematic and prone to conflicts. What is -monitor used for?

When we were testing outside oe-selftest framework ( booting image manually and trigger testing),
the "remote-test-server" used to give connection issues. However, right now without this option the testing is working without any issue. So removed from qemuboot.

Quoted 1 line
Quoted 1 line

What does -j 40 do? Keep in mind that qemu has only 4 virtual cpu cores.

This one passed to speed up the testing while using the "do_check" method. So I removed parallel builds.

Quoted 1 line
Quoted 1 line

What happens if the test executed via runCmd fails? Specifically, will the failure be properly reported?

While executing testing, if there any testcase failures testing gets terminated with below message,
"command did not execute successfully:"

So we are passing "--no-fail-fast" as a test argument, which wont exit the shell and the testing continues even if there are failures.

Quoted 1 line
Quoted 1 line

I'm wondering because the output of the test is redirected to summary.txt (which is then left unused), and stderr is discarded altogether.

This is because I only capture the test results as much as possible. Now modified to consider stderr also.

Quoted 1 line
Quoted 1 line

Will t_thread be stopped if runCmd fails?

Now changed the implementation to discard thread usage. Even in case of any failure the test used to end after timeout set in "SShcontrol" if the timeout is less (60 seconds) then some of the tests used to get missed.

So instead of using copy_to and run from sshcontrol.py, I tried copying the remote-test-server to the image and executing in the background as below,

#Copy remote-test-server through scp and execute through background ssh sshargs = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR'
cmd = "scp %s %s/build/x86_64-unknown-linux-gnu/stage2-tools-bin/remote-test-server root@%s:~/ ;" % (sshargs, builddir, qemu.ip)
testcommand = '~/remote-test-server -v remote'
cmd = cmd + "ssh %s -f root@%s \"%s\";" % (sshargs, qemu.ip, testcommand)

And kill "remote-test-server" through ssh once testing is complete killcommand = "kill -9 \$(ps | grep remote-test-server | grep -v \"grep\" | awk '{print \$1}')"
cmd = cmd + "ssh %s root@%s \"%s\";" % (sshargs, qemu.ip, killcommand)

Quoted 45 lines

Testing in progress will send the v5 version patches.

Regards,
Vinay

Quoted 38 lines · Alexander Kanavin
Quoted 3 lines · Vinay Kumar

Build remote-test-server copy to image and execute remotely through background ssh.

Thanks, I do not have any further comments about the overall structure, the below are more specific concerns.

meta/lib/oeqa/selftest/cases/rust.py line 26

Quoted 3 lines
meta/lib/oeqa/selftest/cases/rust.py new file +2 -0
+               with runqemu("core-image-minimal", runqemuparams = "nographic", qemuparams= " -monitor \
+                        telnet:127.0.0.1:1234,server,nowait -serial mon:stdio -serial null") as qemu:

Hardcoding the ip port this way is problematic and prone to conflicts. What is -monitor used for?

Quoted 2 lines

+ cmd = cmd + " cd %s; python3 src/bootstrap/bootstrap.py -j 40 --verbose test %s --target %s > summary.txt 2> /dev/null " % (builddir, testargs, targetsys)

What does -j 40 do? Keep in mind that qemu has only 4 virtual cpu cores.

Quoted 2 lines

+ runCmd(cmd)

What happens if the test executed via runCmd fails? Specifically, will the failure be properly reported?

I'm wondering because the output of the test is redirected to summary.txt (which is then left unused), and stderr is discarded altogether.

meta/lib/oeqa/selftest/cases/rust.py line 46

Quoted 3 lines
meta/lib/oeqa/selftest/cases/rust.py new file +2 -0
+                       # Stop ssh background execution
+                       t_thread.stop()

Will t_thread be stopped if runCmd fails?

Alex

Finished dev [unoptimized + debuginfo] target(s) in 0.27s
Building stage0 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Finished release [optimized] target(s) in 0.25s
Copying stage0 std from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Could not determine the LLVM submodule commit hash. Assuming that an LLVM rebuild is not necessary.
To force LLVM to rebuild, remove the file /ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/x86_64-unknown-linux-gnu/llvm/llvm-finished-building
Building stage0 compiler artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Finished release [optimized] target(s) in 0.29s
Copying stage0 rustc from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Assembling stage1 compiler (x86_64-unknown-linux-gnu)
Building stage1 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Finished release [optimized] target(s) in 0.24s
Copying stage1 std from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building stage1 compiler artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Finished release [optimized] target(s) in 0.28s
Copying stage1 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Assembling stage2 compiler (x86_64-unknown-linux-gnu)
Building stage2 std artifacts (x86_64-unknown-linux-gnu -> aarch64-poky-linux)
Finished release [optimized] target(s) in 0.27s
Copying stage2 std from stage2 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / aarch64-poky-linux)
Uplifting stage1 std (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Copying stage2 std from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building test helpers
running: "/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/wrapper/build-rust-cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-o" "/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/x86_64-unknown-linux-gnu/native/rust-test-helpers/rust_test_helpers.o" "-c" "/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/src/test/auxiliary/rust_test_helpers.c" exit code: 0
running: "/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/wrapper/build-rust-ar" "crs" "/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/x86_64-unknown-linux-gnu/native/rust-test-helpers/librust_test_helpers.a" "/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/x86_64-unknown-linux-gnu/native/rust-test-helpers/rust_test_helpers.o" exit code: 0
Building test helpers
running: "/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/wrapper/target-rust-cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-o" "/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/aarch64-poky-linux/native/rust-test-helpers/rust_test_helpers.o" "-c" "/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/src/test/auxiliary/rust_test_helpers.c" cargo:warning=In file included from /ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/recipe-sysroot/usr/include/bits/libc-header-start.h:33,

cargo:warning=                 from /ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/recipe-sysroot/usr/include/stdint.h:26,
cargo:warning=                 from /ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/recipe-sysroot-native/usr/lib/aarch64-poky-linux/gcc/aarch64-poky-linux/10.2.0/include/stdint.h:9,
cargo:warning=                 from /ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/src/test/auxiliary/rust_test_helpers.c:3:
cargo:warning=/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/recipe-sysroot/usr/include/features.h:397:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
cargo:warning=  397 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
cargo:warning=      |    ^~~~~~~

exit code: 0
running: "/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/wrapper/target-rust-ar" "crs" "/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/aarch64-poky-linux/native/rust-test-helpers/librust_test_helpers.a" "/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/aarch64-poky-linux/native/rust-test-helpers/rust_test_helpers.o" exit code: 0
REMOTE copy libs to emulator (aarch64-poky-linux)
Building stage0 std artifacts (x86_64-unknown-linux-gnu -> aarch64-poky-linux)
Compiling core v0.0.0 (/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/src/libcore)
Compiling libc v0.2.71
Compiling compiler_builtins v0.1.32
Compiling unwind v0.0.0 (/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/src/libunwind)
Compiling backtrace-sys v0.1.37
Compiling hashbrown v0.6.2
Compiling std v0.0.0 (/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/src/libstd)
Compiling rustc-std-workspace-core v1.99.0 (/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/src/tools/rustc-std-workspace-core)
Compiling alloc v0.0.0 (/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/src/liballoc)
Compiling cfg-if v0.1.10
Compiling rustc-demangle v0.1.16
Compiling panic_abort v0.0.0 (/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/src/libpanic_abort)
Compiling backtrace v0.3.46
Compiling rustc-std-workspace-alloc v1.99.0 (/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/src/tools/rustc-std-workspace-alloc)
Compiling panic_unwind v0.0.0 (/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/src/libpanic_unwind)
Compiling rustc-std-workspace-std v1.99.0 (/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/src/tools/rustc-std-workspace-std)
Compiling term v0.0.0 (/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/src/libterm)
Compiling proc_macro v0.0.0 (/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/src/libproc_macro)
Compiling unicode-width v0.1.6
Compiling getopts v0.2.21
Compiling test v0.0.0 (/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/src/libtest)
Finished release [optimized] target(s) in 29.63s
Copying stage0 std from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / aarch64-poky-linux)
Building stage0 tool remote-test-server (aarch64-poky-linux)
Compiling remote-test-server v0.1.0 (/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/src/tools/remote-test-server)
Finished release [optimized] target(s) in 1.44s
Building stage0 tool remote-test-client (x86_64-unknown-linux-gnu)
Compiling remote-test-client v0.1.0 (/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/src/tools/remote-test-client)
Finished release [optimized] target(s) in 1.89s
Connecting to remote device 192.168.7.2:12345 ...
done pushing "/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-poky-linux/lib/libtest-67d9128c59938acd.so"
done pushing "/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-poky-linux/lib/libstd-f091982808d4dcf3.so"
Building stage0 tool compiletest (x86_64-unknown-linux-gnu)
Compiling proc-macro2 v1.0.3
Compiling unicode-xid v0.2.0
Compiling syn v1.0.11
Compiling serde v1.0.99
Compiling memchr v2.3.3
Compiling ryu v1.0.0
Compiling log v0.4.8
Compiling cfg-if v0.1.10
Compiling anyhow v1.0.31
Compiling itoa v0.4.4
Compiling libc v0.2.71
Compiling lazy_static v1.4.0
Compiling regex-syntax v0.6.17
Compiling same-file v1.0.4
Compiling unicode-width v0.1.6
Compiling diff v0.1.11
Compiling thread_local v1.0.1
Compiling walkdir v2.2.7
Compiling getopts v0.2.21
Compiling env_logger v0.7.1
Compiling aho-corasick v0.7.10
Compiling quote v1.0.2
Compiling regex v1.3.7
Compiling serde_derive v1.0.106
Compiling serde_json v1.0.40
Compiling rustfix v0.5.0
Compiling compiletest v0.0.0 (/ala-lpggp31/vinay/rev-5/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/src/tools/compiletest)
Finished release [optimized] target(s) in 34.69s
Check compiletest suite=ui mode=ui (x86_64-unknown-linux-gnu -> aarch64-poky-linux)

14,590 lines not shown · raw message

Part of this message is not shown here. View the raw message.

#72 lore raw

PATCH v4 5/5 rust.inc : Fix for aarch64 feature.

In reply to Vinay Kumar

While executing ui testing observed failures due to below warning,

"'+v8' is not a recognized feature for this target (ignoring feature)"

Same got fixed by backporting below patch,
http://git.yoctoproject.org/cgit.cgi/poky-contrib/commit/?h=rmacleod/rust-wip-2021-02-16&id=f243e4bbd5414ce519336753a68c53ee60cbe89e

---
 meta/recipes-devtools/rust/rust.inc | 3 ---
 1 file changed, 3 deletions(-)
meta/recipes-devtools/rust/rust.inc +0 -3
index ee3176b559..fb20bbd0fb 100644
@@ -64,9 +64,6 @@ def llvm_features_from_tune(d):
     if 'neon' in feat:
         f.append("+neon")
 
-    if 'aarch64' in feat:
-        f.append("+v8")
-
     if 'mips32' in feat:
         f.append("+mips32")
 
Signature · 1 line
2.17.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

#74 lore raw

Re: [OE-core] [PATCH v3 4/5] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Hi Alex,

I have sent the v4 version of patches with "do_check" functionality included in "rust.py"
Also, verified for qemuarm64 target with fresh run.

Please let me know in case of any corrections.

Regards,
Vinay

Quoted 40 lines · Vinay Kumar via lists.openembedded.org

Hi Alex,

I made changes as you suggested, getting expected results. Verifying with a fresh run. Will send the final patch for review.

Regards,
Vinay

Quoted 26 lines · Alexander Kanavin

meta/lib/oeqa/selftest/cases/rust.py line 45

Quoted 10 lines · Vinay Kumar
meta/lib/oeqa/selftest/cases/rust.py new file +8 -0
+                       # Set TEST_DEVICE_ADDR to image ip
+                       cmd  = "export TEST_DEVICE_ADDR=%s:12345;" % qemu.ip
+                       runCmd(cmd)
+
+                        # Test execution
+                       bitbake("{} -c check".format(recipe))
+                       # Stop ssh background execution
+                       t_thread.stop()

TEST_DEVICE_ADDR set this way will not propagate into the task environment. The task itself consists only of:

do_check () {

    rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" > summary.txt 2> /dev/null
}

so you can simply move that directly into selftest:

runCmd("export TEST_DEVICE_ADDR=%s:12345 rust_runx test --no-fail-fast --bless --target "%s"" %(....))

Alex

#75 lore raw

PATCH v3 5/5 rust.inc : Fix for aarch64 feature.

In reply to Vinay Kumar

While executing ui testing observed failures due to below warning,

"'+v8' is not a recognized feature for this target (ignoring feature)"

Same got fixed by backporting below patch,
http://git.yoctoproject.org/cgit.cgi/poky-contrib/commit/?h=rmacleod/rust-wip-2021-02-16&id=f243e4bbd5414ce519336753a68c53ee60cbe89e

---
 meta/recipes-devtools/rust/rust.inc | 3 ---
 1 file changed, 3 deletions(-)
meta/recipes-devtools/rust/rust.inc +0 -3
index ee3176b559..fb20bbd0fb 100644
@@ -64,9 +64,6 @@ def llvm_features_from_tune(d):
     if 'neon' in feat:
         f.append("+neon")
 
-    if 'aarch64' in feat:
-        f.append("+v8")
-
     if 'mips32' in feat:
         f.append("+mips32")
 
Signature · 1 line
2.17.1
#76 lore raw

Re: [PATCH v3 1/5] rust-testsuite.inc : Rust cross testing.

In reply to Vinay Kumar

Where is TARGET_SYS set? I cannot find it anywhere in your patchset.

Note that when using tap, the target ip address is unknown until qemu is started, so you need to engineer the code in a way that everything that needs to know the address is configured at that point.

Alex

Quoted 206 lines · Vinay Kumar

Below list of functions are part of rust-testsuite.inc setup_cargo_environment(): Build bootstrap and some early stage tools. do_rust_setup_snapshot(): Install the snapshot version of rust binaries. do_configure(): To generate config.toml
do_compile(): To build "remote-test-server" for qemutarget image. do_check(): To execute testing on qmutarget image.

---
 meta/recipes-devtools/rust/rust-testsuite.inc | 163 ++++++++++++++++++
 1 file changed, 163 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-testsuite.inc
meta/recipes-devtools/rust/rust-testsuite.inc new file +17 -0
new file mode 100644
index 0000000000..88fb4e70d9
@@ -0,0 +1,163 @@
+SUMMARY = "Rust testing"
+HOMEPAGE = "https://rustc-dev-guide.rust-lang.org/tests/intro.html"
+SECTION = "test"
+LICENSE = "MIT | Apache-2.0"
+
+inherit rust
+inherit cargo_common
+
+DEPENDS += "file-native python3-native"
+EXCLUDE_FROM_WORLD = "1"
+
+# Path of target specification file "target-poky-linux.json"
+export RUST_TARGET_PATH="${STAGING_LIBDIR_NATIVE}/rustlib"
+
+export FORCE_CRATE_HASH="${BB_TASKHASH}"
+
+# We don't want to use bitbakes vendoring because the rust sources do

their

meta/recipes-devtools/rust/rust-testsuite.inc new file +11 -0
+# own vendoring.
+CARGO_DISABLE_BITBAKE_VENDORING = "1"
+
+# We can't use RUST_BUILD_SYS here because that may be "musl" if
+# TCLIBC="musl". Snapshots are always -unknown-linux-gnu
+SNAPSHOT_BUILD_SYS = "${BUILD_ARCH}-unknown-linux-gnu"
+setup_cargo_environment () {
+    # The first step is to build bootstrap and some early stage tools,
+    # these are build for the same target as the snapshot, e.g.
+    # x86_64-unknown-linux-gnu.
+    # Later stages are build for the native target (i.e.

target.x86_64-linux)

meta/recipes-devtools/rust/rust-testsuite.inc new file +8 -0
+    cargo_common_do_configure
+
+    printf '[target.%s]\n' "${SNAPSHOT_BUILD_SYS}" >> ${CARGO_HOME}/config
+    printf "linker = '%s'\n" "${RUST_BUILD_CCLD}" >> ${CARGO_HOME}/config
+}
+
+do_rust_setup_snapshot () {
+    for installer in

"${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do

meta/recipes-devtools/rust/rust-testsuite.inc new file +4 -1
+        "${installer}" --prefix="${WORKDIR}/rust-snapshot"
--disable-ldconfig
+    done
+
+    # Some versions of rust (e.g. 1.18.0) tries to find cargo in

stage0/bin/cargo

meta/recipes-devtools/rust/rust-testsuite.inc new file +16 -0
+    # and fail without it there.
+    mkdir -p ${RUSTSRC}/build/${BUILD_SYS}
+    ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${BUILD_SYS}/stage0
+}
+addtask rust_setup_snapshot after do_unpack before do_configure
+do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
+
+python do_configure() {
+    import json
+    from distutils.version import LooseVersion
+    try:
+        import configparser
+    except ImportError:
+        import ConfigParser as configparser
+
+    # toml is rather similar to standard ini like format except it likes

values
+ # that look more JSON like. So for our purposes simply escaping all
values

meta/recipes-devtools/rust/rust-testsuite.inc new file +7 -0
+    # as JSON seem to work fine.
+
+    e = lambda s: json.dumps(s)
+
+    config = configparser.RawConfigParser()
+
+    # [target.ARCH-unknown-linux-gnu] in case of x86_64

[target.ARCH-poky-linux]

meta/recipes-devtools/rust/rust-testsuite.inc new file +4 -0
+    target_section = "target.{}".format(d.getVar('TARGET_SYS', True))
+    config.add_section(target_section)
+
+    # Points to wrapper files which contain target specific compiler and

linker commands.

meta/recipes-devtools/rust/rust-testsuite.inc new file +3 -0
+    config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
+    config.set(target_section, "linker",

e(d.expand("${RUST_TARGET_CCLD}")))

meta/recipes-devtools/rust/rust-testsuite.inc new file +2 -0
+
+    # If we don't do this rust-native will compile it's own llvm for

BUILD.

meta/recipes-devtools/rust/rust-testsuite.inc new file +2 -0
+    # [target.${BUILD_ARCH}-unknown-linux-gnu]
+    target_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS',

True))

meta/recipes-devtools/rust/rust-testsuite.inc new file +22 -0
+    config.add_section(target_section)
+
+    # Wrapper scripts of build system.
+    config.set(target_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
+
+    # [llvm]
+    config.add_section("llvm")
+    config.set("llvm", "targets", e("ARM;AArch64;Mips;PowerPC;RISCV;X86"))
+
+    # [rust]
+    config.add_section("rust")
+    config.set("rust", "rpath", e(True))
+    config.set("rust", "channel", e("stable"))
+
+    if LooseVersion(d.getVar("PV")) < LooseVersion("1.32.0"):
+        config.set("rust", "use-jemalloc", e(False))
+
+    # Whether or not to optimize the compiler and standard library
+    config.set("rust", "optimize", e(True))
+
+    # Emits extraneous output from tests to ensure that failures of the

test

meta/recipes-devtools/rust/rust-testsuite.inc new file +5 -0
+    # harness are debuggable just from logfiles
+    config.set("rust", "verbose-tests", e(True))
+
+    # Override default linker cc.
+    config.set("rust", "default-linker",

e(d.expand("${RUST_BUILD_CCLD}")))

meta/recipes-devtools/rust/rust-testsuite.inc new file +21 -0
+
+    # [build]
+    config.add_section("build")
+    config.set("build", "submodules", e(False))
+    config.set("build", "docs", e(False))
+
+    rustc = d.expand("${WORKDIR}/rust-snapshot/bin/rustc")
+    config.set("build", "rustc", e(rustc))
+
+    cargo = d.expand("${WORKDIR}/rust-snapshot/bin/cargo")
+    config.set("build", "cargo", e(cargo))
+
+    config.set("build", "vendor", e(True))
+
+    targets = [d.getVar("TARGET_SYS", True)]
+    config.set("build", "target", e(targets))
+
+    hosts = [d.getVar("SNAPSHOT_BUILD_SYS", True)]
+    config.set("build", "host", e(hosts))
+
+    # We can't use BUILD_SYS since that is something the rust snapshot

knows
+ # nothing about when trying to build some stage0 tools (like
fabricate)

meta/recipes-devtools/rust/rust-testsuite.inc new file +15 -0
+    config.set("build", "build", e(d.getVar("SNAPSHOT_BUILD_SYS", True)))
+
+    with open("config.toml", "w") as f:
+        config.write(f)
+
+    # set up ${WORKDIR}/cargo_home
+    bb.build.exec_func("setup_cargo_environment", d)
+}
+
+
+rust_runx () {
+    echo "COMPILE ${PN}" "$@"
+
+    # CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a
+    # wide range of targets (not just TARGET). Yocto's settings for them

will

meta/recipes-devtools/rust/rust-testsuite.inc new file +9 -0
+    # be inappropriate, avoid using.
+    unset CFLAGS
+    unset LDFLAGS
+    unset CXXFLAGS
+    unset CPPFLAGS
+
+    oe_cargo_fix_env
+
+    python3 src/bootstrap/bootstrap.py

${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose

meta/recipes-devtools/rust/rust-testsuite.inc new file +13 -0
+}
+rust_runx[vardepsexclude] += "PARALLEL_MAKE"
+
+do_compile () {
+
+    rust_runx build src/tools/remote-test-server --target "${TARGET_SYS}"
+}
+
+do_check[dirs] += "${B}"
+do_check[nostamp] = "1"
+do_check () {
+
+    rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" >

summary.txt 2> /dev/null

meta/recipes-devtools/rust/rust-testsuite.inc new file +2 -1
+}
+addtask do_check after do_compile
--

2.17.1

#77 lore raw

Re: [PATCH v3 1/5] rust-testsuite.inc : Rust cross testing.

Nevermind, I found where TARGET_SYS comes from :)

Alex

Quoted 218 lines · Alexander Kanavin

Where is TARGET_SYS set? I cannot find it anywhere in your patchset.

Note that when using tap, the target ip address is unknown until qemu is started, so you need to engineer the code in a way that everything that needs to know the address is configured at that point.

Alex

Quoted 208 lines · Vinay Kumar

Below list of functions are part of rust-testsuite.inc setup_cargo_environment(): Build bootstrap and some early stage tools. do_rust_setup_snapshot(): Install the snapshot version of rust binaries. do_configure(): To generate config.toml
do_compile(): To build "remote-test-server" for qemutarget image. do_check(): To execute testing on qmutarget image.

---
 meta/recipes-devtools/rust/rust-testsuite.inc | 163 ++++++++++++++++++
 1 file changed, 163 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-testsuite.inc
meta/recipes-devtools/rust/rust-testsuite.inc new file +17 -0
new file mode 100644
index 0000000000..88fb4e70d9
@@ -0,0 +1,163 @@
+SUMMARY = "Rust testing"
+HOMEPAGE = "https://rustc-dev-guide.rust-lang.org/tests/intro.html"
+SECTION = "test"
+LICENSE = "MIT | Apache-2.0"
+
+inherit rust
+inherit cargo_common
+
+DEPENDS += "file-native python3-native"
+EXCLUDE_FROM_WORLD = "1"
+
+# Path of target specification file "target-poky-linux.json"
+export RUST_TARGET_PATH="${STAGING_LIBDIR_NATIVE}/rustlib"
+
+export FORCE_CRATE_HASH="${BB_TASKHASH}"
+
+# We don't want to use bitbakes vendoring because the rust sources do

their

meta/recipes-devtools/rust/rust-testsuite.inc new file +11 -0
+# own vendoring.
+CARGO_DISABLE_BITBAKE_VENDORING = "1"
+
+# We can't use RUST_BUILD_SYS here because that may be "musl" if
+# TCLIBC="musl". Snapshots are always -unknown-linux-gnu
+SNAPSHOT_BUILD_SYS = "${BUILD_ARCH}-unknown-linux-gnu"
+setup_cargo_environment () {
+    # The first step is to build bootstrap and some early stage tools,
+    # these are build for the same target as the snapshot, e.g.
+    # x86_64-unknown-linux-gnu.
+    # Later stages are build for the native target (i.e.

target.x86_64-linux)

meta/recipes-devtools/rust/rust-testsuite.inc new file +3 -0
+    cargo_common_do_configure
+
+    printf '[target.%s]\n' "${SNAPSHOT_BUILD_SYS}" >>

${CARGO_HOME}/config

meta/recipes-devtools/rust/rust-testsuite.inc new file +5 -0
+    printf "linker = '%s'\n" "${RUST_BUILD_CCLD}" >> ${CARGO_HOME}/config
+}
+
+do_rust_setup_snapshot () {
+    for installer in

"${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do

meta/recipes-devtools/rust/rust-testsuite.inc new file +4 -1
+        "${installer}" --prefix="${WORKDIR}/rust-snapshot"
--disable-ldconfig
+    done
+
+    # Some versions of rust (e.g. 1.18.0) tries to find cargo in

stage0/bin/cargo

meta/recipes-devtools/rust/rust-testsuite.inc new file +16 -0
+    # and fail without it there.
+    mkdir -p ${RUSTSRC}/build/${BUILD_SYS}
+    ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${BUILD_SYS}/stage0
+}
+addtask rust_setup_snapshot after do_unpack before do_configure
+do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
+
+python do_configure() {
+    import json
+    from distutils.version import LooseVersion
+    try:
+        import configparser
+    except ImportError:
+        import ConfigParser as configparser
+
+    # toml is rather similar to standard ini like format except it likes

values
+ # that look more JSON like. So for our purposes simply escaping all
values

meta/recipes-devtools/rust/rust-testsuite.inc new file +7 -0
+    # as JSON seem to work fine.
+
+    e = lambda s: json.dumps(s)
+
+    config = configparser.RawConfigParser()
+
+    # [target.ARCH-unknown-linux-gnu] in case of x86_64

[target.ARCH-poky-linux]

meta/recipes-devtools/rust/rust-testsuite.inc new file +4 -0
+    target_section = "target.{}".format(d.getVar('TARGET_SYS', True))
+    config.add_section(target_section)
+
+    # Points to wrapper files which contain target specific compiler and

linker commands.

meta/recipes-devtools/rust/rust-testsuite.inc new file +3 -0
+    config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
+    config.set(target_section, "linker",

e(d.expand("${RUST_TARGET_CCLD}")))

meta/recipes-devtools/rust/rust-testsuite.inc new file +2 -0
+
+    # If we don't do this rust-native will compile it's own llvm for

BUILD.

meta/recipes-devtools/rust/rust-testsuite.inc new file +2 -0
+    # [target.${BUILD_ARCH}-unknown-linux-gnu]
+    target_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS',

True))

meta/recipes-devtools/rust/rust-testsuite.inc new file +9 -0
+    config.add_section(target_section)
+
+    # Wrapper scripts of build system.
+    config.set(target_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
+
+    # [llvm]
+    config.add_section("llvm")
+    config.set("llvm", "targets",

e("ARM;AArch64;Mips;PowerPC;RISCV;X86"))

meta/recipes-devtools/rust/rust-testsuite.inc new file +13 -0
+
+    # [rust]
+    config.add_section("rust")
+    config.set("rust", "rpath", e(True))
+    config.set("rust", "channel", e("stable"))
+
+    if LooseVersion(d.getVar("PV")) < LooseVersion("1.32.0"):
+        config.set("rust", "use-jemalloc", e(False))
+
+    # Whether or not to optimize the compiler and standard library
+    config.set("rust", "optimize", e(True))
+
+    # Emits extraneous output from tests to ensure that failures of the

test

meta/recipes-devtools/rust/rust-testsuite.inc new file +5 -0
+    # harness are debuggable just from logfiles
+    config.set("rust", "verbose-tests", e(True))
+
+    # Override default linker cc.
+    config.set("rust", "default-linker",

e(d.expand("${RUST_BUILD_CCLD}")))

meta/recipes-devtools/rust/rust-testsuite.inc new file +21 -0
+
+    # [build]
+    config.add_section("build")
+    config.set("build", "submodules", e(False))
+    config.set("build", "docs", e(False))
+
+    rustc = d.expand("${WORKDIR}/rust-snapshot/bin/rustc")
+    config.set("build", "rustc", e(rustc))
+
+    cargo = d.expand("${WORKDIR}/rust-snapshot/bin/cargo")
+    config.set("build", "cargo", e(cargo))
+
+    config.set("build", "vendor", e(True))
+
+    targets = [d.getVar("TARGET_SYS", True)]
+    config.set("build", "target", e(targets))
+
+    hosts = [d.getVar("SNAPSHOT_BUILD_SYS", True)]
+    config.set("build", "host", e(hosts))
+
+    # We can't use BUILD_SYS since that is something the rust snapshot

knows
+ # nothing about when trying to build some stage0 tools (like
fabricate)

meta/recipes-devtools/rust/rust-testsuite.inc new file +15 -0
+    config.set("build", "build", e(d.getVar("SNAPSHOT_BUILD_SYS", True)))
+
+    with open("config.toml", "w") as f:
+        config.write(f)
+
+    # set up ${WORKDIR}/cargo_home
+    bb.build.exec_func("setup_cargo_environment", d)
+}
+
+
+rust_runx () {
+    echo "COMPILE ${PN}" "$@"
+
+    # CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a
+    # wide range of targets (not just TARGET). Yocto's settings for them

will

meta/recipes-devtools/rust/rust-testsuite.inc new file +9 -0
+    # be inappropriate, avoid using.
+    unset CFLAGS
+    unset LDFLAGS
+    unset CXXFLAGS
+    unset CPPFLAGS
+
+    oe_cargo_fix_env
+
+    python3 src/bootstrap/bootstrap.py

${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose

meta/recipes-devtools/rust/rust-testsuite.inc new file +13 -0
+}
+rust_runx[vardepsexclude] += "PARALLEL_MAKE"
+
+do_compile () {
+
+    rust_runx build src/tools/remote-test-server --target "${TARGET_SYS}"
+}
+
+do_check[dirs] += "${B}"
+do_check[nostamp] = "1"
+do_check () {
+
+    rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" >

summary.txt 2> /dev/null

meta/recipes-devtools/rust/rust-testsuite.inc new file +2 -1
+}
+addtask do_check after do_compile
--

2.17.1

#78 lore raw

Re: [OE-core] [PATCH v2 6/7] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

In reply to Alexander Kanavin

Hi Alex,

As we are developing patches on the branch:
http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=rmacleod/rust-wip-2021-02-02

Sent my patches v3 on top of this.
https://lists.openembedded.org/g/openembedded-core/message/152121

Below changes in rust.py does not make connection with the "remote-test-server" running on qemu image.
===============================
"cmd = "export TEST_DEVICE_ADDR=%s:12345;" % qemu.ip" runCmd(cmd)
bitbake("{} -c check".format(recipe))

Expected below line in generated summary.txt in
b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src
===============================
running: "/ala-lpggp31/vinay/review-3/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/x86_64-unknown-linux-gnu/stage0-too ls-bin/remote-test-client" "spawn-emulator" "aarch64-poky-linux" "/ala-lpggp31/vinay/review-3/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/ru stc-1.46.0-src/build/x86_64-unknown-linux-gnu/stage0-tools-bin/remote-test-server" "/ala-lpggp31/vinay/review-3/b1/tmp/work/cortexa57-poky-linux/rust-test
suite/1.46.0-r0/rustc-1.46.0-src/build/tmp"
Connecting to remote device 192.168.7.2:12345 ...

If we set "export TEST_DEVICE_ADDR=192.168.7.2:12345;" in do_check of rust-testsuite.inc connection establishes with image
and the test execution is as expected.

Also, please let me know if there in other way to share/publish the source.

Regards,
Vinay

Quoted 160 lines · Alexander Kanavin

If you publish the code to a branch, and show exactly the errors you get, I could try to look at it.

Alex

Quoted 154 lines · Alexander Kanavin

You cannot hardcode the ip address like that; it's set dynamically when qemu starts, and you can only access it from selftest or runtime test.

Alex

Quoted 148 lines · Vinay Kumar

Hi Alex,

Tried your suggestions to copy and run in rust.py without any issue as below.
===============================
builddir = get_bb_var("B", "rust-testsuite")
ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user="root", timeout=600) ssh.copy_to(builddir + "/" + "build/x86_64-unknown-linux-gnu/stage2-tools-bin/remote-test-server","~/") t_thread = threading.Thread(target=ssh.run, args=("~/remote-test-server -v remote",))
t_thread.start()
===============================

If we set "TEST_DEVICE_ADDR" in rust.py through "runCmd" as shown below, the remote-test-client does not connect to the image. So a lot of tests fail.
===============================
"cmd = "export TEST_DEVICE_ADDR=%s:12345;" % qemu.ip" runCmd(cmd)
bitbake("{} -c check".format(recipe))
===============================

Also, I tried to move do_check content to rust.py without any success.
===============================
cmd = "export PATH=%s/../recipe-sysroot-native/usr/lib/rustlib/:" % builddir cmd= cmd + "%s/../recipe-sysroot-native/usr/bin:$PATH;" % builddir cmd = cmd + "export RUST_TARGET_PATH=%s/../recipe-sysroot-native/usr/lib/rustlib/;" % builddir
cmd = cmd + "cd " + builddir + ";"
cmd = "export TEST_DEVICE_ADDR=\"%s:12345\";" % qemu.ip
cmd = cmd + "python3 src/bootstrap/bootstrap.py -j 40 --verbose test --no-fail-fast --bless --target aarch64-poky-linux > summary.txt 2>&1"

Error:
File "/ala-lpggp31/vinay/review-2/poky-contrib/meta/lib/oeqa/utils/commands.py", line 210, in runCmd
raise AssertionError("Command '%s' returned non-zero exit status %d:\n%s" % (command, result.status, exc_output))
AssertionError: Command 'export TEST_DEVICE_ADDR="192.168.7.2:12345";python3 src/bootstrap/bootstrap.py -j 40 --verbose test --no-fail-fast --bless --target aarch64-poky-linux > summary.txt 2>&1' returned non-zero exit status 2:
===============================

So in rust.py only copy and execution of "remote-test-server" is taken care of. And the test execution is by do_check of rust-testsuite.inc as below,
===============================

do_check () {
    export TEST_DEVICE_ADDR="192.168.7.2:12345"
    rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" >

summary.txt 2> /dev/null
}

Let me know if this ok. will send patches with changes for review.

Regards,
Vinay

Quoted 85 lines · Vinay Kumar via lists.openembedded.org

Hi Alex,

Tried testing outside oe-selftest framework, it works fine without any errors,

export TEST_DEVICE_ADDR="192.168.7.4:12345"
rust_runx test --no-fail-fast --bless --target "aarch64-poky-linux" > summary.txt 2> /dev/null

Also, log (summary.txt) shows "remote-test-client" is connecting to
the image without any issue.
=======================================
running: "/ala-lpggp31/vinay/review-2/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/x86_64-unknown-linux-gnu/stage0-tools-bin/remote-test-client" "spawn-emulator" "aarch64-poky-linux" "/ala-lpggp31/vinay/review-2/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/x86_64-unknown-linux-gnu/stage0-tools-bin/remote-test-server" "/ala-lpggp31/vinay/review-2/b1/tmp/work/cortexa57-poky-linux/rust-testsuite/1.46.0-r0/rustc-1.46.0-src/build/tmp"
Connecting to remote device 192.168.7.4:12345 ...

Will integrate these changes in oe-selftest and let you know.

Regards,
Vinay

Quoted 58 lines · Vinay Kumar

Checking suggestions, the booted image with tap seems to be working by passing "-monitor telnet:127.0.0.1:1234,server,nowait"
so I will execute testing and update you.
==========================

root@qemuarm64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.4  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:116 errors:0 dropped:0 overruns:0 frame:0
          TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:945121 (922.9 KiB)  TX bytes:9529 (9.3 KiB)
root@qemuarm64:~# ./remote-test-server -v remote
starting test server
listening on 0.0.0.0:12345!
==========================

Regards,
Vinay

Quoted 33 lines · Alexander Kanavin

Thanks, can you please look into the error? The line where it happens and the way to get a backtrace is right there :) There's no reason it shouldn't work.

Alex

Quoted 26 lines · Vinay Kumar

Hi Alex,

Error on qemu image (ex. Aarch64) booted with tap interface.
===========================

root@qemuarm64:~# ./remote-test-server
starting test server
thread 'main' panicked at 'TcpListener::bind(bind_addr) failed with
Cannot assign requested address (os error 99)',
src/tools/remote-test-server/src/main.rs:90:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
===========================
Quoted 11 lines · Alexander Kanavin
Quoted 4 lines · Vinay Kumar

"remote-test-server" on qemu-image with a tap interface throws an error. The emulators for rust testing are with tcp port forwarding so used slirp method with added rust port.

I'm not sure I understand - what kind of error? In both cases the server starts listening on a port, so in slirp scenario the address is 127.0.0.1:12345 (prone to breakage if something else on the build host took that port btw, including another instance of the same test), in tap it would be 192.168.7.2:12345. For the client you simply supply that via TEST_DEVICE_ADDR. No?

Alex

#79 lore raw

Re: [OE-core] [PATCH v2 6/7] oeqa/selftest/cases/rust.py: Rust oe-selftest script.

Quoted 5 lines · Vinay Kumar

If we set "export TEST_DEVICE_ADDR=192.168.7.2:12345;" in do_check of rust-testsuite.inc connection establishes with image
and the test execution is as expected.

That's because bitbake sanitizes the environment of the tasks and those externally set variables do not propagate into do_check().

I would suggest that you do not try to do the testing step as a bitbake task in a recipe, but rather move what it does directly into meta/lib/oeqa/selftest/cases/rust.py.

I will respond to the patch separately.

Alex

#80 lore raw

PATCH v2 7/7 rust.inc : Fix for aarch64 feature.

In reply to Vinay Kumar

While executing ui testing observed failures due to below warning, "'+v8' is not a recognized feature for this target (ignoring feature)"

Same got fixed by backporting below patch,
http://git.yoctoproject.org/cgit.cgi/poky-contrib/commit/?h=rmacleod/rust-wip-2021-02-16&id=f243e4bbd5414ce519336753a68c53ee60cbe89e

---
 meta/recipes-devtools/rust/rust.inc | 3 ---
 1 file changed, 3 deletions(-)
meta/recipes-devtools/rust/rust.inc +0 -3
index ee3176b559..fb20bbd0fb 100644
@@ -64,9 +64,6 @@ def llvm_features_from_tune(d):
     if 'neon' in feat:
         f.append("+neon")
 
-    if 'aarch64' in feat:
-        f.append("+v8")
-
     if 'mips32' in feat:
         f.append("+mips32")
 
Signature · 1 line
2.17.1
#81 lore raw

Re: [PATCH v2 1/7] rust-testsuite.inc : Rust cross testing.

In reply to Vinay Kumar

I believe rust itself is not yet in oe-core? Which patchset is this based on?

Alex

Quoted 213 lines · Vinay Kumar

Below list of functions are part of rust-testsuite.inc setup_cargo_environment(): Build bootstrap and some early stage tools. do_rust_setup_snapshot(): Install the snapshot version of rust binaries. do_configure(): To generate config.toml
do_compile(): To build "remote-test-server" for qemutarget image. do_check(): To execute testing by copying remote-test-server to qmutarget image.

---
 meta/recipes-devtools/rust/rust-testsuite.inc | 166 ++++++++++++++++++
 1 file changed, 166 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-testsuite.inc
meta/recipes-devtools/rust/rust-testsuite.inc new file +17 -0
new file mode 100644
index 0000000000..d1c5496da4
@@ -0,0 +1,166 @@
+SUMMARY = "Rust testing"
+HOMEPAGE = "https://rustc-dev-guide.rust-lang.org/tests/intro.html"
+SECTION = "test"
+LICENSE = "MIT | Apache-2.0"
+
+inherit rust
+inherit cargo_common
+
+DEPENDS += "file-native python3-native"
+EXCLUDE_FROM_WORLD = "1"
+
+# Path of target specification file "target-poky-linux.json"
+export RUST_TARGET_PATH="${STAGING_LIBDIR_NATIVE}/rustlib"
+
+export FORCE_CRATE_HASH="${BB_TASKHASH}"
+
+# We don't want to use bitbakes vendoring because the rust sources do

their

meta/recipes-devtools/rust/rust-testsuite.inc new file +11 -0
+# own vendoring.
+CARGO_DISABLE_BITBAKE_VENDORING = "1"
+
+# We can't use RUST_BUILD_SYS here because that may be "musl" if
+# TCLIBC="musl". Snapshots are always -unknown-linux-gnu
+SNAPSHOT_BUILD_SYS = "${BUILD_ARCH}-unknown-linux-gnu"
+setup_cargo_environment () {
+    # The first step is to build bootstrap and some early stage tools,
+    # these are build for the same target as the snapshot, e.g.
+    # x86_64-unknown-linux-gnu.
+    # Later stages are build for the native target (i.e.

target.x86_64-linux)

meta/recipes-devtools/rust/rust-testsuite.inc new file +8 -0
+    cargo_common_do_configure
+
+    printf '[target.%s]\n' "${SNAPSHOT_BUILD_SYS}" >> ${CARGO_HOME}/config
+    printf "linker = '%s'\n" "${RUST_BUILD_CCLD}" >> ${CARGO_HOME}/config
+}
+
+do_rust_setup_snapshot () {
+    for installer in

"${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do

meta/recipes-devtools/rust/rust-testsuite.inc new file +4 -1
+        "${installer}" --prefix="${WORKDIR}/rust-snapshot"
--disable-ldconfig
+    done
+
+    # Some versions of rust (e.g. 1.18.0) tries to find cargo in

stage0/bin/cargo

meta/recipes-devtools/rust/rust-testsuite.inc new file +16 -0
+    # and fail without it there.
+    mkdir -p ${RUSTSRC}/build/${BUILD_SYS}
+    ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${BUILD_SYS}/stage0
+}
+addtask rust_setup_snapshot after do_unpack before do_configure
+do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
+
+python do_configure() {
+    import json
+    from distutils.version import LooseVersion
+    try:
+        import configparser
+    except ImportError:
+        import ConfigParser as configparser
+
+    # toml is rather similar to standard ini like format except it likes

values
+ # that look more JSON like. So for our purposes simply escaping all
values

meta/recipes-devtools/rust/rust-testsuite.inc new file +7 -0
+    # as JSON seem to work fine.
+
+    e = lambda s: json.dumps(s)
+
+    config = configparser.RawConfigParser()
+
+    # [target.ARCH-unknown-linux-gnu] in case of x86_64

[target.ARCH-poky-linux]

meta/recipes-devtools/rust/rust-testsuite.inc new file +4 -0
+    target_section = "target.{}".format(d.getVar('TARGET_SYS', True))
+    config.add_section(target_section)
+
+    # Points to wrapper files which contain target specific compiler and

linker commands.

meta/recipes-devtools/rust/rust-testsuite.inc new file +3 -0
+    config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
+    config.set(target_section, "linker",

e(d.expand("${RUST_TARGET_CCLD}")))

meta/recipes-devtools/rust/rust-testsuite.inc new file +2 -0
+
+    # If we don't do this rust-native will compile it's own llvm for

BUILD.

meta/recipes-devtools/rust/rust-testsuite.inc new file +2 -0
+    # [target.${BUILD_ARCH}-unknown-linux-gnu]
+    target_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS',

True))

meta/recipes-devtools/rust/rust-testsuite.inc new file +22 -0
+    config.add_section(target_section)
+
+    # Wrapper scripts of build system.
+    config.set(target_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
+
+    # [llvm]
+    config.add_section("llvm")
+    config.set("llvm", "targets", e("ARM;AArch64;Mips;PowerPC;RISCV;X86"))
+
+    # [rust]
+    config.add_section("rust")
+    config.set("rust", "rpath", e(True))
+    config.set("rust", "channel", e("stable"))
+
+    if LooseVersion(d.getVar("PV")) < LooseVersion("1.32.0"):
+        config.set("rust", "use-jemalloc", e(False))
+
+    # Whether or not to optimize the compiler and standard library
+    config.set("rust", "optimize", e(True))
+
+    # Emits extraneous output from tests to ensure that failures of the

test

meta/recipes-devtools/rust/rust-testsuite.inc new file +5 -0
+    # harness are debuggable just from logfiles
+    config.set("rust", "verbose-tests", e(True))
+
+    # Override default linker cc.
+    config.set("rust", "default-linker",

e(d.expand("${RUST_BUILD_CCLD}")))

meta/recipes-devtools/rust/rust-testsuite.inc new file +21 -0
+
+    # [build]
+    config.add_section("build")
+    config.set("build", "submodules", e(False))
+    config.set("build", "docs", e(False))
+
+    rustc = d.expand("${WORKDIR}/rust-snapshot/bin/rustc")
+    config.set("build", "rustc", e(rustc))
+
+    cargo = d.expand("${WORKDIR}/rust-snapshot/bin/cargo")
+    config.set("build", "cargo", e(cargo))
+
+    config.set("build", "vendor", e(True))
+
+    targets = [d.getVar("TARGET_SYS", True)]
+    config.set("build", "target", e(targets))
+
+    hosts = [d.getVar("SNAPSHOT_BUILD_SYS", True)]
+    config.set("build", "host", e(hosts))
+
+    # We can't use BUILD_SYS since that is something the rust snapshot

knows
+ # nothing about when trying to build some stage0 tools (like
fabricate)

meta/recipes-devtools/rust/rust-testsuite.inc new file +15 -0
+    config.set("build", "build", e(d.getVar("SNAPSHOT_BUILD_SYS", True)))
+
+    with open("config.toml", "w") as f:
+        config.write(f)
+
+    # set up ${WORKDIR}/cargo_home
+    bb.build.exec_func("setup_cargo_environment", d)
+}
+
+
+rust_runx () {
+    echo "COMPILE ${PN}" "$@"
+
+    # CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a
+    # wide range of targets (not just TARGET). Yocto's settings for them

will

meta/recipes-devtools/rust/rust-testsuite.inc new file +9 -0
+    # be inappropriate, avoid using.
+    unset CFLAGS
+    unset LDFLAGS
+    unset CXXFLAGS
+    unset CPPFLAGS
+
+    oe_cargo_fix_env
+
+    python3 src/bootstrap/bootstrap.py

${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose

meta/recipes-devtools/rust/rust-testsuite.inc new file +12 -0
+}
+rust_runx[vardepsexclude] += "PARALLEL_MAKE"
+
+do_compile () {
+
+    rust_runx build src/tools/remote-test-server --target "${TARGET_SYS}"
+}
+
+do_check[dirs] += "${B}"
+do_check[nostamp] = "1"
+do_check () {
+    scp -P 2222 -o StrictHostKeyChecking=no

build/${SNAPSHOT_BUILD_SYS}/stage2-tools-bin/remote-test-server [email protected]:~/
+ ssh -p 2222 -o StrictHostKeyChecking=no -f [email protected]
"~/remote-test-server -v remote"

meta/recipes-devtools/rust/rust-testsuite.inc new file +3 -0
+
+    export TEST_DEVICE_ADDR="127.0.0.1:12345"
+    rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" >

summary.txt 2> /dev/null

meta/recipes-devtools/rust/rust-testsuite.inc new file +2 -1
+}
+addtask do_check after do_compile
--

2.17.1

#82 lore raw

Re: [PATCH v2 1/7] rust-testsuite.inc : Rust cross testing.

Hi Alex,

The patchset is based on below rust branch,
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=rmacleod/rust-wip-2021-02-02

Regards,
Vinay

Quoted 195 lines · Alexander Kanavin

I believe rust itself is not yet in oe-core? Which patchset is this based on?

Alex

Quoted 189 lines · Vinay Kumar

Below list of functions are part of rust-testsuite.inc setup_cargo_environment(): Build bootstrap and some early stage tools. do_rust_setup_snapshot(): Install the snapshot version of rust binaries. do_configure(): To generate config.toml
do_compile(): To build "remote-test-server" for qemutarget image. do_check(): To execute testing by copying remote-test-server to qmutarget image.

---
 meta/recipes-devtools/rust/rust-testsuite.inc | 166 ++++++++++++++++++
 1 file changed, 166 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust-testsuite.inc
meta/recipes-devtools/rust/rust-testsuite.inc new file +166 -1
new file mode 100644
index 0000000000..d1c5496da4
@@ -0,0 +1,166 @@
+SUMMARY = "Rust testing"
+HOMEPAGE = "https://rustc-dev-guide.rust-lang.org/tests/intro.html"
+SECTION = "test"
+LICENSE = "MIT | Apache-2.0"
+
+inherit rust
+inherit cargo_common
+
+DEPENDS += "file-native python3-native"
+EXCLUDE_FROM_WORLD = "1"
+
+# Path of target specification file "target-poky-linux.json"
+export RUST_TARGET_PATH="${STAGING_LIBDIR_NATIVE}/rustlib"
+
+export FORCE_CRATE_HASH="${BB_TASKHASH}"
+
+# We don't want to use bitbakes vendoring because the rust sources do their
+# own vendoring.
+CARGO_DISABLE_BITBAKE_VENDORING = "1"
+
+# We can't use RUST_BUILD_SYS here because that may be "musl" if
+# TCLIBC="musl". Snapshots are always -unknown-linux-gnu
+SNAPSHOT_BUILD_SYS = "${BUILD_ARCH}-unknown-linux-gnu"
+setup_cargo_environment () {
+    # The first step is to build bootstrap and some early stage tools,
+    # these are build for the same target as the snapshot, e.g.
+    # x86_64-unknown-linux-gnu.
+    # Later stages are build for the native target (i.e. target.x86_64-linux)
+    cargo_common_do_configure
+
+    printf '[target.%s]\n' "${SNAPSHOT_BUILD_SYS}" >> ${CARGO_HOME}/config
+    printf "linker = '%s'\n" "${RUST_BUILD_CCLD}" >> ${CARGO_HOME}/config
+}
+
+do_rust_setup_snapshot () {
+    for installer in "${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do
+        "${installer}" --prefix="${WORKDIR}/rust-snapshot" --disable-ldconfig
+    done
+
+    # Some versions of rust (e.g. 1.18.0) tries to find cargo in stage0/bin/cargo
+    # and fail without it there.
+    mkdir -p ${RUSTSRC}/build/${BUILD_SYS}
+    ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${BUILD_SYS}/stage0
+}
+addtask rust_setup_snapshot after do_unpack before do_configure
+do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
+
+python do_configure() {
+    import json
+    from distutils.version import LooseVersion
+    try:
+        import configparser
+    except ImportError:
+        import ConfigParser as configparser
+
+    # toml is rather similar to standard ini like format except it likes values
+    # that look more JSON like. So for our purposes simply escaping all values
+    # as JSON seem to work fine.
+
+    e = lambda s: json.dumps(s)
+
+    config = configparser.RawConfigParser()
+
+    # [target.ARCH-unknown-linux-gnu] in case of x86_64 [target.ARCH-poky-linux]
+    target_section = "target.{}".format(d.getVar('TARGET_SYS', True))
+    config.add_section(target_section)
+
+    # Points to wrapper files which contain target specific compiler and linker commands.
+    config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
+    config.set(target_section, "linker", e(d.expand("${RUST_TARGET_CCLD}")))
+
+    # If we don't do this rust-native will compile it's own llvm for BUILD.
+    # [target.${BUILD_ARCH}-unknown-linux-gnu]
+    target_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS', True))
+    config.add_section(target_section)
+
+    # Wrapper scripts of build system.
+    config.set(target_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
+
+    # [llvm]
+    config.add_section("llvm")
+    config.set("llvm", "targets", e("ARM;AArch64;Mips;PowerPC;RISCV;X86"))
+
+    # [rust]
+    config.add_section("rust")
+    config.set("rust", "rpath", e(True))
+    config.set("rust", "channel", e("stable"))
+
+    if LooseVersion(d.getVar("PV")) < LooseVersion("1.32.0"):
+        config.set("rust", "use-jemalloc", e(False))
+
+    # Whether or not to optimize the compiler and standard library
+    config.set("rust", "optimize", e(True))
+
+    # Emits extraneous output from tests to ensure that failures of the test
+    # harness are debuggable just from logfiles
+    config.set("rust", "verbose-tests", e(True))
+
+    # Override default linker cc.
+    config.set("rust", "default-linker", e(d.expand("${RUST_BUILD_CCLD}")))
+
+    # [build]
+    config.add_section("build")
+    config.set("build", "submodules", e(False))
+    config.set("build", "docs", e(False))
+
+    rustc = d.expand("${WORKDIR}/rust-snapshot/bin/rustc")
+    config.set("build", "rustc", e(rustc))
+
+    cargo = d.expand("${WORKDIR}/rust-snapshot/bin/cargo")
+    config.set("build", "cargo", e(cargo))
+
+    config.set("build", "vendor", e(True))
+
+    targets = [d.getVar("TARGET_SYS", True)]
+    config.set("build", "target", e(targets))
+
+    hosts = [d.getVar("SNAPSHOT_BUILD_SYS", True)]
+    config.set("build", "host", e(hosts))
+
+    # We can't use BUILD_SYS since that is something the rust snapshot knows
+    # nothing about when trying to build some stage0 tools (like fabricate)
+    config.set("build", "build", e(d.getVar("SNAPSHOT_BUILD_SYS", True)))
+
+    with open("config.toml", "w") as f:
+        config.write(f)
+
+    # set up ${WORKDIR}/cargo_home
+    bb.build.exec_func("setup_cargo_environment", d)
+}
+
+
+rust_runx () {
+    echo "COMPILE ${PN}" "$@"
+
+    # CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a
+    # wide range of targets (not just TARGET). Yocto's settings for them will
+    # be inappropriate, avoid using.
+    unset CFLAGS
+    unset LDFLAGS
+    unset CXXFLAGS
+    unset CPPFLAGS
+
+    oe_cargo_fix_env
+
+    python3 src/bootstrap/bootstrap.py ${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose
+}
+rust_runx[vardepsexclude] += "PARALLEL_MAKE"
+
+do_compile () {
+
+    rust_runx build src/tools/remote-test-server --target "${TARGET_SYS}"
+}
+
+do_check[dirs] += "${B}"
+do_check[nostamp] = "1"
+do_check () {
+    scp -P 2222 -o StrictHostKeyChecking=no build/${SNAPSHOT_BUILD_SYS}/stage2-tools-bin/remote-test-server [email protected]:~/
+    ssh -p 2222 -o StrictHostKeyChecking=no -f [email protected] "~/remote-test-server -v remote"
+
+    export TEST_DEVICE_ADDR="127.0.0.1:12345"
+    rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" > summary.txt 2> /dev/null
+}
+addtask do_check after do_compile
--

2.17.1

#83 lore raw

Re: [PATCH v2 1/7] rust-testsuite.inc : Rust cross testing.

In reply to Vinay Kumar
Quoted 11 lines · Vinay Kumar
meta/recipes-devtools/rust/rust-testsuite.inc new file +4 -0
+do_check[dirs] += "${B}"
+do_check[nostamp] = "1"
+do_check () {
+    scp -P 2222 -o StrictHostKeyChecking=no

build/${SNAPSHOT_BUILD_SYS}/stage2-tools-bin/remote-test-server [email protected]:~/
+ ssh -p 2222 -o StrictHostKeyChecking=no -f [email protected]
"~/remote-test-server -v remote"

meta/recipes-devtools/rust/rust-testsuite.inc new file +3 -0
+
+    export TEST_DEVICE_ADDR="127.0.0.1:12345"
+    rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" >
Quoted 3 lines

summary.txt 2> /dev/null
+}

I think this needs to be moved to selftest itself, is this possible?

Alex

#84 lore raw

Re: [PATCH v2 1/7] rust-testsuite.inc : Rust cross testing.

Hi Alex,

Quoted 2 lines

meta/recipes-devtools/rust/rust-testsuite.inc line 161

Quoted 2 lines
meta/recipes-devtools/rust/rust-testsuite.inc new file +2 -0
+    scp -P 2222 -o StrictHostKeyChecking=no build/${SNAPSHOT_BUILD_SYS}/stage2-tools-bin/remote-test-server [email protected]:~/
+    ssh -p 2222 -o StrictHostKeyChecking=no -f [email protected] "~/remote-test-server -v remote"

I tried copy_to() and run from sshcontrol.py on qemuimage successfully. Howerver, I could not figure out the relative path for "remote-test-server" from rust.py .

Quoted 2 lines

meta/recipes-devtools/rust/rust-testsuite.inc line 164

Quoted 2 lines
meta/recipes-devtools/rust/rust-testsuite.inc new file +2 -0
+    export TEST_DEVICE_ADDR="127.0.0.1:12345"
+    rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" > summary.txt 2> /dev/null

Will try and let you know.

Regards,
Vinay

Quoted 17 lines · Alexander Kanavin

meta/recipes-devtools/rust/rust-testsuite.inc line 165

Quoted 10 lines · Vinay Kumar
meta/recipes-devtools/rust/rust-testsuite.inc new file +9 -0
+do_check[dirs] += "${B}"
+do_check[nostamp] = "1"
+do_check () {
+    scp -P 2222 -o StrictHostKeyChecking=no build/${SNAPSHOT_BUILD_SYS}/stage2-tools-bin/remote-test-server [email protected]:~/
+    ssh -p 2222 -o StrictHostKeyChecking=no -f [email protected] "~/remote-test-server -v remote"
+
+    export TEST_DEVICE_ADDR="127.0.0.1:12345"
+    rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" > summary.txt 2> /dev/null
+}

I think this needs to be moved to selftest itself, is this possible?

Alex

#85 lore raw

Re: [PATCH v2 1/7] rust-testsuite.inc : Rust cross testing.

Quoted 12 lines · Vinay Kumar

Hi Alex,

Quoted 1 line
Quoted 1 line

+ scp -P 2222 -o StrictHostKeyChecking=no

build/${SNAPSHOT_BUILD_SYS}/stage2-tools-bin/remote-test-server [email protected]:~/

Quoted 1 line
Quoted 1 line

+ ssh -p 2222 -o StrictHostKeyChecking=no -f [email protected]

"~/remote-test-server -v remote"

I tried copy_to() and run from sshcontrol.py on qemuimage successfully. Howerver, I could not figure out the relative path for "remote-test-server" from rust.py .

With get_bb_var() you can. Grep for examples in
meta/lib/oeqa/selftest/cases.

Alex

#86 lore raw

Re: [OE-core] [PATCH v2 1/7] rust-testsuite.inc : Rust cross testing.

In reply to Vinay Kumar
Quoted 7 lines · Vinay Kumar

Below list of functions are part of rust-testsuite.inc setup_cargo_environment(): Build bootstrap and some early stage tools. do_rust_setup_snapshot(): Install the snapshot version of rust binaries. do_configure(): To generate config.toml
do_compile(): To build "remote-test-server" for qemutarget image. do_check(): To execute testing by copying remote-test-server to qmutarget image.

some part of these series should go to meta-rust

Quoted 183 lines
---
  meta/recipes-devtools/rust/rust-testsuite.inc | 166 ++++++++++++++++++
  1 file changed, 166 insertions(+)

create mode 100644 meta/recipes-devtools/rust/rust-testsuite.inc

meta/recipes-devtools/rust/rust-testsuite.inc new file +166 -0
new file mode 100644
index 0000000000..d1c5496da4
@@ -0,0 +1,166 @@
+SUMMARY = "Rust testing"
+HOMEPAGE = "https://rustc-dev-guide.rust-lang.org/tests/intro.html"
+SECTION = "test"
+LICENSE = "MIT | Apache-2.0"
+
+inherit rust
+inherit cargo_common
+
+DEPENDS += "file-native python3-native"
+EXCLUDE_FROM_WORLD = "1"
+
+# Path of target specification file "target-poky-linux.json"
+export RUST_TARGET_PATH="${STAGING_LIBDIR_NATIVE}/rustlib"
+
+export FORCE_CRATE_HASH="${BB_TASKHASH}"
+
+# We don't want to use bitbakes vendoring because the rust sources do their
+# own vendoring.
+CARGO_DISABLE_BITBAKE_VENDORING = "1"
+
+# We can't use RUST_BUILD_SYS here because that may be "musl" if
+# TCLIBC="musl". Snapshots are always -unknown-linux-gnu
+SNAPSHOT_BUILD_SYS = "${BUILD_ARCH}-unknown-linux-gnu"
+setup_cargo_environment () {
+    # The first step is to build bootstrap and some early stage tools,
+    # these are build for the same target as the snapshot, e.g.
+    # x86_64-unknown-linux-gnu.
+    # Later stages are build for the native target (i.e. target.x86_64-linux)
+    cargo_common_do_configure
+
+    printf '[target.%s]\n' "${SNAPSHOT_BUILD_SYS}" >> ${CARGO_HOME}/config
+    printf "linker = '%s'\n" "${RUST_BUILD_CCLD}" >> ${CARGO_HOME}/config
+}
+
+do_rust_setup_snapshot () {
+    for installer in "${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do
+        "${installer}" --prefix="${WORKDIR}/rust-snapshot" --disable-ldconfig
+    done
+
+    # Some versions of rust (e.g. 1.18.0) tries to find cargo in stage0/bin/cargo
+    # and fail without it there.
+    mkdir -p ${RUSTSRC}/build/${BUILD_SYS}
+    ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${BUILD_SYS}/stage0
+}
+addtask rust_setup_snapshot after do_unpack before do_configure
+do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
+
+python do_configure() {
+    import json
+    from distutils.version import LooseVersion
+    try:
+        import configparser
+    except ImportError:
+        import ConfigParser as configparser
+
+    # toml is rather similar to standard ini like format except it likes values
+    # that look more JSON like. So for our purposes simply escaping all values
+    # as JSON seem to work fine.
+
+    e = lambda s: json.dumps(s)
+
+    config = configparser.RawConfigParser()
+
+    # [target.ARCH-unknown-linux-gnu] in case of x86_64 [target.ARCH-poky-linux]
+    target_section = "target.{}".format(d.getVar('TARGET_SYS', True))
+    config.add_section(target_section)
+
+    # Points to wrapper files which contain target specific compiler and linker commands.
+    config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
+    config.set(target_section, "linker", e(d.expand("${RUST_TARGET_CCLD}")))
+
+    # If we don't do this rust-native will compile it's own llvm for BUILD.
+    # [target.${BUILD_ARCH}-unknown-linux-gnu]
+    target_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS', True))
+    config.add_section(target_section)
+
+    # Wrapper scripts of build system.
+    config.set(target_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
+
+    # [llvm]
+    config.add_section("llvm")
+    config.set("llvm", "targets", e("ARM;AArch64;Mips;PowerPC;RISCV;X86"))
+
+    # [rust]
+    config.add_section("rust")
+    config.set("rust", "rpath", e(True))
+    config.set("rust", "channel", e("stable"))
+
+    if LooseVersion(d.getVar("PV")) < LooseVersion("1.32.0"):
+        config.set("rust", "use-jemalloc", e(False))
+
+    # Whether or not to optimize the compiler and standard library
+    config.set("rust", "optimize", e(True))
+
+    # Emits extraneous output from tests to ensure that failures of the test
+    # harness are debuggable just from logfiles
+    config.set("rust", "verbose-tests", e(True))
+
+    # Override default linker cc.
+    config.set("rust", "default-linker", e(d.expand("${RUST_BUILD_CCLD}")))
+
+    # [build]
+    config.add_section("build")
+    config.set("build", "submodules", e(False))
+    config.set("build", "docs", e(False))
+
+    rustc = d.expand("${WORKDIR}/rust-snapshot/bin/rustc")
+    config.set("build", "rustc", e(rustc))
+
+    cargo = d.expand("${WORKDIR}/rust-snapshot/bin/cargo")
+    config.set("build", "cargo", e(cargo))
+
+    config.set("build", "vendor", e(True))
+
+    targets = [d.getVar("TARGET_SYS", True)]
+    config.set("build", "target", e(targets))
+
+    hosts = [d.getVar("SNAPSHOT_BUILD_SYS", True)]
+    config.set("build", "host", e(hosts))
+
+    # We can't use BUILD_SYS since that is something the rust snapshot knows
+    # nothing about when trying to build some stage0 tools (like fabricate)
+    config.set("build", "build", e(d.getVar("SNAPSHOT_BUILD_SYS", True)))
+
+    with open("config.toml", "w") as f:
+        config.write(f)
+
+    # set up ${WORKDIR}/cargo_home
+    bb.build.exec_func("setup_cargo_environment", d)
+}
+
+
+rust_runx () {
+    echo "COMPILE ${PN}" "$@"
+
+    # CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a
+    # wide range of targets (not just TARGET). Yocto's settings for them will
+    # be inappropriate, avoid using.
+    unset CFLAGS
+    unset LDFLAGS
+    unset CXXFLAGS
+    unset CPPFLAGS
+
+    oe_cargo_fix_env
+
+    python3 src/bootstrap/bootstrap.py ${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose
+}
+rust_runx[vardepsexclude] += "PARALLEL_MAKE"
+
+do_compile () {
+
+    rust_runx build src/tools/remote-test-server --target "${TARGET_SYS}"
+}
+
+do_check[dirs] += "${B}"
+do_check[nostamp] = "1"
+do_check () {
+    scp -P 2222 -o StrictHostKeyChecking=no build/${SNAPSHOT_BUILD_SYS}/stage2-tools-bin/remote-test-server [email protected]:~/
+    ssh -p 2222 -o StrictHostKeyChecking=no -f [email protected] "~/remote-test-server -v remote"
+
+    export TEST_DEVICE_ADDR="127.0.0.1:12345"
+    rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" > summary.txt 2> /dev/null
+}
+addtask do_check after do_compile
#87 lore raw

Re: [OE-core] [PATCH v2 1/7] rust-testsuite.inc : Rust cross testing.

Hi Khem Raj,

Once the patches get approved will work on adding in meta-rust.

Regards,
Vinay

Quoted 198 lines · Khem Raj
Quoted 7 lines · Vinay Kumar

Below list of functions are part of rust-testsuite.inc setup_cargo_environment(): Build bootstrap and some early stage tools. do_rust_setup_snapshot(): Install the snapshot version of rust binaries. do_configure(): To generate config.toml
do_compile(): To build "remote-test-server" for qemutarget image. do_check(): To execute testing by copying remote-test-server to qmutarget image.

some part of these series should go to meta-rust

Quoted 183 lines
---
  meta/recipes-devtools/rust/rust-testsuite.inc | 166 ++++++++++++++++++
  1 file changed, 166 insertions(+)

create mode 100644 meta/recipes-devtools/rust/rust-testsuite.inc

meta/recipes-devtools/rust/rust-testsuite.inc new file +166 -0
new file mode 100644
index 0000000000..d1c5496da4
@@ -0,0 +1,166 @@
+SUMMARY = "Rust testing"
+HOMEPAGE = "https://rustc-dev-guide.rust-lang.org/tests/intro.html"
+SECTION = "test"
+LICENSE = "MIT | Apache-2.0"
+
+inherit rust
+inherit cargo_common
+
+DEPENDS += "file-native python3-native"
+EXCLUDE_FROM_WORLD = "1"
+
+# Path of target specification file "target-poky-linux.json"
+export RUST_TARGET_PATH="${STAGING_LIBDIR_NATIVE}/rustlib"
+
+export FORCE_CRATE_HASH="${BB_TASKHASH}"
+
+# We don't want to use bitbakes vendoring because the rust sources do their
+# own vendoring.
+CARGO_DISABLE_BITBAKE_VENDORING = "1"
+
+# We can't use RUST_BUILD_SYS here because that may be "musl" if
+# TCLIBC="musl". Snapshots are always -unknown-linux-gnu
+SNAPSHOT_BUILD_SYS = "${BUILD_ARCH}-unknown-linux-gnu"
+setup_cargo_environment () {
+    # The first step is to build bootstrap and some early stage tools,
+    # these are build for the same target as the snapshot, e.g.
+    # x86_64-unknown-linux-gnu.
+    # Later stages are build for the native target (i.e. target.x86_64-linux)
+    cargo_common_do_configure
+
+    printf '[target.%s]\n' "${SNAPSHOT_BUILD_SYS}" >> ${CARGO_HOME}/config
+    printf "linker = '%s'\n" "${RUST_BUILD_CCLD}" >> ${CARGO_HOME}/config
+}
+
+do_rust_setup_snapshot () {
+    for installer in "${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do
+        "${installer}" --prefix="${WORKDIR}/rust-snapshot" --disable-ldconfig
+    done
+
+    # Some versions of rust (e.g. 1.18.0) tries to find cargo in stage0/bin/cargo
+    # and fail without it there.
+    mkdir -p ${RUSTSRC}/build/${BUILD_SYS}
+    ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${BUILD_SYS}/stage0
+}
+addtask rust_setup_snapshot after do_unpack before do_configure
+do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
+
+python do_configure() {
+    import json
+    from distutils.version import LooseVersion
+    try:
+        import configparser
+    except ImportError:
+        import ConfigParser as configparser
+
+    # toml is rather similar to standard ini like format except it likes values
+    # that look more JSON like. So for our purposes simply escaping all values
+    # as JSON seem to work fine.
+
+    e = lambda s: json.dumps(s)
+
+    config = configparser.RawConfigParser()
+
+    # [target.ARCH-unknown-linux-gnu] in case of x86_64 [target.ARCH-poky-linux]
+    target_section = "target.{}".format(d.getVar('TARGET_SYS', True))
+    config.add_section(target_section)
+
+    # Points to wrapper files which contain target specific compiler and linker commands.
+    config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}")))
+    config.set(target_section, "linker", e(d.expand("${RUST_TARGET_CCLD}")))
+
+    # If we don't do this rust-native will compile it's own llvm for BUILD.
+    # [target.${BUILD_ARCH}-unknown-linux-gnu]
+    target_section = "target.{}".format(d.getVar('SNAPSHOT_BUILD_SYS', True))
+    config.add_section(target_section)
+
+    # Wrapper scripts of build system.
+    config.set(target_section, "cxx", e(d.expand("${RUST_BUILD_CXX}")))
+    config.set(target_section, "cc", e(d.expand("${RUST_BUILD_CC}")))
+
+    # [llvm]
+    config.add_section("llvm")
+    config.set("llvm", "targets", e("ARM;AArch64;Mips;PowerPC;RISCV;X86"))
+
+    # [rust]
+    config.add_section("rust")
+    config.set("rust", "rpath", e(True))
+    config.set("rust", "channel", e("stable"))
+
+    if LooseVersion(d.getVar("PV")) < LooseVersion("1.32.0"):
+        config.set("rust", "use-jemalloc", e(False))
+
+    # Whether or not to optimize the compiler and standard library
+    config.set("rust", "optimize", e(True))
+
+    # Emits extraneous output from tests to ensure that failures of the test
+    # harness are debuggable just from logfiles
+    config.set("rust", "verbose-tests", e(True))
+
+    # Override default linker cc.
+    config.set("rust", "default-linker", e(d.expand("${RUST_BUILD_CCLD}")))
+
+    # [build]
+    config.add_section("build")
+    config.set("build", "submodules", e(False))
+    config.set("build", "docs", e(False))
+
+    rustc = d.expand("${WORKDIR}/rust-snapshot/bin/rustc")
+    config.set("build", "rustc", e(rustc))
+
+    cargo = d.expand("${WORKDIR}/rust-snapshot/bin/cargo")
+    config.set("build", "cargo", e(cargo))
+
+    config.set("build", "vendor", e(True))
+
+    targets = [d.getVar("TARGET_SYS", True)]
+    config.set("build", "target", e(targets))
+
+    hosts = [d.getVar("SNAPSHOT_BUILD_SYS", True)]
+    config.set("build", "host", e(hosts))
+
+    # We can't use BUILD_SYS since that is something the rust snapshot knows
+    # nothing about when trying to build some stage0 tools (like fabricate)
+    config.set("build", "build", e(d.getVar("SNAPSHOT_BUILD_SYS", True)))
+
+    with open("config.toml", "w") as f:
+        config.write(f)
+
+    # set up ${WORKDIR}/cargo_home
+    bb.build.exec_func("setup_cargo_environment", d)
+}
+
+
+rust_runx () {
+    echo "COMPILE ${PN}" "$@"
+
+    # CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a
+    # wide range of targets (not just TARGET). Yocto's settings for them will
+    # be inappropriate, avoid using.
+    unset CFLAGS
+    unset LDFLAGS
+    unset CXXFLAGS
+    unset CPPFLAGS
+
+    oe_cargo_fix_env
+
+    python3 src/bootstrap/bootstrap.py ${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose
+}
+rust_runx[vardepsexclude] += "PARALLEL_MAKE"
+
+do_compile () {
+
+    rust_runx build src/tools/remote-test-server --target "${TARGET_SYS}"
+}
+
+do_check[dirs] += "${B}"
+do_check[nostamp] = "1"
+do_check () {
+    scp -P 2222 -o StrictHostKeyChecking=no build/${SNAPSHOT_BUILD_SYS}/stage2-tools-bin/remote-test-server [email protected]:~/
+    ssh -p 2222 -o StrictHostKeyChecking=no -f [email protected] "~/remote-test-server -v remote"
+
+    export TEST_DEVICE_ADDR="127.0.0.1:12345"
+    rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" > summary.txt 2> /dev/null
+}
+addtask do_check after do_compile
#88 lore raw

Re: [OE-core] [PATCH 5/8] There are some error messages like, "error: linker `cc` not found" got fixed by adding "cc" in hosttools.

In reply to Richard Purdie

Hi Richard,

Please excuse the delay in reply, I was loaded with some other priority tasks.

Quoted 2 lines
Quoted 2 lines

I definitely agree this should be fixed elsewhere to use BUILD_CC. We've managed without 'cc' for this long, we shouldn't need to start now

The linker error got fixed by using below setting in config.toml config.set("rust", "default-linker", e(d.expand("${RUST_BUILD_CCLD}")))

So removed 'cc' from hosttools as per your suggestion.

Quoted 1 line
Quoted 1 line

I noticed your patches don't have shortlog entries so the subject lines in these emails are rather long.

Sent v2 version of patches for review with suggested corrections.

Regards,
Vinay

Quoted 32 lines · Richard Purdie
Quoted 10 lines · Vinay Kumar
---
 meta/conf/bitbake.conf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/conf/bitbake.conf +0 -0
index 3438be92b7..83e1b68071 100644

meta/conf/bitbake.conf HOSTTOOLS_DIR = "${TMPDIR}/hosttools" · line 489

Quoted 8 lines
meta/conf/bitbake.conf +1 -1
@@ -483,7 +483,7 @@ HOSTTOOLS_DIR = "${TMPDIR}/hosttools"
 HOSTTOOLS += " \
     [ ar as awk basename bash bzip2 cat chgrp chmod chown chrpath cmp comm cp cpio \
     cpp cut date dd diff diffstat dirname du echo egrep env expand expr false \
-    fgrep file find flock g++ gawk gcc getconf getopt git grep gunzip gzip \
+    fgrep file find flock g++ gawk gcc cc getconf getopt git grep gunzip gzip \
     head hostname iconv id install ld ldd ln ls make md5sum mkdir mkfifo mknod \
     mktemp mv nm objcopy objdump od patch perl pr printf pwd \
     python3 ranlib readelf readlink realpath rm rmdir rpcgen sed seq sh \

I definitely agree this should be fixed elsewhere to use BUILD_CC. We've managed without 'cc' for this long, we shouldn't need to start now!

Also, I noticed your patches don't have shortlog entries so the subject lines in these emails are rather long. We'd need to have that fixed to be able to handle the patches.

Cheers,

Richard

#89 lore raw

PATCH 6/8 We are passing "hostfwd=tcp::12345-:12345" while booting image when slirp is selected. Also, we are using mapped port of ssh :22 to copy remote-test-server to image. We have added a logic to extract the port number whenever multiple instaces of qemu are running (ex., 2222 gets incremented by 1 if its already in use by another qemu).

In reply to Vinay Kumar
---
 scripts/runqemu | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
scripts/runqemu +17 -1
index dd92a64553..c623f38838 100755
@@ -1055,7 +1055,8 @@ class BaseConfig(object):
         logger.info("Network configuration:%s", netconf)
         self.kernel_cmdline_script += netconf
         # Port mapping
-        hostfwd = ",hostfwd=tcp::2222-:22,hostfwd=tcp::2323-:23"
+        # port 12345 is for rust testing.
+        hostfwd = ",hostfwd=tcp::12345-:12345,hostfwd=tcp::2323-:22,hostfwd=tcp::2222-:22"
         qb_slirp_opt_default = "-netdev user,id=net0%s,tftp=%s" % (hostfwd, self.get('DEPLOY_DIR_IMAGE'))
         qb_slirp_opt = self.get('QB_SLIRP_OPT') or qb_slirp_opt_default
         # Figure out the port
@@ -1084,6 +1085,21 @@ class BaseConfig(object):
                         mac += 1
             if p != p_new:
                 ports.append(p_new)
+                temp=__file__.split(os.path.basename(__file__))[0]
+                # To get the mapped port of 22. We use this port number to copy remote-test-server to image. 
+                with open(temp+"../meta/recipes-devtools/rust/rust-test.inc", 'r+') as f:
+                    text = f.readlines()
+                    temp1=[]
+                    for i in text:
+                        temp = re.sub(r'(\S+\s)(-.)(\s\d+)( -o StrictHostKeyChecking=no .*)', r'\1\2 '+str(p_new)+'\\4', i)
+                        temp1.append(temp)
+                    temp2=''
+                    for i in temp1:
+                        temp2=temp2+i
+                    f.seek(0)
+                    f.write(temp2)
+                    f.truncate()
+
                 qb_slirp_opt = re.sub(':%s-' % p, ':%s-' % p_new, qb_slirp_opt)
                 logger.info("Port forward changed: %s -> %s" % (p, p_new))
         mac = "%s%02x" % (self.mac_slirp, mac)
Signature · 1 line
2.17.1
#90 lore raw

PATCH 7/8 These changes are to get the rust target triplet "mips64-unknown-linux-gnuabi64" for mips64.

In reply to Vinay Kumar
---
 meta/classes/rust-common.bbclass | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
meta/classes/rust-common.bbclass +5 -1
index ff7b9da8f3..87fa397c90 100644
@@ -82,9 +82,13 @@ def rust_base_triple(d, thing):
         os = "linux"
 
     # This catches ARM targets and appends the necessary hard float bits
+    # Also, this appends "abi64" in case of mips64 target. Since, rust mips64 target triplet is "mips64-unknown-linux-gnuabi64"
     if os == "linux-gnueabi" or os == "linux-musleabi":
         libc = bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', 'hf', '', d)
-    return arch + vendor + '-' + os + libc
+    if d.getVar('TARGET_ARCH') == 'mips64':
+       return arch + vendor + '-' + os + libc + 'abi64'
+    else:
+       return arch + vendor + '-' + os + libc
 
 # Naming explanation
 # Yocto
Signature · 1 line
2.17.1
#91 lore raw

PATCH 8/8 In case of testing for "x86_64".

In reply to Vinay Kumar

When the target and build section triplet are identical getting below error.
====================
error: failed to run custom build command for memchr v2.3.3

Also, in poky building for x86_64 using "RUST_TARGET_SYS" we were getting below error,
====================
Exception: configparser.DuplicateSectionError: Section 'target.x86_64-unknown-linux-gnu' already exists

So, we are using x86_64-poky-linux as rust target as below,
====================
python3 src/bootstrap/bootstrap.py test --no-fail-fast --bless --target "x86_64-poky-linux"

By default, the rust does not support target option "x86_64-poky-linux",
by setting the path of "x86_64-poky-linux.json" to RUST_TARGET_PATH the rustc consider this for build. The "x86_64-poky-linux.json" gets generated in "${STAGING_LIBDIR_NATIVE}/rustlib" so we changed "RUST_TARGET_PATH" accordingly in rust-test.inc as below

Here, in case of x86_64 target we are using "TARGET_SYS" if both "RUST_TARGET_SYS" and "SNAPSHOT_BUILD_SYS" are identical (x86_64-unknown-linux-gnu).

We were getting below warnings with x86_64 target and got fixed by "--bless" option.
====================
warning: Linking two modules of different data layouts: '' is 'e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128' whereas 'lto_unwind.7rcbfp3g-cgu.3' is 'e-m:e-i64:64-f80:128-n8:16:32:64-S128'

---
 meta/recipes-devtools/rust/rust-test.inc | 37 ++++++++++++++++++------
 1 file changed, 28 insertions(+), 9 deletions(-)
meta/recipes-devtools/rust/rust-test.inc +28 -9
index 3a9b5b367c..1b12591421 100644
@@ -10,8 +10,8 @@ DEPENDS += "file-native python3-native"
 DEPENDS_append_class-native = " rust-llvm-native"
 EXCLUDE_FROM_WORLD = "1"
 
-# We generate local targets, and need to be able to locate them
-export RUST_TARGET_PATH="${WORKDIR}/targets/"
+# In case of x86_64 target we setting this path to location of "x86_64-poky-linux.json".
+export RUST_TARGET_PATH="${STAGING_LIBDIR_NATIVE}/rustlib"
 
 export FORCE_CRATE_HASH="${BB_TASKHASH}"
 
@@ -410,8 +410,12 @@ python do_configure() {
 
     config = configparser.RawConfigParser()
 
-    # [target.ARCH-poky-linux]
-    target_section = "target.{}".format(d.getVar('RUST_TARGET_SYS', True))
+    # [target.ARCH-unknown-linux-gnu] in case of x86_64 [target.ARCH-poky-linux] 
+    if( d.getVar('RUST_TARGET_SYS', True) != d.getVar('SNAPSHOT_BUILD_SYS', True)):
+       target_section = "target.{}".format(d.getVar('RUST_TARGET_SYS', True))
+    else :
+       target_section = "target.{}".format(d.getVar('TARGET_SYS', True))
+
     config.add_section(target_section)
 
     # Points to wrapper files which contain target specific compiler and linker commands. 
@@ -456,8 +460,12 @@ python do_configure() {
 
     config.set("build", "vendor", e(True))
 
-    # Here we are adding "RUST_TARGET_SYS" instead of "TARGET_SYS" as we are using rust supported target.
-    targets = [d.getVar("RUST_TARGET_SYS", True)]
+    # Here we are using "RUST_TARGET_SYS" and incase of x86_64 "TARGET_SYS" as rust supported target.
+    if( d.getVar('RUST_TARGET_SYS', True) != d.getVar('SNAPSHOT_BUILD_SYS', True)):
+        targets = [d.getVar("RUST_TARGET_SYS", True)]
+    else:
+        targets = [d.getVar("TARGET_SYS", True)]
+
     config.set("build", "target", e(targets))
 
     hosts = [d.getVar("SNAPSHOT_BUILD_SYS", True)]
@@ -495,7 +503,13 @@ rust_runx[vardepsexclude] += "PARALLEL_MAKE"
 # We have to build target specific remote-test-server 
 # Reference link - https://rustc-dev-guide.rust-lang.org/tests/intro.html#running-tests-on-a-remote-machine
 do_compile () {
-    rust_runx build src/tools/remote-test-server --target "${RUST_TARGET_SYS}"
+    if [  "${SNAPSHOT_BUILD_SYS}" = "${RUST_TARGET_SYS}" ]
+    then
+       rust_runx build src/tools/remote-test-server --target "${TARGET_SYS}"
+    else
+       rust_runx build src/tools/remote-test-server --target "${RUST_TARGET_SYS}"
+    fi
+
 }
 
 # To test the rust
@@ -506,7 +520,12 @@ do_check () {
     scp -P 2222 -o StrictHostKeyChecking=no build/${SNAPSHOT_BUILD_SYS}/stage2-tools-bin/remote-test-server [email protected]:~/
     ssh -p 2222 -o StrictHostKeyChecking=no -f [email protected] "~/remote-test-server -v remote"
 
-    export TEST_DEVICE_ADDR="127.0.0.1:12345" 
-    rust_runx test --no-fail-fast --target "${RUST_TARGET_SYS}" > summary.txt 2> /dev/null
+    export TEST_DEVICE_ADDR="127.0.0.1:12345"
+    if [  "${SNAPSHOT_BUILD_SYS}" = "${RUST_TARGET_SYS}" ]
+    then
+       rust_runx test --no-fail-fast --bless --target "${TARGET_SYS}" > summary.txt 2> /dev/null
+    else
+       rust_runx test --no-fail-fast --target "${RUST_TARGET_SYS}" > summary.txt 2> /dev/null
+    fi
 }
 addtask do_check after do_compile
Signature · 1 line
2.17.1