1
1
using Test
2
2
using BinaryBuilderBase
3
3
using BinaryBuilderBase: platform_dlext, platform_exeext
4
+ using Pkg
4
5
5
6
@testset " Wrappers utilities" begin
6
7
@test nbits (Platform (" i686" , " linux" )) == 32
@@ -105,13 +106,13 @@ end
105
106
end
106
107
end
107
108
108
- # This tests that compilers for all Intel Linux platforms can build a simple
109
- # C program that we can also run
109
+ # This tests that compilers for all Intel Linux platforms can build simple
110
+ # C, C++, Fortran programs that we can also run
110
111
@testset " Compilation and running" begin
111
- mktempdir () do dir
112
- platforms = filter (p -> Sys. islinux (p) && proc_family (p) == " intel" , supported_platforms ())
112
+ platforms = filter (p -> Sys. islinux (p) && proc_family (p) == " intel" , supported_platforms ())
113
113
114
- @testset " C - $(platform) " for platform in platforms
114
+ @testset " C - $(platform) " for platform in platforms
115
+ mktempdir () do dir
115
116
ur = preferred_runner ()(dir; platform= platform)
116
117
iobuff = IOBuffer ()
117
118
test_c = """
@@ -127,10 +128,66 @@ end
127
128
# Test that we get the output we expect
128
129
@test endswith (readchomp (iobuff), " Hello World!" )
129
130
end
131
+ end
132
+
133
+ @testset " C++ - $(platform) " for platform in platforms
134
+ mktempdir () do dir
135
+ # Use an old GCC with libgfortran3
136
+ options = (preferred_gcc_version= v " 4" , compilers= [:c ])
137
+ shards = choose_shards (platform; options... )
138
+ concrete_platform = get_concrete_platform (platform, shards)
139
+ prefix = setup_workspace (
140
+ dir,
141
+ [],
142
+ concrete_platform,
143
+ default_host_platform;
144
+ )
145
+ # Install `CompilerSupportLibraries_jll` v0.5.0 in the `${prefix}` to make
146
+ # sure it doesn't break compilation of the program for i686-linux-gnu, see
147
+ # https://github.com/JuliaPackaging/BinaryBuilderBase.jl/issues/163
148
+ artifact_paths =
149
+ setup_dependencies (prefix,
150
+ [PackageSpec (; name= " CompilerSupportLibraries_jll" , version= " 0.5.0" )],
151
+ concrete_platform, verbose= false )
152
+ ur = preferred_runner ()(prefix. path;
153
+ platform= concrete_platform,
154
+ shards = shards,
155
+ options... )
156
+ iobuff = IOBuffer ()
157
+ test_cpp = """
158
+ #include <iostream>
159
+ class breakCCompiler; // Courtesy of Meson
160
+ int main() {
161
+ std::cout << "Hello World!" << std::endl;
162
+ return 0;
163
+ }
164
+ """
165
+ test_script = """
166
+ set -e
167
+ echo '$(test_cpp) ' > test.cpp
168
+ # Make sure we can compile successfully also when `\$ {libdir}` is in the
169
+ # linker search path
170
+ g++ -o test test.cpp -L\$ {libdir}
171
+ ./test
172
+ """
173
+ cmd = ` /bin/bash -c "$(test_script) "`
174
+ if arch (platform) == " i686" && libc (platform) == " musl"
175
+ # We can't run C++ programs for this platform
176
+ @test_broken run (ur, cmd, iobuff; tee_stream= devnull )
177
+ else
178
+ @test run (ur, cmd, iobuff; tee_stream= devnull )
179
+ seekstart (iobuff)
180
+ # Test that we get the output we expect
181
+ @test endswith (readchomp (iobuff), " Hello World!" )
182
+ end
183
+ cleanup_dependencies (prefix, artifact_paths, concrete_platform)
184
+ end
185
+ end
130
186
131
- # This tests that compilers for all Intel Linux platforms can build a simple
132
- # Fortran program that we can also run
133
- @testset " Fortran - $(platform) " for platform in filter (p -> Sys. islinux (p) && proc_family (p) == " intel" , supported_platforms ())
187
+ # This tests that compilers for all Intel Linux platforms can build a simple
188
+ # Fortran program that we can also run
189
+ @testset " Fortran - $(platform) " for platform in platforms
190
+ mktempdir () do dir
134
191
ur = preferred_runner ()(dir; platform= platform)
135
192
iobuff = IOBuffer ()
136
193
test_f = """
140
197
"""
141
198
cmd = ` /bin/bash -c "echo '$(test_f) ' > test.f && gfortran -o test test.f && ./test"`
142
199
if arch (platform) == " i686" && libc (platform) == " musl"
200
+ # We can't run Fortran programs for this platform
143
201
@test_broken run (ur, cmd, iobuff; tee_stream= devnull )
144
202
else
145
203
@test run (ur, cmd, iobuff; tee_stream= devnull )
0 commit comments