test_rust.py 2.6 KB

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