@@ -210,6 +210,70 @@ TEST(ToolchainVerifyTestGroup, VerifyToolchain_Msvc) {
210210STRCMP_EQUAL (compiler_info.target_arch .c_str ()," host_arch_tgt_arch" );
211211}
212212
213+ TEST (ToolchainVerifyTestGroup, VerifyToolchain_Custom_VerificationSuccess) {
214+ buildcc::Toolchain::AddVerificationFunc (
215+ buildcc::ToolchainId::Custom,
216+ [](const buildcc::ToolchainExecutables &executables)
217+ -> std::optional<buildcc::ToolchainCompilerInfo> {
218+ (void )executables;
219+ buildcc::ToolchainCompilerInfo compiler_info;
220+ compiler_info.compiler_version =" custom_compiler_version" ;
221+ compiler_info.target_arch =" custom_target_arch" ;
222+ return compiler_info;
223+ },
224+ " success_verification_func" );
225+ buildcc::Toolchaincustom (buildcc::ToolchainId::Custom," custom" ," assembler" ,
226+ " c_compiler" ," cpp_compiler" ," archiver" ," linker" );
227+ buildcc::ToolchainVerifyConfig config;
228+ config.env_vars .clear ();
229+ config.absolute_search_paths .insert (
230+ (fs::current_path () /" toolchains" /" custom" ));
231+ config.verification_identifier =" success_verification_func" ;
232+ auto compiler_info = custom.Verify (config);
233+ STRCMP_EQUAL (compiler_info.compiler_version .c_str (),
234+ " custom_compiler_version" );
235+ STRCMP_EQUAL (compiler_info.target_arch .c_str ()," custom_target_arch" );
236+ }
237+
238+ TEST (ToolchainVerifyTestGroup, VerifyToolchain_Custom_VerificationFailure) {
239+ buildcc::Toolchain::AddVerificationFunc (
240+ buildcc::ToolchainId::Custom,
241+ [](const buildcc::ToolchainExecutables &executables)
242+ -> std::optional<buildcc::ToolchainCompilerInfo> {
243+ (void )executables;
244+ return {};
245+ },
246+ " failure_verification_func" );
247+
248+ // Adding verification function with the same identifier throws an exception
249+ CHECK_THROWS (std::exception,
250+ (buildcc::Toolchain::AddVerificationFunc (
251+ buildcc::ToolchainId::Custom,
252+ [](const buildcc::ToolchainExecutables &executables)
253+ -> std::optional<buildcc::ToolchainCompilerInfo> {
254+ (void )executables;
255+ return {};
256+ },
257+ " failure_verification_func" )));
258+ buildcc::Toolchaincustom (buildcc::ToolchainId::Custom," custom" ," assembler" ,
259+ " c_compiler" ," cpp_compiler" ," archiver" ," linker" );
260+
261+ buildcc::ToolchainVerifyConfig config;
262+ config.env_vars .clear ();
263+ config.absolute_search_paths .insert (
264+ (fs::current_path () /" toolchains" /" custom" ));
265+ // Fails since ToolchainId::Custom expects a verification_identifier
266+ CHECK_THROWS (std::exception, custom.Verify (config));
267+
268+ // Fails since we do not get valid ToolchainCompilerInfo
269+ config.verification_identifier =" failure_verification_func" ;
270+ CHECK_THROWS (std::exception, custom.Verify (config));
271+
272+ // Fails since we have not registered a verification function with this id
273+ config.verification_identifier =" unregistered_verification_func" ;
274+ CHECK_THROWS (std::exception, custom.Verify (config));
275+ }
276+
213277TEST (ToolchainVerifyTestGroup,
214278 VerifyToolchain_Msvc_CompilerVersionAndTargetArchFailure) {
215279 buildcc::Toolchainmsvc (buildcc::ToolchainId::Msvc," msvc" ," cl" ," cl" ," cl" ,