Add Windows 7 tests and update ifdefs/etc. to match (#120)
This commit is contained in:
Родитель
af093723ca
Коммит
212ecbf230
|
@ -122,6 +122,7 @@ namespace wil
|
|||
}
|
||||
#endif // WIL_ENABLE_EXCEPTIONS
|
||||
|
||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
|
||||
// Returns tokenHandle or the effective thread token if tokenHandle is null.
|
||||
// Note, this returns an token handle who's lifetime is managed independently
|
||||
// and it may be a pseudo token, don't free it!
|
||||
|
@ -287,6 +288,7 @@ namespace wil
|
|||
return tokenInfo;
|
||||
}
|
||||
#endif
|
||||
#endif // _WIN32_WINNT >= _WIN32_WINNT_WIN8
|
||||
|
||||
/// @cond
|
||||
namespace details
|
||||
|
@ -524,6 +526,7 @@ namespace wil
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
|
||||
/** Determine whether a token represents an app container
|
||||
This method uses the passed in token and emits a boolean indicating that
|
||||
whether TokenIsAppContainer is true.
|
||||
|
@ -573,6 +576,7 @@ namespace wil
|
|||
return value;
|
||||
}
|
||||
#endif // WIL_ENABLE_EXCEPTIONS
|
||||
#endif // _WIN32_WINNT >= _WIN32_WINNT_WIN8
|
||||
|
||||
template<typename... Ts> bool test_token_membership_failfast(_In_opt_ HANDLE token,
|
||||
const SID_IDENTIFIER_AUTHORITY& sidAuthority, Ts&&... subAuthorities)
|
||||
|
|
|
@ -56,6 +56,8 @@ call :execute_test noexcept witest.noexcept.exe
|
|||
if %ERRORLEVEL% NEQ 0 ( popd && goto :eof )
|
||||
call :execute_test normal witest.exe
|
||||
if %ERRORLEVEL% NEQ 0 ( popd && goto :eof )
|
||||
call :execute_test win7 witest.win7.exe
|
||||
if %ERRORLEVEL% NEQ 0 ( popd && goto :eof )
|
||||
popd
|
||||
|
||||
goto :eof
|
||||
|
|
|
@ -17,3 +17,4 @@ add_subdirectory(app)
|
|||
add_subdirectory(cpplatest)
|
||||
add_subdirectory(noexcept)
|
||||
add_subdirectory(normal)
|
||||
add_subdirectory(win7)
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
|
||||
#include <wil/com.h>
|
||||
#include <wil/result.h>
|
||||
|
||||
#if (NTDDI_VERSION >= NTDDI_WIN8)
|
||||
#include <wil/result_originate.h>
|
||||
#endif
|
||||
|
||||
#include <roerrorapi.h>
|
||||
|
||||
|
@ -479,7 +482,7 @@ TEST_CASE("ResultTests::ErrorMacros", "[result]")
|
|||
}
|
||||
|
||||
// The originate helper isn't compatible with CX so don't test it in that mode.
|
||||
#ifndef __cplusplus_winrt
|
||||
#if !defined(__cplusplus_winrt) && (NTDDI_VERSION >= NTDDI_WIN8)
|
||||
TEST_CASE("ResultTests::NoOriginationByDefault", "[result]")
|
||||
{
|
||||
::wil::SetOriginateErrorCallback(nullptr);
|
||||
|
@ -572,4 +575,4 @@ TEST_CASE("ResultTests::AutomaticOriginationOnFailure", "[result]")
|
|||
}();
|
||||
REQUIRE(S_FALSE == GetRestrictedErrorInfo(&restrictedErrorInformation));
|
||||
}
|
||||
#endif // __cplusplus_winrt
|
||||
#endif
|
||||
|
|
|
@ -38,6 +38,7 @@ TEST_CASE("TokenHelpersTests::VerifyOpenCurrentAccessToken", "[token_helpers]")
|
|||
}
|
||||
#endif
|
||||
|
||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
|
||||
TEST_CASE("TokenHelpersTests::VerifyGetTokenInformationNoThrow", "[token_helpers]")
|
||||
{
|
||||
SECTION("Passing a null token")
|
||||
|
@ -92,6 +93,7 @@ TEST_CASE("TokenHelpersTests::VerifyLinkedToken", "[token_helpers]")
|
|||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
bool IsImpersonating()
|
||||
{
|
||||
|
@ -186,6 +188,7 @@ TEST_CASE("TokenHelpersTests::VerifyResetThreadToken", "[token_helpers]")
|
|||
}
|
||||
#endif // WIL_ENABLE_EXCEPTIONS
|
||||
|
||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
|
||||
template <typename T, wistd::enable_if_t<!wil::details::MapTokenStructToInfoClass<T>::FixedSize>* = nullptr>
|
||||
void TestGetTokenInfoForCurrentThread()
|
||||
{
|
||||
|
@ -251,6 +254,7 @@ TEST_CASE("TokenHelpersTests::VerifyGetTokenInformationSecurityImpersonationLeve
|
|||
|
||||
RevertToSelf();
|
||||
}
|
||||
#endif
|
||||
|
||||
bool operator==(const SID_IDENTIFIER_AUTHORITY& left, const SID_IDENTIFIER_AUTHORITY& right)
|
||||
{
|
||||
|
@ -274,6 +278,7 @@ TEST_CASE("TokenHelpersTests::StaticSid", "[token_helpers]")
|
|||
REQUIRE(*GetSidSubAuthority(staticSid.get(), 1) == DOMAIN_ALIAS_RID_GUESTS);
|
||||
}
|
||||
|
||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
|
||||
TEST_CASE("TokenHelpersTests::TestMembership", "[token_helpers]")
|
||||
{
|
||||
bool member;
|
||||
|
@ -318,3 +323,4 @@ TEST_CASE("TokenHelpersTests::Verify_impersonate_token", "[token_helpers]")
|
|||
REQUIRE_NOTHROW(wil::get_token_information<TOKEN_TYPE>());
|
||||
}
|
||||
#endif // WIL_ENABLE_EXCEPTIONS
|
||||
#endif
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
#include <wil/resource.h>
|
||||
#include <wil/win32_helpers.h>
|
||||
#include <wil/filesystem.h>
|
||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
|
||||
#include <wil/wrl.h>
|
||||
#endif
|
||||
#include <wil/com.h>
|
||||
|
||||
#ifdef WIL_ENABLE_EXCEPTIONS
|
||||
|
@ -1015,9 +1017,13 @@ TEST_CASE("WindowsInternalTests::UniqueHandle", "[resource][unique_any]")
|
|||
wchar_t tempFileName[MAX_PATH];
|
||||
REQUIRE_SUCCEEDED(witest::GetTempFileName(tempFileName));
|
||||
|
||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
|
||||
CREATEFILE2_EXTENDED_PARAMETERS params = { sizeof(params) };
|
||||
params.dwFileAttributes = FILE_ATTRIBUTE_TEMPORARY;
|
||||
wil::unique_hfile spValidHandle(::CreateFile2(tempFileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_DELETE, CREATE_ALWAYS, ¶ms));
|
||||
#else
|
||||
wil::unique_hfile spValidHandle(::CreateFileW(tempFileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_DELETE, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, nullptr));
|
||||
#endif
|
||||
|
||||
::DeleteFileW(tempFileName);
|
||||
REQUIRE(spValidHandle.get() != INVALID_HANDLE_VALUE);
|
||||
|
@ -1072,9 +1078,13 @@ TEST_CASE("WindowsInternalTests::UniqueHandle", "[resource][unique_any]")
|
|||
wchar_t tempFileName2[MAX_PATH];
|
||||
REQUIRE_SUCCEEDED(witest::GetTempFileName(tempFileName2));
|
||||
|
||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
|
||||
CREATEFILE2_EXTENDED_PARAMETERS params2 = { sizeof(params2) };
|
||||
params2.dwFileAttributes = FILE_ATTRIBUTE_TEMPORARY;
|
||||
*(&spMoveHandle) = ::CreateFile2(tempFileName2, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_DELETE, CREATE_ALWAYS, ¶ms2);
|
||||
#else
|
||||
*(&spMoveHandle) = ::CreateFileW(tempFileName2, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_DELETE, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, nullptr);
|
||||
#endif
|
||||
|
||||
::DeleteFileW(tempFileName2);
|
||||
REQUIRE(spMoveHandle);
|
||||
|
@ -2931,7 +2941,7 @@ TEST_CASE("WindowsInternalTests::TestUniqueArrayCases", "[resource]")
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus_winrt
|
||||
#if !defined(__cplusplus_winrt) && (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
|
||||
TEST_CASE("WindowsInternalTests::VerifyMakeAgileCallback", "[wrl]")
|
||||
{
|
||||
using namespace ABI::Windows::Foundation;
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
project(witest.win7)
|
||||
add_executable(witest.win7)
|
||||
|
||||
add_definitions("-D_WIN32_WINNT=0x0601")
|
||||
|
||||
target_sources(witest.win7 PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../main.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../CommonTests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../ComTests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../FileSystemTests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../ResourceTests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../ResultTests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../Rpc.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../SafeCastTests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../StlTests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../TokenHelpersTests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../WatcherTests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../WistdTests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../wiTest.cpp
|
||||
)
|
Загрузка…
Ссылка в новой задаче