]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - support/testing/tests/toolchain/test_external.py
ad2f56a20ed7b670a911cfd45a94e124318e9429
[coffee/buildroot.git] / support / testing / tests / toolchain / test_external.py
1 import os
2 import infra
3
4 BASIC_CONFIG = \
5     """
6     BR2_TARGET_ROOTFS_CPIO=y
7     # BR2_TARGET_ROOTFS_TAR is not set
8     """
9
10 def has_broken_links(path):
11     for root, dirs, files in os.walk(path):
12         for f in files:
13             fpath = os.path.join(root, f)
14             if not os.path.exists(fpath):
15                 return True
16     return False
17
18 class TestExternalToolchain(infra.basetest.BRTest):
19     def common_check(self):
20         # Check for broken symlinks
21         for d in ["lib", "usr/lib"]:
22             path = os.path.join(self.builddir, "staging", d)
23             self.assertFalse(has_broken_links(path))
24             path = os.path.join(self.builddir, "target", d)
25             self.assertFalse(has_broken_links(path))
26
27         interp = infra.get_elf_prog_interpreter(self.builddir,
28                                                 self.toolchain_prefix,
29                                                 "bin/busybox")
30         interp_path = os.path.join(self.builddir, "target", interp[1:])
31         self.assertTrue(os.path.exists(interp_path))
32
33 class TestExternalToolchainSourceryArmv4(TestExternalToolchain):
34     config = BASIC_CONFIG + \
35         """
36         BR2_arm=y
37         BR2_arm920t=y
38         BR2_TOOLCHAIN_EXTERNAL=y
39         BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM=y
40         """
41     toolchain_prefix = "arm-none-linux-gnueabi"
42
43     def test_run(self):
44         TestExternalToolchain.common_check(self)
45
46         # Check the architecture variant
47         arch = infra.get_file_arch(self.builddir,
48                                    self.toolchain_prefix,
49                                    "lib/libc.so.6")
50         self.assertEqual(arch, "v4T")
51
52         # Check the sysroot symlink
53         symlink = os.path.join(self.builddir, "staging", "armv4t")
54         self.assertTrue(os.path.exists(symlink))
55         self.assertEqual(os.readlink(symlink), "./")
56
57         # Boot the system
58         img = os.path.join(self.builddir, "images", "rootfs.cpio")
59         self.emulator.boot(arch="armv5",
60                            kernel="builtin",
61                            options=["-initrd", img])
62         self.emulator.login()
63
64 class TestExternalToolchainSourceryArmv5(TestExternalToolchain):
65     config = BASIC_CONFIG + \
66         """
67         BR2_arm=y
68         BR2_TOOLCHAIN_EXTERNAL=y
69         BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM=y
70         """
71     toolchain_prefix = "arm-none-linux-gnueabi"
72
73     def test_run(self):
74         TestExternalToolchain.common_check(self)
75
76         # Check the architecture variant
77         arch = infra.get_file_arch(self.builddir,
78                                    self.toolchain_prefix,
79                                    "lib/libc.so.6")
80         self.assertEqual(arch, "v5TE")
81
82         # Boot the system
83         img = os.path.join(self.builddir, "images", "rootfs.cpio")
84         self.emulator.boot(arch="armv5",
85                            kernel="builtin",
86                            options=["-initrd", img])
87         self.emulator.login()
88
89 class TestExternalToolchainSourceryArmv7(TestExternalToolchain):
90     config = BASIC_CONFIG + \
91         """
92         BR2_arm=y
93         BR2_cortex_a8=y
94         BR2_ARM_EABI=y
95         BR2_ARM_INSTRUCTIONS_THUMB2=y
96         BR2_TOOLCHAIN_EXTERNAL=y
97         BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM=y
98         """
99     toolchain_prefix = "arm-none-linux-gnueabi"
100
101     def test_run(self):
102         TestExternalToolchain.common_check(self)
103
104         # Check the architecture variant
105         arch = infra.get_file_arch(self.builddir,
106                                    self.toolchain_prefix,
107                                    "lib/libc.so.6")
108         self.assertEqual(arch, "v7")
109         isa = infra.get_elf_arch_tag(self.builddir,
110                                      self.toolchain_prefix,
111                                      "lib/libc.so.6",
112                                      "Tag_THUMB_ISA_use")
113         self.assertEqual(isa, "Thumb-2")
114
115         # Check we have the sysroot symlink
116         symlink = os.path.join(self.builddir, "staging", "thumb2")
117         self.assertTrue(os.path.exists(symlink))
118         self.assertEqual(os.readlink(symlink), "./")
119
120         # Boot the system
121         img = os.path.join(self.builddir, "images", "rootfs.cpio")
122         self.emulator.boot(arch="armv7",
123                            kernel="builtin",
124                            options=["-initrd", img])
125         self.emulator.login()
126
127 class TestExternalToolchainLinaroArm(TestExternalToolchain):
128     config = BASIC_CONFIG + \
129         """
130         BR2_arm=y
131         BR2_cortex_a8=y
132         BR2_TOOLCHAIN_EXTERNAL=y
133         BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM=y
134         """
135     toolchain_prefix = "arm-linux-gnueabihf"
136
137     def test_run(self):
138         TestExternalToolchain.common_check(self)
139
140         # Check the architecture variant
141         arch = infra.get_file_arch(self.builddir,
142                                    self.toolchain_prefix,
143                                    "lib/libc.so.6")
144         self.assertEqual(arch, "v7")
145         isa = infra.get_elf_arch_tag(self.builddir,
146                                      self.toolchain_prefix,
147                                      "lib/libc.so.6",
148                                      "Tag_THUMB_ISA_use")
149         self.assertEqual(isa, "Thumb-2")
150
151         # Boot the system
152         img = os.path.join(self.builddir, "images", "rootfs.cpio")
153         self.emulator.boot(arch="armv7",
154                            kernel="builtin",
155                            options=["-initrd", img])
156         self.emulator.login()
157
158 class TestExternalToolchainBuildrootMusl(TestExternalToolchain):
159     config = BASIC_CONFIG + \
160         """
161         BR2_arm=y
162         BR2_cortex_a9=y
163         BR2_ARM_ENABLE_VFP=y
164         BR2_TOOLCHAIN_EXTERNAL=y
165         BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
166         BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
167         BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-cortex-a9-musl-2017.05-444-g6c704ba.tar.bz2"
168         BR2_TOOLCHAIN_EXTERNAL_GCC_6=y
169         BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_11=y
170         BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL=y
171         BR2_TOOLCHAIN_EXTERNAL_CXX=y
172         """
173     toolchain_prefix = "arm-linux"
174
175     def test_run(self):
176         TestExternalToolchain.common_check(self)
177         img = os.path.join(self.builddir, "images", "rootfs.cpio")
178         self.emulator.boot(arch="armv7",
179                            kernel="builtin",
180                            options=["-initrd", img])
181         self.emulator.login()
182
183 class TestExternalToolchainCtngMusl(TestExternalToolchain):
184     config = BASIC_CONFIG + \
185         """
186         BR2_arm=y
187         BR2_cortex_a9=y
188         BR2_ARM_ENABLE_VFP=y
189         BR2_TOOLCHAIN_EXTERNAL=y
190         BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
191         BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
192         BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.net/toolchains/tarballs/arm-ctng-linux-musleabihf.tar.xz"
193         BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="arm-ctng-linux-musleabihf"
194         BR2_TOOLCHAIN_EXTERNAL_GCC_7=y
195         BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10=y
196         BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL=y
197         BR2_TOOLCHAIN_EXTERNAL_CXX=y
198         """
199     toolchain_prefix = "arm-ctng-linux-musleabihf"
200
201     def test_run(self):
202         TestExternalToolchain.common_check(self)
203         img = os.path.join(self.builddir, "images", "rootfs.cpio")
204         self.emulator.boot(arch="armv7",
205                            kernel="builtin",
206                            options=["-initrd", img])
207         self.emulator.login()
208
209 class TestExternalToolchainBuildrootuClibc(TestExternalToolchain):
210     config = BASIC_CONFIG + \
211         """
212         BR2_arm=y
213         BR2_TOOLCHAIN_EXTERNAL=y
214         BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
215         BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
216         BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2017.05-444-g6c704ba.tar.bz2"
217         BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=y
218         BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10=y
219         BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
220         # BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
221         BR2_TOOLCHAIN_EXTERNAL_CXX=y
222         """
223     toolchain_prefix = "arm-linux"
224
225     def test_run(self):
226         TestExternalToolchain.common_check(self)
227         img = os.path.join(self.builddir, "images", "rootfs.cpio")
228         self.emulator.boot(arch="armv7",
229                            kernel="builtin",
230                            options=["-initrd", img])
231         self.emulator.login()
232
233 class TestExternalToolchainCCache(TestExternalToolchainBuildrootuClibc):
234     extraconfig = \
235         """
236         BR2_CCACHE=y
237         BR2_CCACHE_DIR="{builddir}/ccache-dir"
238         """
239
240     def __init__(self, names):
241         super(TestExternalToolchainBuildrootuClibc, self).__init__(names)
242         self.config += self.extraconfig.format(builddir=self.builddir)