-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Kernel mode test harness #1421
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
Closed
Closed
Kernel mode test harness #1421
Changes from all commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
7515060
Update LLVM reference
CaseyCarter 46f7b77
Merge branch 'master' of https://github.com/microsoft/STL into HEAD
cbezault d4ff68b
Avoid relying on upstream libcxx lit.cfg
cbezault f62ad74
Skip bogus failing tests
CaseyCarter 7a859cd
Apply suggestions from code review
CaseyCarter 777d49b
Update LLVM reference to latest
cbezault 5d3ee9a
Update atomic_init per P0883R3
CaseyCarter e46a162
Update LLVM reference once again
CaseyCarter 40b5aac
Fix mis-formatted line in expected_results.txt
CaseyCarter 16c00b2
Fix bad separators in libcxx/expected_results
CaseyCarter c72c9fd
Let's rewrite the test harness
cbezault 0a379b4
Fix merge conflicts
cbezault 8b3708f
Get past file validation
cbezault 352715d
That's what I get for not testing x86
cbezault 9bb228a
Undo unwanted changes to submodules fixup tests which embed /c flag
cbezault 428a2fc
resolve merge conflict
cbezault 0b5cdaf
Resolves GH-1382
cbezault 1843c30
Merge branch 'master' of https://github.com/Microsoft/STL
cbezault 1d3cc67
cleanup the new custom format
cbezault d6eab20
Fix broken custom format
cbezault f5d374c
Respect tests getting marked as unsupported
cbezault c332008
Fix .fail tests
cbezault d0cb477
STL_EDG_DROP at least does something now + other cleanups
cbezault 9f400b0
Make handling the intellisense response file its own step type
cbezault dd9a2a2
Make all compile-only tests compile only
cbezault 331017e
Actually find tests with new suffix
cbezault 74660fd
Update format.py
cbezault 5116e2c
Merge with master
cbezault 82e8f41
Merge branch 'master' of github.com:cbezault/STL
cbezault be7e4a4
Fix a bug that STL found
cbezault bad25da
Rebasing kernel harness on new test infrastructure
2fab494
Code review feedback.
StephanTLavavej 73e08c6
Fix issue with expected results file. Integrate @ben-craig's suggestions
cbezault b91bb8b
It might be deprecated but pickling a tuple is faster than pickling a…
cbezault bf2381a
Resolve merge conflict
cbezault 28f6864
clang format and some other small cleanups
cbezault 54fa098
Update tests/utils/stl/test/format.py
cbezault 0a7194c
Update tests/utils/stl/test/tests.py
cbezault 25d73d5
Change `/analyze` to `/analyze:autolog-`.
StephanTLavavej 691674b
Merge branch 'master' of github.com:cbezault/STL into kernel
cbezault 2443db6
Light up kernel tests in CI
cbezault 32377ab
clang-format
cbezault f0c62c3
Make validate happy
cbezault 19b9294
Merge branch 'master' of https://github.com/Microsoft/STL
cbezault 6887ca0
Get new test format to work with sharding
cbezault 4d34a2d
Merge with origin changes
cbezault 4e51118
Update tests/utils/stl/test/format.py
cbezault ac12e3c
Update tests/utils/stl/test/tests.py
cbezault 7417354
We don't need to set this internal variable
cbezault 227efe0
Update tests/utils/stl/test/tests.py
cbezault 3725d6d
Update tests/utils/stl/test/tests.py
cbezault ad8a003
first kernel test
721cb3f
Point to the WDK
cbezault f7591e3
Merge master
cbezault 51acb66
Fix line endings
cbezault 5032e50
Merge pull request #10 from ben-craig/envlst2
cbezault 4640507
clang-format
cbezault 33319b4
Suppress 5040 in the WDK
cbezault dc58334
Make everything more verbose (maybe)
cbezault e910d81
Add a linking pragma
cbezault 4f3b0fa
Handle calling convention differences
f041be3
Update tests.py
cbezault 593f49a
Merge pull request #11 from ben-craig/kernel3
cbezault 6f78416
clang-format
cbezault db798ef
Always compile kernel tests, but only run on amd64
3886633
Update format.py
cbezault bd9f7e4
Merge pull request #12 from ben-craig/kernel4
cbezault ba553ad
Update format.py
cbezault e31ce62
Merge branch 'main' into kernel
StephanTLavavej 99e3d46
Define CMAKE_CXX_FLAGS and STL_IS_KERNEL on separate lines.
StephanTLavavej aca1692
Merge branch 'main' into local_kernel
ben-craig f44db64
STL review comments
ben-craig 1454c77
Merge branch 'master' into kernel5
cbezault 054d7fc
Merge pull request #13 from ben-craig/kernel5
cbezault File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2489,6 +2489,49 @@ namespace ranges { | |
| }; | ||
|
|
||
| inline constexpr _Drop_fn drop; | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like some ranges changes snuck in by accident? |
||
| // VARIABLE views::counted | ||
| class _Counted_fn { | ||
| private: | ||
| enum class _St { _Span, _Subrange, _Subrange_counted }; | ||
|
|
||
| template <class _It> | ||
| _NODISCARD static _CONSTEVAL _Choice_t<_St> _Choose() noexcept { | ||
| _STL_INTERNAL_STATIC_ASSERT(input_or_output_iterator<_It>); | ||
| if constexpr (contiguous_iterator<_It>) { | ||
| return {_St::_Span, noexcept(span{_STD to_address(_STD declval<_It>()), iter_difference_t<_It>{}})}; | ||
| } else if constexpr (random_access_iterator<_It>) { | ||
| return {_St::_Subrange, | ||
| noexcept(subrange{_STD declval<_It>(), _STD declval<_It>() + iter_difference_t<_It>{}})}; | ||
| } else { | ||
| return {_St::_Subrange_counted, | ||
| noexcept(subrange{ | ||
| counted_iterator{_STD declval<_It>(), iter_difference_t<_It>{}}, default_sentinel})}; | ||
| } | ||
| } | ||
|
|
||
| template <class _It> | ||
| static constexpr _Choice_t<_St> _Choice = _Choose<_It>(); | ||
|
|
||
| public: | ||
| // clang-format off | ||
| template <class _It> | ||
| requires input_or_output_iterator<decay_t<_It>> | ||
| _NODISCARD constexpr auto operator()(_It&& _First, const iter_difference_t<decay_t<_It>> _Count) const | ||
| noexcept(_Choice<decay_t<_It>>._No_throw) { | ||
| // clang-format on | ||
| _STL_ASSERT(_Count >= 0, "The size passed to views::counted must be non-negative"); | ||
| if constexpr (_Choice<decay_t<_It>>._Strategy == _St::_Span) { | ||
| return span{_STD to_address(_STD forward<_It>(_First)), static_cast<size_t>(_Count)}; | ||
| } else if constexpr (_Choice<decay_t<_It>>._Strategy == _St::_Subrange) { | ||
| return subrange{_First, _First + _Count}; | ||
| } else if constexpr (_Choice<decay_t<_It>>._Strategy == _St::_Subrange_counted) { | ||
| return subrange{counted_iterator{_STD forward<_It>(_First), _Count}, default_sentinel}; | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| inline constexpr _Counted_fn counted; | ||
| } // namespace views | ||
|
|
||
| // CLASS TEMPLATE ranges::drop_while_view | ||
|
|
@@ -4088,6 +4131,116 @@ namespace ranges { | |
| inline constexpr auto keys = elements<0>; | ||
| inline constexpr auto values = elements<1>; | ||
| } // namespace views | ||
|
|
||
| // CLASS TEMPLATE ranges::common_view | ||
| // clang-format off | ||
| template <view _Vw> | ||
| requires (!common_range<_Vw> && copyable<iterator_t<_Vw>>) | ||
| class common_view : public view_interface<common_view<_Vw>> { | ||
| // clang-format on | ||
| private: | ||
| /* [[no_unique_address]] */ _Vw _Base{}; | ||
|
|
||
| public: | ||
| common_view() = default; | ||
| constexpr explicit common_view(_Vw _Base_) noexcept(is_nothrow_move_constructible_v<_Vw>) // strengthened | ||
| : _Base(_STD move(_Base_)) {} | ||
| // converting constructor template omitted per LWG-3405 | ||
|
|
||
| _NODISCARD constexpr _Vw base() const& noexcept( | ||
| is_nothrow_copy_constructible_v<_Vw>) /* strengthened */ requires copy_constructible<_Vw> { | ||
| return _Base; | ||
| } | ||
| _NODISCARD constexpr _Vw base() && noexcept(is_nothrow_move_constructible_v<_Vw>) /* strengthened */ { | ||
| return _STD move(_Base); | ||
| } | ||
|
|
||
| _NODISCARD constexpr auto begin() noexcept( | ||
| noexcept(_RANGES begin(_Base)) && is_nothrow_move_constructible_v<iterator_t<_Vw>>) /* strengthened */ { | ||
| if constexpr (random_access_range<_Vw> && sized_range<_Vw>) { | ||
| return _RANGES begin(_Base); | ||
| } else { | ||
| return common_iterator<iterator_t<_Vw>, sentinel_t<_Vw>>{_RANGES begin(_Base)}; | ||
| } | ||
| } | ||
|
|
||
| _NODISCARD constexpr auto begin() const noexcept( | ||
| noexcept(_RANGES begin(_Base)) | ||
| && is_nothrow_move_constructible_v<iterator_t<const _Vw>>) /* strengthened */ requires range<const _Vw> { | ||
| if constexpr (random_access_range<const _Vw> && sized_range<const _Vw>) { | ||
| return _RANGES begin(_Base); | ||
| } else { | ||
| return common_iterator<iterator_t<const _Vw>, sentinel_t<const _Vw>>{_RANGES begin(_Base)}; | ||
| } | ||
| } | ||
|
|
||
| _NODISCARD constexpr auto end() { | ||
| if constexpr (random_access_range<_Vw> && sized_range<_Vw>) { | ||
| return _RANGES begin(_Base) + _RANGES size(_Base); | ||
| } else { | ||
| return common_iterator<iterator_t<_Vw>, sentinel_t<_Vw>>{_RANGES end(_Base)}; | ||
| } | ||
| } | ||
|
|
||
| _NODISCARD constexpr auto end() const requires range<const _Vw> { | ||
| if constexpr (random_access_range<const _Vw> && sized_range<const _Vw>) { | ||
| return _RANGES begin(_Base) + _RANGES size(_Base); | ||
| } else { | ||
| return common_iterator<iterator_t<const _Vw>, sentinel_t<const _Vw>>{_RANGES end(_Base)}; | ||
| } | ||
| } | ||
|
|
||
| _NODISCARD constexpr auto size() noexcept( | ||
| noexcept(_RANGES size(_Base))) /* strengthened */ requires sized_range<_Vw> { | ||
| return _RANGES size(_Base); | ||
| } | ||
| _NODISCARD constexpr auto size() const | ||
| noexcept(noexcept(_RANGES size(_Base))) /* strengthened */ requires sized_range<const _Vw> { | ||
| return _RANGES size(_Base); | ||
| } | ||
| }; | ||
|
|
||
| template <class _Rng> | ||
| common_view(_Rng &&) -> common_view<views::all_t<_Rng>>; | ||
|
|
||
| namespace views { | ||
| // VARIABLE views::common | ||
| class _Common_fn : public _Pipe::_Base<_Common_fn> { | ||
| private: | ||
| enum class _St { _None, _All, _Common }; | ||
|
|
||
| template <class _Rng> | ||
| _NODISCARD static _CONSTEVAL _Choice_t<_St> _Choose() noexcept { | ||
| if constexpr (common_range<_Rng>) { | ||
| return {_St::_All, noexcept(views::all(_STD declval<_Rng>()))}; | ||
| } else if constexpr (copyable<iterator_t<_Rng>>) { | ||
| return {_St::_Common, noexcept(common_view{_STD declval<_Rng>()})}; | ||
| } else { | ||
| return {_St::_None}; | ||
| } | ||
| } | ||
|
|
||
| template <class _Rng> | ||
| static constexpr _Choice_t<_St> _Choice = _Choose<_Rng>(); | ||
|
|
||
| public: | ||
| // clang-format off | ||
| template <viewable_range _Rng> | ||
| requires (_Choice<_Rng>._Strategy != _St::_None) | ||
| _NODISCARD constexpr auto operator()(_Rng&& _Range) const noexcept(_Choice<_Rng>._No_throw) { | ||
| // clang-format on | ||
| if constexpr (_Choice<_Rng>._Strategy == _St::_All) { | ||
| return views::all(_STD forward<_Rng>(_Range)); | ||
| } else if constexpr (_Choice<_Rng>._Strategy == _St::_Common) { | ||
| return common_view{_STD forward<_Rng>(_Range)}; | ||
| } else { | ||
| static_assert(_Always_false<_Rng>, "Should be unreachable"); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| inline constexpr _Common_fn common; | ||
| } // namespace views | ||
| } // namespace ranges | ||
|
|
||
| namespace views = ranges::views; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| PM_CL="/kernel /Zc:preprocessor /std:c++latest /w14640 /Zc:threadSafeInit- /DNO_TEST_ENVIRONMENT_PREPARER" PM_LINK="/IGNORE:4210 /subsystem:native /nodefaultlib stl_kernel.lib BufferOverflowFastFailK.lib ntoskrnl.lib hal.lib wmilib.lib Ntstrsafe.lib libcpmt.lib libcmt.lib" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| set(STL_KERNEL_LOADER_SOURCES | ||
| ${CMAKE_CURRENT_LIST_DIR}/src/stl_kernel_loader/testapp.cpp | ||
| ${CMAKE_CURRENT_LIST_DIR}/src/stl_kernel_loader/install.cpp | ||
| ) | ||
|
|
||
| set(STL_KERNEL_SOURCES | ||
| ${CMAKE_CURRENT_LIST_DIR}/src/stl_kernel/doAssert.cpp | ||
| ${CMAKE_CURRENT_LIST_DIR}/src/stl_kernel/stl_kernel.cpp | ||
| ) | ||
|
|
||
| add_library(stl_kernel STATIC ${STL_KERNEL_SOURCES}) | ||
| set_target_properties(stl_kernel PROPERTIES LINKER_LANGUAGE CXX) | ||
| target_compile_definitions(stl_kernel PRIVATE "__STL_IS_KERNEL") | ||
|
|
||
| # ${WDK_INCLUDE_DIRECTORY}/km/crt isn't in the files under test include paths. | ||
| # doAssert.cpp wants to use RtlStringCbPrintfExA, and that requires pulling in | ||
| # km/crt. If we don't pull in km/crt here, we erroneously pull in user mode | ||
| # crt headers, and that gets us linker errors dealing with missing user mode | ||
| # symbols in this kernel mode binary. | ||
| target_include_directories(stl_kernel PRIVATE | ||
| ${CMAKE_CURRENT_LIST_DIR}/inc | ||
| ${WDK_INCLUDE_DIRECTORY}/km | ||
| ${WDK_INCLUDE_DIRECTORY}/km/crt | ||
| ${WDK_INCLUDE_DIRECTORY}/shared | ||
| ) | ||
|
|
||
| # TRANSITION, WDK needs to suppress C5040 | ||
| if(VCLIBS_TARGET_ARCHITECTURE STREQUAL "x86") | ||
| set(STL_KERNEL_CALLING_CONVENTION "/Gz") | ||
| else() | ||
| set(STL_KERNEL_CALLING_CONVENTION "") | ||
| endif() | ||
|
|
||
| target_compile_options(stl_kernel PRIVATE /kernel /wd5040 ${STL_KERNEL_CALLING_CONVENTION}) | ||
|
|
||
| add_executable(stl_kernel_loader ${STL_KERNEL_LOADER_SOURCES}) | ||
| target_include_directories(stl_kernel_loader PRIVATE | ||
| ${CMAKE_CURRENT_LIST_DIR}/inc | ||
| ${WDK_INCLUDE_DIRECTORY}/ucrt | ||
| ${WDK_INCLUDE_DIRECTORY}/um | ||
| ${WDK_INCLUDE_DIRECTORY}/shared | ||
| ) | ||
| target_compile_options(stl_kernel_loader PRIVATE /EHsc) | ||
| target_link_libraries(stl_kernel_loader PRIVATE | ||
| msvcrt.lib | ||
| kernel32.lib | ||
| ucrt.lib | ||
| AdvApi32.lib | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| param([string]$out="MsvcStlTestingCert.pfx",[string]$pass="placeholderPassword") | ||
|
|
||
| $ErrorActionPreference = 'Stop' | ||
| # Clean up old certificates | ||
| Get-ChildItem cert:\localmachine\My | | ||
| Where-Object { $_.Subject -eq 'CN=MsvcStlTestingCert' } | | ||
| Remove-Item | ||
|
|
||
| Get-ChildItem cert:\localmachine\root | | ||
| Where-Object { $_.Subject -eq 'CN=MsvcStlTestingCert' } | | ||
| Remove-Item | ||
|
|
||
| Get-ChildItem cert:\localmachine\trustedpublisher | | ||
| Where-Object { $_.Subject -eq 'CN=MsvcStlTestingCert' } | | ||
| Remove-Item | ||
|
|
||
| # Make the new cert | ||
| $cert = New-SelfSignedCertificate -Type CodeSigningCert -DnsName "MsvcStlTestingCert" ` | ||
| -certstorelocation cert:\localmachine\my -NotAfter (Get-Date).AddDays(2) | ||
| $path = 'cert:\localMachine\my\' + $cert.thumbprint | ||
| $pwd = ConvertTo-SecureString -String $pass -Force -AsPlainText | ||
| Export-PfxCertificate -cert $path -FilePath $out -Password $pwd | ||
|
|
||
| # install the cert so that we can load our drivers | ||
| Import-PfxCertificate -FilePath $out -CertStoreLocation cert:\localmachine\root -Password $pwd | ||
| Import-PfxCertificate -FilePath $out -CertStoreLocation cert:\localmachine\trustedpublisher -Password $pwd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| #include <cassert> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
-vvnecessary/useful, or is it a relic of development?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this one is useful. Without this, CI failures tell you which tests failed, but give very little output from the failing test. But it's hard for me to verify that since this is in the CI machinery.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say this is useful since upstream broke our ability to write nice output to the xml test results.