Skip to content

Commit

Permalink
Fix test warnings and delayload linking (#2843)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoshibata authored Jan 16, 2020
1 parent 408e600 commit 45c5835
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
6 changes: 3 additions & 3 deletions cmake/winml.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -442,15 +442,15 @@ endif(onnxruntime_USE_DML)

# The default libraries to link with in Windows are kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib
# Remove them and use the onecore umbrella library instead
set(CMAKE_C_STANDARD_LIBRARIES "onecoreuap_apiset.lib")
set(CMAKE_CXX_STANDARD_LIBRARIES "onecoreuap_apiset.lib")
foreach(default_lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdgl32.lib advapi32.lib)
set(removed_libs "${removed_libs} /NODEFAULTLIB:${default_lib}")
endforeach()
set(CMAKE_C_STANDARD_LIBRARIES "${removed_libs} onecoreuap.lib")
set(CMAKE_CXX_STANDARD_LIBRARIES "${removed_libs} onecoreuap.lib")
set_target_properties(winml_dll
PROPERTIES
LINK_FLAGS
"/DEF:${WINML_DIR}/windows.ai.machinelearning.def ${os_component_link_flags} /DELAYLOAD:d3d12.dll /DELAYLOAD:d3d11.dll /DELAYLOAD:dxgi.dll ${delayload_dml} ${removed_libs}")
"/DEF:${WINML_DIR}/windows.ai.machinelearning.def ${os_component_link_flags} /DELAYLOAD:d3d12.dll /DELAYLOAD:d3d11.dll /DELAYLOAD:dxgi.dll ${delayload_dml}")


set_target_properties(winml_dll
Expand Down
4 changes: 2 additions & 2 deletions cmake/winml_unittests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function(add_winml_test)
if (_UT_DEPENDS)
add_dependencies(${_UT_TARGET} ${_UT_DEPENDS})
endif()
target_link_libraries(${_UT_TARGET} PRIVATE ${_UT_LIBS} gtest windowsapp winml_lib_image ${onnxruntime_EXTERNAL_LIBRARIES} winml_lib_telemetry winml_lib_api onnxruntime)
target_link_libraries(${_UT_TARGET} PRIVATE ${_UT_LIBS} gtest winml_lib_image ${onnxruntime_EXTERNAL_LIBRARIES} winml_lib_telemetry winml_lib_api onnxruntime)

add_test(NAME ${_UT_TARGET}
COMMAND ${_UT_TARGET}
Expand Down Expand Up @@ -81,7 +81,7 @@ endif()
add_winml_test(
TARGET winml_test_scenario
SOURCES ${winml_test_scenario_src}
LIBS winml_test_common ${winml_test_scenario_libs}
LIBS winml_test_common delayimp.lib ${winml_test_scenario_libs}
)
target_precompiled_header(winml_test_scenario testPch.h)
target_compile_definitions(winml_test_scenario PRIVATE BUILD_GOOGLE_TEST)
Expand Down
2 changes: 1 addition & 1 deletion winml/test/api/LearningModelSessionAPITest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,4 +417,4 @@ const LearningModelSesssionAPITestApi& getapi() {
CloseSession,
};
return api;
}
}
2 changes: 1 addition & 1 deletion winml/test/common/googleTestMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

#ifndef USE_DML
#define GPUTEST \
WINML_SKIP_TEST("GPU tests disabled because this is a WinML only build (no DML)")
WINML_SUPRESS_UNREACHABLE_BELOW(WINML_SKIP_TEST("GPU tests disabled because this is a WinML only build (no DML)"))
#else
#define GPUTEST \
if (auto noGpuTests = RuntimeParameters::Parameters.find("noGPUtests"); \
Expand Down
14 changes: 8 additions & 6 deletions winml/test/common/taefTestMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ using namespace WEX::TestExecution;
getapi().test_name(); \
}

#define WINML_SKIP_TEST(message) \
Log::Result(TestResults::Skipped, \
std::wstring_convert<std::codecvt_utf8<wchar_t>>().from_bytes(message).c_str()); \
return;
#define WINML_SKIP_TEST(message) \
do { \
Log::Result(TestResults::Skipped, \
std::wstring_convert<std::codecvt_utf8<wchar_t>>().from_bytes(message).c_str()); \
return; \
} while (0)

#define WINML_EXPECT_NO_THROW(statement) VERIFY_NO_THROW(statement)
#define WINML_EXPECT_TRUE(statement) VERIFY_IS_TRUE(statement)
Expand All @@ -43,7 +45,7 @@ using namespace WEX::TestExecution;

#ifndef USE_DML
#define GPUTEST \
WINML_SKIP_TEST("GPU tests disabled because this is a WinML only build (no DML)")
WINML_SUPRESS_UNREACHABLE_BELOW(WINML_SKIP_TEST("GPU tests disabled because this is a WinML only build (no DML)"))
#else
#define GPUTEST \
bool noGPUTests; \
Expand All @@ -58,4 +60,4 @@ using namespace WEX::TestExecution;
if (SUCCEEDED(RuntimeParameters::TryGetValue(L"EdgeCore", edgeCoreRun)) && edgeCoreRun) { \
WINML_SKIP_TEST("This test is disabled by the EdgeCore runtime parameter."); \
return; \
}
}
10 changes: 9 additions & 1 deletion winml/test/common/test.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#pragma once

using VoidTest = void (*)();
using SetupTest = VoidTest;

constexpr bool alwaysTrue() {
return true;
}
#define WINML_SUPRESS_UNREACHABLE_BELOW(statement) \
if (alwaysTrue()) { statement; }

#ifdef BUILD_GOOGLE_TEST
#include "googleTestMacros.h"
#else
#ifdef BUILD_TAEF_TEST
#include "taefTestMacros.h"
#endif
#endif
#endif

0 comments on commit 45c5835

Please sign in to comment.