@@ -71,3 +71,44 @@ using BinaryBuilderBase: download_verify, list_tarball_files
7171 end
7272 end
7373end
74+
75+ using BinaryBuilderBase: march_comparison_strategy
76+ using Base. BinaryPlatforms: Platform, platforms_match, set_compare_strategy!
77+ @testset " Microarchitecture augmentation" begin
78+ linux_x86_64 = Platform (" x86_64" , " linux" )
79+ linux_avx = Platform (" x86_64" , " linux" ; march= " avx" )
80+ linux_avx2 = Platform (" x86_64" , " linux" ; march= " avx2" )
81+ linux_avx512 = Platform (" x86_64" , " linux" ; march= " avx512" )
82+ # Platform with non-existing microarchitecture
83+ linux_bad = Platform (" x86_64" , " linux" ; march= " bad" )
84+
85+ # Without any custom comparison strategy, the base platform without march matches
86+ # everything, but the others are all incompatible
87+ @test platforms_match (linux_x86_64, linux_avx)
88+ @test platforms_match (linux_x86_64, linux_avx2)
89+ @test platforms_match (linux_x86_64, linux_avx512)
90+ @test platforms_match (linux_x86_64, linux_bad)
91+ @test ! platforms_match (linux_avx, linux_avx2)
92+ @test ! platforms_match (linux_avx, linux_avx512)
93+ @test ! platforms_match (linux_avx, linux_bad)
94+ @test ! platforms_match (linux_avx2, linux_bad)
95+ @test ! platforms_match (linux_avx2, linux_avx512)
96+ @test ! platforms_match (linux_avx512, linux_bad)
97+
98+ # Teach AVX2 platform how to compare the others
99+ set_compare_strategy! (linux_avx2, " march" , march_comparison_strategy)
100+ for compatible_p in (linux_x86_64, linux_avx)
101+ @test platforms_match (compatible_p, linux_avx2)
102+ @test platforms_match (linux_avx2, compatible_p)
103+ end
104+ for incompatible_p in (linux_avx512, linux_bad)
105+ @test ! platforms_match (incompatible_p, linux_avx2)
106+ @test ! platforms_match (linux_avx2, incompatible_p)
107+ end
108+
109+ # Teach also AVX platform how to compare
110+ set_compare_strategy! (linux_avx, " march" , march_comparison_strategy)
111+ # Now when we compare AVX and AVX2, they must be equal
112+ @test ! platforms_match (linux_avx, linux_avx2)
113+ @test ! platforms_match (linux_avx2, linux_avx)
114+ end
0 commit comments