Rust oe-selftest script
PATCH 1/4 Rust oe-selftest script
The file builds remote-test-server and executes rust testing remotely using background ssh. It adds the necessary test environment and variables to run the rust oe-selftest.
Print the results in case of failure of runCmd().
--- meta/lib/oeqa/selftest/cases/rust.py | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 meta/lib/oeqa/selftest/cases/rust.py
meta/lib/oeqa/selftest/cases/rust.py new file +54 -0
@@ -0,0 +1,54 @@ +# 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", qemuparams = "-m 512") as qemu: +# 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/stage1-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.31.1
PATCH 2/4 Rust cross testing file
The file is main entry point for rust oe-selftest. It configures, compiles and runs the test suite framework.
It implements the above using the following functions: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.tomldo_compile(): To build "remote-test-server" for qemutarget image.
--- meta/recipes-devtools/rust/rust-testsuite.inc | 157 ++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 meta/recipes-devtools/rust/rust-testsuite.inc
meta/recipes-devtools/rust/rust-testsuite.inc new file +157 -0
@@ -0,0 +1,157 @@ +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" + +S = "${RUSTSRC}" +# 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 +} + +include rust-common.inc +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.31.1
PATCH 3/4 Rust oe-selftest file
In reply to [email protected]Add file for rust oe-selftest
--- meta/recipes-devtools/rust/rust-testsuite_1.54.0.bb | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 meta/recipes-devtools/rust/rust-testsuite_1.54.0.bb
meta/recipes-devtools/rust/rust-testsuite_1.54.0.bb new file +3 -0
@@ -0,0 +1,3 @@ +require rust-testsuite.inc +require rust-source-${PV}.inc +require rust-snapshot-${PV}.inc
Signature · 1 line
2.31.1
PATCH 4/4 Modify target cpu for powerpc to "7400"
In reply to [email protected]During rust testing, some ui test failed due to following message. 'powerpc' is not a recognized processor for this target in rust
Hence the target cpu was renamed to "7400" in "llvm_cpu" as per default tune for qemuppc.
--- meta/recipes-devtools/rust/rust-common.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/rust/rust-common.inc +1 -1
@@ -265,7 +265,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.31.1
Re: [OE-core] [PATCH 4/4] Modify target cpu for powerpc to "7400"
Quoted 17 lines · Pgowda
During rust testing, some ui test failed due to following message. 'powerpc' is not a recognized processor for this target in rust
Hence the target cpu was renamed to "7400" in "
llvm_cpu" as per default tune for qemuppc.Signed-off-by Pgowda <[email protected]>--- meta/recipes-devtools/rust/rust-common.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)meta/recipes-devtools/rust/rust-common.inc +0
-0
meta/recipes-devtools/rust/rust-common.inc def llvm_cpu(d): · line 268
Quoted 5 lines
meta/recipes-devtools/rust/rust-common.inc +1
-1@@ -265,7 +265,7 @@ def llvm_cpu(d): trans['x86-64'] = "x86-64" trans['i686'] = "i686" trans['i586'] = "i586" - trans['powerpc'] = "powerpc" + trans['powerpc'] = "7400"
interesting. what happens if you use 'ppc'
Quoted 9 lines
meta/recipes-devtools/rust/rust-common.inc +0
-1trans['mips64'] = "mips64" trans['mips64el'] = "mips64" trans['riscv64'] = "generic-rv64" --2.31.1
Quoted 11 lines · Pgowda
The file builds remote-test-server and executes rust testing remotely using background ssh. It adds the necessary test environment and variables to run the rust oe-selftest.
Print the results in case of failure of
runCmd().Signed-off-by Pgowda <[email protected]>--- meta/lib/oeqa/selftest/cases/rust.py | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 meta/lib/oeqa/selftest/cases/rust.py
Thanks for this series, it would be great to have these new test cases.
We did see a couple of failures in testing on our infrastructure:
https://autobuilder.yoctoproject.org/typhoon/#/builders/59/builds/3970/steps/19/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/73/builds/3967/steps/20/logs/stdio
I also needed to add a maintainers entry:
Cheers,
Richard
Hi Richard,
Thanks for reviewing the patch and your comments.
Quoted 1 line
We did see a couple of failures in testing on our infrastructure:
We are using the following machine for running tests
Description: Ubuntu 18.04.3 LTS Release: 18.04
Quoted 2 lines
https://autobuilder.yoctoproject.org/typhoon/#/builders/59/builds/3970/steps/19/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/73/builds/3967/steps/20/logs/stdio
We did not see the following error while running X86_64 target
"/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found
Can you please let us know whether this is the failure you mentioned.
Please find attached the log files "rust-testsuite-logs.tar.bz2" for all 6 targets.
We observed some test failures in the logs but there were no build failures.
Quoted 1 line
I also needed to add a maintainers entry:
Thanks very much for adding the maintainers entry.
Regards,
pgowda
Quoted 9 lines · pgowda cve
Hi Richard,
Thanks for reviewing the patch and your comments.
Quoted 1 line
We did see a couple of failures in testing on our infrastructure:
We are using the following machine for running tests
Description: Ubuntu 18.04.3 LTS Release: 18.04
Quoted 6 lines
Quoted 2 lines
https://autobuilder.yoctoproject.org/typhoon/#/builders/59/builds/3970/steps/19/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/73/builds/3967/steps/20/logs/stdioWe did not see the following error while running
X86_64target
"/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found
Can you please let us know whether this is the failure you mentioned.
Yes, that would seem to be what is failing the build in the first case. In the other it is slightly different:
/home/pokybuild/yocto-worker/qemux86/build/build-st-41976/tmp/work/core2-32-poky-linux/rust-testsuite/1.54.0-r0/rustc-1.54.0-src/build/x86_64-unknown-linux-gnu/test/run-make/issue-36710/issue-36710/foo: /lib32/libc.so.6: version `GLIBC_2.33' not found (required by /home/pokybuild/yocto-worker/qemux86/build/build-st-41976/tmp/work/core2-32-poky-linux/rust-testsuite/1.54.0-r0/rustc-1.54.0-src/build/x86_64-unknown-linux-gnu/test/run-make/issue-36710/issue-36710/foo) /home/pokybuild/yocto-worker/qemux86/build/build-st-41976/tmp/work/core2-32-poky-linux/rust-testsuite/1.54.0-r0/rustc-1.54.0-src/build/x86_64-unknown-linux-gnu/test/run-make/issue-36710/issue-36710/foo: /lib32/libc.so.6: version `GLIBC_2.32' not found (required by /home/pokybuild/yocto-worker/qemux86/build/build-st-41976/tmp/work/core2-32-poky-linux/rust-testsuite/1.54.0-r0/rustc-1.54.0-src/build/x86_64-unknown-linux-gnu/test/run-make/issue-36710/issue-36710/foo) /home/pokybuild/yocto-worker/qemux86/build/build-st-41976/tmp/work/core2-32-poky-linux/rust-testsuite/1.54.0-r0/rustc-1.54.0-src/build/x86_64-unknown-linux-gnu/test/run-make/issue-36710/issue-36710/foo: /lib32/libc.so.6: version `GLIBC_2.34' not found (required by /home/pokybuild/yocto-worker/qemux86/build/build-st-41976/tmp/work/core2-32-poky-linux/rust-testsuite/1.54.0-r0/rustc-1.54.0-src/build/x86_64-unknown-linux-gnu/test/run-make/issue-36710/issue-36710/foo)
make: *** [Makefile:14: all] Error 1
I'd note that one is from a debian10 system with no buildtools, the other is from a ubuntu 1604 system which does have a buildtools tarball installed. I suspect it is related to the version of lib on the host verses the version used in the target.
Perhaps try running the build within a buildtools environment to reproduce?
Quoted 4 lines
Please find attached the log files "rust-testsuite-logs.tar.bz2" for all 6 targets.
We observed some test failures in the logs but there were no build failures.
Unfortunately we can't merge this until all the tests pass reliably on our infrastructure.
Quoted 2 lines
Quoted 1 line
I also needed to add a maintainers entry:
Thanks very much for adding the maintainers entry.
Cheers,
Richard
Hi Richard,
Quoted 2 lines
I suspect it is related to the version of lib on the host verses the version used in the target.
That seems to be the problem.
Quoted 1 line
Perhaps try running the build within a buildtools environment to reproduce?
We could reproduce the issue within the buildtools environment.
Please find attached the modified "rust-testsuite.inc" file that fixes the issue and runs as expected on buildtools environment.
Please review the patch and let us know if any further changes are needed.
Thanks,
pgowda