Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test warnings and delayload linking #2843

Merged
merged 1 commit into from
Jan 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed because of line 89, which sets delay loaded 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 @@ -64,7 +64,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; }
Copy link
Contributor Author

@tiagoshibata tiagoshibata Jan 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried if constexpr which would ensure the unused code doesn't get compiled, but VS still shows a warning (looks like a bug: https://developercommunity.visualstudio.com/content/problem/421660/warning-c4702-is-overzealous-with-if-constexpr-gua.html)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it required to fix C4702 warnings ?

Copy link
Contributor Author

@tiagoshibata tiagoshibata Jan 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because the code after GPUTEST is unreachable if building without DML


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