From 48d163af1f10db093408bbe91b05beff4338ec02 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Fri, 12 Jan 2024 09:26:28 -0800 Subject: [PATCH] Remove two tests from test_logging_apis.cc (#19100) ### Description In some environments the test code has undefined behavior. To prove it, save the following code as test.cpp ```c++ #include #include int main(){ char buf[1024]; int ret = snprintf(buf, sizeof(buf), "%ls","abc"); if(ret <0){ std::cout<< ret<< std::endl; } else{ std::cout<< "OK: ret="< --- .../test/logging_apis/test_logging_apis.cc | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/onnxruntime/test/logging_apis/test_logging_apis.cc b/onnxruntime/test/logging_apis/test_logging_apis.cc index 0bf3b65bc755a..d72c47493d800 100644 --- a/onnxruntime/test/logging_apis/test_logging_apis.cc +++ b/onnxruntime/test/logging_apis/test_logging_apis.cc @@ -269,23 +269,6 @@ TEST_F(RealCAPITestsFixture, CppApiORTCXXLOGF) { line_num = __LINE__ + 1; ORT_CXX_LOGF_NOEXCEPT(cpp_ort_logger, OrtLoggingLevel::ORT_LOGGING_LEVEL_INFO, "Ignored %d", line_num); - - // - // Test errors due to formatting error. - // - - // Catch expected exception from ORT_CXX_LOGF macro. - try { - line_num = __LINE__ + 1; - ORT_CXX_LOGF(cpp_ort_logger, OrtLoggingLevel::ORT_LOGGING_LEVEL_ERROR, "%ls", "abc"); - FAIL(); - } catch (const Ort::Exception& excpt) { - ASSERT_THAT(excpt.what(), testing::HasSubstr("Failed to log message due to formatting error")); - } - - // The formatting error is ignored with the ORT_CXX_LOGF_NOEXCEPT macro - line_num = __LINE__ + 1; - ORT_CXX_LOGF_NOEXCEPT(cpp_ort_logger, OrtLoggingLevel::ORT_LOGGING_LEVEL_ERROR, "%ls", "abc"); } TEST_F(MockCAPITestsFixture, CppLogMacroBypassCApiCall) {