1import os 2import shutil 3 4import infra.basetest 5 6 7class TestRustBase(infra.basetest.BRTest): 8 9 def login(self): 10 img = os.path.join(self.builddir, "images", "rootfs.cpio") 11 self.emulator.boot(arch="armv7", 12 kernel="builtin", 13 options=["-initrd", img]) 14 self.emulator.login() 15 16 17class TestRustBin(TestRustBase): 18 config = \ 19 """ 20 BR2_arm=y 21 BR2_cortex_a9=y 22 BR2_ARM_ENABLE_NEON=y 23 BR2_ARM_ENABLE_VFP=y 24 BR2_TOOLCHAIN_EXTERNAL=y 25 BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0" 26 BR2_SYSTEM_DHCP="eth0" 27 BR2_TARGET_ROOTFS_CPIO=y 28 # BR2_TARGET_ROOTFS_TAR is not set 29 BR2_PACKAGE_HOST_RUSTC=y 30 BR2_PACKAGE_RIPGREP=y 31 """ 32 33 def test_run(self): 34 self.login() 35 self.assertRunOk("rg Buildroot /etc/issue") 36 37 38class TestRust(TestRustBase): 39 config = \ 40 """ 41 BR2_arm=y 42 BR2_cortex_a9=y 43 BR2_ARM_ENABLE_NEON=y 44 BR2_ARM_ENABLE_VFP=y 45 BR2_TOOLCHAIN_EXTERNAL=y 46 BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0" 47 BR2_SYSTEM_DHCP="eth0" 48 BR2_TARGET_ROOTFS_CPIO=y 49 # BR2_TARGET_ROOTFS_TAR is not set 50 BR2_PACKAGE_HOST_RUSTC=y 51 BR2_PACKAGE_HOST_RUST=y 52 BR2_PACKAGE_RIPGREP=y 53 """ 54 55 def test_run(self): 56 self.login() 57 self.assertRunOk("rg Buildroot /etc/issue") 58 59 60class TestRustVendoring(infra.basetest.BRConfigTest): 61 config = \ 62 """ 63 BR2_arm=y 64 BR2_cortex_a9=y 65 BR2_ARM_ENABLE_NEON=y 66 BR2_ARM_ENABLE_VFP=y 67 BR2_TOOLCHAIN_EXTERNAL=y 68 # BR2_TARGET_ROOTFS_TAR is not set 69 BR2_PACKAGE_HOST_RUSTC=y 70 BR2_PACKAGE_RIPGREP=y 71 BR2_PACKAGE_PYTHON3=y 72 BR2_PACKAGE_PYTHON_CRYPTOGRAPHY=y 73 BR2_BACKUP_SITE="" 74 """ 75 76 def setUp(self): 77 super(TestRustVendoring, self).setUp() 78 79 def tearDown(self): 80 self.show_msg("Cleaning up") 81 if self.b and not self.keepbuilds: 82 self.b.delete() 83 84 def check_download(self, package): 85 # store downloaded tarball inside the output dir so the test infra 86 # cleans it up at the end 87 dl_dir = os.path.join(self.builddir, "dl") 88 # enforce we test the download 89 if os.path.exists(dl_dir): 90 shutil.rmtree(dl_dir) 91 env = {"BR2_DL_DIR": dl_dir} 92 self.b.build(["{}-dirclean".format(package), 93 "{}-legal-info".format(package)], 94 env) 95 96 def test_run(self): 97 self.check_download("ripgrep") 98 self.check_download("python-cryptography") 99