test_external.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. import os
  2. import infra
  3. BASIC_CONFIG = \
  4. """
  5. BR2_TARGET_ROOTFS_CPIO=y
  6. # BR2_TARGET_ROOTFS_TAR is not set
  7. """
  8. def has_broken_links(path):
  9. for root, dirs, files in os.walk(path):
  10. for f in files:
  11. fpath = os.path.join(root, f)
  12. if not os.path.exists(fpath):
  13. return True
  14. return False
  15. class TestExternalToolchain(infra.basetest.BRTest):
  16. def common_check(self):
  17. # Check for broken symlinks
  18. for d in ["lib", "usr/lib"]:
  19. path = os.path.join(self.builddir, "staging", d)
  20. self.assertFalse(has_broken_links(path))
  21. path = os.path.join(self.builddir, "target", d)
  22. self.assertFalse(has_broken_links(path))
  23. with open(os.path.join(self.builddir, ".config"), 'r') as configf:
  24. configlines = [line.strip() for line in configf.readlines()]
  25. if "BR2_BINFMT_ELF=y" in configlines:
  26. interp = infra.get_elf_prog_interpreter(self.builddir,
  27. self.toolchain_prefix,
  28. "bin/busybox")
  29. interp_path = os.path.join(self.builddir, "target", interp[1:])
  30. self.assertTrue(os.path.exists(interp_path))
  31. class TestExternalToolchainLinaroArm(TestExternalToolchain):
  32. config = BASIC_CONFIG + \
  33. """
  34. BR2_arm=y
  35. BR2_cortex_a8=y
  36. BR2_TOOLCHAIN_EXTERNAL=y
  37. BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM=y
  38. """
  39. toolchain_prefix = "arm-linux-gnueabihf"
  40. def test_run(self):
  41. TestExternalToolchain.common_check(self)
  42. # Check the architecture variant
  43. arch = infra.get_file_arch(self.builddir,
  44. self.toolchain_prefix,
  45. "lib/libc.so.6")
  46. self.assertEqual(arch, "v7")
  47. isa = infra.get_elf_arch_tag(self.builddir,
  48. self.toolchain_prefix,
  49. "lib/libc.so.6",
  50. "Tag_THUMB_ISA_use")
  51. self.assertEqual(isa, "Thumb-2")
  52. # Boot the system
  53. img = os.path.join(self.builddir, "images", "rootfs.cpio")
  54. self.emulator.boot(arch="armv7",
  55. kernel="builtin",
  56. options=["-initrd", img])
  57. self.emulator.login()
  58. class TestExternalToolchainBuildrootMusl(TestExternalToolchain):
  59. config = BASIC_CONFIG + \
  60. """
  61. BR2_arm=y
  62. BR2_cortex_a9=y
  63. BR2_ARM_ENABLE_VFP=y
  64. BR2_TOOLCHAIN_EXTERNAL=y
  65. BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
  66. BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
  67. BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-cortex-a9-musl-2017.05-1078-g95b1dae.tar.bz2"
  68. BR2_TOOLCHAIN_EXTERNAL_GCC_6=y
  69. BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_12=y
  70. BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL=y
  71. BR2_TOOLCHAIN_EXTERNAL_CXX=y
  72. """
  73. toolchain_prefix = "arm-linux"
  74. def test_run(self):
  75. TestExternalToolchain.common_check(self)
  76. img = os.path.join(self.builddir, "images", "rootfs.cpio")
  77. self.emulator.boot(arch="armv7",
  78. kernel="builtin",
  79. options=["-initrd", img])
  80. self.emulator.login()
  81. class TestExternalToolchainCtngMusl(TestExternalToolchain):
  82. config = BASIC_CONFIG + \
  83. """
  84. BR2_arm=y
  85. BR2_cortex_a9=y
  86. BR2_ARM_ENABLE_VFP=y
  87. BR2_TOOLCHAIN_EXTERNAL=y
  88. BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
  89. BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
  90. BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.net/toolchains/tarballs/arm-ctng-linux-musleabihf.tar.xz"
  91. BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="arm-ctng-linux-musleabihf"
  92. BR2_TOOLCHAIN_EXTERNAL_GCC_7=y
  93. BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10=y
  94. BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL=y
  95. BR2_TOOLCHAIN_EXTERNAL_CXX=y
  96. """
  97. toolchain_prefix = "arm-ctng-linux-musleabihf"
  98. def test_run(self):
  99. TestExternalToolchain.common_check(self)
  100. img = os.path.join(self.builddir, "images", "rootfs.cpio")
  101. self.emulator.boot(arch="armv7",
  102. kernel="builtin",
  103. options=["-initrd", img])
  104. self.emulator.login()
  105. class TestExternalToolchainBuildrootuClibc(TestExternalToolchain):
  106. config = BASIC_CONFIG + \
  107. """
  108. BR2_arm=y
  109. BR2_TOOLCHAIN_EXTERNAL=y
  110. BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
  111. BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
  112. BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2017.05-1078-g95b1dae.tar.bz2"
  113. BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=y
  114. BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10=y
  115. BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
  116. # BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
  117. BR2_TOOLCHAIN_EXTERNAL_CXX=y
  118. """
  119. toolchain_prefix = "arm-linux"
  120. def test_run(self):
  121. TestExternalToolchain.common_check(self)
  122. img = os.path.join(self.builddir, "images", "rootfs.cpio")
  123. self.emulator.boot(arch="armv7",
  124. kernel="builtin",
  125. options=["-initrd", img])
  126. self.emulator.login()
  127. class TestExternalToolchainCCache(TestExternalToolchainBuildrootuClibc):
  128. extraconfig = \
  129. """
  130. BR2_CCACHE=y
  131. BR2_CCACHE_DIR="{builddir}/ccache-dir"
  132. """
  133. def __init__(self, names):
  134. super(TestExternalToolchainBuildrootuClibc, self).__init__(names)
  135. self.config += self.extraconfig.format(builddir=self.builddir)