24b2ef0c67
Currently the tests TestRust and TestRustBin do check for vendoring by
requiring package ripgrep to be built but only if the download
directory is already empty, otherwise the existing contents of the download
directory will be reused and therefore not be redownloaded.
This new test will only verify that the required packages are downloaded
and vendored correctly without doing a runtime test. It does so by setting a
path to a folder "dl" inside the build directory (output-directory/testname/)
and then setting the environment variable BR2_DL_DIR to this path before the
build starts. BR2_DL_DIR is not set in the config options because it would be
overridden by the user's own environment variable if defined. This code was
essentially copied from the file test_gitforge.py which was added in commit
1ca6ab6ace
We want the package ripgrep to be built since it requires vendoring
directly. Additionally we want the package python-cryptography to be
built because it has rust dependencies and therefore indirectly also requires
vendoring.
Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>
Signed-off-by: Antoine Coutant <antoine.coutant@smile.fr>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
99 lines
2.6 KiB
Python
99 lines
2.6 KiB
Python
import os
|
|
import shutil
|
|
|
|
import infra.basetest
|
|
|
|
|
|
class TestRustBase(infra.basetest.BRTest):
|
|
|
|
def login(self):
|
|
img = os.path.join(self.builddir, "images", "rootfs.cpio")
|
|
self.emulator.boot(arch="armv7",
|
|
kernel="builtin",
|
|
options=["-initrd", img])
|
|
self.emulator.login()
|
|
|
|
|
|
class TestRustBin(TestRustBase):
|
|
config = \
|
|
"""
|
|
BR2_arm=y
|
|
BR2_cortex_a9=y
|
|
BR2_ARM_ENABLE_NEON=y
|
|
BR2_ARM_ENABLE_VFP=y
|
|
BR2_TOOLCHAIN_EXTERNAL=y
|
|
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
|
|
BR2_SYSTEM_DHCP="eth0"
|
|
BR2_TARGET_ROOTFS_CPIO=y
|
|
# BR2_TARGET_ROOTFS_TAR is not set
|
|
BR2_PACKAGE_HOST_RUSTC=y
|
|
BR2_PACKAGE_RIPGREP=y
|
|
"""
|
|
|
|
def test_run(self):
|
|
self.login()
|
|
self.assertRunOk("rg Buildroot /etc/issue")
|
|
|
|
|
|
class TestRust(TestRustBase):
|
|
config = \
|
|
"""
|
|
BR2_arm=y
|
|
BR2_cortex_a9=y
|
|
BR2_ARM_ENABLE_NEON=y
|
|
BR2_ARM_ENABLE_VFP=y
|
|
BR2_TOOLCHAIN_EXTERNAL=y
|
|
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
|
|
BR2_SYSTEM_DHCP="eth0"
|
|
BR2_TARGET_ROOTFS_CPIO=y
|
|
# BR2_TARGET_ROOTFS_TAR is not set
|
|
BR2_PACKAGE_HOST_RUSTC=y
|
|
BR2_PACKAGE_HOST_RUST=y
|
|
BR2_PACKAGE_RIPGREP=y
|
|
"""
|
|
|
|
def test_run(self):
|
|
self.login()
|
|
self.assertRunOk("rg Buildroot /etc/issue")
|
|
|
|
|
|
class TestRustVendoring(infra.basetest.BRConfigTest):
|
|
config = \
|
|
"""
|
|
BR2_arm=y
|
|
BR2_cortex_a9=y
|
|
BR2_ARM_ENABLE_NEON=y
|
|
BR2_ARM_ENABLE_VFP=y
|
|
BR2_TOOLCHAIN_EXTERNAL=y
|
|
# BR2_TARGET_ROOTFS_TAR is not set
|
|
BR2_PACKAGE_HOST_RUSTC=y
|
|
BR2_PACKAGE_RIPGREP=y
|
|
BR2_PACKAGE_PYTHON3=y
|
|
BR2_PACKAGE_PYTHON_CRYPTOGRAPHY=y
|
|
BR2_BACKUP_SITE=""
|
|
"""
|
|
|
|
def setUp(self):
|
|
super(TestRustVendoring, self).setUp()
|
|
|
|
def tearDown(self):
|
|
self.show_msg("Cleaning up")
|
|
if self.b and not self.keepbuilds:
|
|
self.b.delete()
|
|
|
|
def check_download(self, package):
|
|
# store downloaded tarball inside the output dir so the test infra
|
|
# cleans it up at the end
|
|
dl_dir = os.path.join(self.builddir, "dl")
|
|
# enforce we test the download
|
|
if os.path.exists(dl_dir):
|
|
shutil.rmtree(dl_dir)
|
|
env = {"BR2_DL_DIR": dl_dir}
|
|
self.b.build(["{}-dirclean".format(package),
|
|
"{}-legal-info".format(package)],
|
|
env)
|
|
|
|
def test_run(self):
|
|
self.check_download("ripgrep")
|
|
self.check_download("python-cryptography")
|